other:python:misc_by_jyp
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
other:python:misc_by_jyp [2021/08/25 10:12] – [Using ordered dictionaries] Added more details jypeter | other:python:misc_by_jyp [2021/08/27 13:56] – Added file name generation section jypeter | ||
---|---|---|---|
Line 50: | Line 50: | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
+ | |||
+ | |||
+ | === Example: getting the full path of the Python used === | ||
+ | |||
+ | Note: the actual python may be different from the default python! | ||
+ | |||
+ | < | ||
+ | / | ||
+ | |||
+ | $ / | ||
+ | >>> | ||
+ | >>> | ||
+ | '/ | ||
+ | >>> | ||
+ | '/ | ||
+ | |||
+ | |||
+ | === Example: getting the full path of a script === | ||
+ | |||
+ | < | ||
+ | >>> | ||
+ | '/ | ||
+ | >>> | ||
+ | True | ||
+ | >>> | ||
+ | '/ | ||
+ | >>> | ||
+ | True | ||
+ | </ | ||
+ | |||
=== Example: getting the size(s) of all the files in a directory === | === Example: getting the size(s) of all the files in a directory === | ||
Line 72: | Line 102: | ||
>>> | >>> | ||
64792</ | 64792</ | ||
+ | |||
+ | ==== Generating file names ==== | ||
+ | |||
+ | === Name depending on the current date/time === | ||
+ | |||
+ | < | ||
+ | >>> | ||
+ | >>> | ||
+ | >>> | ||
+ | ' | ||
+ | </ | ||
+ | |||
+ | === Temporary file === | ||
+ | |||
+ | < | ||
+ | >>> | ||
+ | >>> | ||
+ | < | ||
+ | >>> | ||
+ | '/ | ||
+ | >>> | ||
+ | >>> | ||
==== Using command-line arguments ==== | ==== Using command-line arguments ==== | ||
other/python/misc_by_jyp.txt · Last modified: 2024/11/04 15:01 by jypeter