Created
August 9, 2015 22:03
-
-
Save stuartmyles/2d20566074709a5a80bc to your computer and use it in GitHub Desktop.
Python ast code to figure out how to call an instance object method and pass in a parameter, i.e. equivalent to result = self._baz(theResult)"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ast | |
# ast code to figure out how to call an instance object method and pass in a parameter, i.e. equivalent to | |
# result = self._baz(theResult)" | |
class Greeter: | |
def _baz(self, theStr): | |
return theStr | |
def baz(self, theResult): | |
theTree = ast.parse("result = self._baz(theResult)") | |
print(ast.dump(theTree)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment