Default argument for QApplication?
phil at riverbankcomputing.com
Fri Aug 27 13:51:22 BST 2021
On 27/08/2021 13:04, Florian Bruhin wrote:
> On Fri, Aug 27, 2021 at 12:25:49PM +0100, Phil Thompson wrote:
>> On 27/08/2021 12:20, Florian Bruhin wrote:
>> > Hi,
>> > PyQt requires passing sys.argv (or  for quick tests) to QApplication,
>> > probably because Qt in C++ requires passing argc/argv.
>> > I recently noticed that PySide (both 2 and 6) doesn't require that, and
>> > defaults to sys.argv when no argument is given. While a  is only two
>> > characters, sometimes even for quick test scripts it'd be good to pass
>> > custom arguments to Qt, and an "import sys" and passing "sys.argv" is a
>> > bit more typing :)
>> > Maybe PyQt should default to sys.argv as well? Or do you prefer
>> > "explicit is better than implicit" here?
>> It's something I've considered many times (because it's a trivial
>> but if you start improving on the Qt API (rather than just trying to
>> predictably follow it) then you'd never stop.
> Fair point. PySide does those kind of things (turning certain objects
> into context managers, allowing optional snake_case access of
> everything, etc.). But I'm not exactly convinced it's a good idea. Even
> more so since obviously duplicating the entire Qt documentation is a
> pain point, thus it's a good idea to stay close to upstream, so that
> upstream docs can be used.
Implementing context managers is reasonable as it is adding
functionality rather than changing it - QApplication is a context
manager in PyQt.
Allowing snake_case is just dumb.
More information about the PyQt