Patches item #1491866, was opened at 2006-05-19 23:27 Message generated for change (Comment added) made by hwundram You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1491866&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Core (C code) Group: Python 2.5 Status: Open Resolution: None Priority: 5 Submitted By: Heiko Wundram (hwundram) Assigned to: Nobody/Anonymous (nobody) Summary: Complex representation Initial Comment: As per request on c.l.p: http://groups.google.de/group/comp.lang.python/browse_thread/thread/26c93fefefd3a100/bf1924ce28fac1ac?hl=de#bf1924ce28fac1ac I've implemented a small patch to change the output of repr(x) for complex variables, so that complex(repr(x)) works for any complex x. This changes the output of repr(x) to '<r>+<i>j' without brackets, but leaves the string output untouched. This change of behaviour would be in line with int(repr(x)) and float(repr(x)) being defined for any int or float x, repectively. I don't know whether this patch is sensible, and whether it breaks any current code, because (for example) eval("5*%r" % (1+2j,)) won't work properly anymore, or whether it'd be more sensible to change the complex constructor to also accept a bracketed expression. I'll attach a patch to do the latter later. ---------------------------------------------------------------------- >Comment By: Heiko Wundram (hwundram) Date: 2006-05-20 00:28 Message: Logged In: YES user_id=791932 The second patch (python-complex-constructor.diff) changes the constructor to accept bracketed complex numbers which are enclosed in a single bracket. I'd rather say this is the better appropach to have complex(repr(x)) work, but I leave both patches attached to this bug. The latter patch also creates test cases testing for formatting errors with bracketed expressions. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1491866&group_id=5470 _______________________________________________ Patches mailing list Patches@python.org http://mail.python.org/mailman/listinfo/patches