2010/11/24 Anderson Lizardo <[email protected]>:
> On Tue, Nov 23, 2010 at 5:09 PM, Lauro Moura <[email protected]> wrote:
>> My proposal is to replace the operators by plain methods like
>> filterEqual, filterLessThan, etc. Originally I was thinking about
>> using just equal, lessThan, etc, but Hugo pointed that adding a
>> "filter" prefix or suffix would be better.
>>
>> request.setFilter(gallery.year.filterLessOrEqual("2010"))
>> request.setFilter(gallery.author.filterEqual("James Joyce"))
>
> +1 for the proposed API.

I think the operator overloading is okay - it maps more directly from
the C++ code, so it's easier to "port" application code from C++ to
Python and vice versa. You do the same for camelCase method names
(PEP-8 says you should use lower_case_with_underscore method names),
after all. If the operator overloading is used, I can use the PySide
bindings without having to look at PySide-specific documentation
(least surprise), but if these new method names (filterLessOrEqual)
are introduced, I have to look them up and they have to be well
documented and I have to know that things are different if I port
(parts of) my Python code to C++.

Also, is it possible in the C++ API to do something like this?

request.setFilter(gallery.year <= "2010" || gallery.author == "John")

If it is possible, how would that map to your proposed solution?


Thomas
_______________________________________________
PySide mailing list
[email protected]
http://lists.openbossa.org/listinfo/pyside

Reply via email to