jaraco/inflect

inconsistency in handling spaces

Open

#26 opened on Jul 28, 2015

 (3 comments) (0 reactions) (0 assignees)Python (125 forks)github user discovery
featurehelp wanted

Repository metrics

Stars
 (1,082 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

>>> p.number_to_words('11 11')
'one thousand, one hundred and eleven'
>>> p.ordinal(11)
'11th'
>>> p.ordinal('11 ')
'11 th'
>>> p.ordinal('11  ')
'11  th'
>>> p.ordinal('11 11')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ssara29/others/Abin/src/inflect/inflect.py", line 2797, in ordinal
    n = int(num)
ValueError: invalid literal for int() with base 10: '11 11'

While number_to_words is removing all intervening spaces, ordinal ain't doing the same. Why the inconsistency? Why isn't number_to_words complaining about the space?

Contributor guide