__class__ for 2.2 types

Martin v. Loewis martin at v.loewis.de
Mon Feb 18 18:44:04 EST 2002


"Steve Holden" <sholden at holdenweb.com> writes:

> Well, syntactically the period acts as a delimiter when there are no spaces,
> but here the spaces themselves are the delimiters. Technically isn't the
> period acting as an operator here, the operation being "find in namespace"
> or some such?

Not really. The period isn't really a delimiter. Instead, it may or
may not be a token of its own: the previous token extends as much as
it can, resulting in "2." being a single token, but "a." being two
tokens. White space normally really delimits a token, as it is not
part of the token, but is no token on its own, either (unless it is
part of a string literal or comment, in which case it does not delimit
a token).

Now, once the input is broken into tokens, it turns out that "." is
not an operator (atleast not more than the ':' in a lambda expression
is an operator, or the while keyword). It appears in the production
'trailer', as in

power: atom trailer* ('**' factor)*
trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME

In case you wonder what an atom is:

atom: '(' [testlist] ')' | '[' [listmaker] ']' | '{' [dictmaker] '}' 
      | '`' testlist '`' | NAME | NUMBER | STRING+

Regards,
Martin



More information about the Python-list mailing list