HomePage | RecentChanges

Showing revision 2

SpittingCobra

Online python code generator.

It gets it's code from this wiki.

class  Person : 

   def __init__(self) :
      self.city = London
      self.age = 46
      self.name = Fred
      self.tags = ['programmer', 'cool']

   def copy(self) :
      # This is an "intelligent" copy routine. 
      # Instance variables that are scoped as "internal" are deep copied,
      # instance variables scoped as "external" are shallow copied
      c =  Person()
      c.city = self.city
      c.age = self.age
      c.name = self.name
      c.tags = self.tags[:]
      return c

   def inspect(self) :
      s = ''
      s = s + "city : %s\n" % self.city
      s = s + "age : %s\n" % self.age
      s = s + "name : %s\n" % self.name
      s = s + "tags : %s\n" % self.tags
      return s