In article <[EMAIL PROTECTED]>, Maric Michaud <[EMAIL PROTECTED]> wrote:
> Le Mercredi 24 Mai 2006 22:04, Diez B. Roggisch a écrit : > > Nope, not in that way. But you might consider writing a proxy/wrapper > > for an object. That looks like this (rouch sketch from head): > > > > class FileWrapper(object): > > def init (self, f): > > self. f = f > > > > def getattr (self, name): > > return getattr(self. f, name) > > > > def myreadline(self): > > .... > Why use a proxy when you can just inherit from the builtin file object ? > > class myFile(file) : > def myreadline(self) : print 'yo' > > > In [20]: myFile('frwiki-20060511-abstract.xml') > Out[20]: <open file 'frwiki-20060511-abstract.xml', mode 'r' at 0xa78cc1e4> > > In [21]: myFile('frwiki-20060511-abstract.xml').myreadline() > yo > > In [22]: BINGO! This is exactly what I want. I didn't realize that I could open using file itself instead of open. I did find this in another section of Python in a Nutshell thanks to your suggestion. Thank you. And thanks to all who answered. -- Lou Pecora (my views are my own) REMOVE THIS to email me.
-- http://mail.python.org/mailman/listinfo/python-list