Python Forum
Best way to accommodate unknown number of variables?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best way to accommodate unknown number of variables?
#10
dynamic variable names in general practice (specific cases can be shown to be OK) should not be done because risks like name collision and security. that PHP (and others) allow this does not reduce these risks. Python provides one or more isolated name spaces for this called dictionaries. if all indexes are integers, lists can be used. but a dictionary helps keep your project simple and any hashable type can be used. even a tuple containing only hashable data can be used as a "name" (actually a key).
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
RE: Best way to accommodate unknown number of variables? - by Skaperen - May-30-2022, 03:57 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Create X Number of Variables and Assign Data RockBlok 8 1,070 Nov-14-2023, 08:46 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020