help on object programing

mike mike at netadv.net
Fri Aug 17 13:37:46 EDT 2007


On Aug 17, 11:07 am, yadin <conra2... at yahoo.com> wrote:
> class big(self):
>
>     x = 32
>     list = []
>     def inside (self):
>
>         class small(self): # a new class defined inside the first
>
>             y = 348
>             list.append(y) # send the value to first list
>             list.append(x)
>
> print list
>
> how can i define my variables so that there are valid outside the
> class???


Well, first you have to create an instance of the class big:
  bigInstance = big();

then to get to bigInstance's list you do bigInstance.list and you can
get to the list:
  print bigInstance.list;

but the list will be empty.

check out the dive into python book to understand it object oriented
programming a little more.
http://www.diveintopython.org/





More information about the Python-list mailing list