ethereum.utils
Utility functions used in this specification.
has_field
Returns True
if class_
has a field with the given name
.
def has_field(class_: Any, name: str) -> bool:
10 | """ |
---|---|
11 | Returns `True` if `class_` has a field with the given `name`. |
12 | """ |
13 | try: |
14 | all_fields = fields(class_) |
15 | except TypeError: |
16 | return False |
17 | |
18 | return any(x.name == name for x in all_fields) |