Re: [IronPython] How do I test if a variable is defined?

2008-11-04 Thread Tony Meyer
On Wed, Nov 5, 2008 at 8:06 AM, Michael Foord <[EMAIL PROTECTED]> wrote: > Marty Nelson wrote: >> >> How do I test in Iron Python (in python) if a variable is defined? >> [...] > try: > name > except NameError: > # variable 'name' is not defined If you're running some sort of checker (pylint,

Re: [IronPython] How do I test if a variable is defined?

2008-11-04 Thread Michael Foord
Marty Nelson wrote: How do I test in Iron Python (in python) if a variable is defined? 'name' in locals() or 'name' in globals() try: name except NameError: # variable 'name' is not defined The second idiom is actually fairly common. All the best, Michael === Notice: This e-ma

[IronPython] How do I test if a variable is defined?

2008-11-04 Thread Marty Nelson
How do I test in Iron Python (in python) if a variable is defined? === Notice: This e-mail message, together with any attachments, contains information of Symyx Technologies, Inc. or any of its affiliates or subsidiaries that may be confidential, proprietary, copyrighted, privileged and/or

Re: [IronPython] Loading Python modules from Silverlight Isolated Storage

2008-11-04 Thread Dino Viehland
Another option, assuming it's possible, would be to exec the function definition as well as the lambda. Also I would expect exec ... in locals() would work the same as "in dict(locals())". Which might also be problematic if you expect to see changes in the closure: def f(): a = 1 d =

Re: [IronPython] Loading Python modules from Silverlight Isolated Storage

2008-11-04 Thread Michael Foord
Kenneth Miller wrote: Thanks for the reply. Would you mind elaborating? Execing explicitly in locals solves the problem for Python 2.6: >>> def f(): ... a = 1 ... exec 'g = lambda: a' in locals() ... return g ... >>> g = f() >>> g() 1 >>> I don't think this would work in Python 3.0 thou

Re: [IronPython] Loading Python modules from Silverlight Isolated Storage

2008-11-04 Thread Kenneth Miller
Thanks for the reply. Would you mind elaborating? Regards, Ken On Nov 4, 2008, at 8:47 AM, Michael Foord wrote: Kenneth Miller wrote: All, The problem is illustrated here: This code will work properly: http://paste.pocoo.org/show/90071/ This code produces an error: http://paste.pocoo.or

Re: [IronPython] Loading Python modules from Silverlight Isolated Storage

2008-11-04 Thread Michael Foord
Kenneth Miller wrote: All, The problem is illustrated here: This code will work properly: http://paste.pocoo.org/show/90071/ This code produces an error: http://paste.pocoo.org/show/90072/ Different issue. Exec'ing explicitly inside a namespace avoids that problem altogether. Michael

Re: [IronPython] Loading Python modules from Silverlight Isolated Storage

2008-11-04 Thread Kenneth Miller
All, The problem is illustrated here: This code will work properly: http://paste.pocoo.org/show/90071/ This code produces an error: http://paste.pocoo.org/show/90072/ Regards, Ken On Nov 4, 2008, at 4:42 AM, Michael Foord wrote: Kenneth Miller wrote: It was proven to me that while exec mi

Re: [IronPython] [Python-Dev] Fwd: Removal of GIL through refcounting removal.

2008-11-04 Thread Michael Foord
Josiah Carlson wrote: On Mon, Nov 3, 2008 at 10:59 AM, Curt Hagenlocher <[EMAIL PROTECTED] > wrote: On Mon, Nov 3, 2008 at 11:50 AM, Josiah Carlson <[EMAIL PROTECTED] > wrote: On Sun, Nov 2, 2008 at 3:51 PM, <[EMAIL PROTECTED]

Re: [IronPython] Question Regarding WPF : DataBinding, DataTemplates and C# Extensions

2008-11-04 Thread Ivan Porto Carrero
Michael is right. The control still does have some limitations. When I finish my IronRuby book I'll look at changing some of the implementation. At this moment you would need a create a formatter for ironpython You can view the RubyFormatter here: http://code.google.com/p/dynamic-script-control/s

Re: [IronPython] Question Regarding WPF : DataBinding, DataTemplates and C# Extensions

2008-11-04 Thread Michael Foord
Simon Dahlbacka wrote: As the error message says, it cannot find the type LocalTimes. You may be interested in DynamicScriptControl: http://www.codeplex.com/dynamicscriptcontrol It needs a bit (but not much) work to get it working with IronPython. From the project page: We created a contr

Re: [IronPython] Loading Python modules from Silverlight Isolated Storage

2008-11-04 Thread Michael Foord
Kenneth Miller wrote: It was proven to me that while exec might work for simple cases, more advanced usage (declaring a lambda function inside an exec) can be problematic. It was advised that I generate python modules and dynamically import them. If memory served me, it's not possible to impor