473,378 Members | 1,471 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Python 2.5 long

I have this bit of code, which I copied from my book;
Expand|Select|Wrap|Line Numbers
  1. def checkIndex(key):
  2.     if not isinstance(key,(int, long)): raise TypeError
  3.     if key < 0: raise IndexError
But I am currently using Python 3.1, does anyone knows what long is in Python3? Because I am getting an error saying long is not defined, and when I try in Python 2 it works
May 23 '11 #1
3 1903
dwblas
626 Expert 512MB
Python integers don't have a length, so use int only. If you have huge numbers, then use the decimal class which can handle both extremely small and extremely large numbers. Try this snippet as a test:
Expand|Select|Wrap|Line Numbers
  1. x_int = int("123")
  2. print len(x_int) 
May 23 '11 #2
bvdet
2,851 Expert Mod 2GB
int and long are unified as int in Python 3.X. See PEP 237.
May 23 '11 #3
Cool, thanks for the help dudes, that helped!
May 23 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Peter Kwan | last post by:
Hi, I believe I have discovered a bug in Python 2.3. Could anyone suggest a get around? When I tested my existing Python code with the newly released Python 2.3, I get the following warning: ...
8
by: Christian Seberino | last post by:
c extension compilation gives this gripe about python itself with -Wall and -pedantic switches --> /usr/include/python2.2/longobject.h:48: warning: ISO C89 does not support `long long' Is there...
9
by: Francois Fernandes | last post by:
Hi! Is it possible to easyly integrate c++ classes in python? I don't want to use boost c++. Does anyone know how to start or where to find documentation for this? thx
89
by: Radioactive Man | last post by:
In python 2.3 (IDLE 1.0.3) running under windows 95, I get the following types of errors whenever I do simple arithmetic: 1st example: >>> 12.10 + 8.30 20.399999999999999 >>> 1.1 - 0.2...
0
by: Peter Otten | last post by:
QOTW: "It seems if you lurk here long enough you eventually get all you questions answered without even asking!" - Ted Landis "We're going to learn from Python. JavaScript is pretty close to...
6
by: Gonzalo Monzón | last post by:
Hi all! I have been translating some Python custom C extension code into Python, as I need these modules to be portable and run on a PocketPC without the need of compile (for the purpose its a...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 398 open ( +5) / 3334 closed (+19) / 3732 total (+24) Bugs : 904 open ( -4) / 6011 closed (+36) / 6915 total (+32) RFE : 222 open...
40
by: =?iso-8859-1?B?QW5kcuk=?= | last post by:
I'm really annoyed at Python - and not for the reasons already mentioned on this list. Everyone know that programming is supposed to be a dark art, nearly impossible to learn. Computer code is...
1
by: Neal Becker | last post by:
What's wrong with this? type(struct.unpack('l','\00'*8)) <type 'int'> Why I am getting 'int' when I asked for 'long'? This is on python-2.5.1-15.fc8.x86_64
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.