Posts: 4
Threads: 4
Joined: Mar 2017
hello,
I have been able to find helpful lists of key words to be used in Python - such as - "if", "print", "while".
And
I have been able to find helpful lists of built-in functions to be used in Python - such as - "input()", "len", "max".
_____
But in neither of these lists did I see some of what I see in Pythons' script. . .
Things like "setheading()", "sleep()", "up()", "shape"
Does anyone know of a resource that is a little more comprehensive (than just the key words and built-in functions) that might include directional or formatting commands such as "setheading()", "sleep()", "up()", "shape."?
Thanks!
Posts: 1,298
Threads: 38
Joined: Sep 2016
Mar-22-2017, 02:25 PM
(This post was last modified: Mar-22-2017, 02:26 PM by sparkz_alot.)
(Mar-22-2017, 02:08 PM)mattkrebs Wrote: Things like "setheading()", "sleep()", "up()", "shape"
These are 'functions' used in imported modules (in this case, "turtle" ?). In cases like this you must check the doc's for the module itself.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Posts: 3,458
Threads: 101
Joined: Sep 2016
Those are just functions. Their meaning is entirely tied to whatever program/framework/api you happen to be looking at, and don't mean anything at all to python in general (except sleep, which might be from the time module).
If you're in an interactive prompt, you can find all available functions by typing dir() . If there's one that you don't know what it does or how to use it, then call help() on it.
>>> import time
>>> dir()
['__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'time']
>>> dir(time)
['_STRUCT_TM_ITEMS', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'altzone', 'asctime', 'clock', 'ctime', 'daylight', 'get_clock_info', 'gmtime', 'localtime', 'mktime', 'monotonic', 'perf_counter', 'process_time', 'sleep', 'strftime', 'strptime', 'struct_time', 'time', 'timezone', 'tzname']
>>> help(time.sleep)
Help on built-in function sleep in module time:
sleep(...)
sleep(seconds)
Delay execution for a given number of seconds. The argument may be
a floating point number for subsecond precision.
>>>
Posts: 12,030
Threads: 485
Joined: Sep 2016
One thing you can do this is a real hack!:
If you have the program where these functions or methods are used
you can do: - You have the name of the module that they came from. There will be an associated import statement
- from command line (preferable cmnder (you can get it here: http://cmder.net/) type the following(for each import):
Then for each module
λ python
>>> import sys
>>> sys.stdout = open('ModuleInfo.txt', 'w')
>>> # Following two lines for each imported module
>>> import modulename
>>> help('modulename')
>>> # when done
>>> quit() This will show detailed help (including all methods and attributes)
for each of the modules.
The last line of each help list will show the path to the code, In case you want to examine it
All of the help will be in file ModuleInfo.txt
Posts: 2,953
Threads: 48
Joined: Sep 2016
Mar-22-2017, 06:08 PM
(This post was last modified: Mar-22-2017, 06:09 PM by wavic.)
The built-ins:
>>> from pprint import pprint
>>> pprint(dir(__builtins__))
['ArithmeticError',
'AssertionError',
'AttributeError',
'BaseException',
'BlockingIOError',
'BrokenPipeError',
'BufferError',
'BytesWarning',
'ChildProcessError',
'ConnectionAbortedError',
'ConnectionError',
'ConnectionRefusedError',
'ConnectionResetError',
'DeprecationWarning',
'EOFError',
'Ellipsis',
'EnvironmentError',
'Exception',
'False',
'FileExistsError',
'FileNotFoundError',
'FloatingPointError',
'FutureWarning',
'GeneratorExit',
'IOError',
'ImportError',
'ImportWarning',
'IndentationError',
'IndexError',
'InterruptedError',
'IsADirectoryError',
'KeyError',
'KeyboardInterrupt',
'LookupError',
'MemoryError',
'ModuleNotFoundError',
'NameError',
'None',
'NotADirectoryError',
'NotImplemented',
'NotImplementedError',
'OSError',
'OverflowError',
'PendingDeprecationWarning',
'PermissionError',
'ProcessLookupError',
'RecursionError',
'ReferenceError',
'ResourceWarning',
'RuntimeError',
'RuntimeWarning',
'StopAsyncIteration',
'StopIteration',
'SyntaxError',
'SyntaxWarning',
'SystemError',
'SystemExit',
'TabError',
'TimeoutError',
'True',
'TypeError',
'UnboundLocalError',
'UnicodeDecodeError',
'UnicodeEncodeError',
'UnicodeError',
'UnicodeTranslateError',
'UnicodeWarning',
'UserWarning',
'ValueError',
'Warning',
'ZeroDivisionError',
'_',
'__build_class__',
'__debug__',
'__doc__',
'__import__',
'__loader__',
'__name__',
'__package__',
'__spec__',
'abs',
'all',
'any',
'ascii',
'bin',
'bool',
'bytearray',
'bytes',
'callable',
'chr',
'classmethod',
'compile',
'complex',
'copyright',
'credits',
'delattr',
'dict',
'dir',
'divmod',
'enumerate',
'eval',
'exec',
'exit',
'filter',
'float',
'format',
'frozenset',
'getattr',
'globals',
'hasattr',
'hash',
'help',
'hex',
'id',
'input',
'int',
'isinstance',
'issubclass',
'iter',
'len',
'license',
'list',
'locals',
'map',
'max',
'memoryview',
'min',
'next',
'object',
'oct',
'open',
'ord',
'pow',
'print',
'property',
'quit',
'range',
'repr',
'reversed',
'round',
'set',
'setattr',
'slice',
'sorted',
'staticmethod',
'str',
'sum',
'super',
'tuple',
'type',
'vars',
'zip']
The keywords:
>>> import keyword
>>> pprint(keyword.kwlist)
['False',
'None',
'True',
'and',
'as',
'assert',
'break',
'class',
'continue',
'def',
'del',
'elif',
'else',
'except',
'finally',
'for',
'from',
'global',
'if',
'import',
'in',
'is',
'lambda',
'nonlocal',
'not',
'or',
'pass',
'raise',
'return',
'try',
'while',
'with',
'yield']
Posts: 12,030
Threads: 485
Joined: Sep 2016
And also __file__ for module location
|