Solved

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
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 strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
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…

789 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