Re: Re: Objects in Python

2012-08-25 Thread Chris Angelico
On Sun, Aug 26, 2012 at 3:45 PM, Evan Driscoll wrote: > Third, and more wackily, you could technically create a C implementation > that works like Python, where it stores variables (whose addresses aren't > taken) in a dict keyed by name, and generates code that on a variable access > looks up the

Re: Re: Objects in Python

2012-08-25 Thread Evan Driscoll
On 08/24/2012 05:00 AM, Steven D'Aprano wrote: No. The compiler remembers the address of 'a' by keeping notes about it somewhere in memory during the compilation process. When you run the compiled program, there is no longer any reference to the name 'a'. ... The mapping of name:address is part

Re: Re: Objects in Python

2012-08-25 Thread Evan Driscoll
On 08/24/2012 10:04 PM, Steven D'Aprano wrote: The fact that the end result is the same is hardly surprising -- Python's VM is built on top of C pointer indirection, so of course you can start with pointers and end up with Python semantics. But the practice of coding are very different: * in C,

Re: Re: Objects in Python

2012-08-24 Thread wu wei
On Fri, Aug 24, 2012 at 7:14 PM, Evan Driscoll wrote: > On 8/23/2012 22:17, alex23 wrote: > > But Roy's point was that referring to 'a' as a 'variable' makes no > > sense, as it's not an allocated piece of memory. > > Does the computer just remember what 'a' refers to by keeping notes > about it

Re: Re: Objects in Python

2012-08-24 Thread Evan Driscoll
On 8/23/2012 22:17, alex23 wrote: > But Roy's point was that referring to 'a' as a 'variable' makes no > sense, as it's not an allocated piece of memory. Does the computer just remember what 'a' refers to by keeping notes about it in Narnia? Put it this way. If C removed the & operator -- and thu

Re: Re: Objects in Python

2012-08-23 Thread Evan Driscoll
On 08/23/2012 04:19 AM, lipska the kat wrote: > Well we don't want to turn this into a language comparison thread do we, > that might upset too many people but I can't remember ever writing a > method that took an Object as argument, you just can't do that much with > an Object. In the pre-Java-1.

Re: Re: Objects in Python

2012-08-22 Thread Chris Angelico
On Thu, Aug 23, 2012 at 2:49 PM, Evan Driscoll wrote: > On 8/22/2012 18:58, Ben Finney wrote: >> You haven't discovered anything about types; what you have discovered is >> that Python name bindings are not variables. >> >> In fact, Python doesn't have variables – not as C or Java programmers >> w

Re: Re: Objects in Python

2012-08-22 Thread Evan Driscoll
On 8/22/2012 18:58, Ben Finney wrote: > You haven't discovered anything about types; what you have discovered is > that Python name bindings are not variables. > > In fact, Python doesn't have variables – not as C or Java programmers > would understand the term. What it has instead are references

Re: Re: Objects in Python

2012-08-22 Thread Evan Driscoll
On 08/22/2012 02:45 PM, lipska the kat wrote: > On 22/08/12 20:03, Evan Driscoll wrote: >> Second, this concept isn't *so* unfamiliar to you. If I give you the >> following Java code: >> >>void foo(Object o) { ... } >> > looking at this method declaration I can see that the method takes an > ar

Re: Re: Objects in Python

2012-08-22 Thread Evan Driscoll
On 08/22/2012 12:46 PM, lipska the kat wrote: > If you can show me a 'type' that cannot be assigned to > > a > > in the same scope then I would be most interested to know, I haven't > found one yet. As other people have said, you've just pointed out the difference between static typing and dynam