Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

How do I create lists in classes in Python?

python

This topic has been archived. This means that you cannot reply to this topic.
No replies to this topic

#1 Kosarar

Kosarar

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 09 January 2017 - 02:49 AM

I want to operate a local list in a class in Python. I can not do that:

  1. class cCompetition:
  2. lcPersonAll = []
  3.  
  4. def AddPerson(self, cPersonNew):
  5. lcPersonAll.append(cPersonNew)
  6.  
  7. cCompetition1 = cCompetition()
  8. cCompetition1.AddPerson("Smith")
  9.  

However, global list is possible.