[Ironpython-users] Simulating Python's scoping at the DLR level

2011-12-20 Thread Doug Blank
What would be a good way to simulate Python's scoping rules at the DLR level?

For example, if I were running two DLR-based scripts, I can just use
the same ScriptScope for both to have shared globals.

But how would you replicate Python's exact idea of a local environment
in each, while falling back to a shared, global one, in DLR-based
code?

I guess I'm looking for something like:

   Execute("x = y + z", local1, globals);
   Execute("x = y + z", local2, globals);
where local1, local2, and globals are dictionaries, and "x" would end
up being added to the local dictionaries, and "y" and "z" would be
looked for first in local1 or 2, then a shared globals.

Any suggestions?

Thanks!

-Doug
___
Ironpython-users mailing list
[email protected]
http://mail.python.org/mailman/listinfo/ironpython-users


Re: [Ironpython-users] Simulating Python's scoping at the DLR level

2011-12-20 Thread Curt Hagenlocher
I don't think you can replicate Python's semantics exactly, because Python
compiles an entire block at once but your scope would only see reads and
writes sequentially as they happen. For instance, in Python, the following
code will generate an error:

a = 1
def test():
print(a)
a = 2

That's because the assignment to "a" in "test" causes Python to consider
"a" to be a local variable for the duration of the entire function. This
isn't something you can duplicate with a ScriptScope-level component.

Having said that, and with the disclaimer that it's been over two years
since I've looked at DLR source code, here's what I think you want to do:

1. Given that you have two scopes -- a "global" scope and a "local" scope,
think carefully about the behavior that you want to define for the eight
possible cases of (read/write)(present/absent in local
scope)(present/absent in global scope).
2. Implement an IDynamicMetaObjectProvider which implements this behavior
on top of two other IDMOPs.
3. Using the global and local ScriptScopes (or Scopes, or ScopeStorages),
construct an instance of this new type.
4. Pass this object to ScriptRuntime.CreateScope to create a new
ScriptScope from the combined child scopes.

The delegating IDMOP can probably be built pretty efficently by being smart
about the error/fallback.
On Tue, Dec 20, 2011 at 12:15 AM, Doug Blank  wrote:

> What would be a good way to simulate Python's scoping rules at the DLR
> level?
>
> For example, if I were running two DLR-based scripts, I can just use
> the same ScriptScope for both to have shared globals.
>
> But how would you replicate Python's exact idea of a local environment
> in each, while falling back to a shared, global one, in DLR-based
> code?
>
> I guess I'm looking for something like:
>
>   Execute("x = y + z", local1, globals);
>Execute("x = y + z", local2, globals);
> where local1, local2, and globals are dictionaries, and "x" would end
> up being added to the local dictionaries, and "y" and "z" would be
> looked for first in local1 or 2, then a shared globals.
>
> Any suggestions?
>
> Thanks!
>
> -Doug
> ___
> Ironpython-users mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/ironpython-users
>
___
Ironpython-users mailing list
[email protected]
http://mail.python.org/mailman/listinfo/ironpython-users


[Ironpython-users] Reload module within embedded C# app

2011-12-20 Thread Daniel Fernandez




Hi All, I have an embedded Python engine in my C# app that executes python 
scripts. I have a filewatcher watching if any python scripts have been 
modified.  I am trying to perform a reload within my C# app but I didn't 
couldn't figure out how to perform this. The best I could figured out was to 
Compile the ScriptSource again when the change occurs. Any tips?? Thanks Danny  
  ___
Ironpython-users mailing list
[email protected]
http://mail.python.org/mailman/listinfo/ironpython-users


[Ironpython-users] bug / issue tracking for ironpython releases

2011-12-20 Thread Peter Schwalm

Hi ironpython,

I have a question regarding issues for ironpython. Where should I place 
indications for (possible) errors in the latest release? (I use 2.7.1)


I have found an issue tracker at

http://ironpython.codeplex.com/workitem/list/advanced

but it looks orphaned since October this year.

Especially I would like to report problems with:

a) pdb which I think does not work consistently

b) some tracebacks on exceptions/errors which do not report the 
last line of execution.


c) the use of sys.argv (sys.argv[0]) which as it looks behaves 
different from standard python.


Should problems of this kind be reported to this mailing list or does 
there exist a new bug tracker?


Thank you
Peter Schwalm





___
Ironpython-users mailing list
[email protected]
http://mail.python.org/mailman/listinfo/ironpython-users


Re: [Ironpython-users] bug / issue tracking for ironpython releases

2011-12-20 Thread Jeff Hardy
On Tue, Dec 20, 2011 at 7:36 PM, Peter Schwalm  wrote:
> Hi ironpython,
>
> I have a question regarding issues for ironpython. Where should I place
> indications for (possible) errors in the latest release? (I use 2.7.1)
>
> I have found an issue tracker at
>
>    http://ironpython.codeplex.com/workitem/list/advanced

That's the right place.

>
> but it looks orphaned since October this year.
>

Not at all. I just updated some issues a few hours ago.

> Especially I would like to report problems with:
>
>    a) pdb which I think does not work consistently
>
>    b) some tracebacks on exceptions/errors which do not report the last line
> of execution.
>
>    c) the use of sys.argv (sys.argv[0]) which as it looks behaves different
> from standard python.

Please do!

- Jeff
___
Ironpython-users mailing list
[email protected]
http://mail.python.org/mailman/listinfo/ironpython-users


Re: [Ironpython-users] Reload module within embedded C# app

2011-12-20 Thread Jeff Hardy
On Tue, Dec 20, 2011 at 6:33 PM, Daniel Fernandez
 wrote:
> Hi All,
>
> I have an embedded Python engine in my C# app that executes python scripts.
> I have a filewatcher watching if any python scripts have been modified.  I
> am trying to perform a reload within my C# app but I didn't couldn't figure
> out how to perform this. The best I could figured out was to Compile the
> ScriptSource again when the change occurs. Any tips??

That's what I do for NWSGI (more or less). When a script change is
detected it reloads, recompiles, and executes the script, and then
pulls the variables that it needs and continues on.

- Jeff
___
Ironpython-users mailing list
[email protected]
http://mail.python.org/mailman/listinfo/ironpython-users