Re: How to print out html tags excluding the attributes

2019-07-22 Thread Rhodri James
On 21/07/2019 02:04, sum abiut wrote: I want to use regular expression to print out the HTML tags excluding the attributes. That's a very good way of creating hard-to-read code and introducing subtle bugs and unexpected behaviours. Try using an HTML parser like BeautifulSoup instead. -- Rh

Cool Mailing List For Article Writers

2019-07-22 Thread Abdur-Rahmaan Janhangeer
Greetings all, There is a really nice list for people writing about Python. Share your latest articles and get reviews ^^_ Link: https://mail.python.org/mailman/listinfo/python-authors Abdur-Rahmaan Janhangeer Mauritius -- https://mail.python.org/mailman/listinfo/python-list

asyncio, transports, protocols, etc.

2019-07-22 Thread Hugh Sasse
Hello, I'm trying to get my head around asyncio, and I think I'm mostly there now, (but expect to be proved wrong :-)!). It appears to be about the newest of the PEPs according to my searches, including PEP 0, so I don't expect a huge amount of supporting documentation out there yet. Lookin

Re: Proper shebang for python3

2019-07-22 Thread Tim Daneliuk
On 7/20/19 4:28 PM, Brian Oney wrote: > Why not make a compromise? What would be a potential pitfall of the > following spitbang? > > #!python Not sure this really changes the discussion. -- https://mail.python.org/mailman/listinfo/python-list

Google Search results pointing to Python 2 (most of the time)

2019-07-22 Thread Santiago Basulto
Hello community, this is my first email to this list. Sorry if this sounds dumb, but anytime I do a google search I notice that the first result is from Python 2 docs. I always have to remind my students about it, and sometimes I even trip myself. [image: image.png] With the deprecation of Py2 so

List comprehension strangeness

2019-07-22 Thread Nicholas Cole
I was profiling a slow function in an application last week, and came across something that I still can’t explain. Inside a loop that was being called 4 times, inside a for loop that ran for a few dozen times there was a list compression of the form: [x.id for x in some_function()] According to t

Re: List comprehension strangeness

2019-07-22 Thread Calvin Spealman
It is impossible to diagnose without seeing more context. Specifically, you'll need to share the code around this line. The whole function, preferably. On Mon, Jul 22, 2019 at 9:31 AM Nicholas Cole wrote: > I was profiling a slow function in an application last week, and came > across something

Re: List comprehension strangeness

2019-07-22 Thread Bob Gailer
The function IMHO must be returning a generator. I would look for a problem in the generator code. -- https://mail.python.org/mailman/listinfo/python-list

Re: List comprehension strangeness

2019-07-22 Thread Chris Angelico
On Mon, Jul 22, 2019 at 11:33 PM Nicholas Cole wrote: > > I was profiling a slow function in an application last week, and came > across something that I still can’t explain. Inside a loop that was being > called 4 times, inside a for loop that ran for a few dozen times there was > a list compress

Re: Embedding Python in C

2019-07-22 Thread Jesse Ibarra
On Saturday, July 20, 2019 at 1:11:51 PM UTC-6, Stefan Behnel wrote: > Jesse Ibarra schrieb am 20.07.19 um 04:12: > > Sorry, I am not understanding. Smalltlak VW 8.3 does not support Python. > > I can only call Pyhton code through C/Python API. > > Ok, but that doesn't mean you need to write code

Re: List comprehension strangeness

2019-07-22 Thread Bob Gailer
The length of the list produced by the comprehension also give you good information. -- https://mail.python.org/mailman/listinfo/python-list

Transfer Image from Raspberry Pi (Python) to Android app (Java)

2019-07-22 Thread rkartunova--- via Python-list
Hi everyone! I need help transferring an image via TCP from a python program on my raspberry pi to an android application. I have set up a client-server architecture such that my raspberry pi 3 records audio, performs some analysis on it, and then sends the data (via TCP) to the android app to

