Is it possible to access the name of a superclass static method, when
defining a subclass attribute, without specifically naming the super-
class?
Contrived example:
class SuperClass(object):
@staticmethod
def foo():
pass
class SubClass(SuperClass):
bar = SuperCl
I am trying to figure out a way to gracefully deal with uncallable
classmethod objects. The class hierarchy below illustrates the issue.
(Unfortunately, I haven't been able to come up with a shorter example.)
import datetime
class DUID(object):
_subclasses = {}
def __init_subclass__
On 11/11/22 11:29, Dieter Maurer wrote:
Ian Pilcher wrote at 2022-11-11 10:21 -0600:
class SuperClass(object):
@staticmethod
def foo():
pass
class SubClass(SuperClass):
bar = SuperClass.foo
^^
Is there a way to do this without
On 11/11/22 11:02, Thomas Passin wrote:
You can define a classmethod in SubClass that seems to do the job:
class SuperClass(object):
@staticmethod
def spam(): # "spam" and "eggs" are a Python tradition
print('spam from SuperClass')
class SubClass(SuperClass):
@cla
On 11/11/22 16:47, Cameron Simpson wrote:
On 11Nov2022 15:29, Ian Pilcher wrote:
* Can I improve the 'if callable(factory):' test above? This treats
all non-callable objects as classmethods, which is obviously not
correct. Ideally, I would check specifically for a classmethod,
On 11/12/22 14:57, Cameron Simpson wrote:
You shouldn't need a throwaway class, just use the name "classmethod"
directly - it's the type!
if not callable(factory):
if type(factory) is classmethod:
# replace fctory with a function calling factory.__func__
Does Python provide any way to call the "p" variants of the I/O
multiplexing functions?
Looking at the documentation of the select[1] and selectors[2] modules,
it appears that they expose only the "non-p" variants.
[1] https://docs.python.org/3/library/select.html
[2] https://docs.python.org/3/l
On 12/2/22 14:00, Ian Pilcher wrote:
Does Python provide any way to call the "p" variants of the I/O
multiplexing functions?
Just to close this out ...
As others suggested, there's no easy way to call the "p" variants of the
I/O multiplexing functions, but thi
I just discovered this behavior, which is problematic for my particular
use. Is there a different set API (or operator) that can be used to
add an element to a set, and replace any equal element?
If not, am I correct that I should call set.discard() before calling
set.add() to achieve the behavi
On 12/30/22 15:47, Paul Bryan wrote:
What kind of elements are being added to the set? Can you show
reproducible sample code?
The objects in question are DHCP leases. I consider them "equal" if
the lease address (or IPv6 prefix) is equal, even if the timestamps have
changed. That code is not
On 12/30/22 17:00, Paul Bryan wrote:
It seems to me like you have to ideas of what "equal" means. You want to
update a "non-equal/equal" value in the set (because of a different time
stamp). If you truly considered them equal, the time stamp would be
irrelevant and updating the value in the set
I've been banging my head on Sphinx for a couple of days now, trying to
get it to include the docstrings of a private (name starts with two
underscores) inner class. All I've managed to do is convince myself
that it really can't do it.
See https://github.com/sphinx-doc/sphinx/issues/11181.
Is t
On 2/7/23 14:53, Weatherby,Gerard wrote:
Yes.
Inspect module
import inspect
class Mine:
def __init__(self):
self.__value = 7
def __getvalue(self):
/"""Gets seven"""
/return self.__value
mine = Mine()
data = inspect.getdoc(mine)
for m in inspect.getmembers(mine):
if '__getvalue' in m[0]:
On 2/8/23 08:25, Weatherby,Gerard wrote:
No.
I interpreted your query as “is there something that can read docstrings
of dunder methods?”
Have you tried the Sphinx specific support forums?
https://www.sphinx-doc.org/en/master/support.html
Yes. I've posted to both the -user and -dev group
Seems like an FAQ, and I've found a few things on StackOverflow that
discuss the technical differences in edge cases, but I haven't found
anything that talks about which form is considered to be more Pythonic
in those situations where there's no functional difference.
Is there any consensus?
--
le "/tmp/test.py", line 32
return ips
^
SyntaxError: invalid syntax
I've checked for tabs and mismatched parentheses.
Aargh!
--
Ian Pilcher arequip...@gmail.com
"I grew up before Mark Zuckerberg invented friendship"
--
https://mail.python.org/mailman/listinfo/python-list
On 03/08/2018 05:26 PM, Chris Angelico wrote:
On Fri, Mar 9, 2018 at 10:23 AM, Ian Pilcher wrote:
(Because I certainly can't.)
ips.update(_san_dnsname_ips(cname, True)
return ips
I've checked for tabs and mismatched parentheses.
Check the immediately prec
bone-headed to use properly,
apparently.
--
====
Ian Pilcher arequip...@gmail.com
"I grew up before Mark Zuckerberg invented
now that I know that it exists).
As far as I can remember, none of the logging tutorials that I read ever
mentioned it.
--
========
Ian Pilcher arequip...@gmail.com
"I grew
ts of ip.packed
into the bytearray without changing its size?
TIA
--
====
Ian Pilcher arequip...@gmail.com
"I grew up before Mark Zuckerberg invented
, etc.).
PyArg_ParseTuple should be able to handle this with an "O!" format unit,
but I can't figure out how to retrieve the type object for
logging.Logger.
Any hints, links, etc. appreciated.
Thanks!
--
========
On 10/4/19 4:30 PM, Ian Pilcher wrote:
Ideally, I would pass my existing Logging.logger object into my C
function and use PyObject_CallMethod to call the appropriate method on
it (info, debug, etc.).
As I've researched this further, I've realized that this isn't the
correc
On 10/5/19 12:55 PM, Ian Pilcher wrote:
This is straightforward, except that I cannot figure out how to retrieve
the __name__.
Making progress. I can get a __name__ value with:
PyDict_GetItemString(PyEval_GetGlobals(), "__name__")
I say "a __name__ value" because t
do I access that
later in one of my extension functions? The only thing I can think of
would be to save it in a static variable, but static variables seem to
be a no-no in extensions.
--
========
Ian Pilcher
ts wrong and you get memory leaks of
worse crash python.
Well, I like driving cars with manual transmissions, so ...
--
========
Ian Pilcher arequip...@gmail.com
"I grew up before
bject actually is a logger. Doing
that validation (by using an "O!" unit in the PyArg_ParseTuple format
string) requires access to the logging.Logger type object, and I was
unable to find a way to access that object by name.
--
=====
--record=INSTALLED_FILES
Is there a way to tell Distutils to use 'python2'?
Thanks!
--
========
Ian Pilcher arequip...@gmail.com
--
always found library
called netlinkg but it actually does something like modify network address
or check network card...
Any idea is welcome
https://pypi.org/project/pyroute2/
--
Ian Pilcher
Matthew Sacks wrote:
> How can I access "DB" from the list directly using an index?
list[0][1]
... or did I misunderstand your question?
--
========
Ian Pilcher arequip
How do a set a default for option-1 *only* in section-1?
--
Ian Pilcher arequip...@gmail.com
"I grew up before Mark Zuckerberg invented frien
you!
--
====
Ian Pilcher arequip...@gmail.com
"I grew up before Mark Zuckerberg invented friendship"
--
https://mail.python.org/mailman/listinfo/python-list
e")
Perfect. Thank you!
--
============
Ian Pilcher arequip...@gmail.com
"I grew up before Mark Zuckerberg invented friendship"
--
https:/
creating my PID file manually in the child process, but
systemd complains, because it wants the PID file to exist before the
parent exits.
--
============
Ian Pilcher arequip...@gmail.com
&q
grandpappy, and it ought
to be good enough you young whippersnappers today.
In other words ... facepalm.
Thanks!
--
Ian Pilcher arequip...@gmail.com
"I grew up before Mark Zucke
?
--
Ian Pilcher arequip...@gmail.com
"I grew up before Mark Zuckerberg invented friendship"
--
https://mail.python.org/mailman/listinfo/python-list
ing a certificate) without a backend, and all of the
backends are "hazmat".
So what's the point of marking something as hazmat, if a large portion
of the rest of the module can't be used without it?
--
=======
end one of them?
--
============
Ian Pilcher arequip...@gmail.com
"I grew up before Mark Zuckerberg invented friendship"
=
tinue on and exit cleanly, so it doesn't seem to
strictly require the access.
Does anyone know why Python is trying to access this file, or what
functionality I might be missing if I don't allow the access?
--
==========
n the system.
Delightful.
--
========
Ian Pilcher arequip...@gmail.com
"I grew up before Mark Zuckerberg invented friendship"
--
https://mail
namelist = []
for foo in foolist:
namelist.append(foo.name)
Is there a way to avoid the for loop and create 'namelist' with a single
expression?
--
========
Ian Pilcher arequip
On 08/02/2017 12:49 PM, Chris Angelico wrote:
On Thu, Aug 3, 2017 at 3:21 AM, Ian Pilcher wrote:
You can't eliminate the loop, but you can compact it into a single
logical operation:
namelist = [foo.name for foo in foolist]
That's a "list comprehension", and is an eleg
__? (I.e. will
any other methods/operators that add values to the dictionary call my
__setitem__ method?)
--
============
Ian Pilcher arequip...@gmail.com
"I grew up before Mark
the call to __new__ actually initializes the set (since my
__init__ never calls the superclass __init__).
Is this a particular behavior of frozenset, or am I missing something
about the way that __new__ and __init__ interact?
--
========
mainly me being unfamiliar with the frozenset API (and not
overly concerned about the size of the _registry, since I expect that
there will be a very small number of entries). Your version is much
more elegant.
Thank you!
--
========
Ian Pil
On 08/09/2017 07:54 AM, Steve D'Aprano wrote:
On Wed, 9 Aug 2017 10:08 am, Ian Pilcher wrote:
I have created a class to provide a "hash consing"[1] set.
Your footnote for [1] appears to be missing. What's a hash consing set? It
appears to be nothing more than frozen set
How can I programmatically get the fully qualified name of a class from
its class object? (I'm referring to the name that is shown when str()
or repr() is called on the class object.)
Neither the __name__ or __qualname__ class attributes include the
module. For example:
>>> import logging
On 8/22/23 11:13, Greg Ewing via Python-list wrote:
Classes have a __module__ attribute:
>>> logging.Handler.__module__
'logging'
Not sure why I didn't think to look for such a thing. Looks like it's
as simple as f'{cls.__module__}.{cls.__qualname__}'.
Thanks!
--
==
(Note: I have mail delivery disabled for this list and read it through
GMane, so I am unable to respond with correct threading if I'm not cc'ed
directly.)
On 1/17/25 7:26 PM, dn via Python-list wrote:
On 18/01/25 12:33, Ian Pilcher via Python-list wrote:
I am making my first atte
(Note: I have mail delivery disabled for this list and read it through
GMane, so I am unable to respond with correct threading if I'm not cc'ed
directly.)
On 1/18/25 8:52 AM, Ian Pilcher wrote:
(And even that wouldn't really be correct, if it worked, because it
doesn't e
I am making my first attempt to use type hinting in a new project, and
I'm quickly hitting areas that I'm having trouble understanding. One of
them is how to write type hints for a method decorator.
Here is an example that illustrates my confusion. (Sorry for the
length.)
import collections.a
(Note: I have mail delivery disabled for this list and read it through
GMane. Please copy me on any responses, so that I can respond with
proper threading.)
From the things that I probably shouldn't spend my free time on
department ...
As background, I'm working on a project that is going to i
Given a class object (C), is it possible to *reliably* determine whether
the class was compiled with PEP 563 (from __future__ import annotations)
enabled?
Note that simply looking for the presence of C.__module__.annotations is
not really reliable. It will fail in the presence of any of these
co
52 matches
Mail list logo