Re: Color representation as rgb, int and hex

2019-09-08 Thread MRAB
On 2019-09-08 20:58, Eko palypse wrote: I'm confused about the following import sys print(tuple(bytes.fromhex('282C34'))) print(tuple((0x282C34).to_bytes(3, byteorder=sys.byteorder))) which results in (40, 44, 52) (52, 44, 40) on my machine. Shouldn't I expect the same result? You haven't s

Re: Why is "Subscribing to topic topic/test" printed in console log before connect message?

2019-09-10 Thread MRAB
On 2019-09-10 17:59, Spencer Du wrote: Hi I have code for publish and subscribe over mqtt. In the console log I have "Subscribing to topic topic/test" printed before connect message why is this? I want to this to be printed after the connect message. How do I fix this problem. Please run gui.

Re: Weird Python Bug

2019-09-13 Thread MRAB
On 2019-09-13 20:17, CrazyVideoGamez wrote: For some reason, if you put in the code def odd_ones_out(numbers): for num in numbers: count = numbers.count(num) if not count % 2 == 0: for i in range(count): numbers.remove(num) return numbers

Re: # type: a

2019-09-15 Thread MRAB
On 2019-09-15 15:45, Hongyi Zhao wrote: Hi, In pycharm, when I commented out the following line: # type: a The pycharm still told me that: Unresolved reference 'a' Till I commented like the following, the warning will disappear: # type: # a Why? PyCharm has comment-based type hints, and

Re: re not working

2019-09-16 Thread MRAB
On 2019-09-17 02:31, CrazyVideoGamez wrote: For some reason these are different: pattern = r'[0-9]{4,6}' And pattern2 = r'[0-9][0-9][0-9][0-9]([0-9]){0,2}' And when I try to match them import re re.search(pattern, '1234') and import re re.search(pattern2, '1234') are different. Help? Pyt

Re: Irritating bytearray behavior

2019-09-16 Thread MRAB
On 2019-09-17 02:37, Ian Pilcher wrote: I am using a bytearray to construct a very simple message, that will be sent across the network. The message should always be 20 bytes: 2 bytes - address family (AF_INET or AF_INET6) - network byte order 2 bytes - (padding) 4 or 16 bytes - IP

Re: Unicode UCS2, UCS4 and ... UCS1

2019-09-19 Thread MRAB
On 2019-09-19 09:55, Gregory Ewing wrote: Eli the Bearded wrote: There isn't anything called UCS1. Apparently there is, but it's not a character set, it's a loudspeaker. https://www.bhphotovideo.com/c/product/1205978-REG/yorkville_sound_ucs1_1200w_15_horn_loaded.html The OP might mean Py_UCS

Re: Won't Uninstall

2019-09-20 Thread MRAB
On 2019-09-20 03:59, Fred Vincent wrote: Python 3.7.4 won’t uninstall, I have tried doing what I can such as going to the control panel and uninstalling the program there, but that did not work. Since I am unable to delete it I am unable to download a different version of python. How do I fix

Re: Most efficient way to replace "," with "." in a array and/or dataframe

2019-09-21 Thread MRAB
On 2019-09-22 00:42, Markos wrote: Hi, I have a table.csv file with the following structure: , Polyarene conc ,, mg L-1 ,,, Spectrum, Py, Ace, Anth, 1, "0,456", "0,120", "0,168" 2, "0,456", "0,040", "0,280" 3, "0,152", "0,200", "0,280" I open as dataframe with the command: data = pd.read_

Re: CSV reader ignore brackets

2019-09-24 Thread MRAB
On 2019-09-25 00:09, Cameron Simpson wrote: On 24Sep2019 15:55, Mihir Kothari wrote: I am using python 3.4. I have a CSV file as below: ABC,PQR,(TEST1,TEST2) FQW,RTE,MDE Really? No quotes around the (TEST1,TEST2) column value? I would have said this is invalid data, but that does not help yo

Re: NameError: name 'msvcrt' is not defined

2019-09-26 Thread MRAB
On 2019-09-27 03:14, Hongyi Zhao wrote: Hi, I use python on Debian, when running some python codes, I meet the following error: --- input_username.py", line 18, in read_input if msvcrt.kbhit(): NameError: name 'msvcrt' is not defined How to solve this issue? That

Re: Access violation in Python garbage collector (visit_decref) - how to debug?

2019-10-04 Thread MRAB
On 2019-10-04 20:32, Geoff Bache wrote: Hi all, We are running Python embedded in our C++ product and are now experiencing crashes (access violation reading 0xff on Windows) in the Python garbage collector. We got this on Python 3.6.4 originally, but I can reproduce it with both Python

Re: Get __name__ in C extension module

