Python classes: Simplify?
Steven Lehar
slehar at gmail.com
Thu Mar 22 06:51:05 EDT 2012
It seems to me that the Python class system is needlessly confusing. Am I
missing something?
For example in the class Complex given in the documentation
*class Complex:*
* def __init__(self, realpart, imagpart):*
* self.r = realpart*
* self.i = imagpart*
*
*
*x = Complex(3.0, -4.5)*
I initially found it profoundly confusing that __init__( ) calls for 3
arguments, but you call Complex( ) with 2. Furthermore, why not call the
initialization function after the class name as is done in other languages?
Isn't that the simplest conceptually? Demonstrating with the above example:
*class Complex:*
* def Complex(realpart, imagpart):*
* Complex.r = realpart*
* Complex.i = imagpart*
*
*
*x = Complex(3.0, -4.5)*
*
*
Is there a good reason why classes cannot be defined that way? (Besides the
problem of backward-compatibility)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120322/e1da6f38/attachment.html>
More information about the Python-list
mailing list