This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
notes:python_cheat_sheet [2026/07/23 04:55] 114.119.151.209 old revision restored (2026/07/06 16:17) |
notes:python_cheat_sheet [2026/07/24 15:24] (current) 47.79.201.32 old revision restored (2026/06/21 13:23) |
||
|---|---|---|---|
| Line 91: | Line 91: | ||
| from fib import fib1, fib2 | from fib import fib1, fib2 | ||
| </ | </ | ||
| - | * <code python>__name__</ | + | * %%__name__%% is set to the name of the module or to %%__main__%% if called from the command line. |
| * The search list for modules is the variable sys.path initialized from the directory containing the input script (or the current directory), PYTHONPATH and the installation-dependent default. | * The search list for modules is the variable sys.path initialized from the directory containing the input script (or the current directory), PYTHONPATH and the installation-dependent default. | ||
| * When a module is imported, a byte-code version is stored to module.pyc which speeds up successive loads. | * When a module is imported, a byte-code version is stored to module.pyc which speeds up successive loads. | ||
| Line 103: | Line 103: | ||
| * str() returns a readable representations, | * str() returns a readable representations, | ||
| * Strings have several formatting methods. | * Strings have several formatting methods. | ||
| - | * [[ http:// | + | * // |
| * To open a file <code python> open('/ | * To open a file <code python> open('/ | ||
| - | * File methods include read, readline, write. | + | * [[http:// |
| * //pickle// contains load and dump methods for serializing objects. Support should be added for new object types. | * //pickle// contains load and dump methods for serializing objects. Support should be added for new object types. | ||