Difference between 'function' and 'method'

castironpi at gmail.com castironpi at gmail.com
Sat Mar 8 19:03:02 CET 2008

On Mar 7, 1:34 pm, castiro... at gmail.com wrote:
> On Mar 7, 6:44 am, Sion Arrowsmith <si... at chiark.greenend.org.uk>
> wrote:
> > Gabriel Genellina <gagsl-... at yahoo.com.ar> wrote:
> > >En Thu, 06 Mar 2008 23:46:43 -0200, <castiro... at gmail.com> escribi�:
> > >> [ ... ]
> > >You may look at the SimpleXMLRPCServer class and see how it implements  
> > >introspection. It's rather easy (and doesn't require metaclasses nor  
> > >decorators nor any other fancy stuff; I think it works the same since  
> > >Python 2.1). Apparently you're doing a similar thing, but using pickles  
> > >instead of xmlrpc.
> > It's not that difficult to graft pickles into SimpleXMLRPCServer --
> > I've done it, and if you're trying to sling large data structures
> > over the connection it's a massive performance win (even with
> > sgmlop in place to speed up XML parsing).
> >    her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
> Yeah, but I'd be grafting a non-blocking RPC sequence too.
> -Instantiate- attributes of ISS upon instantiation.
> class C:
>   d= D
> c= C()
> assert isinstance( c.d, D )
> assert c.d is c.d
> Which ones?

Two options: instantiate all attributes, or ones with a certain
property, such as name or superclass.

class C:
   inst_d= D
   #actually gets bound to 'd', optionally

class C:
   d= inst( D )

I think what I'm looking for is an attribute wrapper.

class C:
   d= D

But the closest the syntax goes is:

class C:
   class d( D ): pass

(which takes us back to one of Steven's posts some days ago.)  ( def
f(x=None):/class C:/x= X/return C. ) and the d= inst( D ) solution.)

You either need to assign something to assign something to its name,

class C:
   d= X

or declare it, but that only allows def and class statements

class C:
   attr d: D

is ideal.

More information about the Python-list mailing list