2019-10-06 Thread MRAB
On 2019-10-06 15:48, Ian Pilcher wrote: On 10/5/19 12:55 PM, Ian Pilcher wrote: This is straightforward, except that I cannot figure out how to retrieve the __name__. Making progress. I can get a __name__ value with: PyDict_GetItemString(PyEval_GetGlobals(), "__name__") I say "a __name_

Re: Get __name__ in C extension module

2019-10-06 Thread MRAB
On 2019-10-07 00:38, Ian Pilcher wrote: On 10/6/19 11:55 AM, MRAB wrote: > Don't you already have the module's name? You have to specify it in the > PyModuleDef struct that you pass to PyModule_Create. I do. Perhaps I'm trying to be too Pythonic, but there's so m

Re: Access violation in Python garbage collector (visit_decref) - how to debug?

2019-10-07 Thread MRAB
On 2019-10-07 08:04, Geoff Bache wrote: It's possible. Our embedding code is fairly simple and we've tried to encapsulate all the DECREFing in resource objects, i.e. that do DECREF in their destructor when they go out of scope. We hoped this would minimise this sort of problem. The C++ calling

Re: python3, regular expression and bytes text

2019-10-12 Thread MRAB
On 2019-10-12 20:48, Serhiy Storchaka wrote: 12.10.19 21:08, Eko palypse пише: So how can I make it work with utf8 encoded text? You cannot. First, \w in re.LOCALE works only when the text is encoded with the locale encoding (cp1252 in your case). Second, re.LOCALE supports only 8-bit charsets

Re: Mailscanner

2019-10-12 Thread MRAB
On 2019-10-12 21:06, Doris Marca Guaraca wrote: Hi sorry to bother you maybe you can help me, could you tell me which is the path that contains the main file of the bayes filter, I can't find it, or, I'm not sure this is the file / opt / zimbra / zimbramon /lib/Mail/Filter.pm Thank you in adv

Re: python3, regular expression and bytes text

2019-10-12 Thread MRAB
On 2019-10-12 20:57, Eko palypse wrote: You cannot. First, \w in re.LOCALE works only when the text is encoded with the locale encoding (cp1252 in your case). Second, re.LOCALE supports only 8-bit charsets. So even if you set the utf-8 locale, it would not help. Regular expressions with re.LO

Re: Except with empty tuple

2019-10-16 Thread MRAB
On 2019-10-16 15:03, Antoon Pardon wrote: I would like to verify I understand correctly. It is about the following construct: try: statement1 statement2 ... except (): pass As far as I understand and my tests seem to confirm this, this is equivalle

Re: Instantiating sub-class from super

2019-10-16 Thread MRAB
On 2019-10-16 19:43, duncan smith wrote: On 16/10/2019 04:41, DL Neil wrote: On 16/10/19 1:55 PM, duncan smith wrote: On 15/10/2019 21:36, DL Neil wrote: On 16/10/19 12:38 AM, Rhodri James wrote: On 14/10/2019 21:55, DL Neil via Python-list wrote: ... So, yes, the "label" is unimportant - ex

Re: Instantiating sub-class from super

2019-10-17 Thread MRAB
On 2019-10-17 20:06, Eryk Sun wrote: On 10/17/19, Dennis Lee Bieber wrote: On Wed, 16 Oct 2019 19:52:50 +0100, MRAB declaimed the following: Researchers find bug in Python script may have affected hundreds of studies https://arstechnica.com/information-technology/2019/10/chemists-discover

Re: Print formatting

2019-10-18 Thread MRAB
On 2019-10-18 18:03, Jagga Soorma wrote: Hello, I am new to python and trying to write a script that outputs some data about users. I was able to write it and dump the data but can't seem to align the output in column 2 correctly. Here is what I am trying to do: -- output: user1 data1 use

Re: Win32api problems

2019-10-22 Thread MRAB
On 2019-10-22 17:31, Albert-Jan Roskam wrote: On 22 Oct 2019 11:23, GerritM wrote: ImportError: DLL load failed: The specified > procedure could not be found. I've had the same error before and I solved it by adding the location where the win32 dlls live to PATH. Maybe PATH gets messed up

Re: installation problem

2019-10-23 Thread MRAB
On 2019-10-24 00:47, fateme jbr wrote: Dear Python team I have installed Python 3.7.4 on windows 10. I have access to IDLE and I can run simple programs, but when I type python in command window nothing happens. I wanna install pip and afterward some libraries and it is when the problem occurs.

Re: How to decode UTF strings?

