Re: Inconsistent return values

Markus Schaber

Hi, Deanna,

I think it‘s the difference between a statement and an expression.


Statements don’t have return values in general, only if they’re expressions. “if”-statements are not expressions.


My guess is: If the last statement is an expression, it uses it’s result as return value, and None otherwise.




Mit freundlichen Grüßen / Best regards

Markus Schaber

software Automation.

CODESYS Development GmbH
A member of the CODESYS Group

Markus Schaber | Team Leader Automation Server
Tobias-Dannheimer-Str. 5 | 87439 Kempten | Germany
Tel. +49-831-54031-979
m.schaber@... |

CODESYS Online Help:

Geschäftsführer / CEOs: Dipl.-Inf. Dieter Hess, Dipl.-Inf. Manfred Werner
Handelsregister / Trade register: Kempten HRB 13379
| USt-IDNr. / Tax ID No.: DE 307355786

Diese E-Mail enthält möglicherweise vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind
oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail.
Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received
this e-mail in error, please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure
or distribution of the material in this e-mail is strictly forbidden.

Von: <> Im Auftrag von ddelapasse@...
Gesendet: Freitag, 23. Oktober 2020 21:59
Betreff: [ironpython] Inconsistent return values



I'm relatively new to ironpython and trying to understand my options for returning values back to my C# app.  Can someone explain why option 1 returns fine, but option 2 returns null.   Trying to allow my web app users to code up some "formulas" (basic logic) and this seems like a great option, but I need to understand "the rules".   The responses will be sometimes text and sometimes numeric so wrapping in json.dumps seems like a good plan.


-------- option 1 (returns "last line") ----------

import json

json.dumps("last line")

---------    option 2 (returns null)     -----------
import json

if True==True:





Join to automatically receive all group messages.