[Ironpython-users] Setting __name__ to __main__

Doug Blank doug.blank at gmail.com
Wed Nov 23 19:47:10 CET 2011


Perhaps this is what you are thinking of:

PythonEngine engine = new PythonEngine(pyEngineOptions);
engine.DefaultModule = engine.CreateModule("__main__", true);
From:

http://ironpython.codeplex.com/workitem/2537

-Doug


On Wed, Nov 23, 2011 at 1:13 PM, Dino Viehland <dinov at microsoft.com> wrote:
> I think there's a ModuleOptions flag which controls it but don't remember
> how to flow it in off the top of my head
> ________________________________
> From: Jeff Hardy
> Sent: 11/23/2011 7:31 AM
> To: Markus Schaber
> Cc: ironpython-users at python.org
> Subject: Re: [Ironpython-users] Setting __name__ to __main__
>
> Your best bet is to look at the source to ipy.exe, which has to do the
> same thing.
>
> - Jeff
>
> On Mon, Nov 21, 2011 at 9:21 AM, Markus Schaber
> <m.schaber at 3s-software.com> wrote:
>> Hi,
>>
>> I want to set the __name__ variable to "__main__" in the script I execute.
>> However, it seems that the __name__ variable always is overridden with the
>> filename of the executed file.
>>
>> The attached example program gives the output "name: test" instead of
>> "name: __main__".
>>
>> Googling brought up the following issues:
>>
>> http://ironpython.codeplex.com/workitem/2537 - Here, they use the
>> PythonEngine.DefaultModule API which I cannot find.
>>
>>
>> Best regards
>>
>> Markus Schaber
>> --
>> ___________________________
>> We software Automation.
>>
>> 3S-Smart Software Solutions GmbH
>> Markus Schaber | Developer
>> Memminger Str. 151 | 87439 Kempten | Germany | Tel. +49-831-54031-0 | Fax
>> +49-831-54031-50
>>
>> Email: m.schaber at 3s-software.com | Web: http://www.3s-software.com
>> CoDeSys internet forum: http://forum.3s-software.com
>> Download CoDeSys sample projects:
>> http://www.3s-software.com/index.shtml?sample_projects
>>
>> Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner |
>> Trade register: Kempten HRB 6186 | Tax ID No.: DE 167014915
>>
>>
>> _______________________________________________
>> Ironpython-users mailing list
>> Ironpython-users at python.org
>> http://mail.python.org/mailman/listinfo/ironpython-users
>>
>>
> _______________________________________________
> Ironpython-users mailing list
> Ironpython-users at python.org
> http://mail.python.org/mailman/listinfo/ironpython-users
>
>
> _______________________________________________
> Ironpython-users mailing list
> Ironpython-users at python.org
> http://mail.python.org/mailman/listinfo/ironpython-users
>
>


More information about the Ironpython-users mailing list