Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
coding idea
#1
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.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
have a look at
https://github.com/jazzband/inflect
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
inflect is very interesting. no more excuses for bad number grammar on websites in Python.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020