Monday, October 07, 2019

Visual Studio Code Python Hello World

Okay, was following this one : https://www.youtube.com/watch?v=WdGyfCceCvM but it's a couple years old already, so some things are off..

For a start, to build-and-run, you have to set things up once.

But, unlike this geek says, it's no longer CTRL-SHIFT-P and then "Tasks : Configure Task Runner"

You have to go for "Tasks : Configure Default Build Task" -- choose the only "Creates tasks.json file from template" and then choose Others..

Honestly, this is not the way - that video is crap.

Try this : https://code.visualstudio.com/docs/python/python-tutorial

Crap. Even that on is sh*t. How does M$ get away with being so crappy?

I install Python from *their* store and then, I have to manually edit the path using sysdm.cpl and then, all I can get is python to give me something. And their effing doc says to try "py -0" and "py -3 --version". And, in the integrated terminal, even python doesn't give me respect. Damn M$!! Nadella my foot. Bordello is more like it. Or maybe Nutella - since that actually exists.

Now, on the VSC's Terminal not seeing python, yes, when it starts up, it captures the PATH and that's that - so, you either have to find a way to update VSC's path, or restart. Restarting is not too painful - so, with that done, it actually does find it.. - the new one that is :)

One decent leg that this tutorial doc has over the golf cap dude is the CTRL-SHIFT-P (Command Pallette) "Python: select interpreter" thing - it was finding my Anaconda installs..

And then, again, it's again hair pulling time - Terminal sees the new install of Python, but Command Pallette doesn't. *ds of M$!!

I'm watching the beginner series (why? after years of dabbling in py? I want to nail down modules and packages and string formatting and decorators once and for all :) from M$ : https://www.youtube.com/watch?v=jFCNu1-Xdsw&list=PLlrxD0HtieHhS8VzuMCfQD4uJ9yne1mE6&index=1

And I'm thinking... the freaking idiots - why can't they follow through - don't they, the software experts, and these are smart people we're talking about, see that people will notice they're typing

python filename.py

every time to run their snippets? Shouldn't an IDE (which is really what the course is marketing) have a run button? I set that up in the first five minutes. What gives????

And another kicker - when talking about dates, they're abandoning the US style and going with DMY - why? To appeal to an international audience?

Then, the whole virtual environments stuff - so poorly integrated into the IDE. And then you have to deal with powershell which is about one tenth of bash. *ds! Is it time for PyCharm?

For virtual environments, first
# install
pip install virtualenv

then they tell you how to create a new venv.. Duh - should you tell someone how to look for what venvs already exist?

python -m venv <new-folder-name>

Of course, no one tells you why "lsvirtualenv" doesn't work :)

To activate an environment,

> <new-folder-name>\Scripts\Activate.bat # if you're in the cmd prompt

In powershell, it's
> <new-folder-name>\Scripts\Activate.ps1




No comments: