parsed.org

Tips by tag: strings

Dynamic Docstrings by Hawk-McKain on May 05, 2008 12:02 AM

Apparently Python only recognizes a doc string a litteral string placed after a function definition, meaning it won't accept an interpolated string, or even 'a'+'b', for whatever reason. For example:

>>> def doc():
...     '''Useful info. Note: %s''' % 'You'll never see this.'
...     print doc.__doc__
>>> doc()
None

To work around this you must explicitly set __doc__. Example:

>>> def doc():
...     doc.__doc__ = '''Useful info. Note: %s''' % 'Bacon is yummy!'
...     print doc.__doc__
>>> doc()
Useful info. Note: Bacon is yummy!
docstringpythonsemanticsstringssyntax
Using 'strings' for Paths in a Binary by xinu on Sep 13, 2005 02:34 PM

If you need to discover on which paths a binary depends, you can sometimes run strings on it and grep for everything starting with a slash:

# strings /usr/sbin/named | grep ^/
/lib/ld-linux.so.2
/etc/named.conf
/etc/rndc.key
/etc/lwresd.conf
/etc/resolv.conf
/var/run/named/named.pid
/var/run/named/lwresd.pid
/dev/null
binaryconfigurationgrepprocessshellstrings
RSS