Skip to content
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

Give the caller namedtuple; factor out the need for dictionaries #13

Open
quinn-dougherty opened this issue Nov 5, 2021 · 1 comment

Comments

@quinn-dougherty
Copy link
Collaborator

passing dicts is good enough for the machine learning in python community, so it's good enough for us.

However, since we don't need quite the flexibility in configs the machine learning community needs, it looks like we can hardcode field names of config objects.

Passing around dictionaries will be annoying for the user in our case because what if a field is incorrect or missing?

From GeeksForGeeks

# Python code to demonstrate namedtuple()

from collections import namedtuple

# Declaring namedtuple()
Student = namedtuple('Student', ['name', 'age', 'DOB'])

# Adding values
S = Student('Nandini', '19', '2541997')

# Access using index
print("The Student age using index is : ", end="")
print(S[1])

# Access using name
print("The Student name using keyname is : ", end="")
print(S.name)
@ejgallego
Copy link
Owner

Indeed, this how ppx_python works for now, see plans on #4 , cc @thierry-martinez ; also, all the objects we generate are coming from well-typed OCaml definitions so definitively we should generate Python types too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants