Replies: 1 comment 8 replies
-
That's certainly more pythonic and is in the sprit of eg It seems pointless to have two different methods that do the same thing. The only thing I would caution against is the default value of None. I would prefer using missing_data. This can then be substituted for eg missing_argument if this is appropriate. |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Rob,
I was starting to look at missing_data usages, and the first one I came across was this, which I don't think should be replaced with an exception.
pysystemtrade/sysdata/config/configdata.py
Line 96 in 16e7dfb
Instead, I would like to create a new method,
get_element(self, element_name, default=None)
, that would eventually replace get_element_or_missing_data and get_element_or_arg_not_supplied.Reasoning:
If there are cases where an exception would be appropriate, we could also haveUnfortunately, Python doesn't allow overloaded methods, but there are other ways (less elegant, IMO) of doing this if desired.get_element(self, element_name)
that would raise an AttributeError (edit: or a custom exception) if the element doesn't exist.What do you think?
Beta Was this translation helpful? Give feedback.
All reactions