I've used Python back on my university days (some numpy coding, some gui apps for both linux and windows) and later professionally, when doing webdev in Pylons and Django. Then I've switched to Ruby and for the last 15 years haven't touched Python at all. And now actually I'd like to get back to it, with some side projects. Ideally I'd love to do some image recognition / qualification apps. Question is - what's the best place to start? I remember some basics, but as I can see, A LOT has changed.
- I used to do everything in vim, but now I adopted VSCode (usually with SSH-Remote) and it's been such an improvement to my productivity. Try to use the integrated test explorer and debugger.
- If you use type annotations (sparingly), your VSCode experience gets even better.
- Many projects use auto formatting with 'black' these days. Initially I was a bit grossed out by this, but I now love it. It frees me up from having to spend mental cycles on complex lines, and removes the friction when reviewing CRs. The one change I make is to have a slightly longer line length.
- pyproject.toml is a new project level config file. Try to only use that file for all your setup and tool configurations
- Since you said you last touched Python 15 years ago, we now have Python 3.x. Syntax is a lot cleaner. There are many smaller differences.
- async/await is new. It is pretty neat if you want to do async programming. Don't expect a major boost (or any boost) in performance over traditional threaded code, but you can expect much cleaner code.
- f-strings are pretty neat, I use them pervasively
- I'm not sure if these are already 15 years old, but "with" context managers are the primitive to use for cleaning up resources.
I find it much more pleasant to ask GPT4's advice and have it write sample code than it is to use web search, Stack Overflow, etc. Even when I know exactly what code to write, it's often faster to ask GPT4 to write it a certain way and then make minimal edits myself.
The paid version of GPT4 used to be the best, but lately the VSCode Insider GitHub Copilot produces comparable or identical results, since it uses GPT4. I have only one custom instruction, "If writing Python code, always use context managers where appropriate."
EDIT: If you don't want to hassle with maintaining a development environment, try Replit[0]. Their AI is not nearly as good as GPT4 though.
[0] https://replit.com/
I've only poked briefly at it, but https://deepseekcoder.github.io/ evals as very strong at code and is probably the best open model available. You can chat with it for free w/ a signup (or run it yourself if you're looking for a project).
If you're looking to poke around with local models more easily, you can give KillianLucas/open-interpreter a try (in conjunction with LM Studio or w/ an OpenAI or Anthropic API key), it's pretty neat (be very careful with code execution, I'd recommend doing it in a sandbox lest you accidentally trash your system).
I guess the one thing that you don't get to do with that approach is build something interesting or use `async-await` but it gets you fluent with the syntax again which is an important first step.
Find a project to start from scratch, or find one to which to contribute. Read as much Python 3 code as you can to get your neurons firing.
[1] stick to venv, pip install, and pip freeze (time spent down the rabbit hole of packaging is time not spent actually coding)
Deleted Comment
This is also confirmed by my own experience.
https://fathomtech.io/blog/python-environments-with-pyenv-an...
Racing through his mega tutorial was a great refresher for me on the fundamentals, and it's easy to plug in computer vision & related libraries/extensions/packages.
It's an incredible tool for learning Python, because it means you can explore all kinds of new tricks and see the results instantly - directly from your browser (or even on your phone).
I have 20+ years of Python experience and I use Code Interpreter mode to try things out several times a day. I think it's an incredible tool for learning.
I wrote a bit more about it here: https://simonwillison.net/2023/Sep/29/llms-podcast/#code-int...
I took the entire pandemic off from programming, and when I had to go back to find a job, I needed to level up quickly to be able to pass programming interviews.
I wrote a program to start downloading stock quotes, then added writing to a database, then added code to graph it with flask, etc. If you choose something you're interested in and keep expanding the scope of the project, it's the best way to learn.
And functionally, Python 3 isn't a huge difference over Python 2, especially if you're starting from scratch again. For me the biggest change is adding parentheses around my print statements. Everything else is pretty similar.
[1] https://adventofcode.com/