A Python Command Line Application Framework

Naked (source: PyPI, GitHub) is a MIT licensed command line application framework that provides a variety of features for Python application developers.


The QuickStart Guide demonstrates how to go from an empty directory to a PyPI push of your first application release using tools provided by the Naked Framework.

Here is a sample of the framework features:

New Projects

  • New Project Generator : Create a complete project directory structure and project file stubs with the naked executable:
naked make

Command Line Parser

  • Simple Command to Python Object Parser :
# positional strings in the command are command object attributes
# short- (e.g. '-p') and long-form (e.g. '--print') options are tested with a method

# user enters: <executable> hello world --print
c = Naked.commandline.Command(sys.argv[0], sys.argv[1:])
if c.cmd == 'hello' and c.cmd2 == "world":
    if c.option('--print'):
        print('Hello World!')
  • Simple Command Argument Management :
# argument testing and assignment by command object methods

# user enters: <executable> -l Python --framework Naked
if c.option_with_arg('-l') and c.option_with_arg('--framework'):
    language = c.arg('-l')
    framework = c.arg('--framework')
    print(framework + ' ' + language)   # prints 'Naked Python' to standard out
  • Simple Command Switch Management :
# switch testing by command object method

if c.option('-s'):
    # do something
elif c.option('-l'):
    # do something else

See the Command Line Parser documentation for details.

State Data

  • Simple State Management :
# assign your own attributes to the command object for later use in your coding logic

if c.option('--spam'):
    c.spam = True
    c.eggs = False
if c.option('--eggs'):
    c.spam = False
    c.eggs = True

# other stuff

if c.spam:
elif c.eggs:

See the Command Line Parser documentation for details.

  • The StateObject : a compendium of automatically generated user state information. It includes data such as the Python interpreter version, operating system, user directory path, current working directory, date, time, and more.
from Naked.toolshed.state import StateObject

state = StateObject() # collects state information at time of instantiation

working_directory = state.cwd
if state.py2:
    print("In the directory " + working_directory + " and using the Python 2 interpreter")
    print("In the directory " + working_directory + " and using the Python 3 interpreter")

See the Toolshed: state documentation for details.


  • GET and POST requests are as simple as:
from import HTTP

http = HTTP("")
if http.get_status_ok():

http = HTTP("")
if http.post_status_ok():

Text and binary file writes from GET and POST requests are just as easy. See the Toolshed: network documentation for details.

File I/O

  • Supports Unicode (UTF-8) reads and writes by default:
from Naked.toolshed.file import FileReader, FileWriter

fr = FileReader('myfile.txt')
u_txt =

fw = FileWriter('newfile.txt')

There are a number of I/O methods in the FileReader and FileWriter classes. See the Toolshed: file documentation for details.

Execution of System Executables and Scripts

  • System Command Execution :
from import execute

  • Ruby Script Execution :
from import execute_rb

  • Node.js Script Execution :
from import execute_js


See the Toolshed: shell documentation for more information, including documentation of exit status code checks & standard output and error stream handling from the Python side using

Explore Environment Variables

  • Access Each String in the User PATH
from import Environment

env = Environment()
if (env.is_var('PATH')):
      for i in env.get_split_var_list('PATH'):

See the Toolshed: shell documentation for details.

Function, Method, Class Extensions

  • The Naked toolshed types library includes extensions of commonly used Python types:

    • XString extends the Python string
    • XDict extends the Python dictionary
    • XList extends the Python list
    • XMaxHeap a max heap priority queue that extends the Python heapq
    • XMinHeap a min heap priority queue that extends the Python heapq
    • XSet extends the Python set
    • XQueue extends the Python deque
  • Faster, compiled C versions of the library modules with an optional post-install compile for those who need a jetpack.

See the The Toolshed Library Overview documentation for an overview and links to the respective parts of the toolshed library documentation.

Text Templates

  • The Ink Templating System - a lightweight, flexible text templating system that allows you to define the replacement tag syntax in your template documents. Available in the library module.
from import Template, Renderer

template_string = "I like {{food}} and {{drink}}"
template = Template(template_string)
template_key = {'food': 'fries', 'drink': 'beer'}
renderer = Renderer(template, template_key)
rendered_text = renderer.render()
print(rendered_text)         # prints "I like fries and beer"

See the Toolshed: ink documentation for details.


  • Benchmarking decorators are available for your methods and functions. Insert a decorator above your function or method and get 10 trials of between 10 and 1 million repetitions of the code with comparison to a built-in test function. Comment it out and it’s gone.
from Naked.toolshed.benchmarking import timer_trials_benchmark

def your_function(arg1, arg2):
    # your code

See the Toolshed: benchmarking documentation for details.


  • The script is added to every project in the path PROJECT/lib/ Insert your test code in the designated testing block and then run naked profile from any directory in your project. cProfile and pstats profiling is implemented with default report settings (which you can modify in the file if you’d like).

Details are available in the naked executable profile documentation. An example is provided in the QuickStart Guide.


  • Testing with the tox, nose, py.test, and the built-in Python unittest test runners can be run from any directory in your project with the naked test command. Use the included tests project directory for your unit test files.

Details are available in the naked executable test documentation. An example is provided in the QuickStart Guide.

Python Documentation

  • Search the built-in Python documentation from the command line with the pyh naked executable command.
$ naked pyh dict

Help on class dict in module __builtin__:

class dict(object)
 |  dict() -> new empty dictionary
 |  dict(mapping) -> new dictionary initialized from a mapping object's
 |      (key, value) pairs
 |  dict(iterable) -> new dictionary initialized as if via:
 |      d = {}
 |      for k, v in iterable:
 |          d[k] = v
 |  dict(**kwargs) -> new dictionary initialized with the name=value pairs
 |      in the keyword argument list.  For example:  dict(one=1, two=2)
 |  Methods defined here:
 |  __cmp__(...)
 |      x.__cmp__(y) <==> cmp(x,y)
 |  __contains__(...)
 |      D.__contains__(k) -> True if D has a key k, else False


There is no need to enter the Python interactive interpreter.

Flexible and No Commitment

  • Every component of the framework is 100% optional. You determine how much (if any) of the Naked source you need in your project. Building a project with the executable does not mandate use of the command parser, the automatically implemented help, usage, and version commands, or any part of the Naked toolshed library.

The goal is to help when you need it and get out of the way when you don’t.