jython: True and False boolean literals?

D

davidmichaelkarr

Aren't there boolean literals for "True" and "False" in Python
(jython)? I can't get "true", "True", "false", or "False" to work. I
ended up having to use "(1==1)" and "(1==0)".
 
K

Kent Johnson

Aren't there boolean literals for "True" and "False" in Python
(jython)? I can't get "true", "True", "false", or "False" to work. I
ended up having to use "(1==1)" and "(1==0)".

No, there are not. Jython implements Python 2.1 which did not have boolean literals. You
can just use 1 and 0.

Kent
 
K

keirr

Kent said:
No, there are not. Jython implements Python 2.1 which did not have boolean literals. You
can just use 1 and 0.
The latest jython is 2.2a1 (which does have True and False as ints)

You could declare your own True and False like this:
class Boolean:
__init__(self, value):
self.__value = value
__repr__(self):
return self.__value != 0
__int__(self):
return int(self.__value)
and so on.

then, True = Boolean(1)
and False = Boolean(0)

Cheers,
Keir
 
B

Bengt Richter

Aren't there boolean literals for "True" and "False" in Python
(jython)? I can't get "true", "True", "false", or "False" to work. I
ended up having to use "(1==1)" and "(1==0)".
You may want to upgrade to a newer version.

Regards,
Bengt Richter
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top