I'm wrong or Will we fix the ducks limp?

Ian Kelly ian.g.kelly at gmail.com
Fri Jun 3 11:35:06 EDT 2016


On Fri, Jun 3, 2016 at 9:04 AM, Sayth Renshaw <flebber.crue at gmail.com> wrote:
>
>
>> The problem is that you think that *variables* have a type. This isn't
>> the case. Objects have a type. A variable is a name by which you can
>> refer to an object. There are various ways in which you can associate a
>> object with a variable, the most obvious being an assignment statement.
>
> So at the point I create the variable it refers to an object.
>
> More correctly when I create the variable and assign a list action to the variable I believe I should be creating a reference to a list object in one motion; however python would like me to create the object first before creating a reference to it, is that the catch?
>
> I am not allowed to create references to an object at the same time I create the object is that correct?

I'd say leave references out of this. They don't correspond 1:1 with
variables, and bringing them up is only going to confuse the issue.

When you call the append method you're not "assigning a list action"
to the variable. You're just trying to call a method named "append".
That could be the list append method. Or it could be the array append
method. Or the deque append method. Or you may have written your own
class with an append method. How is the interpreter supposed to know
which one you mean?

In general, it can't, so it doesn't try. You have to create an object
before you can start doing anything it.


More information about the Python-list mailing list