Re: Fallback for operator and other dunder methods

2023-08-04 Thread Edmondo Giovannozzi via Python-list
Il giorno mercoledì 26 luglio 2023 alle 20:35:53 UTC+2 Dom Grigonis ha scritto: > 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

Re: Debugging reason for python running unreasonably slow when adding numbers

2023-03-21 Thread Edmondo Giovannozzi
Il giorno lunedì 20 marzo 2023 alle 19:10:26 UTC+1 Thomas Passin ha scritto: > On 3/20/2023 11:21 AM, Edmondo Giovannozzi wrote: > > > >>> def sum1(): > >>> s = 0 > >>> for i in range(100): > >>> s += i > >>> return s

Re: Debugging reason for python running unreasonably slow when adding numbers

2023-03-20 Thread Edmondo Giovannozzi
> > def sum1(): > > s = 0 > > for i in range(100): > > s += i > > return s > > > > def sum2(): > > return sum(range(100)) > Here you already have the numbers you want to add. Actually using numpy you'll be much faster in this case: § import numpy as np §

Re: Line continuation and comments

2023-02-22 Thread Edmondo Giovannozzi
Il giorno mercoledì 22 febbraio 2023 alle 09:50:14 UTC+1 Robert Latest ha scritto: > I found myself building a complicated logical condition with many ands and > ors > which I made more manageable by putting the various terms on individual lines > and breaking them with the "\" line

Re: Fast lookup of bulky "table"

2023-01-17 Thread Edmondo Giovannozzi
Il giorno martedì 17 gennaio 2023 alle 00:18:04 UTC+1 Dino ha scritto: > On 1/16/2023 1:18 PM, Edmondo Giovannozzi wrote: > > > > As a comparison with numpy. Given the following lines: > > > > import numpy as np > > a = np.random.randn(400,100_000) > &

Re: Fast lookup of bulky "table"

2023-01-16 Thread Edmondo Giovannozzi
Il giorno domenica 15 gennaio 2023 alle 05:26:50 UTC+1 Dino ha scritto: > Hello, I have built a PoC service in Python Flask for my work, and - now > that the point is made - I need to make it a little more performant (to > be honest, chances are that someone else will pick up from where I left

Re: Fwd: Installation hell

2022-12-20 Thread Edmondo Giovannozzi
Personally I use winpython: https://winpython.github.io/ That have all the scientific packages already available. It can run without being installed and uses spyder as an IDE (for small projects it's ok). And, I can import pygame (even though I have not tested if everything works) in python

Re: Byte arrays and DLLs

2022-07-02 Thread Edmondo Giovannozzi
Il giorno venerdì 1 luglio 2022 alle 00:46:13 UTC+2 ery...@gmail.com ha scritto: > On 6/30/22, Rob Cliffe via Python-list wrote: > > > > AKAIK it is not possible to give ctypes a bytearray object and persuade > > it to give you a pointer to the actual array data, suitable for passing > > to a

Re: C is it always faster than nump?

2022-02-28 Thread Edmondo Giovannozzi
Il giorno sabato 26 febbraio 2022 alle 19:41:37 UTC+1 Dennis Lee Bieber ha scritto: > On Fri, 25 Feb 2022 21:44:14 -0800, Dan Stromberg > declaimed the following: > >Fortran, (still last I heard) did not support pointers, which gives Fortran > >compilers the chance to exploit a very nice class

Re: Extracting dataframe column with multiple conditions on row values

2022-01-09 Thread Edmondo Giovannozzi
dft.values == key1 ]second = first[first.values == key2 > ]print(second[2]) > I get a 6 as an answer and suppose it could be done in one more complex > expression if needed! LOL! > -Original Message- > From: Edmondo Giovannozzi > To: pytho...@python.org > Sent: Sat, Jan 8, 2022

Re: Extracting dataframe column with multiple conditions on row values

2022-01-08 Thread Edmondo Giovannozzi
Il giorno sabato 8 gennaio 2022 alle 02:21:40 UTC+1 dn ha scritto: > Salaam Mahmood, > On 08/01/2022 12.07, Mahmood Naderan via Python-list wrote: > > I have a csv file like this > > V0,V1,V2,V3 > > 4,1,1,1 > > 6,4,5,2 > > 2,3,6,7 > > > > And I want to search two rows for a match and find

Re: Negative subscripts

2021-11-26 Thread Edmondo Giovannozzi
Il giorno venerdì 26 novembre 2021 alle 10:23:46 UTC+1 Frank Millman ha scritto: > Hi all > > In my program I have a for-loop like this - > > >>> for item in x[:-y]: > ...[do stuff] > > 'y' may or may not be 0. If it is 0 I want to process the entire list > 'x', but of course -0 equals

