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

Gregory Ewing greg.ewing at canterbury.ac.nz
Wed Jun 8 01:59:24 EDT 2016


Random832 wrote:
> Er, how would that make them not first class?

They wouldn't be as transparent as references in C++,
which you just assign to like any other variable.

That works because C++ makes a distinction between
initialisation and assignment. It's not so easy to
separate those in Python.

> "Assign to the variable object that is in this
> variable" would be a distinct operation from "Assign to this variable",
> just like "add one to this value" or "call this function" etc.

That would be like pointers in C that you have
to explicitly dereference. I'm not sure whether
C could be described as having "first class
variables", though.

If transparency is not required, you can easily
create wrapper objects in Python that refer
to an attribute or element of an object.

-- 
Greg



More information about the Python-list mailing list