Newbie question on Classes

Reedick, Andrew jr9445 at ATT.COM
Fri Jan 11 16:28:50 EST 2008


> -----Original Message-----
> From: python-list-bounces+jr9445=att.com at python.org [mailto:python-
> list-bounces+jr9445=att.com at python.org] On Behalf Of John Machin
> Sent: Friday, January 11, 2008 4:08 PM
> To: python-list at python.org
> Subject: Re: Newbie question on Classes
> 
> On Jan 11, 9:27 am, "Reedick, Andrew" <jr9... at ATT.COM> wrote:
> > > -----Original Message-----
> > > From: python-list-bounces+jr9445=att.... at python.org
[mailto:python-
> > > list-bounces+jr9445=att.... at python.org] On Behalf Of Adrian Wood
> > > Sent: Thursday, January 10, 2008 4:47 PM
> > > To: python-l... at python.org
> > > Subject: Newbie question on Classes
> >
> >
> > How about searching the garbage collector?
> 
> Not a good idea, because gc is an implementation artifact and in fact
> is specific to the C Python implementation; you won't find it in e.g.
> Iron Python or Jython.
> 

a) I forgot the ';-)' and/or <tongue_in_cheek> tag.

b) It was junk code.  A cleaner loop would be (which I figured out 5
minutes after posting =P ):
	for i in gc.get_objects():
		if isinstance(i, Person):
			print i.__class__, "%x" % id(i), i.SomeMethod()

c) It's good to know about GC being CPython only.

d) You forgot to mention the problem that some of the objects could be
'deleted' but not garbage collected yet.

e) Most importantly, anyone who is using the garbage collector as their
object manager isn't into proper coding practices in the first place.





More information about the Python-list mailing list