[Ironpython-users] Calling a method whose name is a Python keyword

Douglas S. Blank dblank at cs.brynmawr.edu
Mon Feb 27 13:49:12 CET 2012


> Hi,
>
> I answer my own question to get the solution into the archives:
>
>> I have a .NET object which exposes a method "import(some, parameters)"
>> method. However, I cannot call this method as "import" is a reserved
>> keyword in IronPython. How to call this method?
>
> The "__getattribute__" method seems to be the solution:
>
> Foo.__getattribute("import")(some, parameters)

Yes, that would be the standard Python way. Or slightly cleaner:

getattr(Foo, "import")(some, parameters)

-Doug

>
> 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
>



More information about the Ironpython-users mailing list