Default argument for QApplication?

Florian Bruhin me at the-compiler.org
Fri Aug 27 13:04:46 BST 2021


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 change),
> 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 the
upstream docs can be used.

Florian

-- 
            me at the-compiler.org | https://www.qutebrowser.org 
       https://bruhin.software/ | https://github.com/sponsors/The-Compiler/
       GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
             I love long mails! | https://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210827/79fdfec9/attachment.sig>


More information about the PyQt mailing list