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.

Is “from matplotlib import pyplot as plt” == “import matplotlib.pyplot as plt”?

Even though they are equivalent, I think there is a pretty good argument that the second form import matplotlib.pyplot as plt is objectively more readable: It is generally customary to use import matplotlib.pyplot as plt and suggested in the matplotlib documentation (see http://matplotlib.org/users/pyplot_tutorial.html etc…) so this will be more familiar to most readers. import matplotlib.pyplot … Read more

What is a “method” in Python?

It’s a function which is a member of a class: Simple as that! (There are also some alternative kinds of method, allowing you to control the relationship between the class and the function. But I’m guessing from your question that you’re not asking about that, but rather just the basics.)

What is the use of python-dotenv?

From the Github page: Reads the key,value pair from .env and adds them to environment variable. It is great of managing app settings during development and in production using 12-factor principles. Assuming you have created the .env file along-side your settings module. Add the following code to your settings.py .env is a simple text file. … Read more

Invalid character in identifier

I am working on the letter distribution problem from HP code wars 2012. I keep getting an error message that says “invalid character in identifier”. What does this mean and how can it be fixed? Here is the page with the information.