2019-10-25 Thread MRAB
On 2019-10-26 03:10, Arne Vajhøj wrote: On 10/25/2019 4:52 PM, DFS wrote: =?iso-8859-9?b?T/B1eg==?= =?utf-8?Q?=EB=AF=B8?= =?GBK?B?0Pu66A==?= =?UTF-8?B?zp3Or866zr/PgiDOks6tz4HOs86/z4I=?= How does something like: from email.header import decode_header def test(s): print(s) s2 =

Re: Installing Python 3.8 on PC with Python 3.7. How to do with version conflicts?

2019-10-28 Thread MRAB
On 2019-10-28 18:27, DL Neil via Python-list wrote: Dottore, On 28/10/19 7:37 AM, Dott. Ugo Donini wrote: I cannot use Python 3.8 on my PC with installed Python 3.7. Is it possible to update the existing Python 3.7 without reinstalling Python 3.8. Conflicts problems. Thankyou Ugo Donini Invia

Re: Installing Python 3.8 on PC with Python 3.7. How to do with version conflicts?

2019-10-28 Thread MRAB
On 2019-10-28 19:42, Terry Reedy wrote: On 10/28/2019 2:47 PM, MRAB wrote: On 28/10/19 7:37 AM, Dott. Ugo Donini wrote: I cannot use Python 3.8 on my PC with installed Python 3.7. Is it possible to update the existing Python 3.7 without reinstalling If you're using Windows, you&#

Re: Calculations and Variables

2019-10-31 Thread MRAB
On 2019-10-31 18:46, ferzan saglam wrote: The code below which I have written should print the result of 43.6 with the given values I have included at the end of this question, but for some odd reason I get the result of 44.44. bill = (input("Enter the total cost of the meal: \n"))

Re: Trouble trying to get started with pygame

2019-10-31 Thread MRAB
On 2019-11-01 03:47, originallmo...@gmail.com wrote: It's been years since I've done anything with Python, and it wasn't a language I was terribly familiar with even then. I'm using Python 3.8 on my Windows 7 laptop. Python itself works so far as I can tell. I can get it to import pip without

Re: Calculations and Variables

2019-11-01 Thread MRAB
On 2019-11-01 12:36, Rhodri James wrote: On 31/10/2019 20:14, MRAB wrote: On 2019-10-31 18:46, ferzan saglam wrote: The code below which I have written should print the result of 43.6 with the given values I have included at the end of this question, but for some odd reason I get the result

Re: Trouble trying to get started with pygame

2019-11-01 Thread MRAB
On 2019-11-02 01:55, originallmo...@gmail.com wrote: On Friday, November 1, 2019 at 1:05:35 AM UTC-4, MRAB wrote: On 2019-11-01 03:47, originallmo...@gmail.com wrote: > It's been years since I've done anything with Python, and it wasn't a language I was terribly familiar w

Re: Trouble trying to get started with pygame

