recursion in Class-methods?

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Fri Jun 27 04:10:23 EDT 2008


defn noob a écrit :
> class Graph(object):
> 
> where does anyone write like that?

Almost everywhere nowadays.

> I've seen only examples like i have
> written.

Most of the doc has still not been updated since the introduction of 
newstyle classes years ago. You'll find more here:
http://docs.python.org/ref/node33.html


> is the object then passed to init?

Nope, it's the base class for your Graph class.

> 
> class Graph(object):
>     def __init__(self, dictionary):
>         self.structure = dictionary
> 
> or
> 
> class Graph(object):
>     def __init__(self, object):
>         self.structure = object
> 

parent class list in a class statement and argument list of an 
initializer are totally unrelated.

The syntax for a class statement is:
classdef  	::=  	"class" classname [inheritance] ":" suite
inheritance 	::= 	"(" [expression_list] ")"
classname 	::= 	identifier

cf http://docs.python.org/ref/class.html

> 
> and "mutable containers", do you refer to "path=[]" as a parameter.

Indeed. This is one of the most (in)famous Python gotchas.



More information about the Python-list mailing list