Proposal: Magic Constants

John Roth newsgroups at jhrothjr.com
Thu Aug 28 22:11:07 EDT 2003


"Michael Hudson" <mwh at python.net> wrote in message
news:7h365kj6jp8.fsf at pc150.maths.bris.ac.uk...
> "John Roth" <newsgroups at jhrothjr.com> writes:
>
> > "Michael Hudson" <mwh at python.net> wrote in message
> > news:7h3r837ce12.fsf at pc150.maths.bris.ac.uk...
> > > "John Roth" <newsgroups at jhrothjr.com> writes:
> > >
> > > > But these are existing literal syntax. I was thinking
> > > > more of random code where someone could currently
> > > > juxtapose a literal and an identifier, say, without an
> > > > intervening white space character.
> > >
> > > >>> 10and 1
> > > 1
> > > >>> 5or 7
> > > 5
> > >
> > > Very much a wart of the tokenizer, though.
> >
> > Ah, right. I forgot about alphabetic operators.
> >
> > Why do you call it a wart, though?  I would have
> > thought that not requiring white space in that context
> > was a feature.
>
> Well, it's just odd.  I'm pretty sure it's not intentional, and fairly
> sure it's not documented.  I don't care enough to check, though :-)

The whitespace rule (from the Python Language Reference Manual)
is:

[begin excerpt LRM 2.1.8 in Python 2.2.3]
Except at the beginning of a logical line or in string literals, the
whitespace characters space, tab and formfeed can be used interchangeably to
separate tokens. Whitespace is needed between two tokens only if their
concatenation could otherwise be interpreted as a different token (e.g., ab
is one token, but a b is two tokens).
[end excerpt]

John Roth
>
> Cheers,
> mwh
>
> -- 
>   In many ways, it's a dull language, borrowing solid old concepts
>   from many other languages & styles:  boring syntax, unsurprising
>   semantics, few  automatic coercions, etc etc.  But that's one of
>   the things I like about it.                 -- Tim Peters, 16 Sep 93






More information about the Python-list mailing list