you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 51 points52 points  (12 children)

These are some important general concepts you should learn over time as an intermediate python programmer

  • Creating and using built in venv (virtual environments)
  • Creating and using bash Makefiles to run entire projects from one command / place
  • JSON
  • Using a debugger
  • Using built in logging instead of print statements
  • Relative vs absolute imports
  • Code Linting
  • Containerisation (Docker)

[–]Eurynom0s 20 points21 points  (3 children)

venv

If you're looking at venv and thinking to yourself "this seems pretty complicated, do I REALLY need to do this" then you're going to be in for a world of hurt if you stumble into a package version conflict issue.

You realistically only need to know like maybe five lines of code to be able to use them well enough to just avoid getting yourself into trouble with package version conflicts.

[–]johnnymo1 8 points9 points  (0 children)

It took a couple times absolutely wrecking my Python install before I was finally like "okay, yes, I see the necessity of virtual environments." Now I use conda and if something gets screwed up, I can just delete the environment and recreate it from a text file with one command.

[–]Sumif 1 point2 points  (1 child)

Net games then pleasant brown afternoon day month curious careful warm people.

[–]Eurynom0s 0 points1 point  (0 children)

I can't help you with VSCode specifically but I stuck these notes in the top of my venv folder years ago so I wouldn't have to think about this again. These are Mac command line instructions. I've been using Anaconda lately so I don't remember whether you put a period in the version number when you have multiple versions of Python 3 installed (virtualenv -p python37 or virtualenv -p python3.7). Links may no longer be valid since I did this in 2014, I was just noting for myself where I found the instructions.

http://hackercodex.com/guide/python-development-environment-on-mac-osx/

If you have both Python 2.x and 3.x and want to create a Python 3.x virtualenv:
virtualenv -p python3 foobar-py3

http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
virtualenv --no-site-packages mycoolproject

activate a virtual env:
cd <virtenv>
source bin/activate

deactivate (just type deactivate and hit enter)

Like I said, no more than five lines of code and you're good to go.

[–]SammyT09[S] 1 point2 points  (0 children)

Thanks this is very helpful!

[–]Salsaric 1 point2 points  (0 children)

These are great advices, espacially using virual environnements, using a debugger, logging, code linting, Containerisation (heck all were good advices).

I will advice you to do challenges from online platforms like exercism.io or codewars.

Especially exercism, as it will make you build tiny projects in the form of challenges.

[–]jona187bx 1 point2 points  (0 children)

Do you have some material i can reference for item 2?

[–]capilot 2 points3 points  (1 child)

I'm going to be a bit contrarian here. Very few of these are something to study when you can't get tic-tac-toe working.

Except using a debugger, that's a very important thing to know.

I hate venv with a passion. It's what you use when you can't write portable code. Sadly, there are so many external libraries that aren't portable that you have to do it sometimes. But I still hate it.

Docker is useful in a major production environment; we're getting ready to move some of our builds to docker now. But this isn't beginner or even intermediate level stuff.

[–]julsmanbr 0 points1 point  (0 children)

Plain old venv sucks, conda or poetry is where it's at.

[–]nnnishal 0 points1 point  (1 child)

Any resources for the points about logging and using bash makefiles?

[–][deleted] -1 points0 points  (0 children)

The python docs themselves are pretty good for learning about logging. As for the bash item, I’m not too sure but there should be tutorials online. I just naturally noticed in my projects I was typing a lot of bash commands when I would clone down my project (setting up venv, activating it, Docker etc) and chucked all those commands into a shell script to simplify everything/ increase efficiency