rhodri at wildebst.demon.co.uk
Fri Jul 24 14:05:58 EDT 2009
On Fri, 24 Jul 2009 16:03:58 +0100, Piet van Oostrum <piet at cs.uu.nl> wrote:
>>>>>> "Rhodri James" <rhodri at wildebst.demon.co.uk> (RJ) wrote:
>> RJ> On Fri, 24 Jul 2009 14:55:45 +0100, Hrvoje Niksic
>> <hniksic at xemacs.org> wrote:
>>>> Ben Finney <ben+python at benfinney.id.au> writes:
>>>>> Utpal Sarkar <doetoe at gmail.com> writes:
>>>>>> Is there a way I can tell a variable that the object it is pointing
>>>>>> too is not owned by it, in the sense that if it is the only
>>>>>> to the object it can be garbage collected?
>>>>> Python doesn't have “pointers”, and doesn't really have “variables”
>>>>> either, at least not how many other languages use that term.
>>>> The OP didn't use the term "pointer", but the word "pointing", which
>>>> makes sense in the context. The term "variable" is used in the Python
>>>> language reference and elsewhere, and is quite compatible with how
>>>> popular languages (Java, PHP, Lisp, ...) use it.
>> RJ> Only superficially. Treating Python variables the same as C
>> RJ> (say) is one of the classic ways that newbies come unstuck when
>> RJ> objects appear on the scene. While the OP appears to have the
>> right idea,
>> RJ> your "correction" here could be quite misleading.
> If you read the OP, it is clear that he talked about a class variable,
> which is a perfectly legal notion in Python, and is mentioned as such in
> the language reference manual:
> `Variables defined in the class definition are class variables'
Yes. I didn't think I needed to say that explicitly.
> And who was talking about C variables?
Hrvoje, implicitly. 'The term "variable" is used in the Python
language reference and elsewhere, and is quite compatible with how
other popular languages (Java, PHP, Lisp, ...) use it.' I listed
C as another example of a popular language because I am very familiar
with how C's variables work; I don't know Java, I've never programmed
PHP in anger and it's twenty years since I last touched Lisp.
The point was, and remains, that this newsgroup gets regular traffic
from people who expect Python's variables to act like C's variables,
demonstrating that describing them as "quite compatible" is somewhat
Rhodri James *-* Wildebeest Herder to the Masses
More information about the Python-list