Chris Angelico writes:
> On Thu, 3 Feb 2022 at 15:43, Cecil Westerhof via Python-list
> wrote:
>>
>> Chris Angelico writes:
>>
>> >> > (Side point: The OP's code is quite inefficient, as it creates a new
>> >> > thread for each reiteration, but there's nothing wrong with that if
>> >> > you're
Cecil Westerhof writes:
> I need (sometimes) to repeatedly execute a function. For this I wrote
> the below class. What do you think about it?
I wrote some unit test for the class. Is this the correct way to do
this?
For example in test_correct_params_no_start I check four things. Some
people sa
2qdxy4rzwzuui...@potatochowder.com writes:
> FWIW, I'd find some way to tell users the units (seconds, milliseconds,
> fortnights, etc.) instead of making them wade through your code to find
> the call to (and possibly the [broken] help text of) Timer.
You mean with docstring?
--
Cecil Westerho
On Thu, 3 Feb 2022 at 15:43, Cecil Westerhof via Python-list
wrote:
>
> Chris Angelico writes:
>
> >> > (Side point: The OP's code is quite inefficient, as it creates a new
> >> > thread for each reiteration, but there's nothing wrong with that if
> >> > you're looking for something simple.)
> >>
Chris Angelico writes:
>> > (Side point: The OP's code is quite inefficient, as it creates a new
>> > thread for each reiteration, but there's nothing wrong with that if
>> > you're looking for something simple.)
>>
>> It is just something I wrote fast. How could I do this in a better way?
>
> I'
On Thu, 3 Feb 2022 at 15:28, <2qdxy4rzwzuui...@potatochowder.com> wrote:
>
> On 2022-02-03 at 15:07:22 +1100,
> Chris Angelico wrote:
>
> > On Thu, 3 Feb 2022 at 14:52, <2qdxy4rzwzuui...@potatochowder.com> wrote:
> > >
> > > On 2022-02-03 at 12:39:43 +1100,
> > > Cameron Simpson wrote:
> > >
> >
On 2022-02-03 at 15:07:22 +1100,
Chris Angelico wrote:
> On Thu, 3 Feb 2022 at 14:52, <2qdxy4rzwzuui...@potatochowder.com> wrote:
> >
> > On 2022-02-03 at 12:39:43 +1100,
> > Cameron Simpson wrote:
> >
> > > You have:
> > >
> > > def _check_interval(self, interval):
> > > if not type
On Thu, 3 Feb 2022 at 14:52, <2qdxy4rzwzuui...@potatochowder.com> wrote:
>
> On 2022-02-03 at 12:39:43 +1100,
> Cameron Simpson wrote:
>
> > You have:
> >
> > def _check_interval(self, interval):
> > if not type(interval) in [int, float]:
> > raise TypeError('{} is not nume
On 2022-02-03 at 12:39:43 +1100,
Cameron Simpson wrote:
> You have:
>
> def _check_interval(self, interval):
> if not type(interval) in [int, float]:
> raise TypeError('{} is not numeric'.format(interval))
>
> This check is better written:
>
> if not isinstance(inte
Cameron Simpson writes:
> You have:
>
> def _check_interval(self, interval):
> if not type(interval) in [int, float]:
> raise TypeError('{} is not numeric'.format(interval))
>
> This check is better written:
>
> if not isinstance(interval, (int,float)):
>
> which handl
On Thu, 3 Feb 2022 at 13:32, Avi Gross via Python-list
wrote:
>
> Jen,
>
> I would not be shocked at incompatibilities in the system described making it
> hard to exchange anything, including text, but am not clear if there is a
> limitation of four bytes in what can be shared. For me, a charact
Jen,
I would not be shocked at incompatibilities in the system described making it
hard to exchange anything, including text, but am not clear if there is a
limitation of four bytes in what can be shared. For me, a character string can
use any number of contiguous bytes in memory that some kind
On Thu, 3 Feb 2022 at 12:24, Cecil Westerhof via Python-list
wrote:
>
> Chris Angelico writes:
>
> > On Thu, 3 Feb 2022 at 09:33, Barry wrote:
> > (Side point: The OP's code is quite inefficient, as it creates a new
> > thread for each reiteration, but there's nothing wrong with that if
> > you'
You have:
def _check_interval(self, interval):
if not type(interval) in [int, float]:
raise TypeError('{} is not numeric'.format(interval))
This check is better written:
if not isinstance(interval, (int,float)):
which handles subclasses of these types (but note that
Cecil Westerhof writes:
>> (regardless of your OS). The same could be done with this timer; an
>> __exit__ method would make a lot of sense here, and would allow the
>> timer to be used in a with block to govern its execution. (It also
>> isn't really necessary, but if you want a good Pythonic wa
Chris Angelico writes:
> On Thu, 3 Feb 2022 at 09:33, Barry wrote:
> (Side point: The OP's code is quite inefficient, as it creates a new
> thread for each reiteration, but there's nothing wrong with that if
> you're looking for something simple.)
It is just something I wrote fast. How could I
On Thu, 3 Feb 2022 at 09:33, Barry wrote:
>
>
>
> > On 2 Feb 2022, at 21:12, Marco Sulla wrote:
> >
> > You could add a __del__ that calls stop :)
>
> Didn’t python3 make this non deterministic when del is called?
>
> I thought the recommendation is to not rely on __del__ in python3 code.
>
The
> On 2 Feb 2022, at 21:12, Marco Sulla wrote:
>
> You could add a __del__ that calls stop :)
Didn’t python3 make this non deterministic when del is called?
I thought the recommendation is to not rely on __del__ in python3 code.
Barry
>
>> On Wed, 2 Feb 2022 at 21:23, Cecil Westerhof via Py
> On 2 Feb 2022, at 18:19, Jen Kris via Python-list
> wrote:
>
> It's not clear to me from the struct module whether it can actually
> auto-detect endianness.
It is impossible to auto detect endian in the general case.
> I think it must be specified, just as I had to do with int.from_byte
You could add a __del__ that calls stop :)
On Wed, 2 Feb 2022 at 21:23, Cecil Westerhof via Python-list
wrote:
>
> I need (sometimes) to repeatedly execute a function. For this I wrote
> the below class. What do you think about it?
> from threading import Timer
>
>
>
> class repeated_tim
I need (sometimes) to repeatedly execute a function. For this I wrote
the below class. What do you think about it?
from threading import Timer
class repeated_timer(object):
def __init__(self, fn, interval, start = False):
if not callable(fn):
raise Ty
On Wed, 2 Feb 2022 19:16:19 +0100 (CET), Jen Kris
declaimed the following:
>It's not clear to me from the struct module whether it can actually
>auto-detect endianness. I think it must be specified, just as I had to do
>with int.from_bytes(). In my case endianness was dictated by how the four
An ASCII string will not work. If you convert 32894 to an ascii string you
will have five bytes, but you need four. In my original post I showed the C
program I used to convert any 32-bit number to 4 bytes.
Feb 2, 2022, 10:16 by python-list@python.org:
> I applaud trying to find the right
It's not clear to me from the struct module whether it can actually auto-detect
endianness. I think it must be specified, just as I had to do with
int.from_bytes(). In my case endianness was dictated by how the four bytes
were populated, starting with the zero bytes on the left.
Feb 1, 202
I applaud trying to find the right solution but wonder if a more trivial
solution is even being considered. It ignores big and little endians and just
converts your data into another form and back.
If all you want to do is send an integer that fit in 32 bits or 64 bits, why
not convert it to a
Michael Welle wrote at 2022-2-1 19:28 +0100:
> ...
>That doesn't happen when the 'real' issue occurs. Attaching strace to
>the Python process I can see that resolv.conf is stat'ed and open'ed. I
>guess now I'm more confused than before ;). There must be an additional
>condition that I'm missing.
T
On Wed, 2 Feb 2022 at 14:34, Lars Liedtke wrote:
>
> This is a quite philosophical queston if you look at it in general:
> "What value do you give a variable, that is not set?"
Maybe I expressed my question badly. My existential doubt is why
setdefault has an optional parameter for the value and
On Wed, 2 Feb 2022 00:40:22 +0100 (CET), Jen Kris
declaimed the following:
>
> breakup = int.from_bytes(byte_val, "big")
>print("this is breakup " + str(breakup))
>
>Python prints: this is breakup 32894
>
>Note that I had to switch from little endian to big endian. Python is little
>endian by
This is a quite philosophical queston if you look at it in general:
"What value do you give a variable, that is not set?"
You are right, at first it seems strange to have a default of None. But
how do you want to signal that no default is set yet? Especially if you
think of a dict that can have
Just out of curiosity: why dict.setdefault() has the default parameter
that well, has a default value (None)? I used setdefault in the past,
but I always specified a value. What's the use case of setting None by
default?
--
https://mail.python.org/mailman/listinfo/python-list
> On 1 Feb 2022, at 23:40, Jen Kris wrote:
>
> Barry, thanks for your reply.
>
> On the theory that it is not yet possible to pass data from a non-Python
> language to Python with multiprocessing.shared_memory, I bypassed the problem
> by attaching 4 bytes to my FIFO pipe message from NASM
31 matches
Mail list logo