Definition of '1j'?

S

stephenhicks

Hi,

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.-2+3k

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.

Thanks,
 
G

Gabriel Genellina

At said:
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

Nope - it's hardcoded inside the parser (see tokenizer.c)
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.
-2+3k

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.

For a thing like 3k to be recognized as a complex number I'm afraid
the only option would be to modify the Python sources.



Gabriel Genellina
Softlab SRL





__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top