obda.net

Finding All Loggers in Python

Add a comment

cheat-sheet articles are about code snippets that I need every once in a while, and which I constantly forget about.

logging.Logger.manager.loggerDict holds a dictionary of all loggers that have been requested.

>>> import logging
>>> logging.Logger.manager.loggerDict
{}
>>> logging.getLogger('foo')
<logging.Logger object at 0x7f11d4d104d0>
>>> logging.getLogger('bar')
<logging.Logger object at 0x7f11d4cb7ad0>
>>> logging.Logger.manager.loggerDict
{'foo': <logging.Logger object at 0x7f11d4d104d0>,
'bar': <logging.Logger object at 0x7f11d4cb7ad0>}

Found at http://code.activestate.com/lists/python-list/621740/.

Zsh History Expansion

1 comment

cheat-sheet articles are about code snippets that I need every once in a while, and which I constantly forget about.

Shortcut Description
!! the entire previous command
!!^ the first argument from the previous command
!!* all arguments from the previous command
!!:n the n-th word from the previous command
!!$ the last word from the previous command
!# the entire current command line (typed in so far)
!#^ the first argument from the current command line
!#* all arguments from the current command line
!#:n the n-th word from the current command line
!#$ the last word from the current command line

For more information, read Andrew Grangaard’s Zsh history expansion article.

Zsh Line Editor Shortcuts

Add a comment

cheat-sheet articles are about code snippets that I need every once in a while, and which I constantly forget about.

Note: These shortcuts are valid for Zsh’s emacs mode, not necessarily for vi mode.

Shortcut Description
M-. insert the last word from the previous history entry1
C-u kill the current line
C-v C-j insert newline at current cursor position
C-x C-e edit current command line in $EDITOR
C-x C-f char move to the next occurrence of character char

  1. press M-. repeatedly to get the last words from older history entries