2019-11-01 Thread MRAB
On 2019-11-02 02:28, originallmo...@gmail.com wrote: I tried what you suggested at the command prompt and (Despite being able to open Python from my start menu), it tells me Python isn't installed. I'm curious, and, I probably should have mentioned it earlier: I have Python on my D drive (Beca

Re: Trouble trying to get started with pygame

2019-11-03 Thread MRAB
On 2019-11-04 01:52, originallmo...@gmail.com wrote: On Friday, November 1, 2019 at 11:17:42 PM UTC-4, MRAB wrote: On 2019-11-02 02:28, originallmo...@gmail.com wrote: > I tried what you suggested at the command prompt and (Despite being able to open Python from my start menu), it tells

Re: Trouble trying to get started with pygame

2019-11-04 Thread MRAB
On 2019-11-04 05:21, originallmo...@gmail.com wrote: On Sunday, November 3, 2019 at 9:40:05 PM UTC-5, MRAB wrote: On 2019-11-04 01:52, originallmo...@gmail.com wrote: > On Friday, November 1, 2019 at 11:17:42 PM UTC-4, MRAB wrote: >> On 2019-11-02 02:28, originallmo...@gmail.com wrot

Re: What's the difference between running a script under command box and interpreter?

2019-11-04 Thread MRAB
On 2019-11-04 21:05, Peter J. Holzer wrote: On 2019-11-03 16:34:39 -0800, jf...@ms4.hinet.net wrote: I innocently thought that when import module through "from test import *", I am working on test's globals under REPL. I didn't noticed the REPL has its own globals. Well, you imported every glo

Re: psutil.boot_time() ... doesn't ?

2019-11-06 Thread MRAB
On 2019-11-06 22:53, Terry Reedy wrote: On 11/6/2019 3:09 PM, R.Wieser wrote: Dennis, Depends upon the OS... My apologies, its Linux (as on a Raspberry Pi). I don't know how much Linux is customized for RP, but last I knew, Python on RP is MicroPython, not CPython. So I expect OS-related f

Re: Trouble trying to get started with pygame

2019-11-06 Thread MRAB
On 2019-11-07 02:26, originallmo...@gmail.com wrote: Can py find Python? Did you try to install pygame with: py -m pip install pygame Well, "py -m pip install pygame" has come the closest so far to working. I saw it try to load it and everything, but then, it spat out a series of errors, but

Re: Python 3.8 install

2019-11-07 Thread MRAB
On 2019-11-07 13:52, Daniel wrote: How to install Python 3.8 on top of Python 3.6? Don't do that. If you're using Windows, you install into a separate folder, usually called Python36 for Python 3.6 and Python38 for Python 3.8. -- https://mail.python.org/mailman/listinfo/python-list

Re: nonlocal fails ?

2019-11-14 Thread MRAB
On 2019-11-14 13:06, R.Wieser wrote: Hello all, I've just tried to use a "nonlocal MyVar" statement in a procedure defenition, but it throws an error saying "Syntax error: no binding for nonlocal 'MyVar' found. According to platform.python_version() I'm running version 3.8.3 Why am I getting t

Re: Reading mail getting [, ...

2019-11-14 Thread MRAB
On 2019-11-14 19:43, Abdur-Rahmaan Janhangeer wrote: Greetings, Using this code to read mail. I'm printing to file only mails sent by some people. For some mails i get the body as the below instead of actual text: [, ] instead of the actual mail body. Here is the code: # # import imaplib imp

Re: py2 vs py3: zlib.adler32/crc32

2019-11-14 Thread MRAB
On 2019-11-14 19:22, Karsten Hilbert wrote: Hi all, I am unsure how to solve: I use adler32/crc32 to generate integer values from data for setting up an advisory lock in PostgreSQL. The PG function pg_try_advisory_lock() https://www.postgresql.org/docs/12/functions-admin.html#FUNCTIONS-AD

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread MRAB
On 2019-11-14 20:00, R.Wieser wrote: Dave, Can you expand on what you are trying to accomplish with this? There is a small 433 MHz rf transmitter connected to the pin, and when I send the right pattern a wireless wall-wart will respond and switch a lamp on or off. Its just ment as an exam

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread MRAB
On 2019-11-15 00:37, Dennis Lee Bieber wrote: On Thu, 14 Nov 2019 21:00:59 +0100, "R.Wieser" declaimed the following: :-) I already wrote that program in C{something} (I'm not sure what my Pi offers by default) a while ago, but "ported" it to python. For the above mentioned "example" reaso

Re: Writing a CPython extension - calling another sibbling method ?

2019-11-18 Thread MRAB
On 2019-11-18 07:52, R.Wieser wrote: Hello all, I'm trying to edit a binary extension to Python, and have a situation where I would like to create method which adds a single argument, and than jumps to / calls another method. Like this: static PyObject *py_proc1(PyObject *self, PyObject *args)

Re: Writing a CPython extension - calling another sibbling method ?

2019-11-18 Thread MRAB
On 2019-11-18 20:15, R.Wieser wrote: MRAB, One possibility is to refactor the code so that py_proc1 and py_proc2 themselves just handle their arguments and then call the function that does the actual work. The thing is that the arguments of py_proc1 and py_proc2 are the same, but for a

Re: Recommendations for intro to python+programming lecture to Humanities MA students

2019-11-20 Thread MRAB
On 2019-11-20 21:58, Terry Reedy wrote: On 11/20/2019 11:09 AM, Göktuğ Kayaalp wrote: The first problem is installation: apart from me, a Debian user, everybody has Windows or Mac laptops, and IDK how you install Python on them. The simplest thing is to use the 3.8.0 python.org installers. T

[OT] A conversation with the creator of the world’s most popular programming language on removing brain friction for better work.

2019-11-26 Thread MRAB
Off-topic, but might be of interest: A conversation with the creator of the world’s most popular programming language on removing brain friction for better work. https://blog.dropbox.com/topics/work-culture/-the-mind-at-work--guido-van-rossum-on-how-python-makes-thinking -- https://mail.python.

Re: How to convert the following IDL program lines to equivalent Python program lines?

2019-11-28 Thread MRAB
On 2019-11-28 15:35, Dennis Lee Bieber wrote: On Thu, 28 Nov 2019 12:45:27 +, Ben Bacarisse declaimed the following: Madhavan Bomidi writes: print,'Column ',J,' of product matrix A*AINV:',format='(1X,A7,I3,A27)' I don't know what the 1X format does. The A7 and A27 formats just see

Re: What does the blue color section in background mean?

2019-12-05 Thread MRAB
On 2019-12-05 03:28, lampahome wrote: I tried to plot graph about a time-series with library statsmodel. I decide to plot autocorrelation function, but I don't know the blue section in the example graph mean... Can anyone tell me? The plot_acf example link: https://www.statsmodels.org/dev/gene

Re: ImportError: No module named Adafruit_SSD1306 Update

2019-12-05 Thread MRAB
On 2019-12-05 18:49, RobH wrote: On 05/12/2019 10:07, RobH wrote: On 04/12/2019 23:15, Python wrote: Le 05/12/2019 à 00:06, RobH a écrit : On 04/12/2019 22:33, Wildman wrote: On Wed, 04 Dec 2019 20:25:33 +, RobH wrote: I am trying to do this project on a pi zero: http://frederickvanden

Re: ImportError: No module named Adafruit_SSD1306 Update

2019-12-05 Thread MRAB
On 2019-12-05 20:39, Joel Goldstick wrote: On Thu, Dec 5, 2019 at 3:31 PM RobH wrote: On 05/12/2019 19:40, Rhodri James wrote: > On 05/12/2019 19:30, Rhodri James wrote: >> On 05/12/2019 18:49, RobH wrote: >>> Update: >>> I did python3 Internet.py >>> and now only get this error: >>> >>> pi@ra

Re: ModuleNotFoundError: No module named 'email.mime'; 'email' is not a package

2019-12-08 Thread MRAB
On 2019-12-08 19:13, b...@bbhoyer.com wrote: Just registered Thanks Original Message Subject: ModuleNotFoundError: No module named 'email.mime'; 'email' is not a package From: <[1]b...@bbhoyer.com> Date: Sun, December 08, 2019 11:14 am

Re: Aw: Re: stuck on time

2019-12-08 Thread MRAB
On 2019-12-08 20:34, Michael Torrie wrote: On 12/8/19 11:47 AM, RobH wrote: Err, excuse me, I was not attempting to hack into someone else's code. As the code is in the public domain, I wanted it to work as is, like it did for the author, without changing anything. No worries, you're totally

Re: Python3 - How do I import a class from another file

2019-12-10 Thread MRAB
On 2019-12-10 17:18, R.Wieser wrote: Chris, Okay. What should happen when you do this? x = 5 del x Should the integer 5 be deleted? Yep. What do you think happens instead ? I've not seen you explain or support anything in that regard, not even now. There is a bit of a problem with the a

Re: Python3 - How do I import a class from another file

2019-12-10 Thread MRAB
On 2019-12-10 19:25, R.Wieser wrote: Rhodri, the object that is the integer 5 *isn't* deleted That was not the question. And you're now referring to the object as well as the integer, which makes it confusing. You also have not explained what happens instead. In short, your above statement

Re: Python3 - How do I import a class from another file

2019-12-10 Thread MRAB
On 2019-12-10 21:08, R.Wieser wrote: Chris, Once again, you make positive assertions about things you don't understand. And you have refused to bring any kind of help (explanation!) forward that could have shown me the erring of my ways, as well as refusing to adress my (attempting to explain

Re: Fwd: Problem installing pygame

2019-12-14 Thread MRAB
On 2019-12-14 02:12, Eric Gonzalez wrote: Get Outlook for Android From: Eric Gonzalez Sent: Thursday, December 12, 2019 9:35:40 PM To: python-list@python.org Subject: Problem installing pygame Hello, with the above mentioned i am having

Re: Problem Running Python

2019-12-16 Thread MRAB
On 2019-12-15 14:54, Patrick Igwilo via Python-list wrote: Hello,I downloaded and tried installing Python 3.8.0 on my windows 8.1 PC from the websitewww.python.org/downloadsAfter the 32-bit version was automatically downloaded and I successfully installed same (even though my PC has a 64-bit

Re: strptime for different languages

2019-12-18 Thread MRAB
On 2019-12-18 18:12, Tobiah wrote: What I tried is a cascade of try's: try: d = strptime(date_string, format_string_1) except: try: d = strptime(date_string, format_string_2) except: try: d = strptime(date_string, format_string_3) except: ... This is not

Re: urllib unqoute providing string mismatch between string found using os.walk (Python3)

2019-12-21 Thread MRAB
On 2019-12-22 00:22, Michael Torrie wrote: On 12/21/19 2:46 PM, Ben Hearn wrote: These 2 paths look identical, one from the drive & the other from an xml url: a = '/Users/macbookpro/Music/tracks_new/_NS_2018/J.Staaf - ¡Móchate! _PromoMix_.wav'

Re: problem related to using pip

2020-01-17 Thread MRAB
On 2020-01-17 15:09, Ayush Srivastava wrote: when i was running this code on cmd of latest versin of python3.8.1 i got this error pip install qsharp *output* Unable to create process using 'C:\ProgramData\Anaconda3\python.exe C:\ProgramDa ta\Anaconda3\Scripts\pip-script.py install qsharp' "p

Re: Modify Python code as newbie

2020-01-17 Thread MRAB
On 2020-01-18 00:34, ron.egg...@ecoation.com wrote: Hi, I'm semi new to Python but need to modify a program that calls the mqtt_client.publish() function from aws iot. Now, if the publish function fails, it raises an exception. I need to change the code so that when an exception is raised, i

Re: Sandboxing eval()

2020-01-19 Thread MRAB
On 2020-01-19 17:35, mus...@posteo.org wrote: Is it actually possible to build a "sandbox" around eval, permitting it only to do some arithmetic and use some math functions, but no filesystem acces or module imports? I have an application that loads calculation recipes (a few lines of variable a

Re: tkinter treeview widget - bind doubleclick to items only ?

2020-01-20 Thread MRAB
On 2020-01-20 10:49, R.Wieser wrote: Hello all, I've create a treeview, and would (ofcourse) want to register some mouse-clicking on it, and for that I've found the ".bind()" method. https://stackoverflow.com/questions/3794268/command-for-clicking-on-the-items-of-a-tkinter-treeview-widget Ther

Re: tkinter treeview widget - bind doubleclick to items only ?

2020-01-21 Thread MRAB
On 2020-01-21 06:30, R.Wieser wrote: MRAB, self.treeview.bind('', self.on_dclick) That is what I used. Doubleclicking on the heading caused the "on_dclick" code to execute, though initially the ".identify()" call in my code returns an empty ID (no row pre

Re: Clarification on Immutability please

2020-01-21 Thread MRAB
On 2020-01-22 01:52, Ethan Furman wrote: On 01/21/2020 10:55 AM, Michael Torrie wrote: Slicing returns a new object whether one is slicing a tuple, list, or a string, the latter two are mutable objects. Strings are not mutable. In the case of tuples and strings, if the slicing encompasses th

Re: Threading

2020-01-24 Thread MRAB
On 2020-01-24 21:33, Matt wrote: So I would create 10 threads. And each would pop items off list like so? def start_test(): while big_list: list_item = big_list.pop() print list_item, port sleep(1) port = 80 for i = 1 to 10 t = Thread(target=start_test)

Re: Suggestions on mechanism or existing code - maintain persistence of file download history

2020-01-29 Thread MRAB
On 2020-01-29 20:00, jkn wrote: Hi all I'm almost embarrassed to ask this as it's "so simple", but thought I'd give it a go... I want to be a able to use a simple 'download manager' which I was going to write (in Python), but then wondered if there was something suitable already out ther

Re: Help on dictionaries...

2020-01-29 Thread MRAB
On 2020-01-30 01:51, Michael Torrie wrote: On 1/29/20 6:14 PM, Souvik Dutta wrote: Hey I was thinking how I can save a dictionary in python(obviously) so that the script is rerun it automatically loads the dictionary. You could use the pickle module for that. See the python.org documentation o

Re: I can't access dataframe fields

2020-02-15 Thread MRAB
On 2020-02-16 00:50, Markos wrote: Hi all, I created the following data frame (updated_distance_matrix) P1    P2    P4    P5   (P3, P6) P1 0,00 0,244307 0,367696 0,341760 0 P2 0.234307 0.00 0.194165 0.1443178 0 P4 0.366969 0.194165 0.00 0.28425

Re: python

2020-02-22 Thread MRAB
On 2020-02-22 18:18, lberia...@gmail.com wrote: hi guys can you help me.how to find maximum and minimum in list using while loop python You don't need to use a loop. Use the 'max' and 'min' functions. -- https://mail.python.org/mailman/listinfo/python-list

Re: Friday Finking: Poly more thick

2020-02-29 Thread MRAB
On 2020-03-01 02:08, Christman, Roger Graydon wrote: DL Neil asked: How does one code a function/method signature so that it will accept either a set of key-value pairs, or the same data enclosed as a dict, as part of a general-case and polymorphic solution? Will this do for you? def any_as

Re: Possible Addition to Python Language: Marked Sub-condition

2020-03-08 Thread MRAB
On 2020-03-08 10:05, Shrinivas Kulkarni wrote: Hello Everyone While writing python code, I frequently come across the need to do certain tasks based on combined conditions. Much of the task for all the sub-conditions are common but some are specific to one or more of these sub-conditions. A si

Re: using classes

2020-03-12 Thread MRAB
On 2020-03-12 10:54, joseph pareti wrote: The following code that uses a class 'Fahrzeug' and an inherited class 'PKW' runs correctly. However, if I use the 'super ' statement in in the PKW class, it ends with the following error message: *Traceback (most recent call last): File "erben_a.py",

Re: Multiple comparisons in a single statement

2020-03-12 Thread MRAB
On 2020-03-12 18:08, Chris Angelico wrote: On Fri, Mar 13, 2020 at 4:55 AM Stephen Tucker wrote: A quickie (I hope!). I am running Python 2.7.10 (and, yes, I know, support for it has been withdrawn.) This is the same in Python 3. I have three tuples that have been generated separately and

Re: pyttsx3 installation error

2020-03-13 Thread MRAB
On 2020-03-13 19:52, jlaat...@gmail.com wrote: Got the same error here please help ERROR: Command errored out with exit status 1: command: 'c:\users\jerald lashy jeffery\appdata\local\programs\python\python38-32\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users

Re: [Mostly OT] Feedback on Python homework using Canvas LMS

2020-03-16 Thread MRAB
On 2020-03-16 18:31, Irv Kalb wrote: This is for anyone who teaches Python and uses the Canvas Learning Management System (maybe a small group). I teach Python at two colleges in Silicon Valley in California. At both schools we use Canvas. Overall, it works very well. I use it to post notes

Re: Reduce waiting queue at supermarket from Corona with Python-Webapp

2020-03-16 Thread MRAB
On 2020-03-16 21:55, Barry Scott wrote: On 16 Mar 2020, at 17:38, Orges Leka wrote: Dear Python developers, I am a data scientist and use Python regularly. I have a question: How difficult is it to write a Python web-app, with the following basic functionality: Am I right in thinking that

Re: [Mostly OT] Feedback on Python homework using Canvas LMS

2020-03-17 Thread MRAB
On 2020-03-16 21:49, Grant Edwards wrote: On 2020-03-16, Irv Kalb wrote: I like both suggestions, and will probably go with the non-breaking space (Option space on my Mac). I tested that and it works well. Until somebody tries to cut/paste the snippets you post into a .py file and run them.

Re: Tkinter: which ttk widget for database table primary key?

2020-03-18 Thread MRAB
On 2020-03-18 20:39, Rich Shepard wrote: Subject might be confusing so I'll expand it here. My application uses a database backend in which each table has a unique and database-generated sequential numeric key. I want to display that key in the GUI for that class but it's not entered by the user

Re: ZipFile and timestamps

2020-03-18 Thread MRAB
On 2020-03-18 20:38, Manfred Lotz wrote: I unzip a zip file like follows which works fine. with ZipFile(zip_file, 'r') as zip: zip.extractall(tmp_dir) The only caveat is that the unpacked files and dirs do have a current timestamp i.e. the timestamps of the files are not preserved.

Re: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired in NumPy)

2020-03-19 Thread MRAB
On 2020-03-19 15:17, Musbur wrote: Hello, either it's me or everybody else who's missing the point. I understand the OP's proposal like this: dict[set] == {k: dict[k] for k in set} list[iterable] == [list[i] for i in iterable] Am I right? "Iterable" is too broad because it includes tuples an

Re: queue versus list

2020-03-19 Thread MRAB
On 2020-03-19 20:08, duncan smith wrote: Hello, I have generator code along the following lines, Q = queue.Queue() Q.put(x) while not Q.empty(): x = Q.get() if : yield x else: Q.put() If I change it to, Q = [] Q.append(x) for x in Q: if :

Re: datepicker fails to find firstweekday in calendar

2020-03-20 Thread MRAB
On 2020-03-20 22:43, Rich Shepard wrote: I'm running Python3-3.8.2 on Slackware-14.2/x86_64 and I tried to run Miguel Martinez Lopez's datepicker.py (version 1.0.7) before learning how I can use it in my application. It fails to find the attribute in the imported calendar module: $ python3 datep

Re: Unable to install or operate PIP on Windows 10

2020-03-29 Thread MRAB
On 2020-03-29 23:34, Steven Hobbs wrote: Hi all, I have installed Python 3.7.7 on Windows 10 and I understood that pip came installed. However when I try using pip I get an unrecognised command error. I tried following the instructions on this website: https://docs.python.org/3/installing/ind

Re: how to specify trusted hosts in windows config file

2020-03-30 Thread MRAB
On 2020-03-30 16:25, dcwhat...@gmail.com wrote: Hi, I'm able to get past the CERTIFICATE_VERIFY_FAILED error with various packages by specifying trusted host on the command line. But I can't seem to upgrade pip itself. I keep getting the message "You are using pip version 19.2.3, however

Re: How to instantiate a custom Python class inside a C extension?

2020-04-01 Thread MRAB
On 2020-04-01 13:42, Musbur wrote: Hi guys, I'm wondering how to create an instance of an extension class I wrote. There's a minimal self-contained C module at the bottom of this post which exports two things: 1) a class Series, and 2) a function make_series() which is supposed to create a Serie

Re: Python error

2020-04-02 Thread MRAB
On 2020-04-02 19:09, J Conrado wrote: Hi, I have the version of python installed: Python 3.7.6 and Python 3.8.1 If I type: python Python 3.7.6 (default, Jan  8 2020, 19:59:22) [GCC 7.3.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information. >>> impo

Re: Installation of Camelot

2020-04-14 Thread MRAB
On 2020-04-14 16:20, anson freer wrote: I am a new Python user and using "Installation of Camelot" site I have python 3.7 64bit and Anaconda installed site states The easiest way to install Camelot is to install it with conda, which is a package manager and environment management system for the A

Re: python read line by line and keep indent

2020-04-18 Thread MRAB
On 2020-04-18 08:59, Souvik Dutta wrote: Okay so I was not able to say properly. You are indeed doing the same thing that you were doing i.e. writting the modified data just, that now you don't need to close you if file before doing any writting stuff. That is there is a one line deduction from t

Re: Problem in importing pandas

2020-04-23 Thread MRAB
On 2020-04-23 18:57, Amit Jain wrote: Dear Sir/Madam, After *successful installation of PIP for PANDAS *when I try to *import pandas*, It gives error as given below - import pandas as pd Traceback (most recent call last): File "", line 1, in import pandas as pd File "C:\Users\Ami

Re: Python Installation Problem

2020-05-05 Thread MRAB
On 2020-05-05 23:20, Rhodri James wrote: On 05/05/2020 05:34, Adolf Yoshua Marbun wrote: Dear Python, I am currently learning about Python. First thing first, I need to install the interpreter Python 3.8.2 before I get to the IDE. But, I have problem during running command. The installation wa

Re: Debian Buster: ModuleNotFoundError: No module named 'mysql'

2020-05-07 Thread MRAB
On 2020-05-07 12:30, rackf...@gmail.com wrote: I have the same issue. I use visual code from Ms and the remote debugging over an ssh. I am able to do all mysql while in the debugger but running on command line does not work. The DB is logged in as root as this was the only way I could make it w

Re: basic Python question

2020-05-08 Thread MRAB
On 2020-05-08 20:02, joseph pareti wrote: In general I prefer doing: X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42) >clf = RandomForestClassifier(n_estimators = 100, max_depth= None) *clf_f = clf.fit(X_train, y_train)* predicted_labels = clf_f.pred

Re: basic Python question

2020-05-08 Thread MRAB
Uhr schrieb MRAB mailto:pyt...@mrabarnett.plus.com>>: On 2020-05-08 20:02, joseph pareti wrote: > In general I prefer doing: > > > X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)  

Re: scikit learn problem

2020-05-11 Thread MRAB
On 2020-05-11 16:23, Souvik Dutta wrote: Is that the complete error message? It's a strange traceback because it shows a path with slashes (on Windows?) and a path with backslashes. On Mon, 11 May, 2020, 8:25 pm , wrote: On Monday, 11 May 2020 19:11:59 UTC+4:30, pari...@gmail.com wrote:

Re: php to python code converter

2020-05-14 Thread MRAB
On 2020-05-13 17:53, Palash Bauri wrote: That gives a 404 🤷‍♂️, you sure , you pasted the right link ? ~Palash Bauri On Wed, 13 May 2020, 9:07 pm , wrote: On Friday, 8 May 2009 16:08:25 UTC+5:30, bvidinli wrote: > if anybody needs: > http://code.google.com/p/phppython/ $username = "usernam

Re: Multithread and locking issue

2020-05-14 Thread MRAB
On 2020-05-14 23:36, Stephane Tougard wrote: Hello, A multithreaded software written in Python is connected with a Postgres database. To avoid concurrent access issue with the database, it starts a thread who receive all SQL request via queue.put and queue.get (it makes only insert, so no issu

Re: RV: CodecRegistryError problem for an IDE.

2020-05-15 Thread MRAB
On 2020-05-15 18:53, Bryan Cabrera Ramírez wrote: Hi, I'm trying to insall an INET package for an IDE called OMNeT++ and when I try to build the INET the following happens in the command window: Fatal Python error: Py_Initialize: unable to load the file s

Re: Help with installation please

2020-05-15 Thread MRAB
On 2020-05-15 05:18, Jhoana Kacheva Melissa Joseph wrote: Hello, I downloaded python 3.8 in my windows, I selected the box for the path but when I try to run it in powershell it brought me to app store to get it again. How are you running Python? What are you putting on the command line? When

<    10   11   12   13   14   15   16   17   18   19   >