-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
planets data class - ease of access #2
Comments
still want this done? |
@Muhammad-MM Yes! I haven't had a chance to look at the package in a while. |
Hi, this is just a bit of a prototype but what do you think?
|
@Muhammad-MM I've thought about this more, I don't think an extra external file .json or otherwise is the way to go. I would like to see a .py file with a planets module. This would contain a planets class and individual planet child instances which have their default values from the csv built in. Then it would be possible to do: from astroedu.planets import earth
print(earth.r)
>>> 6371000
print(earth.units)
>>> r, Radius in m |
Ah, okay I see. So just to clarify about the values, do you want them to be built into the py file instead of reading off values from the csv? Or should I keep loading the properties from the csv through iteration? |
@Muhammad-MM Yes exactly the values for each planet would be stored in the attributes of the planets class. |
Hi, please check out #3 :) |
planets.csv provides a useful dataset for learning/exploration.
I would like something class/dict based which is easier to access:
Not sure about the units bit etc. Might just leave that for the docs.
I am thinking this could be coded straight into a .py file and then dumped into a .json.
The rest of the code would use the .py file and the .json could be backup/if people want it for other languages.
https://www.blog.pythonlibrary.org/2014/02/14/python-101-how-to-change-a-dict-into-a-class/
https://stackoverflow.com/questions/11821322/elegant-way-to-store-dictionary-permanently-with-python
The text was updated successfully, but these errors were encountered: