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/06/04 21:03] 47.82.13.200 old revision restored (2026/05/29 09:54) |
notes:python_cheat_sheet [2026/06/07 13:59] (current) 150.5.134.52 old revision restored (2026/06/03 02:44) |
||
|---|---|---|---|
| Line 91: | Line 91: | ||
| from fib import fib1, fib2 | from fib import fib1, fib2 | ||
| </ | </ | ||
| - | * %%__name__%% is set to the name of the module or to %%__main__%% if called from the command line. | + | * <code python>__name__</ |
| * 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('/ | ||
| - | * [[http:// | + | * File methods include read, readline, write. |
| - | * //pickle// contains | + | * //pickle// contains load and dump methods for serializing objects. Support should be added for new object types. |