nodes: 0, module; 1, function_definition; 2, function_name:call_once; 3, parameters; 4, block; 5, identifier:func; 6, expression_statement; 7, expression_statement; 8, if_statement; 9, decorated_definition; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, return_statement; 14, comment:"""Decorate a function to only allow it to be called once.
  
    Note that it doesn't make sense to only call a function once if it takes
    arguments (use @functools.lru_cache for that sort of thing), so this only
    works on callables that take no args.
    """; 15, assignment; 16, boolean_operator; 17, block; 18, decorator; 19, function_definition; 20, assignment; 21, assignment; 22, assignment; 23, identifier:_wrapper; 24, identifier:argspec; 25, call; 26, boolean_operator; 27, attribute; 28, raise_statement; 29, call; 30, function_name:_wrapper; 31, parameters; 32, comment:# If we haven't been called yet, actually invoke func and save the result.; 33, block; 34, attribute; 35, False; 36, attribute; 37, lambda; 38, attribute; 39, lambda; 40, attribute; 41, argument_list; 42, attribute; 43, attribute; 44, identifier:argspec; 45, identifier:keywords; 46, call; 47, attribute; 48, argument_list; 49, if_statement; 50, return_statement; 51, identifier:_wrapper; 52, identifier:has_run; 53, identifier:_wrapper; 54, identifier:HasRun; 55, attribute; 56, identifier:_wrapper; 57, identifier:MarkAsRun; 58, call; 59, identifier:inspect; 60, identifier:getargspec; 61, identifier:func; 62, identifier:argspec; 63, identifier:args; 64, identifier:argspec; 65, identifier:varargs; 66, identifier:ValueError; 67, argument_list; 68, identifier:functools; 69, identifier:wraps; 70, identifier:func; 71, not_operator; 72, block; 73, attribute; 74, identifier:_wrapper; 75, identifier:has_run; 76, identifier:setattr; 77, argument_list; 78, string; 79, identifier:func; 80, identifier:argspec; 81, call; 82, expression_statement; 83, expression_statement; 84, identifier:_wrapper; 85, identifier:return_value; 86, identifier:_wrapper; 87, string; 88, True; 89, string_content:Can only decorate functions with no args; 90, attribute; 91, argument_list; 92, call; 93, assignment; 94, string_content:has_run; 95, identifier:_wrapper; 96, identifier:HasRun; 97, attribute; 98, argument_list; 99, attribute; 100, call; 101, identifier:_wrapper; 102, identifier:MarkAsRun; 103, identifier:_wrapper; 104, identifier:return_value; 105, identifier:func; 106, argument_list
code: def call_once(func):
    """Decorate a function to only allow it to be called once.
  
    Note that it doesn't make sense to only call a function once if it takes
    arguments (use @functools.lru_cache for that sort of thing), so this only
    works on callables that take no args.
    """
    argspec = inspect.getargspec(func)
    if argspec.args or argspec.varargs or argspec.keywords:
      raise ValueError('Can only decorate functions with no args', func, argspec)
  
    @functools.wraps(func)
    def _wrapper():
      # If we haven't been called yet, actually invoke func and save the result.
      if not _wrapper.HasRun():
        _wrapper.MarkAsRun()
        _wrapper.return_value = func()
      return _wrapper.return_value
  
    _wrapper.has_run = False
    _wrapper.HasRun = lambda: _wrapper.has_run
    _wrapper.MarkAsRun = lambda: setattr(_wrapper, 'has_run', True)
    return _wrapper