Explanation of list reference

Jussi Piitulainen jpiitula at ling.helsinki.fi
Sun Feb 16 03:35:20 EST 2014


Marko Rauhamaa <marko at pacujo.net> writes:

> Marko Rauhamaa <marko at pacujo.net>:
> 
> > Conceptually, the "everything is a reference" and the "small"/"big"
> > distinction are equivalent (produce the same outcomes). The question
> > is, which model is easier for a beginner to grasp.
> 
> Case in point, if everything is a reference, how come:
> 
>    >>> "hello".__str__()
>    'hello'
>    >>> 1.__str__()
>    SyntaxError: invalid syntax

That's just a clash with number syntax. Once succesfully parsed, there
is no such difference:

  >>> (1).__str__()
  '1'
  >>> 1 .__str__()
  '1'

(I'm not saying anything about anything being a reference, just that
your example didn't get analyzed to a level where there are things.)



More information about the Python-list mailing list