I just read in the 'What's New in Python 2.4' document that the None
data type was converted to a constant: http://python.org/doc/2.4/whatsnew/node15.html
"""
# None is now a constant; code that binds a new value to the name
"None" is now a syntax error.
"""
So, what's the implications of this? I find the lack of explanation a
little puzzling, since I've written code that compares a variable's
type with the 'None' type. For example, a variable would be
initialized to 'None' and if it went through a loop unchanged, I could
determine this at the end by using a conditional type(var) ==
type(None). What will type(None) return now?
Jul 18 '05
16 2092
Michael Hoffman wrote: The fact that True and False are not constants?
Yowza.
a = True
b = False
False = a
True = b
if (1==2)==True:
print "Doom"
Michael Hoffman wrote: The fact that True and False are not constants?
Yowza.
a = True
b = False
False = a
True = b
if (1==2)==True:
print "Doom"
Warren Postma wrote: Michael Hoffman wrote:
The fact that True and False are not constants?
Yowza.
a = True b = False False = a True = b if (1==2)==True: print "Doom"
Why stop there when you can really cause some doom:
py> import __builtin__ as bltin
py> bltin.True, bltin.False = bltin.False, bltin.True
As an example of what doom this causes, try typing it at the interactive
prompt, and then see if you can enter anything else. I can't -- the
prompt just locks up. Woo-hoo! Another way to shoot myself (and my
users) in the foot! =)
STeVe
Steven Bethard said unto the world upon 2005-03-07 11:55: Warren Postma wrote:
Michael Hoffman wrote:
The fact that True and False are not constants?
Yowza.
a = True b = False False = a True = b if (1==2)==True: print "Doom"
Why stop there when you can really cause some doom:
py> import __builtin__ as bltin py> bltin.True, bltin.False = bltin.False, bltin.True
As an example of what doom this causes, try typing it at the interactive prompt, and then see if you can enter anything else. I can't -- the prompt just locks up. Woo-hoo! Another way to shoot myself (and my users) in the foot! =)
STeVe
Hi all,
just tried this in IDLE:
IDLE 1.1 import __builtin__ as bltin bltin.True, bltin.False = bltin.False, bltin.True
=============== =============== == RESTART
=============== =============== ==
The restart was done by IDLE itself -- poor thing just gave up. So, it
looks like Steve has found a `commit suicide' command for an IDLE
shell :-)
Best to all,
Brian vdB ga********@gmai l.com wrote: Sheesh... I didn't actually pull the type(None) comparison out of my code.
Sheesh yourself. Newsgroup readers can't do inspect.hasaclu e('J. Random
Poster'); they rely on duck-typing or goose-typing.
I was simply throwing together a possible situation. Had I thought about it for more than a second I would have remembered how I would actually use it.
Indeed.
Warren Postma <wp@tekran__NOS P7M.com> writes: ga********@gmai l.com wrote:
I just read in the 'What's New in Python 2.4' document that the None data type was converted to a constant: http://python.org/doc/2.4/whatsnew/node15.html
Implication: A long standing wart in Python now gone. Its time to gloat. Are there any really evil glitches LEFT in Python?
Python 2.4 (#1, Dec 1 2004, 14:23:15)
[GCC 3.2.3] on linux2
Type "help", "copyright" , "credits" or "license" for more information. True, False = False, True True
False
Jacek Generowicz napisa³(a): Implication : A long standing wart in Python now gone. Its time to gloat. Are there any really evil glitches LEFT in Python?
Python 2.4 (#1, Dec 1 2004, 14:23:15) [GCC 3.2.3] on linux2 Type "help", "copyright" , "credits" or "license" for more information.
True, False = False, True True
False
Ugh, today I've found this in some legacy code (yes, there *is* legacy
code in Python). And I will not touch this module until such syntax
become illegal.
--
Jarek Zgoda http://jpa.berlios.de/ | http://www.zgodowie.org/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Allison Bailey |
last post by:
Hi Folks,
I'm a brand new Python programmer, so please point me in the right
direction if this is not the best forum for this question....
I would like to open an existing MS Excel spreadsheet and extract
information from specific worksheets and cells.
I'm not really sure how to get started with this process.
I ran the COM Makepy utility from my PythonWin (IDE from ActiveSTate),
|
by: Chris McKeever |
last post by:
I am trying to modify the Mailman Python code to stop mapping
MIME-types and use the extension of the attachment instead. I am
pretty much clueless as to what I need to do here, but I think I have
narrowed it down to the Scrubber.py file..
If this seems like a quick step me through, I would be very
appreciative, could get you something on your Amazon wish-list (that
is me on my knees begging)..
From just my basic understanding, it...
|
by: svilen |
last post by:
hello again.
i'm now into using python instead of another language(s) for
describing structures of data, including names, structure,
type-checks, conversions, value-validations, metadata etc. And i have
things to offer, and to request.
And a lot of ideas, but who needs them....
here's an example (from type_struct.py):
|
by: Kamilche |
last post by:
"""
Emulating Python inheritance manually.
By loading it from disk at run time, you can create new custom types
without programmer intervention, and reload them on demand,
without breaking anything. The only time programmer intervention
is required, is when new functions are added.
It works well for data... I can use 'chicken.color' to access that
attribute, but not for functions. I can't say 'chicken.printme()',
|
by: Paul Cochrane |
last post by:
Hi all,
I've got an application that I'm writing that autogenerates python code
which I then execute with exec(). I know that this is not the best way to
run things, and I'm not 100% sure as to what I really should do. I've had a
look through Programming Python and the Python Cookbook, which have given me
ideas, but nothing has gelled yet, so I thought I'd put the question to the
community. But first, let me be a little more detailed...
| |
by: Edward Diener No Spam |
last post by:
The definition of a component model I use below is a class which allows
properties, methods, and events in a structured way which can be
recognized, usually through some form of introspection outside of that
class. This structured way allows visual tools to host components, and
allows programmers to build applications and libraries visually in a RAD
environment.
The Java language has JavaBeans as its component model which allows Java...
|
by: bcwhite |
last post by:
I've been trying to find out what the future of Python is with regard
to Tk. It seems there are several interfaces that make use of new
functionality, including "Tile" and "Ttk".
If I want to write a program that will run under the standard Python
distribution of the future, what extension module should I work with
today?
Thanks!
|
by: WaterWalk |
last post by:
I've just read an article "Building Robust System" by Gerald Jay
Sussman. The article is here:
http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf
In it there is a footprint which says:
"Indeed, one often hears arguments against building exibility into an
engineered sys-
tem. For example, in the philosophy of the computer language Python it
is claimed:
\There should be one|and preferably only one|obvious...
|
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: 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...
|
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: 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...
|
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: 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...
| |