
Security News
Potemkin Understanding in LLMs: New Study Reveals Flaws in AI Benchmarks
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Python module to emulate the __qualname__
attribute for classes and methods
(Python 3.3+) in older Python versions. See PEP 3155
__ for details.
__ https://www.python.org/dev/peps/pep-3155/
.. image:: https://travis-ci.org/wbolster/qualname.svg?branch=master :target: https://travis-ci.org/wbolster/qualname
.. image:: https://pypip.in/download/qualname/badge.svg :target: https://pypi.python.org/pypi/qualname/ :alt: Downloads
.. image:: https://pypip.in/version/qualname/badge.svg :target: https://pypi.python.org/pypi/qualname/ :alt: Latest Version
.. image:: https://pypip.in/py_versions/qualname/badge.svg :target: https://pypi.python.org/pypi/qualname/ :alt: Supported Python versions
.. image:: https://pypip.in/status/qualname/badge.svg :target: https://pypi.python.org/pypi/qualname/ :alt: Development Status
.. image:: https://pypip.in/license/qualname/badge.svg :target: https://pypi.python.org/pypi/qualname/ :alt: License
::
pip install qualname
Assume these definitions:
::
class C: def f(): pass
class D:
def g():
pass
In Python 3.3+, classes have a __qualname__
property::
C.qualname 'C' C.f.qualname 'C.f' C.D.qualname 'C.D' C.D.g.qualname 'C.D.g'
Unfortunately, Python 2 and early Python 3 versions do not have an (obvious)
equivalent. qualname
to the rescue::
from qualname import qualname
qualname(C) 'C' qualname(C.f) 'C.f' qualname(C.D) 'C.D' qualname(C.D.g) 'C.D.g'
Victory!
Glad you ask.
This module uses source code inspection to figure out how (nested) classes and functions are defined in order to determine the qualified names for them. That means parsing the source file, and traversing the AST (abstract syntax tree). This sounds very hacky, and it is, but the Python interpreter itself does not have the necessary information, so this justifies extreme measures.
Now that you know how it works, you'll also understand that this module only works when the source file is available. Fortunately this is the case in most circumstances.
BSD.
FAQs
__qualname__ emulation for older Python versions
We found that qualname demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.