Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Hi, Pythoners.

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


aonlazio at gmail

Aug 13, 2008, 1:33 PM

Post #1 of 2 (134 views)
Permalink
Hi, Pythoners.

I have come across this code and I tried to figure out what does it do
First, I do not understand the sign @... above the class method, what does
it do?
Second, about the object in AnyWrapper(object), why do they declare "object"
as the superclass?
sometimes I saw (type) what the differences between "object" and "type"?


from ib.lib.overloading import overloaded

class AnyWrapper(object):
@overloaded
def error(self, e):
raise NotImplementedError()
@error.register(object, str)
def error_0(self, strval):
raise NotImplementedError()

Thanks in advance

Aonlazio


tjreedy at udel

Aug 13, 2008, 2:02 PM

Post #2 of 2 (127 views)
Permalink
Re: Hi, Pythoners. [In reply to]

AON LAZIO wrote:
> I have come across this code and I tried to figure out what does it do
> First, I do not understand the sign @... above the class method, what
> does it do?
> Second, about the object in AnyWrapper(object), why do they declare
> "object" as the superclass?
> sometimes I saw (type) what the differences between "object" and "type"?

Object is the base class. Type is the base metaclass. Reread the class
statement doc. @statements are decorators. I believe they are
documented along with function statements, though in 3.0 they apply to
classes also.
>
>
> from ib.lib.overloading import overloaded
>
> class AnyWrapper(object):
> @overloaded
> def error(self, e):
> raise NotImplementedError()
> @error.register(object, str)
> def error_0(self, strval):
> raise NotImplementedError()
>
> Thanks in advance
>
> Aonlazio
>
>
> ------------------------------------------------------------------------
>
> --
> http://mail.python.org/mailman/listinfo/python-list

--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.