Re: pyinstaller wrong classified as Windows virus

2021-11-26 Thread Edmondo Giovannozzi
Il giorno venerdì 26 novembre 2021 alle 08:13:50 UTC+1 Ulli Horlacher ha scritto: > Avi Gross wrote: > > > I am not sure what your real problem is, Ulli, but many antivirus programs > > can be TEMPORARILY shut off. > Meanwhile I found this configuration option. > But this does not help me

Re: How to pass a method as argument?

2021-09-30 Thread Edmondo Giovannozzi
Il giorno giovedì 30 settembre 2021 alle 07:11:28 UTC+2 anila...@gmail.com ha scritto: > I want to write a python calculator program that has different methods to > add, subtract, multiply which takes 2 parameters. I need to have an execute > method when passed with 3 parameters, should call

Re: Data structure for plotting monotonically expanding data set

2021-05-27 Thread Edmondo Giovannozzi
Il giorno giovedì 27 maggio 2021 alle 11:28:31 UTC+2 Loris Bennett ha scritto: > Hi, > > I currently a have around 3 years' worth of files like > > home.20210527 > home.20210526 > home.20210525 > ... > > so around 1000 files, each of which contains information about data > usage in lines

Re: GUI (tkinter) popularity and job prospects for

2020-10-26 Thread Edmondo Giovannozzi
Il giorno venerdì 23 ottobre 2020 alle 18:55:53 UTC+2 john... ha scritto: > On 23/10/2020 05:47, Grant Edwards wrote: > > > >> I think that commercial desktop applications with a python > >> compatible GUI would likely use QT or a Python binding thereof. > > Agreed. If you want to improve you

Re: newbie

2020-09-10 Thread edmondo . giovannozzi
You can also have a look at www.scipy.org where you can find some packages used for scientific programming like numpy, scipy, matplotlib. The last one is a graphic package that may be useful to make some initial plots. Il giorno martedì 8 settembre 2020 22:57:36 UTC+2, Don Edwards ha scritto: >

Re: Can't download Pygame and Pgzero

2020-06-06 Thread edmondo . giovannozzi
Il giorno venerdì 5 giugno 2020 18:35:10 UTC+2, Lily Sararat ha scritto: > To whom it may concern, > I have trouble installing the Pygame and Pgzero on Window.  I based on the > instruction on the "Computer Coding Python Games for Kids" by Carol > Vorderman.  Nothing works.   > I tried Python

Re: Strange use of Lambda arrow

2020-06-06 Thread edmondo . giovannozzi
Have a look at: https://docs.python.org/3/library/typing.html Il giorno venerdì 5 giugno 2020 18:35:10 UTC+2, Agnese Camellini ha scritto: > Hello to everyone, lately i building up an open source project, with some > collaborator, but one of them cannot contribute any more. He is a solution >

Re: python and numpy

2020-04-22 Thread edmondo . giovannozzi
Il giorno martedì 21 aprile 2020 21:04:17 UTC+2, Derek Vladescu ha scritto: > I’ve just begun a serious study of using Python as an aspiring > programmer/data scientist. > Can someone please walk me through how to download Python, SO THAT I will be > able to import numpy? > > Thanks, > Derek >

Re: numpy array question

2020-04-02 Thread edmondo . giovannozzi
Il giorno giovedì 2 aprile 2020 06:30:22 UTC+2, jagmit sandhu ha scritto: > python newbie. I can't understand the following about numpy arrays: > > x = np.array([[0, 1],[2,3],[4,5],[6,7]]) > x > array([[0, 1], >[2, 3], >[4, 5], >[6, 7]]) > x.shape > (4, 2) > y = x[:,0] > y

Re: Difference between array( [1,0,1] ) and array( [ [1,0,1] ] )

2019-06-21 Thread edmondo . giovannozzi
Keep also in mind that numpy is quite different from Matlab. In Matlab every vaiable is a matrix of at least 2 dimensions. This is not the case of numpy (and is not the case in Fortran too). every array can have a different number of dimensions. The transposition of an array with just 1

Re: Difference between array( [1,0,1] ) and array( [ [1,0,1] ] )

2019-06-21 Thread edmondo . giovannozzi
Every array in numpy has a number of dimensions, "np.array" is a function that can create an array numpy given a list. when you write vector_1 = np.array([1,2,1]) you are passing a list of number to thet function array that will create a 1D array. As you are showing: vector_1.shape will

Re: Levenberg-Marquardt non-linear least-squares fitting in Python [follow-on]

