Tags: boolean, false, iended, jython, literals, programming, python

jython: True and False boolean literals?

On Programmer » Python

2,155 words with 5 Comments; publish: Wed, 07 May 2008 01:53:00 GMT; (20078.13, « »)

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)".

All Comments

Leave a comment...

  • 5 Comments
    • davidmichaelkarr.python.todaysummary.com.gmail.com wrote:

      > Aren't there boolean literals for "True" and "False" in Python

      True

      <type 'bool'>

      works for most people :-)

      All the best,

      Keir

      #1; Wed, 07 May 2008 01:54:00 GMT
    • keirr wrote:

      > davidmichaelkarr.python.todaysummary.com.gmail.com wrote:

      >

      > True

      > <type 'bool'>

      > works for most people :-)

      >

      Ahem, who use python. For jython this looks like

      1

      <type 'int'>

      Keir.

      #2; Wed, 07 May 2008 01:55:00 GMT
    • davidmichaelkarr.python.todaysummary.com.gmail.com wrote:

      > 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 l

      iterals. You

      can just use 1 and 0.

      Kent

      #3; Wed, 07 May 2008 01:56:00 GMT
    • Kent Johnson wrote:

      > davidmichaelkarr.python.todaysummary.com.gmail.com wrote:

      > 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

      #4; Wed, 07 May 2008 01:57:00 GMT
    • On 22 Dec 2005 10:51:22 -0800, davidmichaelkarr.python.todaysummary.com.gmail.com wrote:

      >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

      #5; Wed, 07 May 2008 01:58:00 GMT