-----Original Message-----
From: py************* *************** ****@python.org [mailto:python-
li************* ************@py thon.org] On Behalf Of Reedick, Andrew
Sent: Tuesday, July 15, 2008 4:13 PM
To: Victor Noagbodji; py*********@pyt hon.org
Subject: RE: 'if name is not None:' v. 'if name:'
If name:
Then either
a) name is an object, and that object does not have a 'false'
value, such as False, zero, or empty.
or
b) name is NULL/None. No object.
Change that to:
If not name:
Then either
a) name is an object, and that object does not have a 'false'
value, such as False, zero, or empty.
or
b) name is NULL/None. No object. 0 1090 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Stewart Midwinter |
last post by:
I'd like to do something like the following:
a = 1; b = 2; c = None
mylist =
for my in mylist:
if my is None:
print 'you have a problem with %s' % my #this line is problematic
>>> You have a problem with None
|
by: Victor Noagbodji |
last post by:
>>what's the difference between these two statement?
Well that's exactly why I'm asking. Since None returns False in if
statements. Why do people use if name is not None: instead of simply
writing if not name?
--
NOAGBODJI Paul Victor
|
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.
|
by: Jerry Hill |
last post by:
On Tue, Jul 15, 2008 at 4:13 PM, Reedick, Andrew <jr9445@att.comwrote:
This is just plain untrue. If 'name is None' evaluates to true, then
the variable 'name' is bound to the singleton value None. It has
nothing to do with allocated memory or null pointers. All it means is
that someplace along the line you did the equivalent of 'name = None'
in your code.
--
Jerry
|
by: Fredrik Lundh |
last post by:
Victor Noagbodji wrote:
Because they want to distinguish between None and other values that
evaluate to False, of course. As the page I linked to explains, there
are many objects that evaluate to false in a boolean context; None is
just one of them.
Or to spell it out: if you need to distinguish between None and other
false values, use an explicit test. If you don't need to distinguish
| |
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...
|
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,...
|
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,...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |