User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 391,608 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,642 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser:
Views: 234 | Replies: 2
Reply
Join Date: Apr 2008
Posts: 26
Reputation: FreezeBlink is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
FreezeBlink FreezeBlink is offline Offline
Light Poster

Finding all instances of a class?

  #1  
Jun 29th, 2008
Really, the title says it all. Is there any way to compile all the instances of a class into a list, or other such data structure?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2007
Posts: 254
Reputation: BearofNH is on a distinguished road 
Rep Power: 2
Solved Threads: 17
BearofNH's Avatar
BearofNH BearofNH is offline Offline
Posting Whiz in Training

Re: Finding all instances of a class?

  #2  
Jun 30th, 2008
I have done this on occasion. The easiest way to do this is have your __init__() routine append self to a list. If it's not "your" class I suppose you could override the __init__ method of the class.

Fortunately I never had to worry about deletes...
Reply With Quote  
Join Date: Apr 2008
Posts: 26
Reputation: FreezeBlink is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
FreezeBlink FreezeBlink is offline Offline
Light Poster

Re: Finding all instances of a class?

  #3  
Jun 30th, 2008
Sounds like that should work. Thanks!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Python Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Python Forum

All times are GMT -4. The time now is 12:05 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC