[Tutor] My first counter... is broken.

Kyle Babich kb@mm.st
Thu, 8 Aug 2002 11:36:29 UT


I thought I would try to make my first counter.  Once I wrote it and
worked a bug out my counter started working... well, sort of.
It counted 1, 2, and then it jumped to something in the hundreds, then
thousands, and then the page just went white.
This is what showed in my error log:

Traceback (most recent call last):
  File "/home/sites/kmb/www/public_html/njindenial/counter.py", line 8,
  in ?
    number =3D int(number)
ValueError: int() literal too large: 01213121412131215

So I guess the number got too big to be an int()?  But it should have
been counting by 1's not jumping around into hundreds and thousands.
Here is my code:

####################
#! /usr/bin/python

print "Content-type: text/html"
print

counter =3D open("counter.dat", "r+")
number =3D counter.read()
number =3D int(number)
number =3D number + 1
counter.write("%(number)s" % vars())
counter.close()

print "Visior #%(number)s" % vars()
####################

What do I need to do?

Thank you,
--
Kyle