-
Notifications
You must be signed in to change notification settings - Fork 48
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
Reimplement constant groups as Enums #70
Comments
But why? The strings are just fine. |
On Sun, Feb 8, 2015 at 6:10 PM, Lucas Vido [email protected] wrote:
Because with Enums it's easy for the user and for us to verify that
It's not native in Python 3.4 either, it's just in the stdlib. An is a The use of unverified constants is a major source of pain in libraries
If you quote the The reason why we should use enums is in the next """Errors should never pass silently.""" Cheers, Luciano Luciano Ramalho Professor em: http://python.pro.br |
At first, I don't see any problem. But without the I just don't like nesting. The constants like |
On Mon, Feb 9, 2015 at 1:29 AM, Danilo de Jesus da Silva Bellini
I understand the issues you are talking about (attribute ordering in a
This paragraph is not clear to me either... sorry. Perhaps some code Luciano Ramalho Professor em: http://python.pro.br |
I'm just posting here just to warm that moving from string to enum (enum34) will drive some problems with JSON serialization (probably useful to expose boards via a REST API - see https://github.com/garoa/pingo/issues/68 ). |
These are examples, not really details. I'm talking about ways to use the Enum34 package. Some of these are part of the package API/documentation (e.g. the
Yes. I'm talking about different ways to use it to get the same behavior in Python 2 and 3 when using it.
All I'm talking about is about using the Enum34 PyPI package and a way to keep the "legacy" API already implemented in Pingo together with a new enum-based API. I'm not for nor against using enums. The main advantage is code completion and reflection, which I think are nice stuff to have in Pingo, but it would be a problem if casting to/from strings gets complicated or if the code written today that depends on Pingo gets deprecated and broken at the same time. |
On Mon, Feb 16, 2015 at 7:09 PM, scls19fr [email protected] wrote:
Thanks for the reminder and the link, it will be useful.
Luciano Ramalho Professor em: http://python.pro.br |
On Mon, Feb 16, 2015 at 7:26 PM, Danilo de Jesus da Silva Bellini
These are great reasons. I plan to start using iPython with Pingo as
We already have a conversion problem to deal with: native board API
Pingo is still in version 0.2.0. It's unstable and has to be. There We shouldn't slow down our progress because of client code written Best, Luciano Luciano Ramalho Professor em: http://python.pro.br |
@ramalho PR seems to pass unit tests. Sébastien |
Pingo has several groups of constants used for certain attributes such as pin mode (IN, OUT, ANALOG), pin state etc. Currently they are strings because that makes it easy to inspect their values. Ideally they should be enums, but there was a wide variety of enum implementations in Python, making it hard to choose. Since Python 3.4 has an Enum type in the standard library and it has been backported to work with Python 2 in the Enum34 project, Pingo should use it: https://pypi.python.org/pypi/enum34
The text was updated successfully, but these errors were encountered: