[Tutor] problem with defining a global class instance

sharath B N bn.sharath at gmail.com
Fri Nov 17 07:21:28 CET 2006

i am sort of newbie to python. I am trying to do a super Market
simulation with OOP in python. I have problems with using a class
instance as global...
def generate (... ,....,...)

" in this function i define the global variables "
global  stock,stockManager, manager etc.

class Manager
def  create_stockManager(..)
""" this is a method in class manager"""
stockManager = StockManager( name)

now this gives an attribute error sayin .... stockManager has no
attribute create_Stock

if i create the StockManager instance in the generate func
itself...then this problem doesnt come....but i need it this way for
the program to make sense..
can somebody help me

More information about the Tutor mailing list