Home Download Buy Blog Forum Support

Settings.set and Casting

Settings.set and Casting

Postby guillermooo on Tue Feb 01, 2011 3:00 pm

view.settings().set("font_face", "30") will fail silently. view.settings().set("font_face", float("30")) will work.

In v1, Options.set would do the parsing and casting itself. The new behavior seems to be due to JSON having types, but it's inconvenient if you're setting settings at runtime.

I'm doing this now:
Code: Select all
for setter, name, value in genModelineOpts(view):
    try:
        setter(name, float(value))
    except ValueError:
        setter(name, value)


Whereas before I'd just say:

Code: Select all
for setter, name, value in genModelineOpts(view):
    setter(name, value)


I think it'd be better to have the conversion handled transparently.
guillermooo
 
Posts: 729
Joined: Thu Jul 23, 2009 9:06 am

Return to Technical Support

Who is online

Users browsing this forum: Google [Bot] and 17 guests