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

SyntaxError when using " and ' for inches and feet #192

Closed
wolph opened this issue Sep 24, 2014 · 4 comments
Closed

SyntaxError when using " and ' for inches and feet #192

wolph opened this issue Sep 24, 2014 · 4 comments

Comments

@wolph
Copy link

wolph commented Sep 24, 2014

Perhaps this has already been reported but I couldn't find a bugreport or something.

The parser seems to be unable to process units like " and '. Is this something that's fixable?

@wolph
Copy link
Author

wolph commented Sep 24, 2014

Example traceback:

Traceback (most recent call last):
  File "convert.py", line 64, in convert
    in_val = Q_(value)
  File "pint/quantity.py", line 93, in __new__
    inst = cls._REGISTRY.parse_expression(value)
  File "pint/unit.py", line 1175, in parse_expression
    values
  File "<string>", line 1
    10 "

@wolph
Copy link
Author

wolph commented Sep 24, 2014

My definition:

" = inch

@hgrecco
Copy link
Owner

hgrecco commented Sep 24, 2014

The parser is currently builds on top of the python parser and is therefore limited. There is plan for changing this at same point but it has not been a priority. There are few issues we could address with a custom one (See #145, #78, #34 and #25)

There is a way to achieve what you need using a private API. Basically every string that is going to be parsed goes through a string_preprocessor doing some replacements. See here. You could add your own replacement rule.

@hgrecco
Copy link
Owner

hgrecco commented Jan 26, 2015

I am closing this in favor of #226

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