MonkeeSage wrote: > Ilias Lazaridis wrote: >> no, I don't know it. > > OK...so how do you evaluate a language when you don't know its basic > operations? Hmmm, sounds fishy.
The learning-process is an important part of the evaluation. >> 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__ >> function. >> >> But how do I place it within my computers python installation (the big >> init)? > > When you just say: > > def blah(): pass > > Now 'blah' function is in the top-level namespace, just like global > variables. Or if it's in a different file, you'd say 'from blah import > *'. You honestly don't know this?!?? I know how to define it: --- myBlahWithImport.py --- from mylib import blah if (__name__ == '__main__'): blah() --- end file --- what I dont know is, how to negate the need of the import statement. --- myBlah.py --- if (__name__ == '__main__'): blah() --- end file --- >> I am aware of this technique. >> >> But I want to modify existent classes, without touching their code. > > The only way to do this is to explicitly subclass the existent classes > with your own class and modify what you want there in your subclass > (see below), or use multiple inheritence as I suggested previously. > >> 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> >> fh.reopen(mode='wb') >> " >> http://rightfootin.blogspot.com/2006/09/ruby-reopen.html >> >> 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): ) > > Basically, yes. In ruby you can reopen base classes; in python you can > get the same effect by subclassing the base classes with the same name > as the base class, then instantiating all your objects as that class. > This is the exact same idea as a "super-duper super class" as I > mentioned above. That's a part of the construct I was looking for. >> but the limitation is that I cannot do this with the python build-in >> types?: >> >> http://rightfootin.blogspot.com/2006/08/of-rocks-and-reptiles.html > > You can subclass buit-in types using the same name as the parent class. So, that's a 2nd part of the constrcut I was looking for. btw: from which class does "int" inherit? > In fact here is what I use: > > ## my little library to make python more OO > ## i.e., to get rid of the top-level junk... > ## or at least to hide it behind some pretty > ## object attributes :) > ## > ## YMMV - and don't complain if you don't > ## like it; I wrote it for ME, not you > ## > ## Jordan Callicoat < [EMAIL PROTECTED] > > > ## some global methods so we can use them > ## to set up the class methods ... (many code I'll review at a later point) > It's not the most "pythojnic" way to do things, but it works for me. > > Ps. I still have a hard time belieiving that after all the time you've > spent on comp.lang.lisp, comp.lang.ruby and comp.lang.python you still > don't understand these basic concepts...if that's really true, I would > never use your consulting service! "CONSTRUCT - Adding Functionality to the Overall System" This is not a basic concept. Although in smaltalk and ruby is very simple. But I've selected to use Python. . -- http://lazaridis.com -- http://mail.python.org/mailman/listinfo/python-list