I cannot update parso because of the rule from jedi:
<0.8.0,>=0.7.0
This kind of things happens more often, but normally in less of a week
the module that prevents another to be installed is updated and the
restriction is lifted.
But I think it is about half a year that this restriction is
Grant Edwards writes:
> On 2021-10-04, Cecil Westerhof via Python-list wrote:
>> When I run:
>> pip3 list --outdated
>>
>> I get:
>> Package Version Latest Type
>> --- -- -
>> cryptography 3.4.8 35.0.0
When I run:
pip3 list --outdated
I get:
Package Version Latest Type
--- -- -
cryptography 3.4.8 35.0.0 wheel
pyzstd 0.14.4 0.15.0 wheel
The jump from 3 to 35 seems a bit excessive to me. Or is it correct?
On a side node. I have not
"Loris Bennett" writes:
> Marco Sulla writes:
>
>> On Fri, 11 Mar 2022 at 19:10, Michael Torrie wrote:
>>> Both Debian stable and Ubuntu LTS state they have a five year support
>>> life cycle.
>>
>> Yes, but it seems that official security support in Debian ends after
>> three years:
>>
>>
"Peter J. Holzer" writes:
> On 2022-03-28 15:35:07 +0200, Cecil Westerhof via Python-list wrote:
>> "Loris Bennett" writes:
>> > Ubuntu is presumably relying on the Debian security team as well as
>> > other volunteers and at least one compan
In Python when the output of a script is going to a pipe stdout is
buffered. When sending output to tee that is very inconvenient.
We can set PYTHONUNBUFFERED, but then stdout is always unbuffered.
On Linux we can do:
PYTHONUNBUFFERED=T script.py | tee script.log
Now the output is only
"Peter J. Holzer" writes:
> On 2022-03-30 08:48:36 +0200, Marco Sulla wrote:
>> On Tue, 29 Mar 2022 at 00:10, Peter J. Holzer wrote:
>> > They are are about a year apart, so they will usually contain different
>> > versions of most packages right from the start. So the Ubuntu and Debian
>> >
Betty Hollinshead writes:
> "Memoising" is the answer -- see "Python Algorithms" by Magnus Lie Hetland.
> In the mean time, here a simplified version of "memoising" using a dict.
> This version handles pretty large fibonacci numbers!
>
> # fibonacci sequence
> # memoised - but using a simple
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
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
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
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
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?
>
>
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,
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
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
I am creating a class that will call a user defined function on user
defined intervals. In my opinion it is an error when the function
takes more as 10% of interval, or more as half a second. What is
better: just using RuntimeError, or creating two exception classes for
this?
--
Cecil Westerhof
Chris Angelico writes:
> On Sat, 5 Feb 2022 at 04:33, Cecil Westerhof via Python-list
> wrote:
>>
>> Ethan Furman writes:
>>
>> > On 2/4/22 6:28 AM, Cecil Westerhof via Python-list wrote:
>> >
>> >> It was already not a good name, but I am
Barry writes:
>> On 3 Feb 2022, at 04:45, Cecil Westerhof via Python-list
>> wrote:
>>
>> Have to be careful that timing keeps correct when target takes a 'lot'
>> of time.
>> Something to ponder about, but can wait.
>
> You have noticed that your
Cecil Westerhof writes:
It was already not a good name, but I am rewriting the class
completely, so now the name is a complete bumper. (No more timer.) I
am thinking about naming the class repeating_thread, but I cannot say
that I find it a very good name. So if someone has a good idea for a
Igor Berger writes:
> On Friday, February 4, 2022 at 12:28:53 PM UTC-5, Cecil Westerhof wrote:
>> Ethan Furman writes:
>>
>> > On 2/4/22 6:28 AM, Cecil Westerhof via Python-list wrote:
>> >
>> >> It was already not a good name, but I am rewriting
Ethan Furman writes:
> On 2/4/22 6:28 AM, Cecil Westerhof via Python-list wrote:
>
>> It was already not a good name, but I am rewriting the class
>> completely, so now the name is a complete bumper. (No more timer.) I
>> am thinking about naming the class repeating_
Chris Angelico writes:
>> > How difficult would it be to get people to read those lines, though?
>>
>> That does remind me about a system administrator who wanted to make a
>> point. He changed something on the server so all the Windows computers
>> started up and gave a message:
>> If
Chris Angelico writes:
> On Tue, 8 Feb 2022 at 06:51, Cecil Westerhof via Python-list
> wrote:
>>
>> Chris Angelico writes:
>>
>> >> > How difficult would it be to get people to read those lines, though?
>> >>
>> >> That
Chris Angelico writes:
> On Tue, 8 Feb 2022 at 02:53, Grant Edwards wrote:
>>
>> On 2022-02-06, Dennis Lee Bieber wrote:
>> > On Sun, 6 Feb 2022 13:44:07 +0530, "createkmontalb...@gmail.com"
>> > declaimed the following:
>> >
>> >> I cannot open python after downloading it keeps going to
>>
Cecil Westerhof writes:
> To show why it is often easy, but wrong to use recursive functions I
> wrote the following two Fibonacci functions:
> def fib_ite(n):
> if not type(n) is int:
> raise TypeError(f'Need an integer ({n})')
> if n < 0:
> raise
In C when you declare a variable static in a function, the variable
retains its value between function calls.
The first time the function is called it has the default value (0 for
an int).
But when the function changes the value in a call (for example to 43),
the next time the function is called
Thanks for the multiple answers. I was pleasantly surprised.
I have something to think about. :-D
In principle I selected a solution for the problem for which I asked
it, but I first have to finish some other stuff. I hope to find time
to implement it next week.
Everyone a good weekend and
Chris Angelico writes:
> On Wed, 27 Jul 2022 at 01:06, Cecil Westerhof via Python-list
> wrote:
>>
>> I need to get a random integer. At first I tried it with:
>> from secrets import randbelow
>> index = randbelow(len(to_try))
>>
>> This wo
Chris Angelico writes:
> On Wed, 27 Jul 2022 at 06:06, Cecil Westerhof via Python-list
> wrote:
>>
>> Chris Angelico writes:
>>
>> > On Wed, 27 Jul 2022 at 01:06, Cecil Westerhof via Python-list
>> > wrote:
>> >>
>> >> I need
It is not very important, but I am just curious.
Original I had in a program:
values = [*range(100)]
But because it is done quite often I expected that initialising:
range_list = [*range(100)]
and then use:
values = range_list.copy()
Would be more efficient. So I tried:
2qdxy4rzwzuui...@potatochowder.com writes:
> On 2022-07-27 at 17:48:47 +0200,
> Regarding "Re: More efficient code, but slower program,"
> Cecil Westerhof via Python-list wrote:
>
>> r...@zedat.fu-berlin.de (Stefan Ram) writes:
>>
>> > Cecil W
MRAB writes:
> On 27/07/2022 16:43, Cecil Westerhof via Python-list wrote:
>> "Michael F. Stemper" writes:
>>
>>> This is orthogonal to your question, but might be of some use to you:
>>>
>>> The combination of using len(to_try) a
Roel Schroeven writes:
> Cecil Westerhof via Python-list schreef op 27/07/2022 om 17:43:
>> "Michael F. Stemper" writes:
>>
>> > This is orthogonal to your question, but might be of some use to you:
>> >
>> > The combination of using len
Chris Angelico writes:
> Incidentally - if you are actually trying to select a specific item,
> you may want to consider random.choice.
Yes, I try to select a random element, but it has also to be removed.
An element should be used at most once. This is the code I use:
# index =
Alan Bawden writes:
> Cecil Westerhof writes:
>
>Yes, I try to select a random element, but it has also to be removed,
>because an element should not be used more as once.
>
> Instead of using pop to do that why not something like:
>
> def lazy_shuffle(seq):
> """
>
r...@zedat.fu-berlin.de (Stefan Ram) writes:
> Cecil Westerhof writes:
>>values = [*range(100)]
>
> In many cases, any iterable is just fine and a list is not
> required, just as peudo-random numbers often are just fine and
> real-world entropy is not required.
In this case both are. I
Chris Angelico writes:
> On Wed, 27 Jul 2022 at 08:18, Cecil Westerhof via Python-list
> wrote:
>>
>> Chris Angelico writes:
>>
>> > On Wed, 27 Jul 2022 at 06:06, Cecil Westerhof via Python-list
>> > wrote:
>> >>
>> >> Chris A
Dennis Lee Bieber writes:
> On Tue, 26 Jul 2022 23:47:59 +0200, Cecil Westerhof
> declaimed the following:
>
>
>>The new code:
>>from random import SystemRandom
>>system_random = SystemRandom()
>>index = system_random.randint(0, len(to_try) - 1)
>>
>>The first two statements are
Dennis Lee Bieber writes:
> On Wed, 27 Jul 2022 10:45:47 +0200, Cecil Westerhof
> declaimed the following:
>
>
>>What do you mean with where the python version is from?
>
> Base Python.org download, ActiveState package download, Anaconda
> package download, native OS install/extra install
MRAB writes:
>>> When you pop an element from the last, the elements after it need to be
>>> moved down, which takes time.
>>>
>>> Try shuffling the list and then popping the now randomly-ordered
>>> elements off the end.
>> Would shuffling not be a lot more expensive? Especially because I do
>>
Barry writes:
>> On 26 Jul 2022, at 16:07, Cecil Westerhof via Python-list
>> wrote:
>>
>> I need to get a random integer. At first I tried it with:
>>from secrets import randbelow
>>index = randbelow(len(to_try))
>>
>> This works perf
"Michael F. Stemper" writes:
> This is orthogonal to your question, but might be of some use to you:
>
> The combination of using len(to_try) as an argument to randint() and
> saving the output to a variable named "index" suggests that you might
> be setting up to select a random element from
I need to get a random integer. At first I tried it with:
from secrets import randbelow
index = randbelow(len(to_try))
This works perfectly, but it took some time. So I thought I try:
from random import SystemRandom
index = SystemRandom().randint(0, len(to_try) - 1)
A first
If I want to know the dependencies for requests I use:
pip show requests
And one of the lines I get is:
Requires: certifi, charset-normalizer, idna, urllib3
But I want (in this case) to know with version of charset-normalizer
requests needs.
How do I get that?
--
Cecil Westerhof
Senior
DFS writes:
> On 12/14/2022 3:55 AM, Cecil Westerhof wrote:
>> If I want to know the dependencies for requests I use:
>> pip show requests
>> And one of the lines I get is:
>> Requires: certifi, charset-normalizer, idna, urllib3
>> But I want (in this case) to know with version of
r...@zedat.fu-berlin.de (Stefan Ram) writes:
>>"No multiple returns" is often found in programming guidelines.
>
> I religiously followed that when I did more C programming
> than today. Then, I read an article about how the result
> pattern makes functions measurably slower. (It should not
47 matches
Mail list logo