Re: Numbers and truth values

2007-04-29 Thread Beliavsky
On Apr 28, 4:05 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: John Nagle [EMAIL PROTECTED] wrote: I'd have to consider that a bug. Some very early FORTRAN compilers allowed you to redefine integer constants: CALL SET(25,99) WRITE (6,100) 25 100 FORMAT(I6)

Re: Numbers and truth values

2007-04-29 Thread Alex Martelli
Beliavsky [EMAIL PROTECTED] wrote: ... If this has changed in the Fortran 1990 standard or later, then I can only say I'm happy I stopped using Fortran heavily before such standards became widespread in commonly available compilers -- by the late '90s, when I was still using

Numbers and truth values

2007-04-28 Thread Szabolcs
Newbie question: Why is 1 == True and 2 == True (even though 1 != 2), but 'x' != True (even though if 'x': works)? -- http://mail.python.org/mailman/listinfo/python-list

Re: Numbers and truth values

2007-04-28 Thread Michael Hoffman
Szabolcs wrote: Why is 1 == True and 2 == True (even though 1 != 2), Not what I get. Python 2.5 (r25:51908, Mar 13 2007, 08:13:14) [GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin Type help, copyright, credits or license for more information. 2 == True False -- Michael

Re: Numbers and truth values

2007-04-28 Thread Irmen de Jong
Szabolcs wrote: Newbie question: Why is 1 == True and 2 == True (even though 1 != 2), but 'x' != True (even though if 'x': works)? Please check before you post: [E:\Projects]python Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright,

Re: Numbers and truth values

2007-04-28 Thread Steven D'Aprano
On Sat, 28 Apr 2007 14:33:23 +0200, Szabolcs wrote: Newbie question: Why is 1 == True and 2 == True (even though 1 != 2), but 'x' != True (even though if 'x': works)? Everything in Python has a truth-value. So you can always do this: if some_object: print if clause is true else:

Re: Numbers and truth values

2007-04-28 Thread Szabolcs
Steven D'Aprano wrote: 1 == True True 0 == False True 2 == True False Oh my goodness! Now I also get 2 != True. I really don't know what happened. Most probably this (as a result of mistyping): True = 2 # DON'T DO THIS!!! 2 == True True But shouldn't Python forbid this? Is it

Re: Numbers and truth values

2007-04-28 Thread Steven D'Aprano
On Sat, 28 Apr 2007 15:36:19 +0200, Szabolcs wrote: True = 2 # DON'T DO THIS!!! 2 == True True But shouldn't Python forbid this? Is it possible to get a warning when unintentionally redefining built-in thing? Python forbids very few things in comparison to other languages. The

Re: Numbers and truth values

2007-04-28 Thread Alex Martelli
Szabolcs [EMAIL PROTECTED] wrote: ... True = 2 # DON'T DO THIS!!! 2 == True True But shouldn't Python forbid this? Is it possible to get a warning when unintentionally redefining built-in thing? Python can be changed to make some non-reserved builtin identifiers into reserved words,

Re: Numbers and truth values

2007-04-28 Thread John Nagle
Steven D'Aprano wrote: On Sat, 28 Apr 2007 15:36:19 +0200, Szabolcs wrote: True = 2 # DON'T DO THIS!!! 2 == True True But shouldn't Python forbid this? Is it possible to get a warning when unintentionally redefining built-in thing? Python forbids very few things in comparison to

Re: Numbers and truth values

2007-04-28 Thread Alex Martelli
John Nagle [EMAIL PROTECTED] wrote: ... I'd have to consider that a bug. Some very early FORTRAN compilers allowed you to redefine integer constants: CALL SET(25,99) WRITE (6,100) 25 100 FORMAT(I6) SUBROUTINE SET(IVAR, INEWVAL) IVAR =

Re: Numbers and truth values

2007-04-28 Thread Szabolcs
Alex Martelli wrote: Maybe somebody assigning a value to True or False is a common error, but much of my livelihood over the last 10 years has been about mentoring/coaching programmers in Python, and that's one error I have *NEVER* observed, so I'd need a lot of empirical evidence to convince

Re: Numbers and truth values

2007-04-28 Thread Mel Wilson
John Nagle wrote: True, False, and None should be reserved words in Python. None already is. The permissiveness makes it less painful to upgrade to new versions of Python. True and False only recently got assigned conventional values, but you can still import old modules without

Re: Numbers and truth values

2007-04-28 Thread Steven D'Aprano
On Sat, 28 Apr 2007 11:35:36 -0700, John Nagle wrote: Python forbids very few things in comparison to other languages. The attitude is We're all adults here. Because Python is such a dynamic language, it is often hard for the compiler to tell the difference between something you are doing

Re: Numbers and truth values

2007-04-28 Thread Steven D'Aprano
On Sat, 28 Apr 2007 23:54:01 +0200, Szabolcs wrote: But I still think that it is an inconsistency to allow to redefine a _value_ like True or False (not a built-in function that may have been missing in earlier versions). Saying True = 2 is just like saying 3 = 2. Well, it might seem that

Re: Numbers and truth values

2007-04-28 Thread Alex Martelli
Szabolcs [EMAIL PROTECTED] wrote: But I still think that it is an inconsistency to allow to redefine a _value_ like True or False (not a built-in function that may have been missing in earlier versions). Saying True = 2 is just like saying 3 = 2. True and False were *ALSO* missing in earlier