Skip to content

Commit

Permalink
add iter & next support to Variable
Browse files Browse the repository at this point in the history
Signed-off-by: Zhiyuan Chen <“[email protected]”>
  • Loading branch information
Zhiyuan Chen authored and ZhiyuanChen committed Feb 10, 2023
1 parent 6233496 commit e370169
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions chanfig/flat_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,3 +1099,6 @@ def __getstate__(self, *args, **kwargs):
def __setstate__(self, states, *args, **kwargs):
for name, value in states.items():
self.setattr(name, value)

def __wrapped__(self, *args, **kwargs):
pass
6 changes: 6 additions & 0 deletions chanfig/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,5 +393,11 @@ def __deepcopy__(self, memo: Optional[Mapping] = None):
def __format__(self, format_spec):
return self.value if isinstance(self, str) else format(self.value, format_spec)

def __iter__(self):
return iter(self.value)

def __next__(self):
return next(self.value)

def __repr__(self):
return repr(self.value)

0 comments on commit e370169

Please sign in to comment.