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

If constant starts with numeral, CHOICE.<CONSTANT> fails #52

Open
lachlansimpson opened this issue Jul 8, 2019 · 1 comment
Open

If constant starts with numeral, CHOICE.<CONSTANT> fails #52

lachlansimpson opened this issue Jul 8, 2019 · 1 comment

Comments

@lachlansimpson
Copy link

If the constant starts with a numeral (potentially other non-alpha too), the CHOICES. construct doesn't work.

Steps to reproduce.

>>> STATES = Choices(('ONLINE','1-2', 'Online'),('OFFLINE','2-1', 'Offline'),)
>>> STATES.constants
{'ONLINE': ('ONLINE', '1-2', 'Online'), 'OFFLINE': ('OFFLINE', '2-1', 'Offline')}
>>> STATES.ONLINE
'1-2'
>>> STATES = Choices(('1ONLINE','1-2', 'Online'),('2OFFLINE','2-1', 'Offline'),)
>>> STATES.constants
{'1ONLINE': ('1ONLINE', '1-2', 'Online'), '2OFFLINE': ('2OFFLINE', '2-1', 'Offline')}
>>> STATES.1ONLINE
  File "<console>", line 1
    STATES.1ONLINE
           ^
SyntaxError: invalid syntax
@twidi
Copy link
Owner

twidi commented Jul 9, 2019

It's logic because the goal of the constant is to create an attribute. So it will never be possible, but it should raise an error at definition time.

Thanks for the report

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

No branches or pull requests

2 participants