Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8018247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:05:20+00:00 2026-06-04T21:05:20+00:00

I am playing with cgi (uploading file form), and I am receiving the files

  • 0

I am playing with cgi (uploading file form),

and I am receiving the files as storage object and I sotred it in (input) variable.

this is the simple iteration.

for file in input:
  filepath = ....
  filename, fileext = os.path.splitext(filepath)
  file_real_name = ....
  file_size = ....
  file_type = ...
  file_url = ....
  file_short_name = ...
  file_show_link = ....

  # etc

it would be easy if it was only one file , but what If i have more than one ?

how can I have another value that holds all the iteration information in

like uploaded_files where I can access each uploaded file with all the information for the above iteration ?

I tried to read the docs but I cant wrap my head around some iteration concepts yet, sorry 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:05:21+00:00Added an answer on June 4, 2026 at 9:05 pm

    You want to use a data structure to hold your data. Depending on the complexity, you may want to simply use a list of dictionaries:

    files = []
    for file in input:
        files.append({
            "path": get_path(file),
            "name": get_name(file),
            "size": get_size(file),
            ...
        })
    

    Or, if you find you need to perform lots of operations on your data, you might want to make your own class and make a list of objects:

    class SomeFile:
        def __init__(self, path, name, size, ...):
            self.path = path
            ...
    
        def do_something_with_file(self):
            ...
    
    files = []
    for file in input:
        files.append(SomeFile(get_path(file), get_name(file), get_size(file), ...))
    

    Note that here you are following a pattern of building up a list by iterating over an iterator. You can do this efficiently using a list comprehension, e.g:

    [{"path": get_path(file), "name": get_name(file), ...} for file in input]
    

    Also note that file and input are really bad variable names, as they will mask the builtins file() and input().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been playing with the PayPal code: <form action=https://www.paypal.com/cgi-bin/webscr method=post name=paypal> <input type=hidden name=cmd
Playing with jquery for the first time, and I'm trying to get a simple
I´m playing with MassTransit with a simple example and I don´t know what I´m
please help! I'm really going nuts with this problem! I have a CGI perl
Im playing a little bit with heavy-client app. Imagine I have this model: class
playing around with a property file i figured that there seems to be a
Playing around with jQuery a bit (sorry, complete noob) I was wondering why this
While playing around with regexps in Scala I wrote something like this: scala> val
Playing with excel and came up with this error Sub Split() Dim txt As
Playing a little with coffeescript and Rails 3.1.0.rc4. Have this code: yourMom = (location)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.