Re: Extendable Enum like Type?

2019-07-22 Thread Ethan Furman
On 07/19/2019 01:23 AM, Antoon Pardon wrote: I don't seem to have made myself clear. The grammar with its Terminals and NonTerminals is read in from a file. The program doesn't know what they will be. For the moment what I am thinking about is something as follows: grammar = LoadGrammer(Gramma

Creating time stamps

2019-07-22 Thread Michael F. Stemper
I have some code that generates a time-stamp as follows: from datetime import datetime tt = datetime.now() timestamp = "%4d-%02d-%02d %02d:%02d" % \ (tt.year, tt.month, tt.day, tt.hour, tt.minute) I later realized that I could have written it as: from datetime import datetime from

Re: Creating time stamps

2019-07-22 Thread Chris Angelico
On Tue, Jul 23, 2019 at 6:34 AM Michael F. Stemper wrote: > > I have some code that generates a time-stamp as follows: > > from datetime import datetime > tt = datetime.now() > timestamp = "%4d-%02d-%02d %02d:%02d" % \ > (tt.year, tt.month, tt.day, tt.hour, tt.minute) > > I later realize

Re: Creating time stamps

2019-07-22 Thread Skip Montanaro
Assuming you're using Python 3, why not use an f-string? >>> dt = datetime.datetime.now() >>> dt.strftime("%Y-%m-%d %H:%M") '2019-07-22 16:10' >>> f"{dt:%Y-%m-%d %H:%M}" '2019-07-22 16:10' Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: Proper shebang for python3

2019-07-22 Thread Eli the Bearded
In comp.lang.python, Tim Daneliuk wrote: > On 7/20/19 1:20 PM, Chris Angelico wrote: > > On Sun, Jul 21, 2019 at 4:13 AM Michael Speer wrote: > >> You may want to use `#!/usr/bin/env python3` instead. I no longer have one to verify, but I recall Solaris boxen used /bin/env not /usr/bin/env. >

Re: Proper shebang for python3

2019-07-22 Thread אורי
We are using `#!/usr/bin/env python`, for example on https://github.com/speedy-net/speedy-net/blob/master/speedy/core/manage.py For bash we are using `#!/usr/bin/env bash`. I don't know if those are the best but they work. אורי u...@speedy.net On Sat, Jul 20, 2019 at 9:12 PM Michael Speer wrot

Re: Creating time stamps

2019-07-22 Thread Albert-Jan Roskam
On 22 Jul 2019 23:12, Skip Montanaro wrote: Assuming you're using Python 3, why not use an f-string? >>> dt = datetime.datetime.now() >>> dt.strftime("%Y-%m-%d %H:%M") '2019-07-22 16:10' >>> f"{dt:%Y-%m-%d %H:%M}" '2019-07-22 16:10' ===》》 Or if you're running < Python 3.6 (no f strings): form

Re: Creating time stamps

2019-07-22 Thread Michael F. Stemper
On 22/07/2019 15.58, Chris Angelico wrote: > On Tue, Jul 23, 2019 at 6:34 AM Michael F. Stemper > wrote: >> >> I have some code that generates a time-stamp as follows: >> >> from datetime import datetime >> tt = datetime.now() >> timestamp = "%4d-%02d-%02d %02d:%02d" % \ >> (tt.year, tt.

Re: Creating time stamps

2019-07-22 Thread Grant Edwards
On 2019-07-22, Michael F. Stemper wrote: >>> from datetime import datetime >>> from time import strftime >>> timestamp = datetime.now().strftime( "%Y-%m-%d %H:%M" ) [...] > Apparently, the strftime() in that last line is not the one that I > explicitly imported, but a method of datetime.now

Re: Creating time stamps

2019-07-22 Thread MRAB
On 2019-07-22 22:41, Grant Edwards wrote: On 2019-07-22, Michael F. Stemper wrote: from datetime import datetime from time import strftime timestamp = datetime.now().strftime( "%Y-%m-%d %H:%M" ) [...] Apparently, the strftime() in that last line is not the one that I explicitly importe

Re: Creating time stamps

2019-07-22 Thread Michael F. Stemper
On 22/07/2019 16.00, Stefan Ram wrote: > "Michael F. Stemper" writes: >> The first seems a little clunky with its accessing of multiple >> attributes, but the second has an additional import. Is there >> any reason to prefer one over the other? > > |>>> import datetime > |>>> datetime.datetime.no

Re: List comprehension strangeness

2019-07-22 Thread Gregory Ewing
Nicholas Cole wrote: [x.id for x in some_function()] According to the profiler, some_function was being called 52,000 times Is some_function recursive, by any chance? -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Namespaces: memory vs 'pollution'

2019-07-22 Thread Ethan Furman
On 07/20/2019 05:02 PM, DL Neil wrote: Upon closer inspection, I realised it didn't just fail; it failed badly! Some silly, little, boy had imported the PythonEnvironment class but failed to ALSO import PythonVersionError. So, the reported error was not the expected exception! I don't under

Re: Proper shebang for python3

2019-07-22 Thread Cameron Simpson
On 22Jul2019 21:14, Eli the Bearded <*@eli.users.panix.com> wrote: In comp.lang.python, Tim Daneliuk wrote: On 7/20/19 1:20 PM, Chris Angelico wrote: > On Sun, Jul 21, 2019 at 4:13 AM Michael Speer wrote: >> You may want to use `#!/usr/bin/env python3` instead. I no longer have one to verif

Re: Proper shebang for python3

2019-07-22 Thread Cameron Simpson
On 23Jul2019 00:19, אורי wrote: We are using `#!/usr/bin/env python`, for example on https://github.com/speedy-net/speedy-net/blob/master/speedy/core/manage.py For bash we are using `#!/usr/bin/env bash`. I don't know if those are the best but they work. Worthwhile. Plenty of platforms do not

Re: Transfer Image from Raspberry Pi (Python) to Android app (Java)

2019-07-22 Thread Gregory Ewing
rkartun...@yahoo.com wrote: This code does successfully read in the bytes until there are around 2000-3000 bytes left to be read and then it seems to freeze on the int bytes_read = in.read(msg_buff, 0, msg_buff.length) line. This happens because you're trying to read more bytes than the sender

Re: Namespaces: memory vs 'pollution'

2019-07-22 Thread Thomas Jollans
On 22/07/2019 07.06, DL Neil wrote: > > Current thoughts: > > import environment_module as em > > - so, even more of an abbreviation than suggested!? > - I rarely need to write a long list of import statements, so there > won't be many. > - not normally using such abbreviations in my code, they

Re: Namespaces: memory vs 'pollution'

2019-07-22 Thread DL Neil
On 23/07/19 11:00 AM, Ethan Furman wrote: On 07/20/2019 05:02 PM, DL Neil wrote: Upon closer inspection, I realised it didn't just fail; it failed badly! Some silly, little, boy had imported the PythonEnvironment class but failed to ALSO import PythonVersionError. So, the reported error was n

Nesting Custom Errors in Classes

2019-07-22 Thread DL Neil
Do you use nested classes? [following-on from the earlier, "Namespaces: memory vs 'pollution'" discussion thread, wherein a certain 'someone' remembered to from ... import ... as ... an 'action' class but forgot to also import the related custom error class! The original quest was for a wild-c

Re: Namespaces: memory vs 'pollution'

2019-07-22 Thread DL Neil
On 22/07/19 9:40 PM, Thomas Jollans wrote: On 22/07/2019 07.06, DL Neil wrote: Current thoughts: import environment_module as em - so, even more of an abbreviation than suggested!? - I rarely need to write a long list of import statements, so there won't be many. - not normally using suc