Solved

format string needs a int, but the variable is an int and runtime error

Posted on 2006-07-01
1
190 Views
Last Modified: 2010-04-16
Here is the error message:

 
 
TypeError      Python 2.3.4: /usr/bin/python
Sat Jul 1 19:01:46 2006

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.

 /home/timedimensioncom/cgi-bin/schedulelist.py
  202         myReport.controlSet(0,heading)
  203         if myReport.controlTest(0):
  204                 line="%-8s  %-%6s  %-5s  %-5d  %-8s  %-10s  %-6s  %-40s" % (job,heading,hardwaretype,quantity,doortype,doorno,firelabel,location)
  205                 myReport.reserveLines(2)
  206                 myReport.printLine(line)
line undefined, job = '00000001', heading = '000001', hardwaretype = '', quantity = 1, doortype = '', doorno = '', firelabel = '', location = ''

TypeError: int argument required
      args = ('int argument required',)

the format string only has one int format and this is associated with quantity which appears to be an int

Here is a bigger window on the code:

row=cursor.fetchone()
while row is not None:
      job=dejection(row[0])
      heading=dejection(row[1])
      hardwaretype=dejection(row[2])
      quantity=int(row[3])
      
      doortype=dejection(row[4])
      doorno=dejection(row[5])
      firelabel=dejection(row[6])
      location=dejection(row[7])
      handdegree=dejection(row[8])
      dimensions=dejection(row[9])
      material=dejection(row[10])
      review=row[11]
      keying=row[12]
      other=dejection(row[13])
      item=dejection(row[14])
      itemtype=dejection(row[15])
      mfgcode=dejection(row[16])
      description=dejection(row[17])
      quantityitem=int(row[18])
      
      unit=dejection(row[19])
      cost=row[20]
      instock=row[21]
      keyed=row[22]
      name=dejection(row[23])
      myReport.controlSet(0,heading)
      if myReport.controlTest(0):
            line="%-8s  %-%6s  %-5s  %-5d  %-8s  %-10s  %-6s  %-40s" % (job,heading,hardwaretype,quantity,doortype,doorno,firelabel,location)
            myReport.reserveLines(2)
            myReport.printLine(line)
            myReport.printLine(hyphenbar)
      
Please advise.
0
Comment
Question by:astar666
1 Comment
 
LVL 14

Accepted Solution

by:
RichieHindle earned 500 total points
ID: 17026008
You have an extra % in your format string, in the second position: "%-%6s" should be "%-6s".
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Strings in Python are the set of characters that, once defined, cannot be changed by any other method like replace. Even if we use the replace method it still does not modify the original string that we use, but just copies the string and then modif…
Sequence is something that used to store data in it in very simple words. Let us just create a list first. To create a list first of all we need to give a name to our list which I have taken as “COURSE” followed by equals sign and finally enclosed …
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now