diff options
Diffstat (limited to 'examples/unicode_commands.py')
-rwxr-xr-x | examples/unicode_commands.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/unicode_commands.py b/examples/unicode_commands.py new file mode 100755 index 00000000..9aa31c69 --- /dev/null +++ b/examples/unicode_commands.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# coding=utf-8 +"""A simple example demonstrating support for unicode command names. +""" +import math +import cmd2 + + +class UnicodeApp(cmd2.Cmd): + """Example cmd2 application with unicode command names.""" + + def __init__(self): + super().__init__() + self.intro = 'Welcome to MyApp. Note the full Unicode support: π π©' + + def do_πprint(self, arg): + """This command prints π to 5 decimal places.""" + print("π = {0:.6}".format(math.pi)) + + +if __name__ == '__main__': + app = UnicodeApp() + app.cmdloop() + |