can I overload operators like "=>", "->" or something like that?

D

dmitrey

hi all,
can I somehow overload operators like "=>", "->" or something like
that? (I'm searching for appropriate overload for logical implication
"if a then b")
Thank you in advance, D.
 
J

Jacob MacDonald

hi all,
can I somehow overload operators like "=>", "->" or something like
that? (I'm searching for appropriate overload for logical implication
"if a then b")
Thank you in advance, D.

I don't believe that you could overload those particular operators, since to my knowledge they do not exist in Python to begin with.
 
J

Jacob MacDonald

There is no ‘=>’ operator, and no ‘->’ operator, in Python


No, ‘<=’ is the less-than-or-equal operator. There is no ‘=>’operator
in Python.

--
\ “I knew things were changing when my Fraternity Brothers threw |
`\ a guy out of the house for mocking me because I'm gay.” |
_o__) —postsecret.com, 2010-01-19 |
Ben Finney

Thought so.
 
N

Nobody

can I somehow overload operators like "=>", "->" or something like that?
(I'm searching for appropriate overload for logical implication "if a then
b")

You cannot create new operators, but you can control how existing
operators work on types which you define.

IOW, you can't define "->" or "=>", but you could define ">=" or ">>".
 
J

Jussi Piitulainen

Kiuhnm said:
You can also "overload" '<-' ;)

Huh. If you're thinking what you just made me think, maybe x -=1> y
could be made to work. Think of --> but Python doesn't have -- ...

I forget whether it is just the Java people or also the Python group
who feel very strongly that the truth values should not really be
ordered and it is something like a bug in the language that they are.

Because <= already works as a material implication for the built-in
True and False to a certain extent: not for general truth values, and
x <= y <= z does not mean x <= (y <= z), and seen as an arrow the
symbol does feel backwards, and probably other such issues.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top