ten small Python programs
Steve Howell
showell30 at yahoo.com
Sun May 27 02:30:37 EDT 2007
--- Steven D'Aprano
<steve at REMOVE.THIS.cybersource.com.au> wrote:
> On Sat, 26 May 2007 18:48:45 -0700, Steve Howell
> wrote:
>
> > It also has a ComplexNumber class, but I don't
> want to
> > scare away mathphobes.
>
> Is it as short as this one-liner?
>
> ComplexNumber = complex
>
The "It" above refers to *the* Python Tutorial,
written by Guido van Rossum. Here is an excerpt:
>>> class Complex:
... def __init__(self, realpart, imagpart):
... self.r = realpart
... self.i = imagpart
...
>>> x = Complex(3.0, -4.5)
>>> x.r, x.i
(3.0, -4.5)
Obviously, it's not surprising that a useful class in
a tutorial would have a corresponding implementation
in the standard library, but I'm not sure newbies
would learn much about classes from this statement:
ComplexNumber = complex
____________________________________________________________________________________
Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
http://answers.yahoo.com/dir/?link=list&sid=396546091
More information about the Python-list
mailing list