Find the answer to your Linux question:
Results 1 to 3 of 3
Essentially I'm working on a gallery script (which I'm calling view_image.py), and I get the number of the image to display from the url via cgi.FieldStorage. I'm currently using Code: ...
  1. #1
    Linux User Giles's Avatar
    Join Date
    May 2005
    Location
    Gloucestershire and Cambridge, UK
    Posts
    283

    Python: get numerical parameter from cgi.FieldStorage

    Essentially I'm working on a gallery script (which I'm calling view_image.py), and I get the number of the image to display from the url via cgi.FieldStorage. I'm currently using
    Code:
    source = cgi.FieldStorage()
    image_id = source['image_id'].value
    So if I navigate to view_image.py?image_id=1001, that'll give me
    Code:
    image_id='1001'
    Unfortunately that means that image_id is a string, and I need to be able to manipulate it numerically, so I need it as an int instead. I'm sure it must be possible to get a url parameter as a numeral, but I've yet to find anything on google. Does anyone have any ideas?

    Thanks for taking the time to look at this
    Toodle-oo
    Giles
    "Our greatest fear is not that we are powerless. Our greatest fear is Microsoft"
    Registered linux user #391027

  2. #2
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    you can turn it into integer,eg image_id=int(image_id)

  3. #3
    Linux User Giles's Avatar
    Join Date
    May 2005
    Location
    Gloucestershire and Cambridge, UK
    Posts
    283
    Awesome. Thanks very much.

    Giles
    "Our greatest fear is not that we are powerless. Our greatest fear is Microsoft"
    Registered linux user #391027

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...