by mlitwiniuk on 11/14/23, 7:39 PM with 56 comments
by geertj on 11/14/23, 9:20 PM
- 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.
by getpost on 11/14/23, 8:40 PM
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.
by lhnz on 11/14/23, 8:17 PM
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.
by gjvc on 11/14/23, 7:56 PM
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)
by georgespencer on 11/14/23, 8:30 PM
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.
by simonw on 11/14/23, 9:12 PM
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...
by purpleblue on 11/14/23, 8:19 PM
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.
by zaptheimpaler on 11/14/23, 9:06 PM
by nerpderp82 on 11/14/23, 8:50 PM
Install PyCharm
Forget everything you know and work through https://www.dabeaz.com/python-distilled/
by 2plus2eq5 on 11/14/23, 8:18 PM
by JohnBooty on 11/14/23, 8:22 PM
I liked this guide as an overview for more experienced programmers: https://docs.python-guide.org/
I thought the "Learn Enough Python to be Dangerous" book was a good intro but like many books/guides it's kind of redundant for experienced developers.
Mostly, the big revelation has been AI tools like ChatGPT/CoPilot helping with specific syntactic drudgery like "how do i iterate over this thing" as well as bigger questions.
by kelseyfrog on 11/14/23, 8:26 PM
Advent of Code[3] is also coming up in about two weeks. It's another low-stakes way of engaging with a language.
2. betrayed by "project", but it's just solving math problems with your language
by svilen_dobrev on 11/14/23, 8:48 PM
What's there has been there looong time.
Most of stuff / fluff added last 10 years isn't really essential.
have fun
p.s. uh yes. There are python programmers, and there are django/.../"lego" programmers. Seems recently the lego ones are in more demand.. and availability
by blparker on 11/14/23, 8:44 PM
1) Reacclimating yourself with the language. When I'm trying to pick up a a new language or re-engage with a language, I like to work on bite sized problems to understand the syntax and get somewhat comfortable with writing in it. I like to focus on the language and not worry too much about environment setup, best practices, frameworks, etc. You can easily do this by solving some Leetcode/Project Euler problems and running the code in Repl.it.
2) Working through a project. You're going to get the most value out of the time if you try to actually build something. The issue with step 1 above is that it doesn't teach you how things like package management, environment setup, testing, etc. work. It's going to be very slow at first, and you might end up restarting the project several times based on updated learning (which is good).
As it related to Python specifically, fortunately there's loads of very solid information available online. I'd pick one of the well-known frameworks (Django or Flask) and just start trying to build something with it.
by jon-wood on 11/14/23, 9:21 PM
Coming over from Ruby I was very pleasantly surprised by just how good all the tooling is. Type checking is really well supported and an absolute godsend when working on large applications, and VSCode has deep support for the language.
by svaha1728 on 11/14/23, 9:11 PM
https://training.talkpython.fm/courses/mongodb-with-async-py...
FastAPI plays well with OpenAI's APIs and ML APIs in general. There are some great examples on GitHub for that.
by slingnow on 11/14/23, 9:09 PM
Here's your answer: start programming a project that interests you in the domains you listed. Learn something, ask question, iterate.
Seriously, what kind of answer are you expecting here? Are you expecting someone to give you a brand new way of learning a subject? Something outside the bounds of tutorials/videos/documentation/hands-on?
by randcraw on 11/14/23, 9:16 PM
by qd011 on 11/14/23, 10:23 PM
Also check out dataclasses, Pydantic (most of my code these days is gluing together dataclasses and Pydantic models), FastAPI, PyTorch if you're interested in ML.
by kiviuq on 11/15/23, 8:33 AM
by zwieback on 11/14/23, 8:34 PM
by EstesPark on 11/14/23, 8:11 PM
by Tistel on 11/14/23, 9:05 PM
to just get a refresh of the basics (then search for the rest) the tutorial is pretty good: https://docs.python.org/3/tutorial/index.html
if you want to get more depth a good book is Fluent Python by Luciano Ramalho.
by jeremymcanally on 11/14/23, 8:55 PM
by johnea on 11/14/23, 8:45 PM
Of course, if there's no meme for that, it doesn't actually exist does it...
by jujube3 on 11/14/23, 9:04 PM
by wintorez on 11/14/23, 8:29 PM
by franze on 11/14/23, 9:02 PM
Start with ChatGPT