3 ms·
is there any PEP that makes parens around function call params optional? Tried to find it, no luck.
by ant6n 12y ago
is there any PEP that makes parens around function call params optional? Tried to find it, no luck.
- hueving 12y agoThat wouldn't be adequate at this point because the signature for print is different as well.
- actsasbuffoon 12y agoThat would be tricky. Ruby has optional parens for function calls, but it makes it tricky to get a reference to a method without calling it. We have to write "foo.method(:some_method_name)", while the Python equivalent is simply "foo.some_method_name". You might be able to require parens for methods with no arguments, but optional parens with arguments. It might require some clever hacks in the parser, but I suspect it's possible. The bigger question is whether or not the result would be Pythonic.
- ant6n 12y agoMaybe they could just re-introduce print x as syntactic sugar for galling a print function. Like in Matlab, where the operators (+, *, ..) are just syntactic sugar for calling functions add, mul, ..
- DrJosiah 12y agoThe Python 3.x print function and 2.x print statement automatically called the __str__ method on an object to get a representation to print to screen. The result is then sent to the appropriate file handle for actual printing (which can be overridden).
- tripzilch 12y agoIPython has this as a configuration option. I only use it in the interactive interpreter (not sure if it works in scripts, but I don't think that's a good idea anyhow). I like being able to type len flurp to quickly get the length of an array.