469,588 Members | 2,819 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,588 developers. It's quick & easy.

Storing 50 Variables data

440 256MB
Hi ,

I will get the 50 values.Here I have tow scenarios.
Case -1 ) 50 Values may be same data types

10,20,30,50 .......

Case-2) Different data types

10.0,20.0,'Yes',1

How to store these values ?.Whether using a list is a better approach or create a class and 50 memeber variables to the class and use that variables.

Could anybody suggest the better approach to store the variable data.

Thanks
PSB
Aug 22 '07 #1
5 1247
ilikepython
844 Expert 512MB
Hi ,

I will get the 50 values.Here I have tow scenarios.
Case -1 ) 50 Values may be same data types

10,20,30,50 .......

Case-2) Different data types

10.0,20.0,'Yes',1

How to store these values ?.Whether using a list is a better approach or create a class and 50 memeber variables to the class and use that variables.

Could anybody suggest the better approach to store the variable data.

Thanks
PSB
I don't think it has to be so complicated:
Expand|Select|Wrap|Line Numbers
  1. myValues = [10, 0, 20, 'Yes', True, None, 3, 3.21]
  2. myValues.append(12)
  3. myValues.append("No")
  4. print myValues
  5.  
Is threre anything special you want to do with the data?
Aug 22 '07 #2
psbasha
440 256MB
I don't think it has to be so complicated:
Expand|Select|Wrap|Line Numbers
  1. myValues = [10, 0, 20, 'Yes', True, None, 3, 3.21]
  2. myValues.append(12)
  3. myValues.append("No")
  4. print myValues
  5.  
Is threre anything special you want to do with the data?
Yes,I agree that it is very simple to add in the list .
But when retriving the data from the list,the developer has to remember which index of the list stands for what element.If the list is of 10 different values ,there are no issues,if it exceeds more than 10 different values,how we will remember which list index stands for what value.And while editing the values the developer has to edit at the right index,otherwise application will crash.

How to handle this situation?

Thanks
PSB
Aug 22 '07 #3
psbasha
440 256MB
Yes,I agree that it is very simple to add in the list .
But when retriving the data from the list,the developer has to remember which index of the list stands for what element.If the list is of 10 different values ,there are no issues,if it exceeds more than 10 different values,how we will remember which list index stands for what value.And while editing the values the developer has to edit at the right index,otherwise application will crash.

How to handle this situation?

Thanks
PSB
When some maintins the code,how the developer understand ,which index value of the list stands for what value,untill unless the comments are mentioned for each index of the list.

Thanks
PSB
Aug 22 '07 #4
ilikepython
844 Expert 512MB
When some maintins the code,how the developer understand ,which index value of the list stands for what value,untill unless the comments are mentioned for each index of the list.

Thanks
PSB
Will it be possible to convert all the members to strings? When you use them you could use the string.isdigit() or string.isalpha(). How are you getting the data? How are you using it? A little more details, please.
Aug 22 '07 #5
bartonc
6,596 Expert 4TB
When some maintins the code,how the developer understand ,which index value of the list stands for what value,untill unless the comments are mentioned for each index of the list.

Thanks
PSB
What's wrong with using a class to simulate a structure? You get named variables and all of the benefits of dynamic typing:
Expand|Select|Wrap|Line Numbers
  1. >>> class simulateStructure:
  2. ...     name = ""
  3. ...     age = 0
  4. ...     address = None
  5. ...     
  6. >>> simulateStructure.name = "Joe Blow"
  7. >>> simulateStructure.sibbling = "brother"
  8. >>> simulateStructure.sibbling
  9. 'brother'
  10. >>> 
Aug 23 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by bissatch | last post: by
2 posts views Thread by Jax | last post: by
4 posts views Thread by Mike | last post: by
12 posts views Thread by Alex D. | last post: by
22 posts views Thread by guitarromantic | last post: by
5 posts views Thread by Gernot Frisch | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.