sc_printing#
Printing/notification functions.
- Highlights:
sc.heading()
: print text as a ‘large’ headingsc.colorize()
: print text in a certain colorsc.pr()
: print full representation of an object, including methods and each attributesc.sigfig()
: truncate a number to a certain number of significant figuressc.progressbar()
: show a (text-based) progress barsc.capture()
: capture text output (e.g., stdout) as a variable
Classes
Use pretty repr for objects, instead of just showing the type and memory pointer (the Python default for objects). |
|
Like |
|
Create multiple progress bars |
|
Captures stdout (e.g., from |
Functions
Creates a string for a nice columnated list (e.g. to use in __repr__ method). |
|
Return the object ID as per the default Python |
|
Return a sorted string of class attributes for the Python __repr__ method; see |
|
Return a sorted string of object attributes for the Python __repr__ method; see |
|
Return a sorted string of object methods for the Python __repr__ method; see |
|
Return a sorted string of object properties for the Python __repr__ method; see |
|
Print out a detailed representation of an object: methods, properties, attributes, etc. |
|
Pretty-print a detailed representation of an object. |
|
Pretty-print a detailed representation of an object ("pr" is short for "print repr"). |
|
Tiny function to print n blank lines, 3 by default |
|
Small wrapper to make textwrap more user friendly. |
|
Return a string representation of variable x with sigfigs number of significant figures |
|
Return a string representation of variable x with sigfigs number of significant figures |
|
Round number(s) to the specified number of significant figures. |
|
Quickly calculate the mean and standard deviation of an array. |
|
Quickly calculate the median and confidence interval of an array. |
|
Alias to |
|
Alias to |
|
Convert a number of bytes into a human-readable total. |
|
Print a numpy array nicely. |
|
Nicely print a complicated data structure, a la Matlab. |
|
Print out a list of variables. |
|
Colorize output text. |
|
Create a colorful heading. |
|
Alias to print(colors.red(s)) |
|
Alias to print(colors.yellow(s)) |
|
Alias to print(colors.green(s)) |
|
Alias to print(colors.cyan(s)) |
|
Alias to print(colors.blue(s)) |
|
Alias to print(colors.magenta(s)) |
|
Optionally print a message and automatically indent. |
|
Send a Slack notification when something is finished. |
|
Append a message string to a file specified by a filename name/path. |
|
Display progress as a percentage. |
|
Show a progress bar for a for loop. |