2019-03-29 Thread edmondo . giovannozzi
> ltemp = [ydata[i] - ydata[0] for i in range(ll)] > ytemp = [ltemp[i] * .001 for i in range(ll)] > ltemp = [xdata[i] - xdata[0] for i in range(ll)] > xtemp = [ltemp[i] * .001 for i in range(ll)] Use the vectorization given by numpy: ytemp = (ydata - ydata[0]) * 0.001

Re: moving to Python from Java/C++/C

2018-06-26 Thread edmondo giovannozzi
To: itaiyz97 From: edmondo.giovanno...@gmail.com Il giorno luned─¼ 25 giugno 2018 12:40:53 UTC+2, itai...@gmail.com ha scritto: > Hey, > I already have quite an experience in programming, and I wish to study Python as well. I need to study it before I continue with my comp. science academic

Re: moving to Python from Java/C++/C

2018-06-25 Thread edmondo . giovannozzi
Il giorno lunedì 25 giugno 2018 12:40:53 UTC+2, itai...@gmail.com ha scritto: > Hey, > I already have quite an experience in programming, and I wish to study Python > as well. I need to study it before I continue with my comp. science academic > studies. > How do you recommend studying it? As

Re: Python Learning

2017-12-16 Thread edmondo . giovannozzi
Il giorno venerdì 15 dicembre 2017 12:50:08 UTC+1, Varun R ha scritto: > Hi All, > > I'm new to programming, can anyone guide me, how to start learning python > programming language,...plz suggest some books also. > > Thanks all Personally I learnt python from the tutorial that you can find

Re: Python homework

2017-12-14 Thread edmondo . giovannozzi
Il giorno martedì 12 dicembre 2017 00:30:24 UTC+1, jlad...@itu.edu ha scritto: > On Thursday, December 7, 2017 at 4:49:52 AM UTC-8, edmondo.g...@gmail.com > wrote: > > > import numpy > > I teach Python to students at varying levels. As much as I love and use > Numpy in my regular work, I

Re: Python homework

2017-12-07 Thread edmondo . giovannozzi
Il giorno mercoledì 6 dicembre 2017 02:33:52 UTC+1, nick martinez ha scritto: > I have a question on my homework. My homework is to write a program in which > the computer simulates the rolling of a die 50 > times and then prints > (i). the most frequent side of the die > (ii). the average die

Re: What use is of this 'cast=float ,'?

2017-10-27 Thread edmondo . giovannozzi
Il giorno venerdì 27 ottobre 2017 22:35:45 UTC+2, Robert ha scritto: > Hi, > > I read below code snippet on line. I am interested in the second of the last > line. > > cast=float , > > > I've tried it in Python. Even simply with > > float > > > it has no error, but what use is it? >

Re: Python for Dummies exaple

2015-10-14 Thread edmondo . giovannozzi
Il giorno mercoledì 14 ottobre 2015 12:04:30 UTC+2, Chris Angelico ha scritto: > On Wed, Oct 14, 2015 at 8:55 PM, NewsLeecher User wrote: > > But with this script i get an error: > > But i have not so many experience to see what the error is. > > Good someone help me with this ? > > You need to

Re: Strong typing implementation for Python

2015-10-12 Thread edmondo . giovannozzi
Il giorno lunedì 12 ottobre 2015 10:51:50 UTC+2, John Michael Lafayette ha scritto: > Now that Python has static type checking and support for IDE auto-complete > (PEP 484?), I beg you to please use it. In your standard library, in your > production code, in everywhere. I cannot type without

Re: Fast 12 bit to 16 bit sample conversion?

2015-07-20 Thread edmondo . giovannozzi
Il giorno lunedì 20 luglio 2015 15:10:22 UTC+2, Peter Heitzer ha scritto: I am currently writing a python script to extract samples from old Roland 12 bit sample disks and save them as 16 bit wav files. The samples are layouted as follows 0 [S0 bit 11..4] [S0 bit 3..0|S1 bit 3..0] [S1

Re: Python and fortran Interface suggestion

2015-04-22 Thread edmondo . giovannozzi
Il giorno domenica 19 aprile 2015 22:26:58 UTC+2, Dave Angel ha scritto: On 04/19/2015 11:56 AM, pauld11718 wrote: I shall provide with further details Its about Mathematical modelling of a system. Fortran does one part and python does the other part (which I am suppose to provide).

Re: New to Python - block grouping (spaces)

2015-04-20 Thread edmondo . giovannozzi
I work in research and mainly use Fortran and Python. I haven't had any problem with the python indentation. I like it, I find it simple and easy. Well, sometimes I may forget to close an IF block with an ENDIF, in Fortran, so used I am on ending a block just decreasing the indentation, not a