Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am westurner on github.
  • I am westurner (https://keybase.io/westurner) on keybase.
  • I have a public key ASAy7kaQRXpchVfKf1DVN9rRrRQCVYJ_EnHxEyvj1b5fmwo

To claim this, I am signing this object:

@westurner
westurner / 010-variables.ipynb
Last active June 4, 2018 00:17
Python variables, references, aliases, garbage collection, scope
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@westurner
westurner / site_discover.py
Last active August 17, 2024 03:58
find all python*.exe and pip*.exe binaries on os.environ['PATH']
#!/usr/bin/env python
"""
Something like this as e.g site.discover
(for use as ``python -m site.discover``)
could be helpful for explaining and diagnosing multiple pythons and pips
"""
import os
import re
try:
def search_operators(str_):
matches = []
for thing in [[x, getattr(int, x).__doc__] for x in dir(int) if x.startswith('__')]:
print((">>>>", (thing[0], thing[1])))
if thing[1] is not None and "<==>" in thing[1]:
print(('<==>', thing[1].split(" <==> ")[::-1]))
if str_ in thing[1]:
matches.append(thing)
print('')
@westurner
westurner / parse_inputrc.py
Last active September 19, 2016 15:19
parse a readline .inputrc file with Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
"""
parse_inputrc -- parse a readline .inputrc file
.. note:: This probably only handles a subset of ``.inputrc`` syntax.
"""
Verifying that +westurner is my blockchain ID. https://onename.com/westurner
@westurner
westurner / loglevels.py
Created February 15, 2016 20:29
loglevels.py: logging._levelNames { (0) NOTSET ; (10) DEBUG ; (20) INFO ; (30) WARN / WARNING ; (40) ERROR ; (50) CRITICAL / FATAL }
#!/usr/bin/env python
from __future__ import print_function
import logging
###
def addLevelName__TRACE():
logging.addLevelName(8, 'TRACE')
###
@westurner
westurner / ordereddefaultdict.py
Created February 12, 2016 22:14
OrderedDefaultDict_.py
#!/usr/bin/env python
"""
ordereddefaultdict.OrderedDefaultDict
.. code:: bash
$ python ./ordereddefaultdict.py -t
$ nosetests ./ordereddefaultdict.py
$ py.test ./ordereddefaultdict.py
# :*_markdown_github[__html]
# :*_markdown_commonmark[__html]
# Markdown[HTML] > MarkdownGithub[HTML]
# Markdown[HTML] > MarkdownCommonmark[HTML]
rdfx:Markdown a rdfs:Datatype ;
.
rdfx:MarkdownGithub a rdfs:Datatype ;