Re: Getty fully qualified class name from class object

2023-08-23 Thread Ian Pilcher via Python-list
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! --

Getty fully qualified class name from class object

2023-08-22 Thread Ian Pilcher via Python-list
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

Which more Pythonic - self.__class__ or type(self)?

2023-03-02 Thread Ian Pilcher
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? --

Re: Tool that can document private inner class?

2023-02-08 Thread Ian Pilcher
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

Re: Tool that can document private inner class?

2023-02-07 Thread Ian Pilcher
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]:

Tool that can document private inner class?

2023-02-07 Thread Ian Pilcher
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

Re: set.add() doesn't replace equal element

2022-12-31 Thread Ian Pilcher
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

Re: set.add() doesn't replace equal element

2022-12-30 Thread Ian Pilcher
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

set.add() doesn't replace equal element

2022-12-30 Thread Ian Pilcher
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

Re: Calling pselect/ppoll/epoll_pwait

2022-12-13 Thread Ian Pilcher
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 this

Calling pselect/ppoll/epoll_pwait

2022-12-02 Thread Ian Pilcher
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]

Re: Dealing with non-callable classmethod objects

2022-11-12 Thread Ian Pilcher
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__    

Re: Dealing with non-callable classmethod objects

2022-11-12 Thread Ian Pilcher
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

Re: Superclass static method name from subclass

2022-11-11 Thread Ian Pilcher
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):    

Re: Superclass static method name from subclass

2022-11-11 Thread Ian Pilcher
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

Dealing with non-callable classmethod objects

2022-11-11 Thread Ian Pilcher
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

Superclass static method name from subclass

2022-11-11 Thread Ian Pilcher
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 =

Re: Any socket library to communicate with kernel via netlink?

2019-11-20 Thread Ian Pilcher
in, but 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

Distutils - bdist_rpm - specify python interpretter location

2019-10-30 Thread Ian Pilcher
FILES Is there a way to tell Distutils to use 'python2'? Thanks! -- ============ Ian Pilcher arequip...@gmail.com "I grew up before

Re: Get __name__ in C extension module

2019-10-07 Thread Ian Pilcher
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. -- ======

Re: Get __name__ in C extension module

2019-10-06 Thread Ian Pilcher
nd 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 Mark Zuck

Re: Get __name__ in C extension module

2019-10-06 Thread Ian Pilcher
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 arequip

Re: Get __name__ in C extension module

2019-10-06 Thread Ian Pilcher
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" becaus

Get __name__ in C extension module

2019-10-05 Thread Ian Pilcher
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 correct approach. My

Using a logging.Logger in a C extension

2019-10-04 Thread Ian Pilcher
.). 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! -- ======== I

Irritating bytearray behavior

2019-09-16 Thread Ian Pilcher
of ip.packed into the bytearray without changing its size? TIA -- Ian Pilcher arequip...@gmail.com "I grew up before Mark Zuckerberg invented frien

Re: The basics of the logging module mystify me

2018-04-20 Thread Ian Pilcher
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 up before Mark Zucke

Re: Spot the invalid syntax

2018-03-08 Thread Ian Pilcher
-headed to use properly, apparently. -- Ian Pilcher arequip...@gmail.com "I grew up before Mark Zuckerberg invented frien

Re: Spot the invalid syntax

2018-03-08 Thread Ian Pilcher
On 03/08/2018 05:26 PM, Chris Angelico wrote: On Fri, Mar 9, 2018 at 10:23 AM, Ian Pilcher <arequip...@gmail.com> wrote: (Because I certainly can't.) ips.update(_san_dnsname_ips(cname, True) return ips I've checked for tabs and mismatched parentheses.

Spot the invalid syntax

2018-03-08 Thread Ian Pilcher
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

Re: __new__ and __init__ - why does this work?

2017-08-09 Thread Ian Pilcher
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 sets whi

Re: __new__ and __init__ - why does this work?

2017-08-09 Thread Ian Pilcher
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 Pilcher arequip...

__new__ and __init__ - why does this work?

2017-08-08 Thread Ian Pilcher
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? -- ======== I

Subclassing dict to modify values

2017-08-02 Thread Ian Pilcher
m__? (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 Zuck

Re: Get list of attributes from list of objects?

2017-08-02 Thread Ian Pilcher
On 08/02/2017 12:49 PM, Chris Angelico wrote: On Thu, Aug 3, 2017 at 3:21 AM, Ian Pilcher <arequip...@gmail.com> 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 co

Get list of attributes from list of objects?

2017-08-02 Thread Ian Pilcher
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...@gmail.com "I grew up b

Re: Why does Python want to read /proc/meminfo

2017-05-06 Thread Ian Pilcher
Delightful. -- ======== Ian Pilcher arequip...@gmail.com "I grew up before Mark Zuckerberg invented friendship" -- https://mail.python.org/mai

Why does Python want to read /proc/meminfo

2017-05-05 Thread Ian Pilcher
nd 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? -- ==========

Re: cryptography default_backend is "hazmat"?

2017-03-20 Thread Ian Pilcher
ne of them? -- ======== Ian Pilcher arequip...@gmail.com "I grew up before Mark Zuckerberg invented friendship" ==

Re: cryptography default_backend is "hazmat"?

2017-03-18 Thread Ian Pilcher
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? -- ======== I

cryptography default_backend is "hazmat"?

2017-03-18 Thread Ian Pilcher
? -- Ian Pilcher arequip...@gmail.com "I grew up before Mark Zuckerberg invented friendship" -- https://mail.python.org/mailman/listinfo/python-list

Re: python-daemon and PID files

2017-03-05 Thread Ian Pilcher
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

python-daemon and PID files

2017-03-04 Thread Ian Pilcher
ing 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 "I

Re: Noob confused by ConfigParser defaults

2017-02-20 Thread Ian Pilcher
e") Perfect. Thank you! -- ============ Ian Pilcher arequip...@gmail.com "I grew up before Mark Zuckerberg invented friendship" -- https:/

Re: Noob confused by ConfigParser defaults

2017-02-20 Thread Ian Pilcher
nk you! -- ======== Ian Pilcher arequip...@gmail.com "I grew up before Mark Zuckerberg invented friendship" -- https://mail.python.org/mailman/listinfo/python-list

Noob confused by ConfigParser defaults

2017-02-19 Thread Ian Pilcher
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

Re: accessing elements of a tuple

2009-01-30 Thread 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...@gmail.com