473,545 Members | 763 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

python doesn't like my numbers

hi,

is there any way to convince python not to take my (phone)numbers
starting with zero as octals?
int(088)

File "<stdin>", line 1
int(088)
^
SyntaxError: invalid token

thanks
Paul
Jul 18 '05 #1
6 1613
paul k schreef:
hi,

is there any way to convince python not to take my (phone)numbers
starting with zero as octals?
>>> int(088)

File "<stdin>", line 1
int(088)
^
SyntaxError: invalid token

What is the integer value of a phone number?
--
Peter Kleiweg L:NL,af,da,de,e n,ia,nds,no,sv, (fr,it) S:NL,de,en,(da, ia)
info: http://www.let.rug.nl/~kleiweg/ls.html

Jul 18 '05 #2
[paul k]
is there any way to convince python not to take my (phone)numbers
starting with zero as octals?
>>> int(088) File "<stdin>", line 1
int(088)
^
SyntaxError: invalid token


Answer 1: Use strings: that's really what telephone numbers should be

Answer 2: Use valid octal digits in your phone numbers. The digit '8'
cannot appear in base 8 numbers, only the digits 0-7.
int(077) 63 int(088) Traceback (innermost last):
(no code object) at line 0
File "<console>" , line 1
int(088)
^
SyntaxError: invalid syntax


--
alan kennedy
------------------------------------------------------
email alan: http://xhaus.com/contact/alan
Jul 18 '05 #3
paul k wrote:
hi,

is there any way to convince python not to take my (phone)numbers
starting with zero as octals?
>>> int(088)

File "<stdin>", line 1
int(088)
^
SyntaxError: invalid token

thanks
Paul


int("088")
Jul 18 '05 #4
paul k wrote:
is there any way to convince python not to take my (phone)numbers
starting with zero as octals?
>>> int(088) File "<stdin>", line 1
int(088)
^
SyntaxError: invalid token


Why do they have to start with zeros in your source code?

The fact that you're passing the number through int() makes me guess
that you're actually talking about input of some kind which you'll pass
through int(). If that's the case, they will be strings, and the problem
will go away:
int('088')

88
Jul 18 '05 #5
Alan Kennedy wrote:
[paul k] Answer 1: Use strings: that's really what telephone numbers should be Yea, should have done this in the first place...

Answer 2: Use valid octal digits in your phone numbers. The digit '8'
cannot appear in base 8 numbers, only the digits 0-7.

I can't change reality (yet) ;)

thanks for all your comments
Paul
Jul 18 '05 #6
On Sun, 22 Aug 2004 18:52:50 -0400, Leif K-Brooks
<eu*****@ecritt ers.biz> wrote:
paul k wrote:
is there any way to convince python not to take my (phone)numbers
starting with zero as octals?
>>> int(088)

File "<stdin>", line 1
int(088)
^
SyntaxError: invalid token


Why do they have to start with zeros in your source code?


My guess is that his program was simply using "input()"

Im rather new to python and I've to say that I found quite
surprising that the "input" function does also evaluate
(so entering "1+1" i get the number 2 and not the string
"1+1") and that I've to use "raw_input" to get what the
user typed in.

Andrea
Jul 18 '05 #7

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

Similar topics

699
33348
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it...
226
12324
by: Stephen C. Waterbury | last post by:
This seems like it ought to work, according to the description of reduce(), but it doesn't. Is this a bug, or am I missing something? Python 2.3.2 (#1, Oct 20 2003, 01:04:35) on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> d1 = {'a':1} >>> d2 = {'b':2} >>> d3 = {'c':3}
49
2800
by: Ville Vainio | last post by:
I don't know if you have seen this before, but here goes: http://text.userlinux.com/white_paper.html There is a jab at Python, though, mentioning that Ruby is more "refined". -- Ville Vainio http://www.students.tut.fi/~vainio24
24
2289
by: Matt Feinstein | last post by:
Hi all-- I'm new to Python, and was somewhat taken aback to discover that the core language lacks some basic numerical types (e.g., single-precision float, short integers). I realize that there are extensions that add these types-- But what's the rationale for leaving them out? Have I wandered into a zone in the space/time continuum where...
0
1847
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 259 open ( -5) / 2573 closed (+17) / 2832 total (+12) Bugs : 745 open ( +0) / 4405 closed (+21) / 5150 total (+21) RFE : 150 open ( +1) / 130 closed ( +0) / 280 total ( +1) New / Reopened Patches ______________________
68
5791
by: Lad | last post by:
Is anyone capable of providing Python advantages over PHP if there are any? Cheers, L.
137
6963
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very pragmatic - 3) I usually move forward when I get the gut feeling I am correct - 4) Most likely because of 1), I usually do not manage to fully explain...
19
2908
by: rbt | last post by:
Here's the scenario: You have many hundred gigabytes of data... possible even a terabyte or two. Within this data, you have private, sensitive information (US social security numbers) about your company's clients. Your company has generated its own unique ID numbers to replace the social security numbers. Now, management would like the IT...
25
497
by: Byte | last post by:
I know this is probably a stupid question, but I'm learning Python, and am trying to get the if function to work with letters/words. Basicly, I'm trying to write a script that when run, says Please enter your name: Then, if the user types myself as the name , the output is OK. Thats all I want it to do (remember, Im just new). The code...
10
2272
by: notejam | last post by:
I am trying to get started with a interactive version of Python for windows and need some help. I have played with the tutorial, and now want to write a program. In basic language, I could write something like 10 print "hello" 20 print "Jim" and if I run it I would get hello
0
7391
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
7651
Oralloy
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. ...
0
7802
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...
0
5962
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
5320
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
4941
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...
0
3438
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1869
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1010
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.