473,585 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dictionary invalid token error

This works:
>>area_group = {001:06, 002:04, 003:04, 006:9}
This does not (one the end, 09 is used instead of 9)
>>area_group = {001:06, 002:04, 003:04, 006:09}
File "<stdin>", line 1
area_group = {001:06, 002:04, 003:04, 006:09}
SyntaxError: invalid token

Why does 09 cause an invalid token while 9 does not?

############### ############### ############### ##

Python 2.4.4 (#2, Apr 5 2007, 18:43:10)
[GCC 4.1.2 20061115 (prerelease) (Debian AMD64 4.1.1-21)] on linux2

Oct 2 '07 #1
3 4671
This works:
>
>>area_group = {001:06, 002:04, 003:04, 006:9}

This does not (one the end, 09 is used instead of 9)
>>area_group = {001:06, 002:04, 003:04, 006:09}
File "<stdin>", line 1
area_group = {001:06, 002:04, 003:04, 006:09}
SyntaxError: invalid token

Why does 09 cause an invalid token while 9 does not?
Numbers with leading zeros are parsed as octal. 8 and 9 are
invalid digits in octal. Thus, it falls over. 00 through 07
will work fine, but 08 and 09 will go kaput.

http://docs.python.org/ref/integers.html

-tkc

Oct 2 '07 #2

"brad" <by*******@gmai l.comwrote in message news:fd******** **@solaris.cc.v t.edu...
Why does 09 cause an invalid token while 9 does not?
9 isn't a valid octal digit. You probably want to use strings for
storing telephone number like codes, if leading zeroes are
significant.
Oct 2 '07 #3
Tim Chase wrote:
Numbers with leading zeros are parsed as octal. 8 and 9 are invalid
digits in octal. Thus, it falls over. 00 through 07 will work fine,
but 08 and 09 will go kaput.

http://docs.python.org/ref/integers.html

-tkc
Thanks... that makes sense. I'll store them as strings.
Oct 2 '07 #4

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

Similar topics

4
6856
by: evan.cooch | last post by:
Greetings. Suppose I have some function called "CheckIt" - some function to validate form data before submitting it to e CGI script. Pretend the name of the form is "TheForm". If I use the following code, everything work perfctly: <Input type=button VALUE="Submit your form" onClick="javascript:return CheckIt(TheForm)">
4
4724
by: Erik H. | last post by:
I have an ASPX page in which I am trying to bind a datagrid to a dataset pulled from Microsoft Access DB using code inline method. For some reason, the compiler is having a problem with 'using'. Any help here would be much appreciated. Thanks! Getting the following error: CS1519: Invalid token 'using' in class, struct, or interface member...
0
1347
by: s.caron | last post by:
Hi, I'm trying to open an aspx page but I have this error Compiler Error Message: CS1519: Invalid token '=' in class, struct, or interface member declaration in the line : usuario.Credentials = System.Net.CredentialCache.DefaultCredentials; If I put this code in a method like Page_load
3
13721
by: Erik H. | last post by:
I have an ASPX page in which I am trying to bind a datagrid to a dataset pulled from Microsoft Access DB using code inline method. For some reason, the compiler is having a problem with 'using'. Any help here would be much appreciated. Thanks! Getting the following error: Description: An error occurred during the compilation of a resource...
3
2714
by: Twanger | last post by:
I'm getting a compiler error on my ASP.NET page and I can't see the cause. I have a simple C# class compiled into a DLL and placed in my bin directory which has a public property QuestionText. When I try and set the property the compiler throws up Compiler Error Message: CS1519: Invalid token '=' in class, struct, or interface member...
1
9243
by: john wright | last post by:
I have a dictionary oject I created and I want to bind a listbox to it. I am including the code for the dictionary object. Here is the error I am getting: "System.Exception: Complex DataBinding accepts as a data source either an IList or an IListSource at System.Windows.Forms.ListControl.set_DataSource(Object value)
0
5691
by: Ben Holness | last post by:
Hi all, I have a system which allows users to enter a message on a (PHP) website. This message is then put into a (MySQL) Database. A perl script then picks up the message and creates an XML document. The webpages, database and XML are all UTF-8, however every now and then I get an error in the XML parser that tells me I have an invalid...
3
16211
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very strange error. In your experience, where I should looking to find the real error? Surely the sintax of glut is correct... gcc.exe -c...
9
2157
by: Sebouh | last post by:
I'm very close of shooting myself in the head right now. Why in hell does free(xx) give me an error: *** glibc detected *** free(): invalid pointer: 0x08ce6158 *** // The function returns something like the argv parameter in main. char** parser (char* ch) { char** xx = NULL; char* temp; // contains the input which will be modified...
0
7836
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...
0
8336
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...
1
7950
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...
0
8212
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...
0
6606
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...
1
5710
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...
0
3835
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...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.