Definition of '1j'?

stephenhicks at stephenhicks at
Thu Oct 5 02:43:19 CEST 2006


I'm wondering how/where the syntax for, e.g., 1j is defined.  Is it
something I can define myself?  In particular, I make very heavy use of
a complex unit other than j (I'll call it 1k=exp(pi*1j/3)), and it
would be terribly convenient to make my own complex class based on this
unit, which would construct and display results in this form, i.e.
>>> (1+2k)*1k

It's not a terrible inconvenience if this is not possble, since I can
just define K=mycomplex(0,1), but I really do like the 1j notation, and
the problem with the other notation is that K could easily get
overwritten (and thus suggests I need a better name), while 1k would
take intention to mess up.

Steve Hicks

More information about the Python-list mailing list