Hey! Thx for the help,
@Martin, At the moment my only need is basic retrievals of source code of basic files from the internet, so no need for urllib2 or response objects just yet. Now, copying and pasting line by line into the interactive mode I get this: >>> from urllib import urlopen >>> class fetch(urlopen): ... def __init__(self,*args): ... urlopen.__init__(self, *args) ... self.content = self.read() ... Traceback (most recent call last): File "<interactive input>", line 1, in <module> TypeError: Error when calling the metaclass bases function() argument 1 must be code, not str Anybody, any idea what's up with that? On Sat, Dec 20, 2008 at 6:49 PM, Richard Lovely <roadier...@googlemail.com>wrote: > There are three ways as I see it: using __getattr__, using a new init, > or using a property decorator. The last two are probably the most > pythonic, but I'm not familiar with decorators, so here's how I'd do > the second of the three: > > try: > from google.appengine.api.urlfetch import fetch > except: > from urllib import urlopen > > class fetch(urlopen): > def __init__(self, *args): > urlopen.__init__(self, *args) > self.content = self.read() > > > This probably doesn't behave exactly the same way as the google class, > but it should be similar enough? > --- > Richard "Roadie Rich" Lovely, part of the JNP|UK Famile > www.theJNP.com > > > > 2008/12/20 Omer <jaggojaggo...@gmail.com <jaggojaggo%2...@gmail.com>>: > > Hey. > > > > I'm trying to do something I think is basic and am failing. > > > > The goal is: > > [mimicking the google urlopen syntax] > > > > try: > > from google.appengine.api.urlfetch import fetch > > except: > > from urllib import urlopen as fetch > > > > > > How do I add this "fetch" the property of content? > > > > I basically want fetch(url.com).content to replace urlopen(url.com > ).read() > > > > Mind, content is not a method. > > > > Thoughts? > > > > Thx. Omer. > > > > > > _______________________________________________ > > Tutor maillist - Tutor@python.org > > http://mail.python.org/mailman/listinfo/tutor > > > > >
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor