Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




String Modules

There is an older module named string. Almost all of the functions in this module are directly available as methods of the string type. The one remaining function of value is the maketrans function, which creates a translation table to be used by the translate method of a string. Beyond that, there are a number of public module variables which define various subsets of the ASCII characters.

maketrans( from , to ) → string

Return a translation table (a string 256 characters long) suitable for use in string.translate. The strings from and to must be of the same length.

The following example shows how to make and then apply a translation table.

from string import maketrans

t= maketable("aeiou","xxxxx")

phrase= "now is the time for all good men to come to the aid of their party"


'nxw xs thx txmx fxr xll gxxd mxn tx cxmx tx thx xxd xf thxxr pxrty'

More importantly, this module contains a number of definitions of the characters in the ASCII character set. These definitions serve as a central, formal repository for facts about the character set. Note that there are general definitions, applicable to Unicode character setts, different from the ASCII definitions.


The set of all letters, essentially a union of ascii_lowercase and ascii_uppercase.


The lowercase letters in the ASCII character set: 'abcdefghijklmnopqrstuvwxyz'


The uppercase letters in the ASCII character set: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'


The digits used to make decimal numbers: '0123456789'


The digits used to make hexadecimal numbers: '0123456789abcdefABCDEF'


This is the set of all letters, a union of lowercase and uppercase, which depends on the setting of the locale on your system.


This is the set of lowercase letters, and depends on the setting of the locale on your system.


The digits used to make octal numbers: '01234567'


All printable characters in the character set. This is a union of digits, letters, punctuation and whitespace.


All punctuation in the ASCII character set, this is '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'


This is the set of uppercase letters, and depends on the setting of the locale on your system.


A collection of characters that cause spacing to happen. For ASCII this is '\t\n\x0b\x0c\r '

  Published under the terms of the Open Publication License Design by Interspire