changing to function what works like a function
Ian
hobson42 at gmail.com
Mon Mar 7 07:22:10 EST 2011
On 07/03/2011 11:33, Victor Paraschiv wrote:
> Hi everyone
> i understood that the goal of Python is to make programing easy (of
> course, powerful at the same time).
> I think one way to do it is to eliminate unnecessary syntax
> exceptions. One is the following:
> for a complex number "z", to get the real and imaginary part, you
> type: "z.real" and "z.imag".
> At the same time, the most obvious way would be to call it like a
> function, say: "real(z)", and, respectively, "imag(z)". Just like it
> was changed from " print 'something' " , to " print('something') " .
>
> What do you think? There are more examples like this.
>
>
I think it a crazy idea. Python intends to be object oriented so the
"obvious" way is to call a method, or access an attribute.
If there was a risk that the structure of complex numbers might change
(there isn't), and if that would mean that z.real and z.imag could not
work (it doesn't), then
z.real() and z.imag() might be an improvement. As there is no such
risk, the current syntax is as good as it can get.
Ian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110307/3135ce95/attachment-0001.html>
More information about the Python-list
mailing list