A certainl part of an if() structure never gets executed.

Steven D'Aprano steve+comp.lang.python at pearwood.info
Wed Jun 19 04:55:37 EDT 2013


On Wed, 19 Jun 2013 18:21:40 +1000, Chris Angelico wrote:

> You can't reference an object without
> somewhere having either a name or a literal to start it off.

True, but not necessarily a name bound to the object you are thinking of:

some_function()

gives you an object, but it's not a literal, and "some_function" is not 
the name of the object you end up with.

In a sense, you're making a fairly uninteresting claim:

"You cannot refer to an object without referring to something"

which is obviously correct. The ways to refer to something are more 
interesting:

* you can refer to a thing directly by referring to it as a literal;

* you can refer to a thing bound to a name by referring to the name;

* you can refer to a thing in a namespace by referring to the namespace 
in some fashion, followed by a dot, followed by the name in that 
namespace,  e.g. some_object.attribute, __import__('math').pi;

* you can refer to a thing in a sequence by referring to the sequence in 
some fashion, followed by an index number in square brackets, e.g. seq[3];

* you can refer to a thing that is returned by a callable (function, 
method, type, etc.) by referring in some fashion to that callable object, 
followed by calling it, e.g. functions[9](arg) gives you a reference to 
some object which may not be any of `functions`, `9`, or `arg`.


Have I missed any?


-- 
Steven



More information about the Python-list mailing list