CONSTRUCT - Adding Functionality to the Overall System

Ilias Lazaridis ilias at
Wed Sep 20 13:54:18 CEST 2006

MonkeeSage wrote:
> Ilias Lazaridis wrote:
> > where do I place this function...
> The place where you want it to be.
> > ...thus it becomes available within class "Foo" and all other Classes?
> Anything defined in the top-level (i.e., the sys.modules['__main__']
> namespace) is accessible in every scope...but I assume you already know
> that.

no, I don't know it.

how do I define something into the top-level namespace? I assume I
could place it into the root-package of my project, into the __init__

But how do I place it within my computers python installation (the big

> You could also use a super-duper super class from which to derive all
> your other classes, and add/replace any methods you want there:
> class lazaridis(object):

I am aware of this technique.

But I want to modify existent classes, without touching their code.

> > Something like a central import?
> That would probably be the most logical thing to do.
> But again, I assume you already know all this, so why are you asking?
> Is this part of the evaluation process?

I am not evaluating Python, I've started using it:


I've noticed some interesting code on you website:

class file(file):
  def reopen(self, name=None, mode='w', bufsize=None):

fh = file('test.txt', 'rb')
print fh # <open file 'test.txt', mode 'rb' at 0xb7c92814>

does this mean that I can add a method to a class in a similar way with
ruby? (by using class class-name(class-name): )

but the limitation is that I cannot do this with the python build-in


More information about the Python-list mailing list