Hello,
I have a request.
Would it be possible to include `follow_wrapper_chains` and `skip_bound_arg`
arguments to higher level functions of `inspect` module?
Would exposing them, but setting defaults to what they currently are, be
possible?
I sometimes need:
* `getcallargs`, but with
def powers_of_2_in(n):
s = 0
while n % 2 == 0:
s += 1
n = n // 2
return s, n
> On 30 Nov 2023, at 02:44, Julieta Shem via Python-list
> wrote:
>
> How would you write this procedure?
>
> --8<---cut here---start->8---
> def powers_
Yeah, I have been hearing that people are having troubles converting, but I
have only used argparse - got lucky there I guess.
I am thinking just making the function which spits the class out. Maybe not
very optimised solution, but simple.
Argument parsing in my case is very far from being a bo
ats Wichmann via Python-list
> wrote:
>
> On 11/27/23 04:29, Dom Grigonis via Python-list wrote:
>> Hi all,
>> I have a situation, maybe someone can give some insight.
>> Say I want to have input which is comma separated array (e.g.
>> paths='path1,path2,pat
Hi all,
I have a situation, maybe someone can give some insight.
Say I want to have input which is comma separated array (e.g.
paths='path1,path2,path3') and convert it to the desired output - list:
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('paths', type=lambda x: li
Thank you.
> On 16 Nov 2023, at 21:30, Dieter Maurer wrote:
>
> Dom Grigonis wrote at 2023-11-16 21:11 +0200:
>> ...
>>> On 16 Nov 2023, at 21:00, Dieter Maurer wrote:
>>> ...
>>> Methods are not bound during instance creation, they are bound during
>>> access.
>>
>> Good to know. What is the
> On 16 Nov 2023, at 21:00, Dieter Maurer wrote:
>
> Dom Grigonis wrote at 2023-11-16 20:12 +0200:
>> What I am interested in is a callback.
>> Preferably just after methods get bound. So in `object.__new__`.
>
>> I have done it via metaclass, but it is not ideal as there would be too much
>
What I am interested in is a callback.
Preferably just after methods get bound. So in `object.__new__`.
I have done it via metaclass, but it is not ideal as there would be too much
overhead.
I think what I am looking for is custom method binding.
Regards,
DG
> On 16 Nov 2023, at 20:02, Dieter
In case someone is actually going to execute the code, there is a bug:
`set` need to be wrapped in `len` for criteria args.
> On 15 Nov 2023, at 20:13, Dom Grigonis wrote:
>
>
> The specific situation was related to truth values and following out of that
> my considerations regarding equivale
So there is a method __set_name__ which is called on class creation.
The functionality that I am interested in is not retrieving name, but the fact
that it also receives `owner` argument.
Thus, allowing simulation of bound class method.
I was wandering if there is an equivalent functionality of
The specific situation was related to truth values and following out of that my
considerations regarding equivalent of all and any for counting `truths`.
So one of the specific examples:
class Publisher:
def __init__(self):
self.subscribers = dict()
def subscribe(self, sub, crit
significantly slower.
Regards,
DG
> On 15 Nov 2023, at 02:34, Peter J. Holzer via Python-list
> wrote:
>
> On 2023-11-14 00:11:30 +0200, Dom Grigonis via Python-list wrote:
>> Benchmarks:
>> test1 = [False] * 100 + [True] * 2
>> test2 = [True] * 100 + [False] * 2
>
t
>>> would have to be the first n items without a failure.
>>>
>>> Fine, but then someone may want to know WHERE you stopped or for you to
>>> return the sublist of the ones that made the match, or even return
>>> everything that was skipped so you can l
-
> From: Python-list On
> Behalf Of Grant Edwards via Python-list
> Sent: Monday, November 13, 2023 8:19 PM
> To: python-list@python.org
> Subject: Re: xor operator
>
> On 2023-11-14, Dom Grigonis via Python-list wrote:
>>
>>> Except the 'any'
thing.
DG
> On 14 Nov 2023, at 02:33, Mats Wichmann via Python-list
> wrote:
>
> On 11/13/23 16:24, Dom Grigonis via Python-list wrote:
>> I am not arguing that it is a generalised xor.
>> I don’t want anything, I am just gauging if it is specialised or if there is
>
> Except the 'any' and 'all' builtins are _exactly_ the same as bitwise
> or and and applided to many bits. To do something "in line" with that
> using the 'xor' operator would return True for an odd number of True
> values and False for an even Number of True values.
Fair point.
Have you ever
some time
to even convey what I mean. Bad naming didn’t help ofc, but if it was something
that is needed I think it would have clicked much faster.
Thanks,
DG
> On 14 Nov 2023, at 01:12, Chris Angelico via Python-list
> wrote:
>
> On Tue, 14 Nov 2023 at 10:00, Dom Grigonis via
applied to many bits.
This is more in line with cases that `any` and `all` builtins are used.
> On 14 Nov 2023, at 00:51, Grant Edwards via Python-list
> wrote:
>
> On 2023-11-13, Dom Grigonis via Python-list wrote:
>> Hi All,
>>
>> I think it could be useful to
Benchmarks:
test1 = [False] * 100 + [True] * 2
test2 = [True] * 100 + [False] * 2
TIMER.repeat([
lambda: xor(test1), # 0.0168
lambda: xor(test2), # 0.0172
lambda: xor_ss(test1), # 0.1392
lambda: xor_ss(test2), # 0.0084
lambda: xor_new(test1), # 0.0116
lambda: xor_
xor([True, False, False, False], n=1)
xor([False, False, False, True], n=1)
Both of the above would evaluate to true.
Well, it depends how you interpret it.
In binary case it reads: “exclusively one positive bit or the other, but not
both”
In this case one could read: “exclusively one positive se
.
Regards,
DG
> On 13 Nov 2023, at 19:42, Barry wrote:
>
>
>
>> On 13 Nov 2023, at 15:16, Dom Grigonis via Python-list
>> wrote:
>>
>> I think it could be useful to have `xor` builtin, which has API similar to
>> the one of `any` and `all`.
>
Hi All,
I think it could be useful to have `xor` builtin, which has API similar to the
one of `any` and `all`.
* Also, it could have optional second argument `n=1`, which indicates how many
positives indicates `True` return.
* For complete flexibility 3rd argument could indicate if `the number`
I don’t think there i a simple answer to this, although if you find something
interesting, please share.
From my experience, industry is applying variety of testing methods. Starting
from lowest level components and implementing unit tests, finishing with
end-to-end testing platforms.
https://
y = test1(*[a for a in st])
y = test1(*st)
Maybe any of these would be ok for you?
Regards,
DG
> On 25 Sep 2023, at 17:15, Jonathan Gossage via Python-list
> wrote:
>
> I am having a problem using generator expressions to supply the arguments
> for a class instance initialization. The followi
It is by design. `sorted` returns a list, while `reversed` returns an iterator.
Iterators are exhaust-able, and not reusable. So be mindful of this and if you
are going to "re-use” the sequence returned by iterator, convert it to list
first.
Have a look at `itertools` library, which contains a
The issue was more of a wrapping around numpy array. Found the solution
already. Unfortunately, there is no equivalent to __getattr__, the only way is
to dynamically define them from meta. It seems it’s pretty standard to just
have a collection of special method names and using them for similar
Tried exactly that and didn’t work. Neither __getattr__, nor __getattribute__
of meta is being invoked.
> On 26 Jul 2023, at 10:01, Chris Angelico via Python-list
> wrote:
>
> On Wed, 26 Jul 2023 at 16:52, Dom Grigonis wrote:
>>
>> Could you give an example? Something isn’t working for me.
>
Could you give an example? Something isn’t working for me.
> On 26 Jul 2023, at 09:40, Chris Angelico via Python-list
> wrote:
>
> On Wed, 26 Jul 2023 at 12:23, Dom Grigonis via Python-list
> wrote:
>> print(a + 1)# TypeError: unsupported operand type(s) fo
To illustrate what I was trying to achieve:
class A:
def __init__(self, arr):
self.arr = arr
def __getattr__(self, name):
arr_method = getattr(self.arr, name)
def wrapper(*args, **kwargs):
new_arr = arr_method(*args, **kwargs)
return type(se
> On 23 Jul 2023, at 02:12, Chris Nyland via Python-list
> wrote:
>
> So I am stuck on a problem. I have a class which I want to use to create
> another class without having to go through the boiler plate of subclassing.
> Specifically because the subclass needs to have certain class attribute
30 matches
Mail list logo