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

Chris Angelico rosuav at gmail.com
Wed Jun 19 04:21:40 EDT 2013


On Wed, Jun 19, 2013 at 6:06 PM, Dave Angel <davea at davea.name> wrote:
> On 06/19/2013 03:14 AM, Chris Angelico wrote:
>>
>> On Wed, Jun 19, 2013 at 3:42 PM, Dave Angel <davea at davea.name> wrote:
>>>
>>> Names are *one of* the ways we specify which objects are to be used. (We
>>> can
>>> also specify objects via an container and a subscript or slice, or via an
>>> attribute of another object.  And probably another way or two.)
>>
>>
>> But you always have to bootstrap it with either a name.
>
>
> Whatever bootstrap really means in this context.  But if you have myname[3]
> + myname[5], the two objects being added are identified by a subscript
> operation, not just a name.
>
>> Or a literal.
>
>
> A literal is used to create an object, and acts like a temporary name for
> that object, but once again the object being operated on isn't necessarily
> that one. You can subscript and get attributes from a literal as well.
>
>
>> So those are the only two ways to specify which objects are to be
>> used.
>>
>
> That would be a pretty weak language, and it wouldn't be python.
>
>
> Now if you considered "." and "[" as operators, then I could understand your
> point.  But
>    http://docs.python.org/3/reference/lexical_analysis.html#operators
> seems to say differently.
>
> Also see
>    http://docs.python.org/3/reference/expressions.html#primaries

They may not quite be "operators" per se, but the fact is that they're
composites built of primitives. You can't reference an object without
somewhere having either a name or a literal to start it off. Your
example starts with the object identified by the name 'myname', and
the objects referenced by the literals 3 and 5, and builds up from
there. Rebinding 'myname' would change that expression, as would
changing the meanings of 3 or 5, though I don't know of any way to do
the latter :)

ChrisA



More information about the Python-list mailing list