473,588 Members | 2,465 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

None, False, True

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)


Jul 18 '05 #1
16 7103
M-a-S <NO*****@hotmai l.com> 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/
Jul 18 '05 #2
Indigo Moon Man wrote:
M-a-S <NO*****@hotmai l.com> 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.

Jul 18 '05 #3
"M-a-S" <NO*****@hotmai l.com> 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
Jul 18 '05 #4
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

Jul 18 '05 #5
[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
Jul 18 '05 #6

"anton muhin" <an************ *************** *****@rambler.r u> wrote in message news:bk******** *@news.peterlin k.ru...
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
Jul 18 '05 #7

"Max M" <ma**@mxm.dk> wrote in message news:3f******** *************** @dread12.news.t ele.dk...

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"?
Jul 18 '05 #8

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
Jul 18 '05 #9
"M-a-S" <NO*****@hotmai l.com> 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
Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
1847
by: Josef Meile | last post by:
Hi, Textually from the highlights of python 2.4: "Assigning to None - the compiler now treats assigning to None as a SyntaxError." I think in general assignments to built-in types, functions, and variables should be also forbiden. It's a common mistake to do things like this:
20
1718
by: flamesrock | last post by:
Well, after playing with python for a bit I came across something weird: The statement (1 > None) is false (or any other value above 0). Why is this? (The reason I ask is sortof unrelated. I wanted to use None as a variable for which any integer, including negative ones have a greater value so that I wouldn't need to implement any tests or initializations
35
3366
by: Steven Bethard | last post by:
I have lists containing values that are all either True, False or None, e.g.: etc. For a given list: * If all values are None, the function should return None.
5
1542
by: Nicolas Couture | last post by:
Hi, Is it possible to generate a list of `None' ? opts.__dict__.values() below could be represented by --- def get_options(opts): """Return True or False if an option is set or not""" vals = opts.__dict__.values()
2
1573
by: Rodney Maxwell | last post by:
In Python 2.4.1: >>> None = 99 SyntaxError: assignment to None >>> True = 99 >>> False = 99 >>> True == False True ----------------------- So why is 'None' special?
18
4982
by: Alan G Isaac | last post by:
>>None >= 0 False True Explanation appreciated. Thanks, Alan Isaac
0
209
by: Reedick, Andrew | last post by:
a If name is None: Then name is NULL, nothing, nada, no object, no memory allocated, a NULL pointer If name is not None: Then name is an object. It's a pointer to some kind of allocated structure in memory. No idea if it contains a false or true value.
0
7929
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7862
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8228
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8357
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7987
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8223
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6634
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5729
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2372
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.