r/pythontips • • Jan 30 '20

Python Command line

To catch any syntax errors before executing large time consuming scripts you can run the following from your command line

python3 -m py_compile my_script.py

38 Upvotes

8 comments sorted by

13

u/gedon Jan 30 '20

An even better way is to use a decent IDE such as pycharm. You can run in debug mode or even just set break points and step through your code.

4

u/MonkHaus Jan 30 '20

But text editor + cli is more fun :/

3

u/commenda Jan 30 '20

also, at my office for example, that's all I have.

It took me 3 years to get even just nano+python3.6. So I'm not gonna bother to try and convince boneheaded IT to install Pycharm on my PC. So thanks for the suggestion OP.

2

u/MonkHaus Jan 30 '20

That made me laugh! And yeah I know the pain...

8

u/[deleted] Jan 30 '20

Hey there friend, depending on how rebellious you're feeling you can download pycharm then just copy the folder onto your pc and it effectively runs like a portable app. I've been doing this for years.

https://stackoverflow.com/questions/4809214/is-there-an-easy-way-to-put-my-entire-installation-of-intellij-on-a-usb-stick/4809629#4809629

Hope this helps!

3

u/commenda Jan 31 '20

oh man, this is great. thank you

3

u/rjp0008 Jan 31 '20

I go through yearly training about the horrors of usb drives. They’re banned in my office along with unapproved software. We can’t install anything or edit environment variables.

1

u/tLNTDX Feb 09 '20

I have nightmares about such workplaces - like if you actually handle data that requires that level of security from time to time it seems the handling of that data should be confined to a separate system rather than having everyone's daily drivers be so locked down that they become virtually useless.

Unless your job is to actually handle that kind of data 100% of the time of course - then I guess you're screwed.