Downloads
Python
Home
›
The Python Tourist #4: None, empty, and nothing.
April 24, 2008 - 10:54pm — josh (not verified)
if len(tags) == 0
Couldn't you just say something like:
if tags is None:
# 'Error' handling
elif not tags:
# Empty list case
else:
# Process returned list
I like it better than saying "if len(tags) == 0", and if you've already tested for None then it has the same effect. What do you think?
Reply
Your name:
E-mail:
The content of this field is kept private and will not be shown publicly.
Homepage:
Subject:
Comment:
*
Input format
Filtered HTML
Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
Lines and paragraphs break automatically.
WikklyText, Restricted Mode
Write content in
WikklyText
format -
Restricted (Safe) Mode
.
For detailed help, see the
WikklyText Reference
More information about formatting options
Popular content
All time:
All About Python and Unicode
The Python Tourist #4: None, empty, and nothing.
MYOML #6: Metainfo, notes, warnings, and more HTML tags
Building Python extensions for Windows with only free tools
The Python Tourist #2: Taking Exception
Last viewed:
Installing openSUSE 10.1 "Loaded", with YUM
The Python Tourist
Building Python extensions for Windows with only free tools
The Python Tourist #1: Passing Mutable Objects as Default Args
The Python Tourist #4: None, empty, and nothing.
User login
Username:
*
Password:
*
Create new account
Request new password
if len(tags) == 0
# 'Error' handling
elif not tags:
# Empty list case
else:
# Process returned list