python

Autodoc for private methods in Sphinx

I am using Sphinx for documenting my python project. I have the autodoc extension enabled and have the following in my docs. .. autoclass:: ClassName :members: The problem is, it only documents the non-private methods in the class. How do I include the private methods too. ...

Signals registered more than once in django1.1 testserver

I've defined a signal handler function in my models.py file. At the bottom of that file, I use signals.post_save.connect(myhandler, sender=myclass) as recommended in the docs at http://docs.djangoproject.com/en/dev/topics/signals/. However, when I run the test server, simple print-statement debugging shows that the models.py file gets i...

Exploring and decompiling python bytecode

Lets say I have: >>> def test(a): >>> print a Now, I want to explore see how test looks like in its compiled form. >>> test.func_code.co_code '|\x00\x00GHd\x00\x00S' I can get the disassembled form using the dis module: >>> import dis >>> dis.dis(test) 2 0 LOAD_FAST 0 (a) 3 PRINT_ITE...

python and ruby - for what to use it?

Hi, I'm thinking about learning ruby and python a little bit, and it occurred to me, for what ruby/python is good for? When to use ruby and when python, or for what ruby/python is not for? :) What should I do in these languages? thanks ...

Use Google AppEngine datastore outside of AppEngine project

For my little framework Pyxer I would like to to be able to use the Google AppEngine datastores also outside of AppEngine projects, because I'm now used to this ORM pattern and for little quick hacks this is nice. I can not use Google AppEngine for all of my projects because of its's limitations in file size and number of files. A great...

CPython or IronPython ?

What would you use for a brand new cross platform GUI app, CPython or IronPython ? What about - license / freedom - development - - doc - - editors - - tools - libraries - performances - portability What can you do best with one or the other ? - networking - database - GUI - system - multi threading / processing...

Pythonic Swap?

I found that i have to perform a swap in python and i write something like this. arr[first], arr[second] = arr[second], arr[first] I suppose this is not so pythonic. Does somebody know how to do a swap in python more elegent? EDIT: I think another example will show my doubts self.memberlist[someindexA], self.memberlist[someindexB] =...

$_SERVER vs. WSGI environ parameter

I'm designing a site. It is in a very early stage, and I have to make a decision whether or not to use a SingleSignOn service provided by the server. (it's a campus site, and more and more sites are using SSO here, so generally it's a good idea). The target platform is most probably going to be django via mod_wsgi. However, any documenta...

cleaning up when using exceptions and files in python

Hello all, I'm learning python for a couple of days now and am struggling with its 'spirit'. I'm comming from the C/C++/Java/Perl school and I understand that python is not C (at all) that's why I'm trying to understand the spirit to get the most out of it (and so far it's hard)... My question is especially focused on exception handlin...

Can I create a Python extension module in D (instead of C)

I hear D is link-compatible with C. I'd like to use D to create an extension module for Python. Am I overlooking some reason why it's never going to work? ...

Generating random sentences from custom text in Python's NLTK?

I'm having trouble with the NLTK under Python, specifically the .generate() method. generate(self, length=100) Print random text, generated using a trigram language model. Parameters: * length (int) - The length of text to generate (default=100) Here is a simplified version of what I am attempting. import nltk word...

Source interface with Python and urllib2

How do i set the source IP/interface with Python and urllib2? ...

Attribute Cache in Django - What's the point?

I was just looking over EveryBlock's source code and I noticed this code in the alerts/models.py code: def _get_user(self): if not hasattr(self, '_user_cache'): from ebpub.accounts.models import User try: self._user_cache = User.objects.get(id=self.user_id) except User.DoesNotExist: ...

Compile the Python interpreter statically?

I'm building a special-purpose embedded Python interpreter and want to avoid having dependencies on dynamic libraries so I want to compile the interpreter with static libs instead (eg libc.a not libc.so). I would also like to statically link all dynamic libraries that are part of the Python standard library as well. I know this can be ...

online mp3 player

Hi i'm looking for a piece of software that'll allow me to play mp3's from my webserver though a simple web app. support for playlists would be nice ,but non-manditory, though a shuffle funtion is a must. I can run php, ruby, or python apps on my server, and woudl prefer something free or open source (as long as the price is nominal thou...

How to escape a hash (#) char in python?

I'm using pyodbc to query an AS400 (unfortunately), and some column names have hashes in them! Here is a small example: self.cursor.execute('select LPPLNM, LPPDR# from BSYDTAD.LADWJLFU') for row in self.cursor: p = Patient() p.last = row.LPPLNM p.pcp = row.LPPDR# I get errors like this obviously: AttributeError: 'pyodbc.R...

Python 2.5 socket._fileobject is what in Python 3.1?

I'm porting some code that runs on Python 2.5 to Python 3.1. A couple of classes subclass the socket._fileobject: class X(socket._fileobject): .... Is there an equivalent to socket._fileobject in Python 3.1? A quick scan of the source code doesn't turn up anything useful. Thanks! ...

A question regarding string instance uniqueness in python

I was trying to figure out which integers python only instantiates once (-6 to 256 it seems), and in the process stumbled on some string behaviour I can't see the pattern in. Sometimes, equal strings created in different ways share the same id, sometimes not. This code: A = "10000" B = "10000" C = "100" + "00" D = "%i"%10000 E = str(100...

Emulate processing with python?

I'm looking for a basic programmatic animation framework similar to processing except in python. That is, something that allows pixel manipulation, has basic drawing/color primitives, and is geared towards animation. Is pygame pretty much the best bet or are there other options? ...

map raw sql to django orm.

Is there a way to simplify this working code? This code gets for an object all the different vote types, there are like 20 possible, and counts each type. I prefer not to write raw sql but use the orm. It is a little bit more tricky because I use generic foreign key in the model. def get_object_votes(self, obj): """ Get a dicti...