Refactoring a Python Data Validation Interactive Shell

  Рет қаралды 16,801

ArjanCodes

ArjanCodes

Күн бұрын

Пікірлер: 39
@ArjanCodes
@ArjanCodes Ай бұрын
👉 Check out brilliant.org/ArjanCodes/ to try Brilliant for free for 30 days, and get 20% off an annual premium subscription.
@TomDonahue
@TomDonahue Ай бұрын
Thanks Arjan! This was painful in all the right ways :) My first programming language exposure was C# (through the Unity game engine), and it's a language that really encourages abstractions and "clean code" principles. In the command and commandargs classes, I was trying to enforce something similar to C#'s interface structure, and definitely overcomplicated things. I need to get KISS and YAGNI signs posted to my desk... Loved the suggestions, loved the refactor--thanks for taking the time to go through this!
@ArjanCodes
@ArjanCodes Ай бұрын
Hey Tom, thank you for being courageous and submitting your code. It was a lot of fun working on it and I hope the second pair of eyes helps you improve your skills. And feel free to disagree with some of the things I did - there’s always an aspect of personal taste to development.
@MrVernuk
@MrVernuk Ай бұрын
Awesome video about refactoring! I really appreciate your effort to show how the code should look for better understanding and easier changes in the future, with less effort and fewer mistakes!
@ArjanCodes
@ArjanCodes Ай бұрын
Thank you, I’m happy you liked the refactor! 🙏
@djcomidi
@djcomidi Ай бұрын
The python standard library already has support for interactive shells: the cmd module. Create a new class that inherits from cmd.Cmd and implement any action you want by creating a do_actionname function. So much easier than writing your own shell.
@DrGreenGiant
@DrGreenGiant 7 күн бұрын
I've never heard of the CMD module! Thanks for this. Might be a good one for Arjan to do a showcase of, unless I've already missed it
@yassineboujerfaoui1160
@yassineboujerfaoui1160 Ай бұрын
Really like the way you've resolved the Liskov substitution principle violation in 28:01 (which was hidden with a `type: ignore` comment) through functions. I've personally would've gonna for making `Command` classes a generic class as a function of `CommandArgs` classes. But after seeing this, using functions really makes sense!
@twelvethis3979
@twelvethis3979 Ай бұрын
Loved the video, thanks a lot Arjan. Highly instructional. I've been arguing for functions instead of those tiny weird "function classes" in my company for a while. I'll be showing the video to my fellow developers at work.
@johanmartijn
@johanmartijn Ай бұрын
Nice in between remark about the Callable being moved to ABC, which makes no sense 😂
@Martin-lv1xw
@Martin-lv1xw Ай бұрын
Beneficial kinds of stuff. Thanx Arjan.
@Forseti2
@Forseti2 Ай бұрын
I'm really like I've chosen Pycharm at the beginning. It offers many convenient things, eg that moving of code Arjan struggled littlebit with in VSCode - Pycharm automatically refactor imports according the change you made when you moved files to other folder.
@NikolaiPismennyi
@NikolaiPismennyi Ай бұрын
Vscode also does this with standard python plugins. Not sure why Arjan is not using them
@Forseti2
@Forseti2 Ай бұрын
@NikolaiPismennyi okay, interesting - anyway VSCode is rather multipurpose IDE and it's great (no doubt about it), but needs to tweak for special purpose (eg Python development) where Pycharm comes tweaked and prepared immediately after instalation. Ok, let's say plugin installing in VSCode is easy thing, but then the intellisense didn't work as I would expect - after some time I've found that VSCode limits depth of search when observing the dependencies and by default that depth was too low, so it didn't show popups with suggestions,... And there is more such things. Another thing is debugger in VSCode, I don't really like it, but that's maybe thing you can get used to... 🤔 Anyway - for quick tests is VSCode great, for serious work, I prefer Pycharm.
@NikolaiPismennyi
@NikolaiPismennyi Ай бұрын
@@Forseti2 well the plug-ins come by default the moment you try to run python. So you have to make an effort to turn them off. Not disagreeing with you about PyCharm vs VSCode. But I think more people would have used PyCharm if they didn't ask for money for really basic features (like support for Jupyter Notebooks). And now they also don't have any nice AI features vs VSCode based projects like Cursor
@Forseti2
@Forseti2 Ай бұрын
@@NikolaiPismennyi ah, sure, I'm not really not using these features. So it doesn't bother me, but you are right - for people that do, that's dealbraker.
@nemanjaradojkovic1224
@nemanjaradojkovic1224 Ай бұрын
Love your code roasts, Arjan! Would it also make sense to use a `defaultdict` in `register_event` ? And the "could not add..." message in the same function should maybe say "listener already added to event".
@FighterAceee94
@FighterAceee94 Ай бұрын
Arjan you mentioned settings at the end of the video. I'd love to hear your thoughts on setting up an INI configuration file in combination with a Settings GUI and loading of these settings into the application. My GUI project uses very diverse settings all over the codebase, and I'm torn between the current system and some sort of a centralized setting value handling system.
@greyshopleskin2315
@greyshopleskin2315 Ай бұрын
For settings I like pydantic-settings. You can just create a model and you can configure it to automatically read values from environment variables, a .env file, toml and more formats
@romanroman4665
@romanroman4665 Ай бұрын
yeah, python refactoring series ☺
@mnny.j
@mnny.j Ай бұрын
Hi Arjan, what theme are you using? It looks really nice.
@hoseynamiri
@hoseynamiri Ай бұрын
Wow! I love your refactoring videos! Please make code roast. Would you go over a library I built?
@ArjanCodes
@ArjanCodes Ай бұрын
Glad you like them! You can submit your code for a roast on my Discord server (there's a dedicated channel). To join, go to: discord.arjan.codes.
@grzegorzryznar5101
@grzegorzryznar5101 22 күн бұрын
Hello :) Is series about game development and the whole stuff related (events, managing projects) still the case? This will be very good option to see the whole architecture design in practice
@wcontrata
@wcontrata Ай бұрын
Thanks, @TomDonahue and @ArjanCodes!
@ramimashalfontenla1312
@ramimashalfontenla1312 Ай бұрын
Like DocDB video!
@jasonma3449
@jasonma3449 27 күн бұрын
I see no .vscode folder exists in this workspace,why the relative import still works?
@johanmartijn
@johanmartijn Ай бұрын
What would have added are doxstrings. So a new user knows wat each function does
@TheScott10012
@TheScott10012 Ай бұрын
So they made a less flexible data exploration in cli instead of a notebook? I think as part of your code reviews you should also give feedback on whether decisions made before even writing code are good ideas...
@ArjanCodes
@ArjanCodes Ай бұрын
I disagree. I don't want to make any assumptions about the motivation of the developer. Not all tools are aimed to be used by tons of people. There are plenty of projects that developers work on that have a different goal, ranging from learning about a particular technology (such as how to build a CLI), or wanting to have something simple for internal use or as part of an automated script (in which case a notebook won't work).
@joshuadonahue5871
@joshuadonahue5871 Ай бұрын
So they wrote a computer program instead of riding a bycicle? I think as part of your code reviews you should also give feedback on whether decisions made before even writing code are good ideas
@zstrout
@zstrout Ай бұрын
I have something similar that I use all the time. But I 1) just use the python REPL instead of my own custom CLI and 2) change some environment variables in windows (I also did something similar in Linux too) so that I can right click on a file and have an "open in pandas" option that passes the file name as an arg to the script then creates an interactive session with the variable `df` as the dataframe of the file. I then use regular python commands to manipulate the data or plot it. This is like a step between excel and a notebook. It is really a godsend for huge csv or xlsx files that take forever to load in excel.
@DrGreenGiant
@DrGreenGiant 7 күн бұрын
I'm on the fence about this one. It's a fun challenge writing something that already exists as a learning project, you have something you can test against. But also, it's somewhat bad practice to reinvent the wheel unless the wheel is unfit for purpose for your spec (e.g. performance, licensing, etc.) I've been in too many teams in the bare metal world that enforce no libraries (C++) so you have to roll your own everything and spend all your time bugfixing something that doesn't need to exist. Including things like basic strings!
@oleksandrhavrylin6591
@oleksandrhavrylin6591 Ай бұрын
settings.json -> "files.exclude": {"**/__pycache__": true,...}
@raffaelmeyer3440
@raffaelmeyer3440 6 сағат бұрын
You're welcome to roast me: barredterra/pretty_release_notes
15 POWERFUL Python Libraries You Should Be Using
22:31
ArjanCodes
Рет қаралды 70 М.
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
Now I Know Why Most People Don’t Use gRPC
19:11
ArjanCodes
Рет қаралды 64 М.
Please Master This MAGIC Python Feature... 🪄
25:10
Tech With Tim
Рет қаралды 163 М.
Jeff Dean: AI will Reshape Chip Design - NeurIPS 2024
43:53
GradientSpills
Рет қаралды 6 М.
Transformers (how LLMs work) explained visually | DL5
27:14
3Blue1Brown
Рет қаралды 4,6 МЛН
Avoid These BAD Practices in Python OOP
24:42
ArjanCodes
Рет қаралды 86 М.
UV for Python… (Almost) All Batteries Included
17:35
ArjanCodes
Рет қаралды 97 М.
Can I Solve This Unsolved Math Problem?
16:21
CodeParade
Рет қаралды 292 М.
COMPLETE No-Nonsense VSCode Setup for Python Devs
26:05
ArjanCodes
Рет қаралды 58 М.
Protocols vs ABCs in Python - When to Use Which One?
15:31
ArjanCodes
Рет қаралды 46 М.