Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > None, False, True

Reply
Thread Tools

None, False, True

 
 
M-a-S
Guest
Posts: n/a
 
      09-16-2003
Can anybody explain this:

Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> None = 3

<stdin>:1: SyntaxWarning: assignment to None
>>> False = 4
>>> True = 5
>>>
>>> None, False, True

(3, 4, 5)
>>>




 
Reply With Quote
 
 
 
 
Indigo Moon Man
Guest
Posts: n/a
 
      09-16-2003
M-a-S <NO-> spake thusly:
> Can anybody explain this:
>
> Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on
> win32 Type "help", "copyright", "credits" or "license" for more
> information.
>>>>
>>>> None = 3

> <stdin>:1: SyntaxWarning: assignment to None
>>>> False = 4
>>>> True = 5
>>>>
>>>> None, False, True

> (3, 4, 5)


http://www.ibiblio.org/obp/thinkCSpy/chap05.htm

In section 5.9 (Glossary) near the bottom of the link above I found this
entry for None...

None
A special Python value returned by functions that have no
return statement, or a return statement without an argument.

Maybe that has something to do with it.

--
Remove BLINDERS to email me.
Audio Bible Online:
http://www.audio-bible.com/


 
Reply With Quote
 
 
 
 
anton muhin
Guest
Posts: n/a
 
      09-16-2003
Indigo Moon Man wrote:

> M-a-S <NO-> spake thusly:
>
>>Can anybody explain this:
>>
>>Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on
>>win32 Type "help", "copyright", "credits" or "license" for more
>>information.
>>
>>>>>None = 3

>>
>><stdin>:1: SyntaxWarning: assignment to None
>>
>>>>>False = 4
>>>>>True = 5
>>>>>
>>>>>None, False, True

>>
>>(3, 4, 5)

>
>
> http://www.ibiblio.org/obp/thinkCSpy/chap05.htm
>
> In section 5.9 (Glossary) near the bottom of the link above I found this
> entry for None...
>
> None
> A special Python value returned by functions that have no
> return statement, or a return statement without an argument.
>
> Maybe that has something to do with it.
>


Defenitely. If I remember it right, None is going to be promoted into
keywords soon. Therefore the warning.

hth,
anton.

 
Reply With Quote
 
John J. Lee
Guest
Posts: n/a
 
      09-16-2003
"M-a-S" <NO-> writes:

> Can anybody explain this:
>
> Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information
> >>> None = 3

> <stdin>:1: SyntaxWarning: assignment to None
> >>> False = 4
> >>> True = 5
> >>>
> >>> None, False, True

> (3, 4, 5)


I believe there have been discussions about preventing the clobbering
of builtins recently, so it may happen in the future (2.4?).

Dunno why None and not True / False causes a warning, but you can turn
warnings into errors using the warnings framework, I think.


John
 
Reply With Quote
 
Max M
Guest
Posts: n/a
 
      09-16-2003
M-a-S wrote:

> Can anybody explain this:
>
> Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>
>>>>None = 3

>
> <stdin>:1: SyntaxWarning: assignment to None
>
>>>>False = 4
>>>>True = 5
>>>>
>>>>None, False, True

>
> (3, 4, 5)


Yes. You assign new values to the objects None, False and True. You then
print out those values in a tuple.

What's not to understand?

But for others reading your programme you might be better of to keep
them their normal values.


regards Max M

 
Reply With Quote
 
Skip Montanaro
Guest
Posts: n/a
 
      09-16-2003

John> Dunno why None and not True / False causes a warning, but you can
John> turn warnings into errors using the warnings framework, I think.

Too much Python code which needs to run on 2.2 or earlier legitimately
defines True and False something like so:

try:
True
except NameError:
True = (1 == 1)
False = not True

All that valid code would raise SyntaxWarning if it was enabled for True and
False. Note that SyntaxWarning is raised at compilation time, not runtime,
so the compiler doesn't know a priori whether the except clause will
execute.

Skip


 
Reply With Quote
 
Raymond Hettinger
Guest
Posts: n/a
 
      09-16-2003
[John J Lee]
> Dunno why None and not True / False causes a warning


Because there is a lot of existing code that legitimately made
assignments to True and False.

> but you can turn
> warnings into errors using the warnings framework, I think.


Right!


Raymond


 
Reply With Quote
 
M-a-S
Guest
Posts: n/a
 
      09-16-2003

"anton muhin" <> wrote in message news:bk7mkg$4s$...

> Defenitely. If I remember it right, None is going to be promoted into
> keywords soon. Therefore the warning.
>
> hth,
> anton.
>


Will it be lower-case (together with false and true) like all other keywords or is it just a start of mess?

M-a-S


 
Reply With Quote
 
M-a-S
Guest
Posts: n/a
 
      09-16-2003

"Max M" <> wrote in message news:3f675ecd$0$97184$ k...
>
> Yes. You assign new values to the objects None, False and True. You then
> print out those values in a tuple.
>
> What's not to understand?
>
> But for others reading your programme you might be better of to keep
> them their normal values.


Which are ...?

I mean what are None, False and True? Are they just identifiers? Are they
variables defined in __builtins__? Are they literals? Are they language "bricks"
like "for" and "1"?


 
Reply With Quote
 
Martin v. =?iso-8859-15?q?L=F6wis?=
Guest
Posts: n/a
 
      09-16-2003
"M-a-S" <NO-> writes:

> Will it be lower-case (together with false and true) like all other
> keywords or is it just a start of mess?


It is a start of mess.

Actually, None will be the first in a new category of token, the
"reserved identifiers". The exact lexical properties of such tokens
still need to be determined, and it might be that None is only the
second in its category, following "as".

Martin
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[False,True] and [True,True] --> [True, True]????? bdb112 Python 45 04-29-2009 02:35 AM
"0 in [True,False]" returns True Pierre Quentel Python 59 12-16-2005 01:47 PM
TurboGears /.-ed, >new == True< or >new == "True"< Andy Leszczynski Python 4 10-13-2005 06:56 AM
C and C++ are interoperable languages? True or Not True? Chip C++ 6 01-08-2005 11:10 PM
Does true ^ true return false? Siemel Naran C++ 19 06-18-2004 11:06 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57