How to organise classes and modules

Ilkka Poutanen etu.suku at
Mon May 15 13:35:13 CEST 2006

On 2006-05-15, Alex <mizipzor at> wrote:
>>>> import Foo
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: unbound method bar() must be called with Foo instance as
> first argument (got nothing instead)
> ...
> One thing that I tried that worked ok was this:
>>>> import Foo
>>>> instance=Foo.Foo()
> hello world
> But in my opinion, this is very ugly. Especially if the class names

Are you sure you understand object-oriented programming? Reading the
Python tutorial[1] and re-reading the above error messages should clue
you in to what you're doing wrong. To put it simply, the whole point of
classes is that you create instances of them, each having their own
internal state, and then invoke their methods to accomplish whatever it
is that you want your program to accomplish.


Ilkka Poutanen []
And unto this, Conan;

More information about the Python-list mailing list