complex() bug or feature?

Steve Holden sholden at holdenweb.com
Thu Nov 8 09:00:57 EST 2001


"Carsten Gaebler" <clpy at snakefarm.org> wrote in message
news:3BEA8B0F.E594BE84 at snakefarm.org...
> Michael Hudson wrote:
> >
> > Carsten Gaebler <clpy at snakefarm.org> writes:
> >
> > > >>> complex('1', '1')
> > > (1+0j)
>
> > According to the docs, this is in error:
> >
> > ,--http://python.sourceforge.net/devel-docs/lib/built-in-funcs.html---
>
> > I read that to mean that if the first arg is a string, it should be
> > the only arg.  The code simply ignores imag if real is a string.  Do
> > you want to open a bug, or shall I?
>
> Well, where exactly is the bug? Should the docs read 'If _real_ is a
> string, _imag_ is ignored and defaults to zero', or should the
> implementation raise an exception because it violates the docs? I'd
> prefer the latter.

Well the documentation should really make it clear that the single string
argument case is completely different from the single numeric argument case.
The former uses an implied zero as the imaginary component, whereas the
latter extracts the imaginary component from the string.

And yes, the implementation *should* raise an exception with a string first
argument and any second argument. But the docs could use clarification.

regards
 Steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list