misc: Miscellaneous functionality¶
Miscellaneous functionality
Search: nearest_element, nearest_unsorted, nearest_index
Sort: sort_natural, zipsort, issorted
Namedtuples: namedtupled_addcolumn, namedtuple_extend, etc.
Open files: open_with_standard_app, wait_for_file_modified, open_with
Unit conversions: cm_to_pixels, page_dinsize_to_mm, etc.
Other: singleton
Functions¶
|
Return True if all elements in xs are equal |
|
Return |
|
Returns True if x is of the given type, raises TypeError otherwise |
|
Return obj as type. |
|
Return True if obj can be pickled |
|
convert a distance in cm to pixels |
|
recursively update orig with updatewith |
|
Merge the contents of the two dicts. |
|
Returns the index of a "zone" where to place x. |
|
Return all 'public' attributes of this object |
|
Find all elements in seq which are present at least mincount times |
|
Convert a Matplotlib figure to a 4D numpy array with RGBA channels |
|
Iterate over all attributes of objects. |
|
Returns the first path in paths which exists |
|
Get the first value in values which is not sentinel. |
|
Given a list of elements, take a slice similar to seq[start:end:step], but allows step to be a fraction |
|
Create a html table |
|
Convert inches to pixels |
|
Does |
|
|
|
Returns True if seq is sorted |
|
Examples. |
|
Divides seq into two lists: filter(pred, seq), filter(not pred, seq) |
|
Add a column to a sequence of named tuples |
|
Create a new namedtuple constructor with the added columns |
|
Rename the column of a seq of namedtuples |
|
Find the nearest element (the element, not the index) in seq |
|
Return the index of the nearest element in seq to item |
|
Find nearest item in an unsorted sequence |
|
Open a given file with a given app. |
|
Return the (height, width) for a given DIN size and page orientation |
|
Parse a time string |
|
Given a sequence, pick numitems from it at regular intervals |
|
Convert a distance in pixels to cm |
|
Convert pixels to inches |
|
Print rows as table |
|
decorator - keeps __all__ updated |
|
Remove all duplicates in seq while keeping its order If order is not important, use list(set(seq)) |
|
Remove last element of seq matching the given condition, in place |
|
Replace current SIGINT hanler with the given one, return the old one |
|
Decorator - Makes the function return a namedtuple with the given names. |
|
Decorator to make a function return a RecordList instead of a list of tuples |
|
Reverse seq recursively |
|
Convert a color in rgb to its hex representation |
|
Convert seconds to a suitable string representation |
|
Returns the (start, end) indexes if seq contains subseq, or None |
|
Simplify breakpoints in a breakpoint function |
|
A class decorator to create a singleton class |
|
Snap the values of X to the nearest slot in a grid |
|
Find the nearest slot in a grid |
|
Snap x to the nearest slot within multiple overlapping grids |
|
This allows code like. |
|
sort a string sequence naturally |
|
sort dict d naturally and recursively |
|
Returns True if the given string represents a number |
|
Concatenate multiple lists to one big list |
|
To be used when raising a TypeError |
|
Wait until file is modified. |
|
Wrap a flat seq using the given sizes |
|
Sort a and keep b in sync |
Classes¶
Mixin class to provide automatic __repr__ |
|
|
To be used as decorator. |
|
Context manager to install a temporary sigint handler |