3 ms·
JavaScript also supports obj.id == obj["id"]. Python on the other hand does not support this (which is a shame, because obj.id is more readeable than obj['id'])
by amix 18y ago
JavaScript also supports obj.id == obj["id"]. Python on the other hand does not support this (which is a shame, because obj.id is more readeable than obj['id']). But it's possible to hack this on dicts ( http://pastie.org/296506 http://pastie.org/296506 ).
Syntactic sugar in languages is quite convenient, especially for things that are used a lot. Thought a lot of syntactic sugar (like in Perl) can ruin a language and it's readability.
- silentbicycle 18y agoI think syntactic sugar can make some things so convenient that people find novel uses for them. The ranged slicing operations in Python are really nice, for example; so is templating Lisp code with ` , ,@ once you get used to it. Adding SS also adds to what you need to remember to use the language effectively (and to read other peoples' code), but a little bit of syntactic sugar can go a really long way.