Manage QIcon instances on a application global level

Maurizio Berti maurizio.berti at gmail.com
Fri Jul 14 02:31:50 BST 2023


Il giorno ven 7 lug 2023 alle ore 05:32 Charles <peacech at gmail.com> ha
scritto:

> If you are going to put the Icon class in a module why don't just use
> module level __getattr__?
>

While that's possible, it would only be feasible (and safe) whenever the
module is strictly used for that specific purpose, otherwise there could be
inconsistency due to other objects that may share an identical name.

Since __getattr__ opens to the possibility of *any* name, it prevents the
possibility of wildcard imports (which, while normally discouraged, are not
forbidden), or having a multiple purpose module that includes the Icon
class, which could be a problem whenever the module also contains another
class that could theoretically match a "guessed" name.

I chose to use the basic concept of a standalone class as a semantic
context for generic usage.
If you want to make it a __getattr__ enabled module, you can just add that
support using the same logic.

Best regards,
MaurizioB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20230714/a18c0783/attachment.htm>


More information about the PyQt mailing list