Python Forum
is this character printable?
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
is this character printable?
#2
(Aug-15-2018, 05:34 AM)Skaperen Wrote: is this character printable?

Memory from the distant past: "don't open it, don't open - it's Pandora's box" (this is based on personal experience on this subject)

It is believed that Socrates have once said: "wisdom starts with definition of term". Term "printable character" needs to be defined and very precisely.

What is printable character? Does printable character equal to graphical character as defined in ISO 8859 and Unicode: any character intended to be written, printed, or otherwise displayed in a form that can be read by humans?

What about space (there is split opinion)? If space is printable character what about all other Unicode whitespaces (they display space)? What about non-spacing graphical characters which occupy previous characters space (meaning that printable character does not need to occupy any 'own' space)?

Is it 'printable' printable or 'output' printable? Does printable implies that character can be always printed in whatever environment? What about end-user who doesn't have necessary fonts (for example some Asian ones) installed. Does it mean that character is still printable?

But where are the questions there is an answer. To be consistent with the rest of the world there is always:

>>> help(str.isprintable)
Help on method_descriptor:

isprintable(self, /)
    Return True if the string is printable, False otherwise.
    
    A string is printable if all of its characters are considered printable in
    repr() or if it is empty.
(END)
One can rely on Python's "characters are considered printable" and hope that other pythonistas do the same.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
is this character printable? - by Skaperen - Aug-15-2018, 05:34 AM
RE: is this character printable? - by perfringo - Aug-15-2018, 08:55 AM
RE: is this character printable? - by Skaperen - Aug-15-2018, 08:59 PM

Forum Jump:

User Panel Messages

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