[Tutor] Fwd: Class Extend Help
Kent Johnson
kent37 at tds.net
Tue Dec 23 16:23:23 CET 2008
On Tue, Dec 23, 2008 at 9:31 AM, Omer <Jaggojaggo+Py at gmail.com> wrote:
>>>> 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?
That's pretty obscure, not sure why you get exactly that error!
Anyway the code should be
class fetch(object):
urlopen is a function, not a class, so it can't be a base class of
fetch. There is no need for it to be a base class, either; just use
object.
Kent
More information about the Tutor
mailing list