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

Check out new functionality of web3py for namedtuple support #1893

Closed
fubuloubu opened this issue Jan 29, 2024 · 3 comments · Fixed by #2171
Closed

Check out new functionality of web3py for namedtuple support #1893

fubuloubu opened this issue Jan 29, 2024 · 3 comments · Fixed by #2171

Comments

@fubuloubu
Copy link
Member

ethereum/web3.py#2799

Copy link

linear bot commented Jan 29, 2024

@antazoey
Copy link
Member

antazoey commented Jul 8, 2024

One thing I don't like about namedtuples:

>>> Struct = namedtuple("MoneySpent", ["a", "_b"])
ValueError: Field names cannot start with an underscore: '_b'

Would this be an issue?

@antazoey
Copy link
Member

antazoey commented Jul 8, 2024

Here is what it looks like on the web3 type:

>>> mytup = abi_decoded_namedtuple_factory(["foo", "_bar", "baz"])
>>> mytup.foo
_tuplegetter(0, 'Alias for field number 0')
>>> mytup._bar
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'ABIDecodedNamedTuple' has no attribute '_bar'
>>> mytup.baz
_tuplegetter(2, 'Alias for field number 2')

Underscore no longer causes errors but it also doesn't work!

Edit: I made an issue for this: ethereum/web3.py#3429

I consider this a blocker!

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

Successfully merging a pull request may close this issue.

2 participants