Pyhton curses.ascii - Membership Functions














































Pyhton curses.ascii - Membership Functions




Membership Functions

curses.ascii provides many functions to work with ASCII characters. Most of the function provided in curses.ascii are membership functions which can be used to test whether any charcter is part of a specific ASCII character class such as alphanumeric, space, digit etc. These function take any stirng charcter and return True or False based on whether the character belongs to that class or not. The output of all these function is always a boolean value.

All the membership functions provided in curses.ascii are as follows:
  • isalnum(character) -- checks whether a character is alphanumeric(either alphabet or digit[A-Za-z0-9])
  • isalpha(character) -- checks whether a character is an alphabet[A-Za-z]
  • isdigit(character) -- checks whether a character is a number[0-9]
  • isblank(character) -- checks whether a character is blank(space, tab)
  • isascii(character) -- checks whether a character belongs to the ASCII set
  • iscntrl(character) -- checks whether a character is a ASCII control character
  • isgraph(character) -- checks whether a character is a printable character except space
  • isprint(character) -- checks whether a character is a printable character including space
  • ispunct(character) -- checks whether a character is a printable character except space and alphanumeric characters
  • isupper(character) -- checks whether a character is uppercase[A-Z]
  • islower(character) -- checks whether a character is lowercase[a-z]
  • isspace(character) -- checks whether a character is a white-space character 
  • isxdigit(character) -- checks whether a character is hexadecimal
  • isctrl(character) -- checks whether a character is control character
  • ismeta(character) -- checks whether a character is not part of ASCII set

NOTE - Input character should always be a string. Even if the character is a number, it should be inputed as a string.

Example Usage:
Here, We can see few of the function applied on a string character:-


  <-PREV                                                                                                                                              NEXT->

Comments