How to access environment variable values

Environment variables are accessed through os.environ Or you can see a list of all the environment variables using: As sometimes you might need to see a complete list! The Python default installation location on Windows is C:\Python. If you want to find out while running python you can do:

How to Execute a Python Script in Notepad++?

First option: (Easiest, recommended) Open Notepad++. On the menu go to: Run -> Run.. (F5). Type in: Now, instead of pressing run, press save to create a shortcut for it. Notes If you have Python 3.1: type in Python31 instead of Python26 Add -i if you want the command line window to stay open after … Read more

How to generate all permutations of a list?

There’s a function in the standard-library for this: itertools.permutations. If for some reason you want to implement it yourself or are just curious to know how it works, here’s one nice approach, taken from http://code.activestate.com/recipes/252178/: A couple of alternative approaches are listed in the documentation of itertools.permutations. Here’s one: And another, based on itertools.product:

‘str’ object does not support item assignment

In Python, strings are immutable, so you can’t change their characters in-place. You can, however, do the following: The reasons this works is that it’s a shortcut for: The above creates a new string with each iteration, and stores the reference to that new string in s2.