Uzytkownik "Steven Bethard" <[EMAIL PROTECTED]> napisal w
wiadomosci news:[EMAIL PROTECTED]
> Any reason you can't define it like:
>
> class actor(object):
> def __init__(self):
> self.roles = []
> def act(self):
> for role_func in self.roles:
> role_func(self)
Filip Dreger wrote:
Uzytkownik "Steven Bethard" <[EMAIL PROTECTED]> napisal w
wiadomosci news:[EMAIL PROTECTED]
See the documentation:
http://docs.python.org/ref/dynamic-features.html
"""The eval(), execfile(), and input() functions and the exec
statement do not have access to the full environme
Uzytkownik "Steven Bethard" <[EMAIL PROTECTED]> napisal w
wiadomosci news:[EMAIL PROTECTED]
> See the documentation:
>
> http://docs.python.org/ref/dynamic-features.html
>
> """The eval(), execfile(), and input() functions and the exec
> statement do not have access to the full environment for r
Filip Dreger wrote:
If I had a magic function 'exec in current scope' I would implement it
like this:
class actor:
def __init__():
self.roles=[]
def act():
for i in self.roles:
exec i in current scope
then the roles would simply be functions defined in any importable
file. For
Uzytkownik "Steven Bethard" <[EMAIL PROTECTED]> napisal w
wiadomosci news:[EMAIL PROTECTED]
> Filip Dreger wrote:
>> I am trying to find a way of executing functions without creating a
>> nested scope, so they can share local and global namespace (even if
>> they are declared in some other modu
Filip Dreger wrote:
I am trying to find a way of executing functions without creating a
nested scope, so they can share local and global namespace (even if
they are declared in some other module).
Why? Can you explain what the use case is?
STeVe
--
http://mail.python.org/mailman/listinfo/python-
Filip Dreger wrote:
Each function has a func_code property that is suposed to contain the
pure bytecode of the function. All the context (including reference to
relevant namespaces) is stored in different fields of the function
object. Since 'exec' is able to execute any string or bytecode in th
I came up with a simpler description of the problem.
It's all in the simple source:
# we define 'print b' in three different ways: as a string,
# a bytecode and a function
string="print b"
code=compile(string,'string','exec')
def function():
print b
# now we make functions that test if it is
Each function has a func_code property that is suposed to contain the
pure bytecode of the function. All the context (including reference to
relevant namespaces) is stored in different fields of the function
object. Since 'exec' is able to execute any string or bytecode in the
current scope, it