So I saw these two questions on twitter. How is 1.real a syntax error but 1 .real is not?
>>> 1.real
File "<stdin>", line 1
1.real
^
SyntaxError: invalid syntax
>>> 1 .real
1
>>> 1. real
File "<stdin>", line 1
1. real
^
SyntaxError: invalid syntax
>>> 1 . real
1
>>> 1..real
1.0
>>> 1 ..real
File "<stdin>", line 1
1 ..real
^
SyntaxError: invalid syntax
>>> 1.. real
1.0
>>> 1 .. real
File "<stdin>", line 1
1 .. real
^
SyntaxError: invalid syntax
1.is greedily parsed to a float number, and thenrealis missing the., whereas1 .realparses1as anint. Spaces are not allowed around decimal point, but you can have spaces before and after 'method accessor dot' (for lack of a better name). - tobias_k(1).realor1.0.realor1..real(they are all the same) - fferri1.realan attribute access, then1.e4looks like an attribute access, and perfectly fine code that used to produce10000.0suddenly produces an AttributeError. It's not worth the hassle. I'm pretty sure Ruby allows this kind of access, since ints have more interesting methods over there; I'm not sure what they do to handle it. - user2357112 supports Monica