views:

43

answers:

1

Hi, I just run into a problem with the hamster's codebase where a module is loaded with one function and not the other. It's not my code, so I don't know many details, but I'd really like to learn how can such situation arise.

There is a module called hamster which includes i18n.py which has two functions: setup_i18n and C_. There is no __all__ defined in __init__. After loading the module C_ is visible, but the setup function isn't.

Here's the link for i18n file and the repo in general: http://git.gnome.org/browse/hamster-applet/tree/src/hamster/i18n.py?id=94b8ba72dad5b3e711d5f6b6a7018d83d770ce14

The session is only this (after setting the correct sys.path to include the packages)

> from hamster import i18n
> dir(i18n)
['C_', '__builtins__', '__doc__', '__file__', '__name__', 'gettext']
+6  A: 

You have an old version of the file in your system path. Notice that the most recent change to that file in the repo is to add the setup_i18n function. It's also possible you have an old .pyc file that for some reason isn't being compared properly to the .py file.

Ned Batchelder
I cloned the git repo and was about to post an answer saying I couldn't repro this problem (after not finding anything browsing source that would give this behavior), but you've beat me to the punch and explained why too.
Roger Pate
That was the case - there was a stale `.pyc` which was not updated even though `.py` changed. Thanks.
viraptor