Python can’t find module in the same folder

Your code is fine, I suspect your problem is how you are launching it. You need to launch python from your ‘2014_07_13_test’ directory. Open up a command prompt and ‘cd’ into your ‘2014_07_13_test’ directory. For instance: If you cannot ‘cd’ into the directory like this you can add it to sys.path In test.py: Or set/edit the PYTHONPATH … Read more

‘Can’t set attribute’ with new-style properties in Python

The documentation says the following about using decorator form of property: Be sure to give the additional functions the same name as the original property (x in this case.) I have no idea why this is since if you use property as function to return an attribute the methods can be called whatever you like. So you need to … Read more

Python: Write array values into file

The for loop will ask i to iterate over the values of an iterable, and you’re providing a single int instead of an iterable object You should iterate over range(0,len(highscores)): or better, iterate directly over the array

Overflow Error in Python’s numpy.exp function

As fuglede says, the issue here is that np.float64 can’t handle a number as large as exp(1234.1). Try using np.float128 instead: Note however, that there are certain quirks with using extended precision. It may not work on Windows; you don’t actually get the full 128 bits of precision; and you might lose the precision whenever the number passes through pure … Read more

python encoding utf-8

You don’t need to encode data that is already encoded. When you try to do that, Python will first try to decode it to unicode before it can encode it back to UTF-8. That is what is failing here: Just write your data directly to the file, there is no need to encode already-encoded data. If you instead build up unicode values instead, you would … Read more

Start with pyglet or pygame?

pygame is richly active, witness the Aug release of 1.9 with nokia s60 support, enhanced py2app/py2exe support, and a bevvy of experimental features (support for Python 3.1, webcams, gfx, …). Books like Hello World and periodic, fun competitions like ludumdare and pyweek bear witness to the vitality of its community and ecosystem. pyglet has a neat, newer API, and is convenient … Read more