Solved

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

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
This article will show the steps for installing Python on Ubuntu Operating System. I have created a virtual machine with Ubuntu Operating system 8.10 and this installing process also works with upgraded version of Ubuntu OS. For installing Py…
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 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 …

760 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

18 Experts available now in Live!

Get 1:1 Help Now