[pyar] Puedo hacer el equivalente de "." de bash?

Roberto Alsina ralsina en netmanagers.com.ar
Mie Mar 28 15:46:24 ART 2012


Ok, lo que quiero es execfile:

This function is similar to the exec statement, but parses a file 
instead of a string. It is different from the import statement in that 
it does not use the module administration — it reads the file 
unconditionally and does not create a new module. [1]

The arguments are a file name and two optional dictionaries. The file is 
parsed and evaluated as a sequence of Python statements (similarly to a 
module) using the globals and locals dictionaries as global and local 
namespace. If provided, locals can be any mapping object.

Changed in version 2.4: formerly locals was required to be a dictionary.

If the locals dictionary is omitted it defaults to the globals 
dictionary. If both dictionaries are omitted, the expression is executed 
in the environment where execfile() is called. The return value is None.



More information about the pyar mailing list