IPython workflow (edit, run)

When I’m working with python, I usually have two terminal windows open – one with IPython, and the other with a fairly customized Vim. Two good resources: http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/ http://dancingpenguinsoflight.com/2009/02/python-and-vim-make-your-own-ide/ Though it sounds like what you want is IPython’s magic function %ed/%edit: An example of what you can do: In [72]: %ed IPython will make a … Read more

How to get the list of all initialized objects and function definitions alive in python?

Yes. >>> import gc >>> gc.get_objects() Not that you’ll find that useful. There is a lot of them. 🙂 Over 4000 just when you start Python. Possibly a bit more useful is all the variables active locally: >>> locals() And the one active globally: >>> globals() (Note that “globally” in Python isn’t really global as … Read more

How to launch python Idle from a virtual environment (virtualenv)

Short answer Start the virtual environment Run python -m idlelib.idle From this answer. Long answer This answer assumes Python 3. There are a few different virtual environment managers, each of which has a slightly different way of handling where python is installed and how it’s run, as detailed in this answer. This answer assumes the … Read more

How to turn on line numbers in IDLE?

Version 3.8 or newer: To show line numbers in the current window, go to Options and click Show Line Numbers. To show them automatically, go to Options > Configure IDLE > General and check the Show line numbers in new windows box. Version 3.7 or older: Unfortunately there is not an option to display line … Read more

How to run a python script from IDLE interactive shell?

Python3: exec(open(‘helloworld.py’).read()) If your file not in the same dir: exec(open(‘./app/filename.py’).read()) See https://stackoverflow.com/a/437857/739577 for passing global/local variables. In deprecated Python versions Python2 Built-in function: execfile execfile(‘helloworld.py’) It normally cannot be called with arguments. But here’s a workaround: import sys sys.argv = [‘helloworld.py’, ‘arg’] # argv[0] should still be the script name execfile(‘helloworld.py’) Deprecated since 2.6: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)