The following code won’t be allowed in Java, but in python, it works fine:
```python
class A:
A = 3
def __init__(self):
print(self.A)
def p(self):
print(self.A)
self.A += 1
class B(A):
def __init__(self):
print(2)
self.p()
super().
On 15/03/23 10:57 pm, scruel tao wrote:
How can I understand this? Will it be a problem?
I can't remember any details offhand, but I know I've occasionally
made use of the ability to do this. It's fine as long as the method
you're calling doesn't rely on anything you haven't initialised yet.
-
"Loris Bennett" writes:
> I am aware that an individual user could use (mini)conda to install a
> more recent version of Python in his/her home directory, but I am
> interested in how root would install such a program.
Root would install the script and required Python version somewhere
depending
On Tue, 2023-03-14 at 16:22 -0400, aapost wrote:
> On 3/14/23 06:54, John O'Hagan wrote:
[...]
> >
> > Here is minimal code that demonstrates the problem in the subject
> > line:
> >
> > import cv2
> > from tkinter import *
> >
> > images=['a.jpg', 'b.jpg', 'c.jpg'] #change to image paths
> >
Op 15/03/2023 om 10:57 schreef scruel tao:
The following code won’t be allowed in Java, but in python, it works fine:
```python
class A:
A = 3
def __init__(self):
print(self.A)
def p(self):
print(self.A)
self.A += 1
class B(A):
def __init__(self)
> Or use the sum() builtin rather than reduce(), which was
> *deliberately* removed from the builtins. The fact that you can get
> sum() without importing, but have to go and reach for functools to get
> reduce(), is a hint that you probably shouldn't use reduce when sum
> will work.
Out of curios
On Thu, 16 Mar 2023 at 01:26, David Raymond wrote:
> I'm not quite sure why the built-in sum functions are slower than the for
> loop,
> or why they're slower with the generator expression than with the list
> comprehension.
For small-to-medium data sizes, genexps are slower than list comps,
bu
On 3/15/2023 10:24 AM, David Raymond wrote:
Or use the sum() builtin rather than reduce(), which was
*deliberately* removed from the builtins. The fact that you can get
sum() without importing, but have to go and reach for functools to get
reduce(), is a hint that you probably shouldn't use reduc
On 3/15/2023 11:01 AM, Chris Angelico wrote:
On Thu, 16 Mar 2023 at 01:26, David Raymond wrote:
I'm not quite sure why the built-in sum functions are slower than the for loop,
or why they're slower with the generator expression than with the list
comprehension.
For small-to-medium data sizes
On Thu, 16 Mar 2023 at 02:14, Thomas Passin wrote:
>
> On 3/15/2023 11:01 AM, Chris Angelico wrote:
> > On Thu, 16 Mar 2023 at 01:26, David Raymond
> > wrote:
> >> I'm not quite sure why the built-in sum functions are slower than the for
> >> loop,
> >> or why they're slower with the generator
I don't remember making such a mistake ever before, but it might have
happened. -= is a convenient operator so I've probably used it a lot.
Anyway, I found that flake8 flagged this as
E225 missing whitespace around operator
and it's the only linter of pylint, flake8 and pyflake that detects this
> Then I'm very confused as to how things are being done, so I will shut
> up. There's not enough information here to give performance advice
> without actually being a subject-matter expert already.
Short version: In this specific case "weights" is a 5,147 element list of
floats, and "input" is
"Weatherby,Gerard" writes:
> It’s really going to depend on the distribution and whether you have root
> access.
I am interested in providing a package for people with root access for a
variety of distributions.
> If you have Ubuntu and root access, you can add the deadsnakes repo,
> https://l
Anssi Saari writes:
> "Loris Bennett" writes:
>
>> I am aware that an individual user could use (mini)conda to install a
>> more recent version of Python in his/her home directory, but I am
>> interested in how root would install such a program.
>
> Root would install the script and required Pyt
Hi,
I have written a program which, as part of the non-core functionality,
contains a module to generate email. This is currently very specific
to my organisation, so the main program contains
import myorg.mailer
This module is specific to my organisation in that it can ask an
internal serv
Sum is faster than iteration in the general case.
Lifting a test program from Stack Overflow
https://stackoverflow.com/questions/24578896/python-built-in-sum-function-vs-for-loop-performance,
import timeit
def sum1():
s = 0
for i in range(100):
s += i
return s
def sum2(
Moving the generator out:
import timeit
thedata = [i for i in range(1_000_000)]
def sum1():
s = 0
for i in thedata:
s += i
return s
def sum2():
return sum(thedata)
print('For Loop Sum:', timeit.timeit(sum1, number=100))
print( 'Built-in Sum:', timeit.timeit(sum2, number=
Yes, that works, and I’ve used that on a couple of projects.
Another alternative is defining an Abstract Base Class,
https://docs.python.org/3/library/abc.html, and having an institution-specific
implementation passed into your module.
From: Python-list on
behalf of Loris Bennett
Date: Wedne
On 16/03/2023 01.47, Loris Bennett wrote:
I have written a program which, as part of the non-core functionality,
contains a module to generate email. This is currently very specific
to my organisation, so the main program contains
import myorg.mailer
This module is specific to my organisati
On 3/15/23 07:37, John O'Hagan wrote:
On Tue, 2023-03-14 at 16:22 -0400, aapost wrote:
On 3/14/23 06:54, John O'Hagan wrote:
It works up to a point - I can cycle through the images by clicking
the
button - but if I mouse-click on the displayed image (e.g. to use
the
zooming and panning features
On 3/15/2023 2:45 PM, dn via Python-list wrote:
On 16/03/2023 01.47, Loris Bennett wrote:
I have written a program which, as part of the non-core functionality,
contains a module to generate email. This is currently very specific
to my organisation, so the main program contains
import myorg
I do something similar to Thomas. (Also MIT licensed). I like objects. I like
type hints.
Each plugin needs to have check and purpose functions and accepts either
PluginSpec (by default) or AddonSpec if it defines addon = True
This requires a single-level plugin directory with no extra files in
On 3/15/2023 6:06 PM, Weatherby,Gerard wrote:
I do something similar to Thomas. (Also MIT licensed). I like objects. I like
type hints.
Each plugin needs to have check and purpose functions and accepts either
PluginSpec (by default) or AddonSpec if it defines addon = True
I omitted the check
On Monday, March 13, 2023 at 11:32:23 PM UTC-7, Clint Olsen wrote:
> We have an application that involves submitting hundreds to thousands of jobs
> to a shared computing resource, and we're using asyncio to do so because it
> is far less overhead than threading or multiprocessing for the bookkee
On 3/15/23 07:37, John O'Hagan wrote:
On Tue, 2023-03-14 at 16:22 -0400, aapost wrote:
On 3/14/23 06:54, John O'Hagan wrote:
Doing a quick read, tkinter is not threadsafe, so diving in to a
threading solution is probably not the best approach.
But just to throw out another possible soluti
25 matches
Mail list logo