brownplt / lambda-py

Other
58 stars 10 forks source link

locals() doesn't work at the top level #55

Closed amtriathlon closed 11 years ago

amtriathlon commented 11 years ago

This simple test works in Python but, it is failing in our implementation:

a=1 assert "a" in locals()

mpmilano commented 11 years ago

fixed in 5d52e4652001c96c566b359597b8c6b503e20a3e

amtriathlon commented 11 years ago

Matthew, is there any way to make dir() return the same as locals()?

If this is complicated the alternative is support only dir(obj) for now, eventually raising an error indicating to use locals() instead of dir(), let me now.

2013/3/26 Matthew Milano notifications@github.com

fixed in 5d52e46https://github.com/brownplt/lambda-py/commit/5d52e4652001c96c566b359597b8c6b503e20a3e

— Reply to this email directly or view it on GitHubhttps://github.com/brownplt/lambda-py/issues/55#issuecomment-15493572 .

Alejandro.

mpmilano commented 11 years ago

It would seem the obvious choice is to have it actually call locals() whatever that returns.

Locals is a normal function, not a macro.

Would that work?

On Tuesday, March 26, 2013, Alejandro Martinez wrote:

Matthew, is there any way to make dir() return the same as locals()?

If this is complicated the alternative is support only dir(obj) for now, eventually raising an error indicating to use locals() instead of dir(), let me now.

2013/3/26 Matthew Milano <notifications@github.com <javascript:_e({}, 'cvml', 'notifications@github.com');>>

fixed in 5d52e46< https://github.com/brownplt/lambda-py/commit/5d52e4652001c96c566b359597b8c6b503e20a3e>

— Reply to this email directly or view it on GitHub< https://github.com/brownplt/lambda-py/issues/55#issuecomment-15493572> .

Alejandro.

— Reply to this email directly or view it on GitHubhttps://github.com/brownplt/lambda-py/issues/55#issuecomment-15494563 .

amtriathlon commented 11 years ago

Not at all: locals() is a normal function but, it returns the locals of the function calling it, in this case dir() not the locals of the environment where dir() is being called, which is the intended behavior.

I've tried to call what locals calls (%locals) and it doesn't work either.

2013/3/26 Matthew Milano notifications@github.com

It would seem the obvious choice is to have it actually call locals() whatever that returns.

Locals is a normal function, not a macro.

Would that work?

On Tuesday, March 26, 2013, Alejandro Martinez wrote:

Matthew, is there any way to make dir() return the same as locals()?

If this is complicated the alternative is support only dir(obj) for now, eventually raising an error indicating to use locals() instead of dir(), let me now.

2013/3/26 Matthew Milano <notifications@github.com <javascript:_e({}, 'cvml', 'notifications@github.com');>>

fixed in 5d52e46<

https://github.com/brownplt/lambda-py/commit/5d52e4652001c96c566b359597b8c6b503e20a3e>

— Reply to this email directly or view it on GitHub< https://github.com/brownplt/lambda-py/issues/55#issuecomment-15493572> .

Alejandro.

— Reply to this email directly or view it on GitHub< https://github.com/brownplt/lambda-py/issues/55#issuecomment-15494563> .

— Reply to this email directly or view it on GitHubhttps://github.com/brownplt/lambda-py/issues/55#issuecomment-15494866 .

Alejandro.

mpmilano commented 11 years ago

I'm sorry; I immediately assumed that this is being implemented in Core.

I see now that we actually implement this in attr.py in surface syntax. I'll make it happen.

Sorry for throwing you down the wrong path before.

On Tuesday, March 26, 2013, Alejandro Martinez wrote:

Not at all: locals() is a normal function but, it returns the locals of the function calling it, in this case dir() not the locals of the environment where dir() is being called, which is the intended behavior.

I've tried to call what locals calls (%locals) and it doesn't work either.

2013/3/26 Matthew Milano <notifications@github.com <javascript:_e({}, 'cvml', 'notifications@github.com');>>

It would seem the obvious choice is to have it actually call locals() whatever that returns.

Locals is a normal function, not a macro.

Would that work?

On Tuesday, March 26, 2013, Alejandro Martinez wrote:

Matthew, is there any way to make dir() return the same as locals()?

If this is complicated the alternative is support only dir(obj) for now, eventually raising an error indicating to use locals() instead of dir(), let me now.

2013/3/26 Matthew Milano <notifications@github.com <javascript:_e({}, 'cvml', 'notifications@github.com');> <javascript:_e({}, 'cvml', 'notifications@github.com <javascript:_e({}, 'cvml', 'notifications@github.com');>');>>

fixed in 5d52e46<

https://github.com/brownplt/lambda-py/commit/5d52e4652001c96c566b359597b8c6b503e20a3e>

— Reply to this email directly or view it on GitHub< https://github.com/brownplt/lambda-py/issues/55#issuecomment-15493572>

.

Alejandro.

— Reply to this email directly or view it on GitHub< https://github.com/brownplt/lambda-py/issues/55#issuecomment-15494563> .

— Reply to this email directly or view it on GitHub< https://github.com/brownplt/lambda-py/issues/55#issuecomment-15494866> .

Alejandro.

— Reply to this email directly or view it on GitHubhttps://github.com/brownplt/lambda-py/issues/55#issuecomment-15495393 .