Solved

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

Posted on 2006-07-01
1
191 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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Installing Python 2.7.3 version on Windows operating system For installing Python first we need to download Python's latest version from URL" www.python.org " You can also get information on Python scripting language from the above mentioned we…
Dictionaries contain key:value pairs. Which means a collection of tuples with an attribute name and an assigned value to it. The semicolon present in between each key and values and attribute with values are delimited with a comma.  In python we can…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

809 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