Learn to use Python in a day…

Admittedly I am late to the game with Python.  That said, I have trained and qualified myself in the understanding and use of it.

(NOTE:  I watch these videos at 2X speed…  you may want to start at 1.5X if you are not completely comfortable with programming paradigms)

I started by following this 17 video sequence to understand the new syntax and rules.  Its all basic…  but if you are coming from a different language it can be very confusing at first.  I suggest taking the time to step through the basic videos…  not because you don’t know how to set up an if/else structure…  but simply to get comfortable with the style of Python.

Having a lot of experience using languages that are tightly type cast, agnostic to spacing, and deterministic…  my first response to Python was “Trouble – ACK!”

Type casting was traditionally very important for ensuring compiled results came out as expected…  older compilers would let get into trouble in any number of ways.  Compilers these days are orders of magnitude better…  so…  the harsh rules of the past are no longer relevant.

I accept this as a superior tool for quick collaborative development.

Many good changes to legacy methods have been developed and refined (even though a few stinkers snuck through…  like the confusing for new folks += ) and I have decided that I like the language and want to work with it.

Now…  for some more advanced use cases.

-Patrick

Python… how to decompile it

So you want to see the goodies inside of a PYO or PYC compiled Python file (PY) ???  

If so…  you may.  Its byte code (and not true compiled code…) so it is trivial to decompile into something readable that will get you the information you need or want.

Disclaimer:   Too the nOoB

Now I have been doing this since we were writing code in Assembly…  HEX, Assembly, C, C++, Java…  all languages are essentially the same.  I am old and crusty so I get to do things like this ethically.  We learned in the late 90’s by passing arguments back and forth across the stack between ASM and Turbo C (which we installed with floppy disks…).  The forum named “Stack Overflow”…  well…  I am one of those old guys who had to actually count the bytes in the stack and insert carefully.  I know all about overflowing stacks and writing random information to places it should not be.

Onward:

1 – Install both Python 2 and Python 3

https://www.python.org/downloads/

You will need both to be compliant with legacy and current designs.

 

2 – Install an IDE of your choice.

 

 

3 – Set your PATH variable so that you can execute a command prompt from any window:

RHC start menu, Control panel.  Search “path” and select “edit system environment variables”.  Create a new variable PATH and aim it at your python install.  Separate by semi colon.  Use this tutorial:

http://stackoverflow.com/questions/3701646/how-to-add-to-the-pythonpath-in-windows-7

Now you are all set…
To run Python from any folder…  click FILE and select CMD.  You will have avoided typing in a long path and much time has been saved.

To run python just type it.

To run a specific version type

py -2

py -3

To run 2 or 3 respectively.

 

4 – Now…  none of that was required…  but I wanted you to install python so…  now you have.  😉

 

Meat and potatoes:

I tried 2 of the command line tools.  They were obnoxious…  but there is a GUI that rides on top of them and handles the details for you (if you are a python nOoB like me).

The tool to use is this one:   Easy Python Decompiler

https://sourceforge.net/projects/easypythondecompiler/

Test Results:

For Python 2 it works.

For Python 3 it APPEARS to crash…  BUT ACTUALLY WORKS…  its simple point and click…  then the file you want magically appears in the source folder.

 

There you go.  Dont get in trouble and only call the cops if you have to…  Authority figures should be reserved for emergency situations.  Anything else…  I am sure we can handle.

-methods