Hi, first sorry for my poor english, i'm a french guy, i'm trying to make the best :(
I would like to split my python script into multiples files. I want : A file which contains only class creations and methods, A file with some personals functions And a main.py which is the main script. But i'm getting some problems In class creation file, i've a init method which create a character (it works). They are created in main.py like this : herosAll = [ Character(1,"Antaa","Soldat moins fort",15,5,8), Character(2,"Klaitos","Soldat moins fort",15,5,8)] But when i want to display all information about my character with : class Character(): def DisplayAll(): print ('There is', Character.CharacterCount, 'heros') for heros in herosAll: heros.DisplayCharacterInfos() I'm getting : Traceback (most recent call last): File "main.py", line 28, in <module> Character.DisplayAll() File "/home/christopher/class_creation.py", line 53, in DisplayAll for heros in herosAll: NameError: global name 'herosAll' is not defined I know the source of the problem. The list herosAll is declared in main.py so he can't access to it. But i'm stuck here. How can he get it ? Have I to append the list in the init method ? Thank you for ready. -- Brookes Christopher.
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor