[Ironpython-users] Scripting Ansys with IronPython - Unable to callvalues from dictionary

Steve Dower s.j.dower at gmail.com
Fri Nov 25 11:20:09 CET 2011


Probably the keys aren't actually strings but repr() has been
overridden. You could copy the dict with
  dict((repr(key), verifiedValues[key]) for key in verifiedValues)
to get one like you expect (though it may add quotes around the key).

Or you can
  print type(verifiedValues.keys()[0])
and see what you're actually dealing with.

On Fri, Nov 25, 2011 at 21:13, Markus Schaber <m.schaber at 3s-software.com> wrote:
> Hi,
>
> Von: Ossi Heinonen
>> That gives me
>>
>>    print verifiedValues[dict.keys(verifiedValues)[0]]
>>    5.5 [mm]
>>
>>Which is pretty damn exactly what I need! Thank you very much! The only problem now is that the order of the keys seems a bit random but maybe I can find some pattern for that.
>
> My guess is that the String for the Key is not exactly what you expect.
>
> Can you give us the output of the following command:
>
> for c in dict.keys(verifiedValues)[0]:
>    print "%s: '%s'"%(ord(c), c)
>
> Maybe some strange characters (like zero-width space or so) will show up.
>
> And if not, you can still use the ord values to create a matching key string using chr().
>
> Markus
>
> _______________________________________________
> Ironpython-users mailing list
> Ironpython-users at python.org
> http://mail.python.org/mailman/listinfo/ironpython-users
>
> 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