[Ironpython-users] How can IronPython access a public static value defined in C#?

Jimmy Schementi jschementi at gmail.com
Mon Jun 20 21:04:33 CEST 2011


On Jun 20, 2011, at 2:59 PM, Keith Rome wrote:
> Evaluating a property could potentially introduce unexpected side effects. Best practices in OOP says that a property getter should never alter state, but it happens enough in the wild that I would think it to be dangerous to blindly invoke any getters during an import.
> 
> Also, presence of a property (as opposed to a field) implies that the code in the getter will be invoked each time the property is accessed. A consumer of such a construct expects this behavior, and might even depend on it.
> 
> If the auto import of properties is added, then it needs to at least be an opt-in feature.

We already do this with "from Class import StaticProperty". (from DateTime import Now, for example). Making "from StaticClass import *" have the same behavior is what we're going for; right now they behave differently. Using import-star is already a convenience-only feature, so mucking with it's behavior is fair.



More information about the Ironpython-users mailing list