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 1064223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:53:59+00:00 2026-05-16T18:53:59+00:00

I am looking for an appropriate data structure in Python for processing variably structured

  • 0

I am looking for an appropriate data structure in Python for processing variably structured forms. By variably structured forms I mean that the number of form fields and the types of the form’s contents are not known in advance. They are defined by the user who populates the forms with his input.

What are the pros and cons of putting data in A) object attributes (e.g. of an otherwise empty “form”-class) or B) simply lists/dicts? Consider that I have to preserve the sequence of form fields, the form field names and the types.

(Strangely, it has been difficult to find conclusive information on this topic. As I am still new to Python, it’s possible that I have searched for the wrong terms. If my question is not clear enough, please ask in the comments and I will try to clarify.)

  • 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-05-16T18:54:00+00:00Added an answer on May 16, 2026 at 6:54 pm

    Python classes are literally just two dicts (one for functions, one for data), a name and the rules how Python looks for keys. When you access existing keys, there is absolutely no difference to a dict (unless you overwrote the access rules of cause).

    That means that there is no drawback (besides more code) to using classes at all and you should never be afraid to write a class.

    In your particular case I think you should go with classes, for one simple reason: You might want to extend them later. Maybe you want to add constraints on the name (length, allowed letters, uniqueness, …) or the value (not empty, length, type, …) of a field one day. Maybe you want to validate all fields in a form. If you use a class you can do this without changing any code outside the class! And as I said before, even if you don’t, there are no drawbacks!

    I guess my rule of thumb for classes is: Don’t use a class if you’re absolutely sure that there is nothing to add to it. If not just write those few extra lines.

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

Sidebar

Related Questions

I'm looking to build an appropriate data structure for NoSQL storage of a photo
I am looking for an appropriate data structure for my problem. I would like
Possible Duplicate: Common mySQL fields and their appropriate data types What are the recommended
I need a Max-Priority Queue data structure. Looking in Java's Priority Queue I noticed
I'm looking for the proper data structure for this scenario. I have boost available
I'm looking for a way to non-destructively alter data. I have one table that
Need: Ability to dynamically build Forms Structure (simple idea not actual structure) Admin: Form
I'm having trouble finding the right C# data structure. I'm looking for a PriorityList.
I am looking for an appropriate way to store and access pdf files in
I'm looking into using monad comprehensions to represent SQL queries, and generate the appropriate

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.