Re: Best way to check if there is internet?

2022-02-25 Thread Chris Angelico
On Sat, 26 Feb 2022 at 09:04, Barry Scott wrote: > > > > > On 25 Feb 2022, at 18:07, Abdur-Rahmaan Janhangeer > > wrote: > > > > Normally people put Python in the scripting category. > > I learnt typed languages like C++ and Java at first. > > People who learn languages like these tend to put >

Re: Best way to check if there is internet?

2022-02-25 Thread Chris Angelico
On Sat, 26 Feb 2022 at 07:32, <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 2022-02-25 at 13:48:32 -0600, > "Michael F. Stemper" wrote: > > > On 25/02/2022 12.07, Abdur-Rahmaan Janhangeer wrote: > > > > I have been following language feature proposals from various > > > languages. Some decide

Re: C is it always faster than nump?

2022-02-25 Thread Chris Angelico
On Sat, 26 Feb 2022 at 06:44, Avi Gross via Python-list wrote: > > I agree with Richard. > > Some people may be confused and think c is the speed of light and > relativistically speaking, nothing can be faster. (OK, just joking. The uses > of the same letter of the alphabet are not at all relate

Re: C is it always faster than nump?

2022-02-25 Thread Chris Angelico
On Sat, 26 Feb 2022 at 05:49, Richard Damon wrote: > > On 2/25/22 4:12 AM, BELAHCENE Abdelkader wrote: > > Hi, > > a lot of people think that C (or C++) is faster than python, yes I agree, > > but I think that's not the case with numpy, I believe numpy is faster than > > C, at least in some cases.

Re: C is it always faster than nump?

2022-02-25 Thread Chris Angelico
On Sat, 26 Feb 2022 at 03:13, BELAHCENE Abdelkader wrote: > *This is the Python3 program :import timeit as itimport numpy as npimport > systry : n=eval(sys.argv[1])except: print ("needs integer as argument") ; > exit() a=range(1,n+1)b=np.array(a)def func1(): return sum(a)def > func2(): return

Re: Threading question .. am I doing this right?

2022-02-25 Thread Chris Angelico
On Sat, 26 Feb 2022 at 05:16, Robert Latest via Python-list wrote: > > Chris Angelico wrote: > > Depending on your database, this might be counter-productive. A > > PostgreSQL database running on localhost, for instance, has its own > > caching, and data transfers between

Re: Best way to check if there is internet?

2022-02-25 Thread Chris Angelico
On Sat, 26 Feb 2022 at 05:09, Abdur-Rahmaan Janhangeer wrote: > > Normally people put Python in the scripting category. You have a very interesting definition of "normal". ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Threading question .. am I doing this right?

2022-02-24 Thread Chris Angelico
On Fri, 25 Feb 2022 at 06:54, Robert Latest via Python-list wrote: > > I have a multi-threaded application (a web service) where several threads need > data from an external database. That data is quite a lot, but it is almost > always the same. Between incoming requests, timestamped records get a

Re: Best way to check if there is internet?

2022-02-23 Thread Chris Angelico
On Thu, 24 Feb 2022 at 03:39, Akkana Peck wrote: > > 2qdxy4rzwzuui...@potatochowder.com writes: > > I think someone said it way upthread: don't check, just do whatever you > > came to do, and it will work or it will fail (presumably, your program > > can tell the difference, regardless of a past

Re: One-liner to merge lists?

2022-02-22 Thread Chris Angelico
On Wed, 23 Feb 2022 at 15:04, Dan Stromberg wrote: > > On Tue, Feb 22, 2022 at 7:46 AM David Raymond > wrote: > > > > Is there a simpler way? > > > > >>> d = {1: ['aaa', 'bbb', 'ccc'], 2: ['fff', 'ggg']} > > >>> [a for b in d.values() for a in b] > > ['aaa', 'bbb', 'ccc', 'fff', 'ggg'] > > >>> >

Re: Best way to check if there is internet?

2022-02-22 Thread Chris Angelico
On Wed, 23 Feb 2022 at 05:38, Avi Gross via Python-list wrote: > It sounds to me like your main issue is not whether the internet is up right > now but whether the user has an internet connection. If they run the program > on a laptop at home or work then they may well be connected, but sitting

Re: Best way to check if there is internet?

2022-02-22 Thread Chris Angelico
On Wed, 23 Feb 2022 at 02:33, Chris Green wrote: > > Chris Angelico wrote: > > On Tue, 22 Feb 2022 at 19:33, Abdur-Rahmaan Janhangeer > > wrote: > > > > > > As discussed here but, it would have been nevertheless great to have this > >

Re: Best way to check if there is internet?

2022-02-22 Thread Chris Angelico
On Wed, 23 Feb 2022 at 01:06, Antoon Pardon wrote: > > > Op 22/02/2022 om 09:40 schreef Chris Angelico: > > On Tue, 22 Feb 2022 at 19:33, Abdur-Rahmaan Janhangeer > > wrote: > >> As discussed here but, it would have been nevertheless great to have this > >>

Re: One-liner to merge lists?

2022-02-22 Thread Chris Angelico
On Tue, 22 Feb 2022 at 20:46, Frank Millman wrote: > > On 2022-02-22 11:30 AM, Chris Angelico wrote: > > On Tue, 22 Feb 2022 at 20:24, Frank Millman wrote: > >> > >> Hi all > >> > >> I think this should be a simple one-liner, but I cannot fig

Re: One-liner to merge lists?

2022-02-22 Thread Chris Angelico
On Tue, 22 Feb 2022 at 20:24, Frank Millman wrote: > > Hi all > > I think this should be a simple one-liner, but I cannot figure it out. > > I have a dictionary with a number of keys, where each value is a single > list - > > >>> d = {1: ['aaa', 'bbb', 'ccc'], 2: ['fff', 'ggg']} > > I want to com

Re: Best way to check if there is internet?

2022-02-22 Thread Chris Angelico
On Tue, 22 Feb 2022 at 19:40, Chris Angelico wrote: > > On Tue, 22 Feb 2022 at 19:33, Abdur-Rahmaan Janhangeer > wrote: > > > > As discussed here but, it would have been nevertheless great to have this > > tiny function instead of > > nothing > > > >

Re: Best way to check if there is internet?

2022-02-22 Thread Chris Angelico
On Tue, 22 Feb 2022 at 19:33, Abdur-Rahmaan Janhangeer wrote: > > As discussed here but, it would have been nevertheless great to have this > tiny function instead of > nothing > Here's a function that determines whether or not you have an internet connection. It's almost as reliable as some of t

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Chris Angelico
On Mon, 21 Feb 2022 at 16:48, Avi Gross via Python-list wrote: > > Amusingly, Greg, if you had a system where the un-named anonymous function > was to be named the unique value of the empty string, then a second such > anonymous function definition would over-write it, as with any named > funct

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Chris Angelico
On Mon, 21 Feb 2022 at 14:36, Python wrote: > > Barry wrote: > > > > > >> On 20 Feb 2022, at 15:35, Abdur-Rahmaan Janhangeer > >> wrote: > >> > >> Greetings list. > >> > >> Out of curiosity, why doesn't Python accept > >> def (): > >> return '---' > >> > >> () > >> > >> Where the function n

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Chris Angelico
On Mon, 21 Feb 2022 at 09:38, Eryk Sun wrote: > > On 2/20/22, Abdur-Rahmaan Janhangeer wrote: > > > > Out of curiosity, why doesn't Python accept > > def (): > > return '---' > > The `def` keyword is compiled as an assignment statement, not an > expression that evaluates anonymously on the st

Re: Long running process - how to speed up?

2022-02-20 Thread Chris Angelico
On Mon, 21 Feb 2022 at 05:07, Shaozhong SHI wrote: > However, I have no idea whether this approach will be faster than > conventional approach. > > Any one has idea? Try it. Find out. The only way to know is to measure. I can't see the sleep call though. You may need to post your actual code ins

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Chris Angelico
On Mon, 21 Feb 2022 at 02:33, Abdur-Rahmaan Janhangeer wrote: > > Greetings list. > > Out of curiosity, why doesn't Python This is often the wrong question. The question is more: Why should Python? Python doesn't do things just because there's no reason not to. ChrisA -- https://mail.python.or

Re: PYT - The expressions described in the Python language reference yield only boolean values

2022-02-19 Thread Chris Angelico
On Sun, 20 Feb 2022 at 12:00, vanyp wrote: > > *I am trying to learn Python from the grammar given in the Python > language reference and I am surprised.* > The grammar is not the best way to learn the language. It'll show you a lot of unnecessary details. For technical reasons, Python's grammar

Re: Re: Long running process - how to speed up?

2022-02-19 Thread Chris Angelico
On Sat, 19 Feb 2022 at 22:59, Karsten Hilbert wrote: > > > > I have a cvs file of 932956 row and have to have time.sleep in a Python > > > script. It takes a long time to process. > > > > > > How can I speed up the processing? Can I do multi-processing? > > > > > Remove the time.sleep()? > > He'

Re: Long running process - how to speed up?

2022-02-19 Thread Chris Angelico
On Sat, 19 Feb 2022 at 22:30, Shaozhong SHI wrote: > > I have a cvs file of 932956 row and have to have time.sleep in a Python > script. It takes a long time to process. > > How can I speed up the processing? Can I do multi-processing? > Remove the time.sleep()? ChrisA -- https://mail.python.o

Re: Pickle file and send via socket

2022-02-18 Thread Chris Angelico
On Sat, 19 Feb 2022 at 05:47, UTKARSH PANDEY wrote: > > On Wednesday, August 8, 2012 at 8:37:33 PM UTC+5:30, lipska the kat wrote: > > ... > Directly read bytes from file and send it over the socket object from client > side in while loop until all content from file is read. > Almost ten years.

Re: venv and executing other python programs

2022-02-15 Thread Chris Angelico
On Tue, 15 Feb 2022 at 21:19, Roel Schroeven wrote: > > Op 15/02/2022 om 8:21 schreef Reto: > > On Tue, Feb 15, 2022 at 06:35:18AM +0100, Mirko via Python-list wrote: > > > How to people here deal with that? > > > > Don't activate the venv for those programs then? > > The point of a venv is that y

Re: C API - How to return a Dictionary as a Dictionary type

2022-02-14 Thread Chris Angelico
On Tue, 15 Feb 2022 at 12:07, Jen Kris via Python-list wrote: > > I created a dictionary with the Python C API and assigned two keys and values: > > PyObject* this_dict = PyDict_New(); > const char *key = "key1"; > char *val = "data_01"; > PyObject* val_p = PyUnicode_FromString(val); > int r = PyD

Re: URLError:

2022-02-12 Thread Chris Angelico
On Sun, 13 Feb 2022 at 07:17, Shaozhong SHI wrote: > > The following is used in a loop to get response code for each url. > > print (urllib.request.urlopen(url).getcode()) > > However, error message says: URLError: getaddrinfo failed> > > Python 3.6.5 is being used to test whether url is live or

Re: PermissionError: [Errno 13] Permission denied: 'Abc.xlsx'

2022-02-10 Thread Chris Angelico
On Fri, 11 Feb 2022 at 07:57, Christian Gollwitzer wrote: > > Am 10.02.22 um 20:43 schrieb Chris Angelico: > > On Fri, 11 Feb 2022 at 06:41, Dennis Lee Bieber > > wrote: > >> While not tested with Excel, I /have/ encountered cases where an > >>

Re: PermissionError: [Errno 13] Permission denied: 'Abc.xlsx'

2022-02-10 Thread Chris Angelico
On Fri, 11 Feb 2022 at 06:41, Dennis Lee Bieber wrote: > > On Wed, 9 Feb 2022 18:50:12 +, MRAB > declaimed the following: > > >On 2022-02-09 12:45, Christian Gollwitzer wrote: > > >> It's impossible. Excel locks the file deliberately when it is open, so > >> that you can't overwrite it from a

Re: Global VS Local Subroutines

2022-02-10 Thread Chris Angelico
On Fri, 11 Feb 2022 at 03:57, Rob Cliffe via Python-list wrote: > But of course, performance is not the only consideration, as per Chris > Angelico's answer. Yep. In fact, I'd say that performance is the least significant consideration here; do what makes sense. The time difference will be neglig

Re: How to solve the given problem?

2022-02-10 Thread Chris Angelico
On Fri, 11 Feb 2022 at 02:15, NArshad wrote: > > -ChrisA: > You don't reply if you have problems. > When I don't find any solution elsewhere then only I place in this group > You're a help vampire. Stop it. https://slash7.com/2006/12/22/vampires/ Go do some actual research instead of asking peo

Re: Global VS Local Subroutines

2022-02-10 Thread Chris Angelico
On Fri, 11 Feb 2022 at 02:13, BlindAnagram wrote: > > Is there any difference in performance between these two program layouts: > > def a(): > ... > def(b): > c = a(b) > > or > > def(b): > def a(): > ... > c = a(b) > > I would appreciate any insights on

Re: How to solve the given problem?

2022-02-10 Thread Chris Angelico
On Thu, 10 Feb 2022 at 18:41, NArshad wrote: > > > Assume that there is a pattern of feeding for a special fish in a day (10 > hours a day) as below: >150100303030202010 >55 > Today, the fish is fed in the second hour 60 unit in

Re: Best way to check if there is internet?

2022-02-07 Thread Chris Angelico
On Tue, 8 Feb 2022 at 12:20, Ethan Furman wrote: > > On 2/7/22 4:27 PM, Greg Ewing wrote: > > On 8/02/22 8:51 am, Chris Angelico wrote: > > >> Some day, we'll have people on Mars. They won't have TCP connections - > >> at least, not unless s

Re: Best way to check if there is internet?

2022-02-07 Thread Chris Angelico
On Tue, 8 Feb 2022 at 09:31, <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 2022-02-08 at 06:51:20 +1100, > Chris Angelico wrote: > > > Either way, though: would a person on Mars "have the internet"? Yes, > > but not the internet as we know it... >

Re: Best way to check if there is internet?

2022-02-07 Thread Chris Angelico
On Tue, 8 Feb 2022 at 08:30, Cameron Simpson wrote: > > On 08Feb2022 06:51, Chris Angelico wrote: > >Some day, we'll have people on Mars. They won't have TCP connections - > >at least, not unless servers start supporting connection timeouts > >measured in

Re: Best way to check if there is internet?

2022-02-07 Thread Chris Angelico
On Tue, 8 Feb 2022 at 06:41, Grant Edwards wrote: > But, as has been pointed out previously "if there is internet" is too > vague a question to have an answer. > > If all you have is proxied access to outside HTTPS servers, then I > would consider the answer to be "no", but most people would say "

Re: Openning Python program

2022-02-07 Thread Chris Angelico
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 does remind me about a system administrator who wanted to make a

Re: Openning Python program

2022-02-07 Thread Chris Angelico
On Tue, 8 Feb 2022 at 04:30, Cecil Westerhof via Python-list wrote: > > 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 +0

Re: Openning Python program

2022-02-07 Thread Chris Angelico
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 modify/uninstall > >> ?? please hel

Re: Best way to check if there is internet?

2022-02-07 Thread Chris Angelico
gh that situation would probably be best described as "degraded service". (Unless one tool was straight-up misconfigured, of course.) > So What Chris Angelico wrote is propably the best way, ping e.g. Google, > do a DNS lookup and try http for Status 200. Each with its own > Errorha

Re: Best way to check if there is internet?

2022-02-07 Thread Chris Angelico
On Mon, 7 Feb 2022 at 20:18, Abdur-Rahmaan Janhangeer wrote: > > Greetings, > > Using the standard library or 3rd party libraries, what's the > best way to check if there is internet? Checking if google.com > is reachable is good but I wonder if there is a more native, > protocol-oriented > way of

Re: Waht do you think about my repeated_timer class

2022-02-04 Thread Chris Angelico
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 rewriting the class > >> completely, so now the name is a complete bumper. (No more timer.

Re: ssl server: how to disable client cert verfication?

2022-02-03 Thread Chris Angelico
On Fri, 4 Feb 2022 at 09:37, Grant Edwards wrote: > I've looked through the ssl.Context documentation multiple times, and > haven't been able to spot any option or flag that disables client > certificate validation or allows the user to override the actual > client certificate validation process.

Re: Waht do you think about my repeated_timer class

2022-02-02 Thread Chris Angelico
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

Re: Waht do you think about my repeated_timer class

2022-02-02 Thread Chris Angelico
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

Re: Waht do you think about my repeated_timer class

2022-02-02 Thread Chris Angelico
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

Re: Data unchanged when passing data to Python in multiprocessing shared memory

2022-02-02 Thread Chris Angelico
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

Re: Waht do you think about my repeated_timer class

2022-02-02 Thread Chris Angelico
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 th

Re: Waht do you think about my repeated_timer class

2022-02-02 Thread Chris Angelico
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

Re: Segfault after deepcopy in a C extension

2022-01-31 Thread Chris Angelico
On Tue, 1 Feb 2022 at 08:54, Marco Sulla wrote: > PyObject* d = PyDict_New(); > args = PyTuple_New(2); > PyTuple_SET_ITEM(args, 0, d); > PyTuple_SET_ITEM(args, 1, memo); > Py_DECREF(d); > https://docs.python.org/3/c-api/tuple.html#c.PyTuple_SET_ITEM SET_ITEM steals a referenc

Re: What to write or search on github to get the code for what is written below:

2022-01-31 Thread Chris Angelico
On Tue, 1 Feb 2022 at 02:38, NArshad wrote: > > What about CGI? > Do you know any Library Management System based on CGI just like the one on > Django? > Have you done any research, or are you just picking up a new acronym to see if you can suck some more volunteer time out of this list? ChrisA

Re: Puzzling behaviour of Py_IncRef

2022-01-26 Thread Chris Angelico
On Wed, 26 Jan 2022 at 19:04, Tony Flury via Python-list wrote: > > So according to that I should increment twice if and only if the calling > code is using the result - which you can't tell in the C code - which is > very odd behaviour. No, the return value from your C function will *always* hav

Re: Pandas or Numpy

2022-01-23 Thread Chris Angelico
On Mon, 24 Jan 2022 at 04:10, Tobiah wrote: > > I know very little about either. I need to handle score input files > for Csound. Each line is a list of floating point values where each > column has a particular meaning to the program. > > I need to compose large (hundreds, thousands, maybe mill

Re: What to write or search on github to get the code for what is written below:

2022-01-22 Thread Chris Angelico
On Sun, 23 Jan 2022 at 09:15, Dennis Lee Bieber wrote: > A web > application has every action as a distinct connection and needs identifying > tokens [cookies] to let the logic know what was done previously > Usually. Fortunately, we have SOME features that can make life easier, but in general, y

Re: What to write or search on github to get the code for what is written below:

2022-01-22 Thread Chris Angelico
On Sun, 23 Jan 2022 at 07:47, Dennis Lee Bieber wrote: > If you are doing a web application, how are you going to host it? Who > is responsible for managing the web server? Domain name? Firewalls? > Certificates if you need HTTPS rather than plain insecure HTTP. > > I have a Raspbe

Re: Puzzling behaviour of Py_IncRef

2022-01-20 Thread Chris Angelico
On Fri, 21 Jan 2022 at 10:10, Greg Ewing wrote: > > On 20/01/22 12:09 am, Chris Angelico wrote: > > At this point, the refcount has indeed been increased. > > > >> return self; > >> } > > > > And then you say "my return valu

Re: Puzzling behaviour of Py_IncRef

2022-01-19 Thread Chris Angelico
On Thu, Jan 20, 2022 at 1:22 AM Tony Flury wrote: > > > On 19/01/2022 11:09, Chris Angelico wrote: > > On Wed, Jan 19, 2022 at 10:00 PM Tony Flury via Python-list > > wrote: > >> Extension function : > >> > >> stat

Re: Puzzling behaviour of Py_IncRef

2022-01-19 Thread Chris Angelico
On Wed, Jan 19, 2022 at 10:00 PM Tony Flury via Python-list wrote: > Extension function : > > static PyObject *_Node_test_ref_count(PyObject *self) > { > printf("\nIncrementing ref count for self - just for the hell > of it\n"); > printf("\n before self has a ref coun

Re: What to write or search on github to get the code for what is written below:

2022-01-17 Thread Chris Angelico
On Tue, Jan 18, 2022 at 7:44 AM Dennis Lee Bieber wrote: > Heroku-Specific note: a recent web-page I encountered searching for > information for a different question indicates that Heroku does not support > SQLite3 and, by extension, ANY file-based dynamic data storage (so, no > Excel files either

Re: What to write or search on github to get the code for what is written below:

2022-01-17 Thread Chris Angelico
On Tue, Jan 18, 2022 at 2:46 AM NArshad wrote: > > Avi Gross: > > -“They just were hoping someone would post complete code and they could then > move on without learning anything.” > > This is due to the time factor Then pay someone to write it. There are plenty of contractors out there. You can

Re: About Python Compressed Archive or Binaries

2022-01-17 Thread Chris Angelico
On Tue, Jan 18, 2022 at 2:47 AM Chris Angelico wrote: > > On Tue, Jan 18, 2022 at 2:42 AM Sina Mobasheri > wrote: > > > > Java offers download JDK as Compressed Archive or NodeJS offers download > > Node as Binaries both give us a compressed file for Linux and wi

Re: About Python Compressed Archive or Binaries

2022-01-17 Thread Chris Angelico
On Tue, Jan 18, 2022 at 2:42 AM Sina Mobasheri wrote: > > Java offers download JDK as Compressed Archive or NodeJS offers download Node > as Binaries both give us a compressed file for Linux and windows that we can > just unzipped it and put in a custom directory and set some environment > vari

Re: What to write or search on github to get the code for what is written below:

2022-01-13 Thread Chris Angelico
On Fri, Jan 14, 2022 at 7:56 AM Dennis Lee Bieber wrote: > > On Thu, 13 Jan 2022 15:22:50 -0500, Dennis Lee Bieber > declaimed the following: > > Talking to myself in public again... Bad habit... Not as bad as singing choruses in public, which - or so I'm told, by a mad girl in opera - i

Re: Scope confusion in Python REPL

2022-01-13 Thread Chris Angelico
On Thu, Jan 13, 2022 at 9:43 PM Anssi Saari wrote: > > > I ran into what seems odd scoping to me when playing with some matching > examples for 3.10. > > I kinda thought that if I do from foo import * and from bar import * in > the Python REPL, I'd get everything from foo and bar in the main > sco

Re: sharing data across Examples docstrings

2022-01-11 Thread Chris Angelico
On Wed, Jan 12, 2022 at 9:11 AM Sebastian Luque wrote: > > Hello, > > I am searching for a mechanism for sharing data across Examples sections > in docstrings within a class. For instance: This seems like trying to cram too much information into the docstring, but oh well... do what you will. I

Re: Why operations between dict views return a set and not a frozenset?

2022-01-11 Thread Chris Angelico
On Wed, Jan 12, 2022 at 5:49 AM Marco Sulla wrote: > > Ok... so I suppose, since you're inviting me to use dis and look at the > bytecode, that are you talking about constants in assembly, so const in C? > Sorry for the confusion, I'm not so skilled in C and I know nearly nothing > about assemb

Re: symlinks with python3 http.server.CGIHTTPRequestHandler

2022-01-11 Thread Chris Angelico
On Tue, Jan 11, 2022 at 6:17 AM Nat Taylor wrote: > > Is it possible to get http.server.CGIHTTPRequestHandler to run a symlink-ed > script? > > In the example below, GET /cgi-bin/test.py results in a 404 because it is a > symlink. > > % mkdir -p test/cgi-bin > % cd test > % vi test.py > % chmod +x

Re: Why operations between dict views return a set and not a frozenset?

2022-01-10 Thread Chris Angelico
On Tue, Jan 11, 2022 at 10:26 AM Marco Sulla wrote: > > On Wed, 5 Jan 2022 at 23:02, Chris Angelico wrote: > > > > On Thu, Jan 6, 2022 at 8:01 AM Marco Sulla > > wrote: > > > > > > On Wed, 5 Jan 2022 at 14:16, Chris Angelico wrote: > > > &g

Re: What to write or search on github to get the code for what is written below:

2022-01-07 Thread Chris Angelico
On Sat, Jan 8, 2022 at 6:50 AM NArshad wrote: > - All functions mentioned above are to be deployed on the website > pythonhow.com so make according to > https://pythonhow.com/python-tutorial/flask/web-development-with-python-and-flask/ > > - Do you know any other websites to deploy a python web

Re: AttributeError: 'NoneType' object has no attribute 'get'

2022-01-06 Thread Chris Angelico
On Fri, Jan 7, 2022 at 8:47 AM <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 2022-01-06 at 14:21:48 -0700, > Mats Wichmann wrote: > > > And at a more meta level: many functions in the Python world return > > None as an indication that the operation did not succeed. It's useful > > because i

Re: Why operations between dict views return a set and not a frozenset?

2022-01-05 Thread Chris Angelico
On Thu, Jan 6, 2022 at 8:01 AM Marco Sulla wrote: > > On Wed, 5 Jan 2022 at 14:16, Chris Angelico wrote: > > That's an entirely invisible optimization, but it's more than just > > "frozenset is faster than set". It's that a frozenset or tuple can be >

Re: Why operations between dict views return a set and not a frozenset?

2022-01-05 Thread Chris Angelico
On Thu, Jan 6, 2022 at 12:05 AM Marco Sulla wrote: > > On Wed, 5 Jan 2022 at 00:54, Chris Angelico wrote: > > That's because a tuple is the correct data type when returning two > > distinct items. It's not a list that has two elements in it; it's a > >

Re: Why operations between dict views return a set and not a frozenset?

2022-01-04 Thread Chris Angelico
On Wed, Jan 5, 2022 at 7:04 AM Marco Sulla wrote: > > On Tue, 4 Jan 2022 at 19:38, Chris Angelico wrote: > > [...] should the keys view be considered > > frozen or not? Remember the set of keys can change (when the > > underlying dict changes). > > Well, also the

Re: Why operations between dict views return a set and not a frozenset?

2022-01-04 Thread Chris Angelico
On Wed, Jan 5, 2022 at 5:29 AM Marco Sulla wrote: > > $ python > Python 3.10.0 (heads/3.10-dirty:f6e8b80d20, Nov 18 2021, 19:16:18) > [GCC 10.1.1 20200718] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> a = {1:2} > >>> c = {1:2, 3:4} > >>> c.keys() - a.keys

Re: KeyError: 'payload' while running core.py

2022-01-02 Thread Chris Angelico
On Mon, Jan 3, 2022 at 1:46 PM Đông Vũ wrote: > > That is error, please help me fix it. > > Traceback (most recent call last): > File > "C:\Users\vuduc\AppData\Local\Programs\Python\Python39\lib\site-packages\frida\core.py", > line 450, in _on_message > callback(message, data) > File "C:\N

Re: Who wrote Py_UNREACHABLE?

2022-01-02 Thread Chris Angelico
On Mon, Jan 3, 2022 at 3:19 AM Marco Sulla wrote: > > #if defined(RANDALL_WAS_HERE) > # define Py_UNREACHABLE() \ > Py_FatalError( \ > "If you're seeing this, the code is in what I thought was\n" \ > "an unreachable state.\n\n" \ > "I could give you advice for what to

Re: builtins.TypeError: catching classes that do not inherit from BaseException is not allowed

2021-12-30 Thread Chris Angelico
On Fri, Dec 31, 2021 at 9:42 AM hongy...@gmail.com wrote: > > (Also, is this REALLY an optimization? Exception handling isn't the > > fastest. Yes, it avoids some measure of recursion depth, but it looks > > like a pretty inefficient way to do things. Python is not Lisp, and > > there are very ver

Re: builtins.TypeError: catching classes that do not inherit from BaseException is not allowed

2021-12-30 Thread Chris Angelico
On Fri, Dec 31, 2021 at 9:42 AM hongy...@gmail.com wrote: > > On Thursday, December 30, 2021 at 11:24:20 PM UTC+8, Chris Angelico wrote: > > On Fri, Dec 31, 2021 at 2:03 AM hongy...@gmail.com > > wrote: > > > See here [1] for the related discussion. &

Re: builtins.TypeError: catching classes that do not inherit from BaseException is not allowed

2021-12-30 Thread Chris Angelico
On Fri, Dec 31, 2021 at 2:03 AM hongy...@gmail.com wrote: > See here [1] for the related discussion. > > [1] > https://discuss.python.org/t/typeerror-catching-classes-that-do-not-inherit-from-baseexception-is-not-allowed/12800 Why did you post in two places at once? Did you need more people to t

Re: builtins.TypeError: catching classes that do not inherit from BaseException is not allowed

2021-12-30 Thread Chris Angelico
On Fri, Dec 31, 2021 at 2:00 AM hongy...@gmail.com wrote: > > I try to compute the factorial of a large number with tail-recursion > optimization decorator in Python3. The following code snippet is converted > from the code snippet given here [1] by the following steps: > > $ pyenv shell datasci

Re: recover pickled data: pickle data was truncated

2021-12-29 Thread Chris Angelico
On Thu, Dec 30, 2021 at 4:32 AM iMath wrote: > > > You have lost the data in that case. > > But I found the size of the file of the shelve data didn't change much, so I > guess the data are still in it , I just wonder any way to recover my data. Unless two conflicting versions got interleaved, i

Re: What's the public API alternative to _PyObject_GC_IS_TRACKED()?

2021-12-29 Thread Chris Angelico
On Wed, Dec 29, 2021 at 8:07 PM Dieter Maurer wrote: > > Marco Sulla wrote at 2021-12-29 09:29 +0100: > >On second thought, I think I'll do this for the pure py version. But I > >will definitely not do this for the C extension > > Are you sure you need to implement your type in C at all? > > I mad

Re: PIP Certificate problem

2021-12-27 Thread Chris Angelico
On Tue, Dec 28, 2021 at 8:00 AM Aniket wrote: > >I have reinstalled python, and repaired but no help at all. My version of >Python is 3.10.1 > What does "pip --version" tell you? ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: 'array.array' object has no attribute 'tostring' which 3 got it fixed?

2021-12-21 Thread Chris Angelico
On Tue, Dec 21, 2021 at 9:56 PM '2+ wrote: > > hi ;) > > got popos installed on my raspberry pi4 and it is currently running python > 3.9.7 > > i get this error when running my script: > > 'array.array' object has no attribute 'tostring' > > this bug seems to be pretty old .. how long should i be

Re: Call julia from Python: which package?

2021-12-17 Thread Chris Angelico
On Sat, Dec 18, 2021 at 10:01 AM Oscar Benjamin wrote: > > On Fri, 17 Dec 2021 at 22:40, Chris Angelico wrote: > > > > On Sat, Dec 18, 2021 at 9:24 AM Oscar Benjamin > > wrote: > > > When I timed the result in Julia and in Python I found that the Julia > >

Re: Call julia from Python: which package?

2021-12-17 Thread Chris Angelico
On Sat, Dec 18, 2021 at 9:24 AM Oscar Benjamin wrote: > When I timed the result in Julia and in Python I found that the Julia > code was slower than the Python code. Of course I don't know how to > optimise Julia code so I asked one of my colleagues who does (and who > likes to proselytise about J

Re: A problem with itertools.groupby

2021-12-17 Thread Chris Angelico
On Sat, Dec 18, 2021 at 2:32 AM ast wrote: > > Python 3.9.9 > > Hello > > I have some troubles with groupby from itertools > > from itertools import groupby > > li = [grp for k, grp in groupby("aahfffddnnb")] > list(li[0]) > > [] > > list(li[1]) > > [] > > It seems empty ... I don't understand

Re: ast.parse, ast.dump, but with comment preservation?

2021-12-15 Thread Chris Angelico
On Thu, Dec 16, 2021 at 2:47 PM samue...@gmail.com wrote: > > I wrote a little open-source tool to expose internal constructs in OpenAPI. > Along the way, I added related functionality to: > - Generate/update a function prototype to/from a class > - JSON schema > - Automatically add type annotati

Re: problem reading a CSV file

2021-12-13 Thread Chris Angelico
On Tue, Dec 14, 2021 at 12:05 AM Larry Warner wrote: > > Win 10, Chrome, Python 3.10.1 > New at python > error on open statement > > Probably simple error but I do not see it. > > The program is a python example with the file name being changed. I want > to experiment with changing the literal fi

Re: Isn't TypeError built in?

2021-12-12 Thread Chris Angelico
On Mon, Dec 13, 2021 at 12:31 PM Mike Dewhirst via Python-list wrote: > > Obviously something is wrong elsewhere but I'm not sure where to look. > Ubuntu 20.04 with plenty of RAM. > > def __del__(self): > try: > for context_obj in self._context_refs: > t

Re: Return

2021-12-07 Thread Chris Angelico
On Wed, Dec 8, 2021 at 9:04 AM dn via Python-list wrote: > > plus Python, unlike some other languages, allows us to return multiple > values, either as a collection or as an implied-tuple: > > def function_list(): > a_list = [ i for i in range( 9 ) ] > return a_list > > def function_multip

Re: HTML extraction

2021-12-07 Thread Chris Angelico
On Wed, Dec 8, 2021 at 7:55 AM Roland Mueller wrote: > > Hello, > > ti 7. jouluk. 2021 klo 20.08 Chris Angelico (ros...@gmail.com) kirjoitti: >> >> On Wed, Dec 8, 2021 at 4:55 AM Julius Hamilton >> wrote: >> > >> > Hey, >> > >> >

Re: For a hierarchical project, the EXE file generated by "pyinstaller" does not start.

2021-12-07 Thread Chris Angelico
On Wed, Dec 8, 2021 at 4:49 AM Mohsen Owzar wrote: > *** > GPIOContrl.py > *** > class GPIOControl: > def my_print(self, args): > if print_allowed == 1: > print(args) > >

Re: Urllib.request vs. Requests.get

2021-12-07 Thread Chris Angelico
On Wed, Dec 8, 2021 at 4:51 AM Julius Hamilton wrote: > > Hey, > > I am currently working on a simple program which scrapes text from webpages > via a URL, then segments it (with Spacy). > > I’m trying to refine my program to use just the right tools for the job, > for each of the steps. > > Reque

Re: HTML extraction

2021-12-07 Thread Chris Angelico
On Wed, Dec 8, 2021 at 4:55 AM Julius Hamilton wrote: > > Hey, > > Could anyone please comment on the purest way simply to strip HTML tags > from the internal text they surround? > > I know Beautiful Soup is a convenient tool, but I’m interested to know what > the most minimal way to do it would b

Re: Python child process in while True loop blocks parent

2021-12-06 Thread Chris Angelico
On Tue, Dec 7, 2021 at 4:10 AM Jen Kris via Python-list wrote: > > I can't find any support for your comment that "Fork creates a new > process and therefore also a new thread." From the Linux man pages > https://www.man7.org/linux/man-pages/man2/fork.2.html, "The child process is > created wit

A decade or so of Python programming, and I've never thought to "for-elif"

2021-11-29 Thread Chris Angelico
for ns in namespaces: if name in ns: print("Found!") break elif name.isupper(): print("All-caps name that wasn't found") This actually doesn't work. I have been programming in Python for well over a decade, and never before been in a situation where this would be useful. A

<    2   3   4   5   6   7   8   9   10   11   >