At Saturday 9/12/2006 13:15, Stuart D. Gathman wrote:
app.py:
import spf
spf.set_driver('dnspython')
...
Can a function replace itself? For instance, in spf.py, could DNSLookup
do this to provide a default:
def set_driver(d):
if d == 'pydns':
from pydns_driver import DNSLookup
elif d == 'dnspython':
from dnspython_driver import DNSLookup
else: raise Exception('Unknown DNS driver')
def DNSLookup(name,t):
from pydns_driver import DNSLookup
return DNSLookup(name,t)
The above code *almost* works, but DNSLookup is a local name inside
the function. Use the global statement.
As an example, see how getpass.py (in the standard library) manages
the various getpass implementations.
--
Gabriel Genellina
Softlab SRL
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
--
http://mail.python.org/mailman/listinfo/python-list