Spaces in object attribute

Steve Holden sholden at holdenweb.com
Thu Jan 10 10:14:21 EST 2002


"Emile van Sebille" <emile at fenx.com> wrote ...

[periodic surprise]
>
> Well I'll be damned!  Spaces are allowed on either side of the period as
> well.
>
> >>> obj . attr  # look! the period binds!
> 1
> >>> obj      .      attr
> 1
>
> Do people really write programs that use this?  I'm not looking to change
> it, just understand why I got bit by it.  ;-)
>
> I did find http://www.python.org/doc/current/ref/delimiters.html and
> thinking of a period as a delimiter completes my understanding of this.  I
> don't know why I previously assumed differently.  ;-)
>
Not just spaces, in some contexts:

>>> obj.attr=1
>>> (obj
...
...                         .
...
...                                         attr)
1

why-use-one-line-when-five-will-do-ly y'rs  - steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list