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 [2022/12/12 14:50] – Improved by changing the sections' levels jypeter | other:python:misc_by_jyp [2023/04/26 17:50] – Started a Data represenation section jypeter | ||
---|---|---|---|
Line 32: | Line 32: | ||
< | < | ||
+ | ===== Data representation ===== | ||
+ | A few notes for a future section or page about about data representation (bits and bytes) on disk and in memory, vs data format | ||
+ | |||
+ | * Binary data representation | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * Using [[https:// | ||
+ | * Range: | ||
+ | * 4-byte integers: −2, | ||
+ | * 8-byte integers: −9, | ||
+ | * [[https:// | ||
+ | * Range: | ||
+ | * 4-byte float: ~8 significant digits ^10E±38 | ||
+ | * See also [[https:// | ||
+ | * 8-byte float: ~15 significant digits ^10E±308 | ||
+ | |||
+ | * Array addressing | ||
+ | |||
+ | * disk and ram usage: how to check the usage (available ram and disk), best practice on multi-user systems (how much allowed?) | ||
+ | * '' | ||
+ | |||
+ | * understanding and reverse-engineering //binary// format | ||
+ | * '' | ||
+ | |||
+ | * binary vs text format: ascii, utf, raw | ||
+ | * text related functions in python: '' | ||
+ | * lists conversion with '' | ||
+ | |||
+ | * Misc : '' | ||
===== Checking if a file/ | ===== Checking if a file/ | ||
Line 43: | Line 73: | ||
===== Playing with strings ===== | ===== Playing with strings ===== | ||
- | ==== Filenames, etc... ==== | ||
- | |||
- | Check [[other: | ||
- | ==== Splitting strings ==== | + | ==== Splitting |
It's easy to split a string with multiple blank delimiters, or a specific delimiter, but it can be harder to deal with sub-strings | It's easy to split a string with multiple blank delimiters, or a specific delimiter, but it can be harder to deal with sub-strings | ||
Line 257: | Line 284: | ||
Note: a configuration file is also a way to easily store and exchange text data ! | Note: a configuration file is also a way to easily store and exchange text data ! | ||
+ | |||
+ | ===== Working with global variables ===== | ||
+ | |||
+ | There is a good chance you don't actually want/need a //global// variable. Be sure to use the '' | ||
+ | |||
+ | * [[https:// | ||
+ | * Simple module example\\ < | ||
+ | |||
+ | def set_myvar(new_val): | ||
+ | # Note: need to explicitly define a global variable (of a module) | ||
+ | # as ' | ||
+ | # Otherwise, the value will not be REdefined outside the function | ||
+ | global _myvar | ||
+ | _myvar = new_val | ||
+ | |||
+ | def get_myvar(): | ||
+ | return _myvar | ||
+ | |||
+ | def myfunc(nb_repeat = 10): | ||
+ | print(nb_repeat * _myvar)</ | ||
+ | * [[https:// | ||
===== Sorting ===== | ===== Sorting ===== | ||
Line 435: | Line 483: | ||
>>> | >>> | ||
array([3. , 4.5, 8. ])</ | array([3. , 4.5, 8. ])</ | ||
+ | |||
+ | |||
+ | ===== matplotlib related stuff ===== | ||
+ | |||
+ | ==== Working with time axes (and ticks) ==== | ||
+ | |||
+ | If you have problems setting the limits of a time axis, choosing the ticks' locations, or specifying the style of the labels, you should check the: | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
other/python/misc_by_jyp.txt · Last modified: 2024/11/04 15:01 by jypeter