Just downloaded the latest beta of 2.3, and having a bit of fun playing
with the new goodies, lovely work by the way :)
I was a little suprised to find that I could assign a value to 'True',
and 'False' without warning though, and was wondering if this is deliberate.
For example:
if (1 == True): print "true"
True = 0
if (1 == True): print "true"
else: print "true is false"
This snippet is fairly unlikely to ever be written by a sober
individual, but if something similar is constructed by accident, the
repercussions may be interesting if not detected.
Can True (or False for that matter) be relied on for this sort of direct
comparison?. 5 8388
On Wed, Jul 02, 2003 at 03:02:59AM -0700, Erik Max Francis wrote: Culley Angus wrote:
I was a little suprised to find that I could assign a value to 'True', and 'False' without warning though, and was wondering if this is deliberate.
This is true of pretty much all Python features. The only special dispensation goes to None, which is a warning now (in the 2.3 beta):
Python 2.3b2 (#1, Jun 29 2003, 20:30:58) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 Type "help", "copyright" , "credits" or "license" for more information. None = 0
<stdin>:1: SyntaxWarning: assignment to None
Incidentally, the reason why a SyntaxWarning isn't raised for True and False
is that there is a lot of existing code for older pythons that do tricks
like:
True = (1 == 1)
False = not True
Or something similar, and the Python team didn't want to break code, or
cause spurious warnings for code that might otherwise work perfectly well
with 2.3 and 2.2 or even 1.5.2 (depending on what else it did, of course).
-Andrew.
Culley Angus wrote: I was a little suprised to find that I could assign a value to 'True', and 'False' without warning though, and was wondering if this is deliberate.
This is true of pretty much all Python features. The only special
dispensation goes to None, which is a warning now (in the 2.3 beta):
Python 2.3b2 (#1, Jun 29 2003, 20:30:58)
[GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
Type "help", "copyright" , "credits" or "license" for more information. None = 0
<stdin>:1: SyntaxWarning: assignment to None
Python takes the approach of "We're all adults here." If you're using
Python, it presumes that you don't need handholding, and that you won't
do things you know you shouldn't do. For instance, imagine the havoc
that things like this would cause:
int = float file = str sys = 'This is really not a module'
--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ Shooters, looters / Now I got a laptop computer
\__/ Ice Cube
In article <3F************ ***@alcyone.com >,
Erik Max Francis <ma*@alcyone.co m> wrote: Culley Angus wrote:
I was a little suprised to find that I could assign a value to 'True', and 'False' without warning though, and was wondering if this is deliberate.
This is true of pretty much all Python features. The only special dispensation goes to None, which is a warning now (in the 2.3 beta):
Actually, at some point there was a warning for True and False as well,
but it was taken out because there is plenty of code out there like this:
try:
True, False
except NameError:
True, False = 1, 0
(I'm not entirely sure, it can also be that there never was a warning in
place, but it was discussed.)
Just
> Culley Angus wrote: This is true of pretty much all Python features. The only special dispensation goes to None, which is a warning now (in the 2.3 beta)
I most often use this freedom to overwrite "id". I Guess that it's a bad
Zope habbit...
regards Max M
On Wed, Jul 02, 2003 at 03:02:59AM -0700, Erik Max Francis wrote: Culley Angus wrote:
I was a little suprised to find that I could assign a value to 'True', and 'False' without warning though, and was wondering if this is deliberate.
This is true of pretty much all Python features. The only special dispensation goes to None, which is a warning now (in the 2.3 beta):
Python 2.3b2 (#1, Jun 29 2003, 20:30:58) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 Type "help", "copyright" , "credits" or "license" for more information. None = 0
<stdin>:1: SyntaxWarning: assignment to None
Incidentally, the reason why a SyntaxWarning isn't raised for True and False
is that there is a lot of existing code for older pythons that do tricks
like:
True = (1 == 1)
False = not True
Or something similar, and the Python team didn't want to break code, or
cause spurious warnings for code that might otherwise work perfectly well
with 2.3 and 2.2 or even 1.5.2 (depending on what else it did, of course).
-Andrew. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ckerns |
last post by:
I want to loop thru an array of controls,(39 of them...defaults = 0).
If value is null or non-numeric I want to assign the value of "0".
rowString = "L411" //conrol name
if (isNaN(eval ("document.forms."+rowString+".value")) == true )
{
//this alert works if the value is a letter,i.e,"a"
alert("You have entered an non-numeric value.\nEnter a number
in the appropriate box.");
|
by: sneill |
last post by:
How is it possible to take the value of a variable (in this case,
MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name?
In the following example I want 'oIcon' object to have the properties:
mode1, mode2, and mode3.
This seems simple but I can't quite figure it out...
Any ideas anyone?
|
by: MLH |
last post by:
Gentlemen: I have declared an array
Dim MyTables(14) AS Long
Now I want to assign values for MyTables(0) - MyTables(14) equal
to the number of records in each table. Catch, I want the code to
identify only those tables beginning with the letters "JA". Is this
possible? Or, should I break down and manually type in all the
table names?
|
by: Swetha |
last post by:
Hello
I have a DropDownList that I am populating using the following
SqlDataSource:
<asp:DropDownList ID="parentIDDropDownList" runat="server"
DataSourceID="SqlDataSource3" DataTextField="name"
DataValueField="ID"></asp:DropDownList><asp:SqlDataSource
ID="SqlDataSource3" runat="server" ConnectionString="<%$
ConnectionStrings:ConnectionString %>"
|
by: Eugenio |
last post by:
Sorry in advance for my english. :-)
I have a form MS Access97 with two subforms. These subforms have different
data and dimensions, if into the main form I've selected with checkbox "Date
of delivery" instead "Item".
To select the right subforms I make use of this sub:
*****************************************************
Private Sub opzSelezione_AfterUpdate()
| |
by: Michael Bohman |
last post by:
Hi, i have a small problem with assigning a database value to a
RadioButtonList control. On my form i have 3 user admin=1, premium=2 and
basic=3, theese values is stored in an access database in a text string.
My problem is that when i'm loading my form, it uses a repeater control
for each user by the way, I can't find a way to assign either of these
values to the RadioButtonList Control. I can read them from the database
but i wan't the...
|
by: aurora10 |
last post by:
Hi,
I have textfile with True or Flase in it and I need to read this file
so that the value is assigned to a checkbox on the form.
How can I do that ?
Thanks:)
|
by: =?Utf-8?B?RkxEYXZlTQ==?= |
last post by:
I'm developing an application that gets data from 100 sources (via telnet
connections, but you can think stock quotes from a webservice if you like).
I was planning on using the thread pool (25 at a time). I know I would start
all 100 at once and as threads finish, a new thread would become available
and the next one would start.
However, I need to do this over and over (using an app that will run for
days or longer). How can I tell...
|
by: Constantine AI |
last post by:
Hi i have created a Sales Order Header with a Sales Order Line (1 to many relationship) See Picture for image of error! I receive this error when inputting data into the sfrmSOHeader in Add mode. I get this error then i can input data like normal. I dont know why i receive this error but i must get rid of it. The control is not read only, or design-view and definately not too large.
Here is the sfrmSOHeader On Current Code;
Dim...
|
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: 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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |