On Friday 19 August 2011 12:59:52 Tim Doty wrote: > Thanks for the reply! > > On Aug 19, 2011, at 09:10 AM, Hugo Parente Lima <hugo.l...@openbossa.org> wrote: > > See: > > > > http://bugs.pyside.org/show_bug.cgi?id=345 > > http://bugs.pyside.org/show_bug.cgi?id=278 > > > > for an explanation about QSettings issues. > > The first of those bug reports is about PyQt where it is explained that > everything is returned from Qt as a string, but this is only what is > observed on Linux. For example, on Windows int() type is preserved as can > be seen by running the script. And on OSX all types are preserved. As the > example script I gave illustrates, you get different behavior depending on > which platform it is executed on (for executions past the first when saved > settings are restored). > > On review I realize I got my impression about the autoconversion of native > python types from PSEP 101 > (http://www.pyside.org/docs/pseps/psep-0101html). For example, > > "PyQt's approach to dealing with QVariants will be mimicked: Python objects > are automatically converted to and from QVariants wherever QVariants must > be passed as arguments and when QVariants are returned." > > "By supporting automatic conversion to and from QVariants, any Python > object (including dicts, lists, and tuples) can be used wherever a > QVariant is expected, so most programmers most of the time won't have to > know or care about QVariant at all." > > While I suppose that strictly speaking a programmer doesn't need to know > about QVariant the significant variation in behavior between platforms > (proper conversion to/from native python types versus everything becomes a > string) it does mean that if the intention is to have a cross-platform > application then a knowledge of the (undocumented) differences is helpful. > > The documentation is also wrong. For example, it suggests the following to restore an integer value: > >>> margin = settings.value("editor/wrapMargin").toInt()
I fixed this, thanks. > But doing so results in an error: > > AttributeError: 'unicode' object has no attribute 'toInt' > > That particular example would seem to have been taken from PyQt where > QVariant types are returned and have a .toInt() function. Not if you use API2 of PyQt which PySide aims to be compatible. > QSettings() documentation does have a section covering niggles between the > platforms, but omits any mention of the variant behavior. To me it would > make sense to document the differences. I agree, despite of it being a Qt problem, makes sense document this behavior as we hide QVariant from Python programmers, I filed a bug about this documentation issue [1] > Note, I started down this road after successfully converting from PyQt to > PySide on Linux and then discovered that the application would fail to > start on other platforms once the PySide version's settings file was > stored. That particular issue had to do with how None was (or was not) > preserved. [1] http://bugs.pyside.org/show_bug.cgi?id=981 -- Hugo Parente Lima INdT - Instituto Nokia de Tecnologia
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ PySide mailing list PySide@lists.pyside.org http://lists.pyside.org/listinfo/pyside