[IronPython] Documentation/Example for Python expressions

Bruce Bromberek bruce.bromberek at gmail.com
Wed Aug 26 23:32:11 CEST 2009


So you are looking for something more along the lines of this

https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Expressions
or this
https://www.cs.drexel.edu/~rweaver/COURSES/ISTC-2/TOPICS/expr.html

But for python.

This http://www.greenteapress.com/thinkpython/html/book003.html  comes
close, but again it is too programming oriented.

I'll keep an eye out, but If you need something right away I'd modify the
Javascript Pages.  The info is available under a Creative Commons License,
and it would not take too much time to make it 'pythonic'.  I think the
problem you are going to find is most python intro information is geared
towards learning via the interactive interpreter (out of your scope) or too
technical like the BNF grammer from the language reference.

-Bruce

On Wed, Aug 26, 2009 at 2:36 PM, Michael Foord <fuzzyman at voidspace.org.uk>wrote:

> Christian Schmidt wrote:
>
>> Hi Bruce,
>>
>> thanks for your answer.
>>
>>  How much python will you let your users execute?
>>>
>>
>> Potentially everything that can be put into
>>
>> ScriptEngine.CreateScriptSourceFromString(
>>     Expression, _SourceCodeKind.Expression_).Execute(ScriptScope)
>>
>>  Are they just typing in formulas or are they accessing data structure?
>>>
>>
>> Normally they type in simple formulas. But they are also allowed to type
>> in formulas that access functions, properties of classes/objects/data
>> structures and generators.
>>
>>  The Python Tutorial http://docs.python.org/tutorial/index.html   or
>>> http://www.diveintopython.org might be a good place to start, but if
>>> they will not be allowed to forms loops, etc both might be too much.
>>>
>>
>> These are all nicely written introductions to python "programming". But
>> that's too much: As Expression one can only enter "one-liners" - no
>> structured programs, no function or class definitions, no control flow, no
>> import statements ... simply no statements at all.
>>
>>  Can you post an example if what someone would be entering with your
>>> program?
>>>
>>
>> "Distance * AvgSpeed"
>>
>> "Distance**0.9 if Distance > 0 else 5"
>>
>> "sum([pos.time for pos in positions where pos.type = 7])"
>>
>> "complicated_function1(a,b) + complicated_function2({ param1: c, param2:
>> 42 })"
>>
>> where Distance, AvgSpeed, positions, a, b, c, ... are variables from the
>> ScriptScope.
>>
>
> Unfortunately I don't think such a documentation exists (not that I'm aware
> of but the internets is a big place). I wish it did - and if you write one
> then please make it public.
>
> The Python grammar is a good place to get the definitive syntax allowed in
> expressions, at least if you can read BNF.
>
> Michael
>
>
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.ironpython.com
>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>
>
>
> --
> http://www.ironpythoninaction.com/
> http://www.voidspace.org.uk/blog
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20090826/306bfa0a/attachment.html>


More information about the Ironpython-users mailing list