def ast_smart(val):
    """Return a suitable subclass of :class:`ast.AST` for storing numbers
    or strings. For other type of objects, return a node class that will
    indicate that the variable is contained in one of global or local
    namespaces."""

    if isinstance(val, Number):
        return Num(n=val)
    elif isinstance(val, basestring):
        return Str(s=val)
    else:
        return ast_name(str(val))
Return a suitable subclass of :class:`ast.AST` for storing numbers
    or strings. For other type of objects, return a node class that will
    indicate that the variable is contained in one of global or local
    namespaces.