Why not 3.__class__ ?

Michael Abbott michael at rcp.co.uk
Wed Oct 10 18:03:20 CEST 2001


"John Roth" <johnroth at ameritech.net> wrote in
news:ts8qte7m3n97e2 at news.supernews.com: 

> That's not exactly true. Making a feature dependent on whether there is
> white space between components violates the principle of least
> astonishment. It's also a very fertile source for very obscure bugs.

Well, I suppose the only issue is what happens when someone writes
    	3.foo
where the thing on the left is an integer literal and the thing on the 
right is an identifier.  This is, presumably, parsed as
    	<float><identifier>
and I would imagine that this would inevitably cause a syntax error.

Although mildly surprising to the programmer, this doesn't strike me as 
particularly astonishing.  More to the point, I don't see any room for any 
bugs at all here (let alone obscure ones), since the offending syntax is 
caught by the "compiler".



More information about the Python-list mailing list