Python Forum
coding idea - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Forum & Off Topic (https://python-forum.io/forum-23.html)
+--- Forum: Bar (https://python-forum.io/forum-27.html)
+--- Thread: coding idea (/thread-22389.html)



coding idea - Skaperen - Nov-11-2019

here is how i form plurals in f-strings. if you are using a version of Python before 3.6 you can rearrange the code to something that works there.
    if unknown_options:
        num = len(unknown_options)
        msg = f'there {("are","is")[num==1]} {num} unknown option{"s"[num==1:]}'
        raise ValueError(msg)
i don't know if there are any issues with this so i will post it here in the bar to see if i get a reaction about it.


RE: coding idea - buran - Nov-11-2019

have a look at
https://github.com/jazzband/inflect


RE: coding idea - Skaperen - Nov-12-2019

inflect is very interesting. no more excuses for bad number grammar on websites in Python.