Message146020
| Author |
vinay.sajip |
| Recipients |
Trundle, daniel.urban, eric.araujo, eric.snow, ezio.melotti, python-dev, terry.reedy, vinay.sajip |
| Date |
2011年10月20日.15:10:16 |
| SpamBayes Score |
3.811064e-05 |
| Marked as misclassified |
No |
| Message-id |
<1319123417.12.0.473380673552.issue12915@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
The version in logging.config appears to be doing the same job, but is shorter:
def _resolve(name):
"""Resolve a dotted name to a global object."""
name = name.split('.')
used = name.pop(0)
found = __import__(used)
for n in name:
used = used + '.' + n
try:
found = getattr(found, n)
except AttributeError:
__import__(used)
found = getattr(found, n)
return found
The line "used = used + '.' + n" could of course be improved. |
|