Observations on the List - "Be More Kind"
I will declare at the outset, I am a lurker. I don't know enough about Python to give advice that I could 100% guarantee would be helpful. There have been two recent threads that summarise for me where the Python Mailing List has lost its way (and this started before Trump arrived as a new role model for how to treat your fellow man): "Re: This thread is closed [an actual new thread]" "Re: So apparently I've been banned from this list" The level of vitriol and personal attacks on the moderators was profoundly disappointing, but not totally out of character for those who made the attacks. There is no doubt that these people know software and Python and this certainly earns my respect, but perhaps they need to retain a sense of perspective. There are 7 billion people in the world. There are plenty more people at least as good as you and many better, but they don't have the compelling urge to demonstrate their genius. They get on with their work in a quiet professional manner. Some humility in acknowledging that you stand on the shoulders of giants would not go amiss. It might also reflect that you understand the good fortune that dealt you such a good hand in life. You aren't always right, and you don't always have to insist on being right. I found Steve D'Aprano always had to have the last word and had to prove he was right. I found some of his posts to be intemperate in tone. Why is there a need to score points with caustic remarks or throwaway comments? Perhaps the person who posed his question should have read the documents, perhaps he should have searched the archives. Tell them so politely and firmly. If you cannot manage that then why say anything? Not everyone who posts a poorly prepared question is idle and deserves a response that is less than polite. Prepare a boilerplate standard reply that is polite for those questions that are easily resolved by the poster. Perhaps the person who posts something you regard as nonsense is ignorant and lacks the knowledge they think they possess. Instead of wasting your time with scholastic debate, put the time to good use improving your education in subjects you don't excel at. I can guarantee the depth of your ignorance will be profound - there will be much for you to learn. The effort some of you put in to the endless debates suggests that you have plenty of time on your hands - don't waste it. It will be gone soon enough. Don't waste time on the trolls, some of whom undoubtedly enjoy the ability to provoke a response. Develop a greater sense of self awareness to enable you to recognise that you are being played. The intemperate tone of some of the exchanges damages the reputation of the List. Life is hard enough without us adding to it. Try silence as a response. Listen to Frank Turner's latest album: "Be More Kind". That is not a plug to buy the album, but the title seems apposite - and the music is good. Regards Bruce Coram -- https://mail.python.org/mailman/listinfo/python-list
Solved: pip hangs after successful operation (sandboxed environment problem)
It turns out that Comodo Antivirus auto-sandboxes any program that it doesn’t recognize, and this included python in the C:\Users\$user\AppData\Programs directory. This also affects Cygwin and MSYS2 (but not MSYS). If you are thinking about using Comodo, disable the Auto-Containment feature. Alternately, you may try to add the folder locations to the white-list, but this didn’t work for me. Have a nice day, Ryan Sent from Mail for Windows 10 -- https://mail.python.org/mailman/listinfo/python-list
Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to
On Wednesday, June 13, 2018 at 7:14:06 AM UTC-4, INADA Naoki wrote: > > 1st is this script is from a library module online open source > > If it's open source, why didn't you show the link to the soruce? > I assume your code is this: > > https://github.com/siddharth2010/String-Search/blob/6770c7a1e811a5d812e7f9f7c5c83a12e5b28877/createIndex.py > > And self.collFile is opened here: > > https://github.com/siddharth2010/String-Search/blob/6770c7a1e811a5d812e7f9f7c5c83a12e5b28877/createIndex.py#L91 > > You need to add `encoding='utf-8'` argument. OCT 5TH 2018 new question to the Google forum Hello mr naoki thank you for your contributions to the Platform to be able to post questions ...I have a django project and it's slightly different from all django project videos I see on the Net ...I have a docs folder right next to the templates folder. ..in the docs folder I have text files. ...when i update or add text document files in the shell console and I follow all your steps to save and migrate and migrations. .it doesn't add the text file to the docs folder and when i look up the words on my browser page , in a lookfor/search box. just like yours, it only returns the original text files. ..not the text file I added or any modifications i made to the original txt files. .even though if I go back to the python shell console and I can query the new added text file. .it's there.how can I solve this? ?? PS not sure if this is related..as i try to solve this..i cant seem to run a specific module/file in my mainwebapp folder.the filter_docs.py.in that file i have from filter.docs.py import Document..but i will get a module not found filter_docs...so i changed it to from . models import Document...and i will __main__ not a packagemodels.py and filter_docs.py are both in mainwebapp folder...i am trying to run this specific file cuz i think this may solve my docs folder not updating .txt files that i addin the filter_docs.py i have my functions that parse the words/terms in the docs folder...but it doesnt as i said when i made additions...i do see a line in 2 functions that says...# Run once if DocFrequency.objects.all().exists(): return so im thinking if i comment out this conditionel.. will it update my additons when i actually go to my website browser and do a lookup or search for terms in my docs folder?? sorry for the long email Jessica -- https://mail.python.org/mailman/listinfo/python-list
Python indentation (3 spaces)
I am new to Python programming but have significant SQL and C experience. My simple question is,"Why not standardize Python indentations to 3 spaces instead of 4 in order to avoid potential programming errors associated with using "TAB" instead of 4 spaces?" Thoughts? Thomas -- https://mail.python.org/mailman/listinfo/python-list
Re: Python indentation (3 spaces)
On Sat, Oct 6, 2018 at 6:51 AM wrote: > >I am new to Python programming but have significant SQL and C experience. > My simple question is,"Why not standardize Python indentations to 3 spaces > instead of 4 in order to avoid potential programming errors associated with > using "TAB" instead of 4 spaces?" > Thoughts? I don't understand how three spaces would prevent errors in a way that four wouldn't. But you're absolutely welcome to standardize all of your own code on indenting with tabs instead of spaces, or two space indents, or three, or four, or seventeen if you so desire. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python indentation (3 spaces)
05.10.18 23:53, Chris Angelico пише: I don't understand how three spaces would prevent errors in a way that four wouldn't. In many editors and on terminal for a in x: if a: b() <-tab-->c() looks indistinguishable from for a in x: if a: b() c() but the former is a syntax error in Python 3. If use 3-space indentation this error is more visible: for a in x: if a: b() <-tab-->c() -- https://mail.python.org/mailman/listinfo/python-list
Re: Python indentation (3 spaces)
On Sat, Oct 06, 2018 at 12:23:49AM +0300, Serhiy Storchaka wrote: > > I don't understand how three spaces would prevent errors in a way that > > four wouldn't. > In many editors and on terminal > > for a in x: > if a: > b() > <-tab-->c() > > looks indistinguishable from > > for a in x: > if a: > b() > c() > > but the former is a syntax error in Python 3. > > If use 3-space indentation this error is more visible: > > for a in x: >if a: > b() > <-tab-->c() That is only incidental because the "width" of a tab stop is what you define it to be. On my system it might just be 3 spaces which would turn your argument on its head. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B -- https://mail.python.org/mailman/listinfo/python-list
Re: Python indentation (3 spaces)
On Sat, Oct 6, 2018 at 7:25 AM Serhiy Storchaka wrote: > > 05.10.18 23:53, Chris Angelico пише: > > I don't understand how three spaces would prevent errors in a way that > > four wouldn't. > In many editors and on terminal > > for a in x: > if a: > b() > <-tab-->c() > > looks indistinguishable from > > for a in x: > if a: > b() > c() > > but the former is a syntax error in Python 3. Considering that 8-space tabs are at least as common as 4-space, and that tabs measured in millimeters are also entirely viable, I don't think there's any way to define this perfectly consistently. It depends entirely on the particular setup that you have, and therefore is perfect for a per-project style guide. But hey. It's an instant syntax error. It's not exactly hard to fix. Some editors (including the one I use - SciTE) will highlight mismatched indentation right there as you type. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python indentation (3 spaces)
On 10/5/2018 4:48 PM, [email protected] wrote: I am new to Python programming but have significant SQL and C experience. My simple question is,"Why not standardize Python indentations to 3 spaces instead of 4 in order to avoid potential programming errors associated with using "TAB" instead of 4 spaces?" IDLE (and other modern editors and IDEs) turns a typed TAB into a user-settable n spaces, where n defaults to 4 (minimum 2, maximum 16). -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
How to await multiple replies in arbitrary order (one coroutine per reply)?
I am using asyncio and am fairly new to it. I have a stream to which I write commands and from which I read replies. (In this case the stream is custom wrapper around DDS written in C++ and pybind11). Multiple commands can run at the same time and I cannot predict which will finish first. I need aa different coroutine (or asyncio.Task or other awaitable object) for each command that is running. Is there a simple way to handle this in asyncio? So far the best I have come up is the following (greatly simplified), which works but has some misfeatures: import asyncio from iolib import read_reply, write_command, TIMED_OUT class RemoteCommand: def __init__(self): self._tasks = dict() def start(self, cmd, timeout): """Start a command""" cmd_id = write_command(cmd) task = asyncio.ensure_future(self._wait_for_command(cmd_id=cmd_id, timeout=timeout)) self._tasks[cmd_id] = task if len(self._tasks) == 1: asyncio.ensure_future(self._handle_replies()) return task async def _wait_for_command(self, cmd_id, timeout): """Wait for a command to finish""" await asyncio.sleep(timeout) if cmd_id in self._tasks: del self._tasks[cmd_id] return TIMED_OUT # our standard end code for timeouts async def _handle_replies(self): while True: cmd_id, end_code = read_reply() if cmd_id in self._tasks: task = self._tasks.pop(cmd_id) task.set_result(end_code) if not self._tasks: return await asyncio.sleep(0.1) Misfeatures include: - asyncio.Task is not documented to have a "set_result" method. The documentation says that Task is "A Future-like object that runs a Python coroutine" and Future does have such a method. - When "_handle_replies" calls "task.set_result(data)" this does not seem to cancel the "await asyncio.sleep(timeout)" in the task, resulting in scary messages to stdout. I have tried saving *that* as another task and canceling it, but it seems clumsy and I still see scary messages. I think what I'm looking for is a task-like thing I can create that I can end when *I* say it's time to end, and if I'm not quick enough then it will time out gracefully. But maybe there's a simpler way to do this. It doesn't seem like it should be difficult, but I'm stumped. Any advice would be appreciated. -- Russell -- https://mail.python.org/mailman/listinfo/python-list
Re: Python indentation (3 spaces)
The point that OP is trying to make is that a fixed standard that is distinguishable from the even-spacing Tab-length convention in code and text editors will establish a level of trust between the end developer and upstream developers or co-developers who may not have the same development environment. For example, the first Python library I ever tried to use was poorly maintained and had spaces on one line with tabs on the next, and the author mixed naming conventions and syntax from Python 2 and 3 in his code. That type of experience doesn’t exactly instill trust in the coding language’s standards, when a noob tries to use a library they found and ends up having to debug weird errors with weirder error messages on the first project they do. Flexibility is great until the learning curve comes into play. That said, there is an easy fix for tab misuse: in Visual Studio Code, you can replace all Tabs with Spaces by highlighting the entire code block, hitting Tab once and Shift-Tab after. Peace Ryan On Fri, Oct 5, 2018 at 4:51 PM Terry Reedy wrote: > On 10/5/2018 4:48 PM, [email protected] wrote: > > I am new to Python programming but have significant SQL and C > experience. My simple question is,"Why not standardize Python indentations > to 3 spaces instead of 4 in order to avoid potential programming errors > associated with using "TAB" instead of 4 spaces?" > > IDLE (and other modern editors and IDEs) turns a typed TAB into a > user-settable n spaces, where n defaults to 4 (minimum 2, maximum 16). > > -- > Terry Jan Reedy > > -- > https://mail.python.org/mailman/listinfo/python-list > -- Ryan Johnson -- https://mail.python.org/mailman/listinfo/python-list
Re: asyncio await different coroutines on the same socket?
On Oct 3, 2018, Ian Kelly wrote (in article): > On Wed, Oct 3, 2018 at 7:47 AM Russell Owen wrote: > > Using asyncio I am looking for a simple way to await multiple events where > > notification comes over the same socket (or other serial stream) in > > arbitrary > > order. For example, suppose I am communicating with a remote device that can > > run different commands simultaneously and I don't know which command will > > finish first. I want to do this: > > > > coro1 = start(command1) > > coro2 = start(command2) > > asyncio.gather(coro1, coro2) > > > > where either command may finish first. I’m hoping for a simple and > > idiomatic way to read the socket and tell each coroutine it is done. So far > > everything I have come up with is ugly, using multiple layers of "async > > def”, keeping a record of Tasks that are waiting and calling "set_result" > > on those Tasks when finished. Also Task isn’t even documented to have the > > set_result method (though "future" is) > > Because Tasks are used to wrap coroutines, and the result of the Task > should be determined by the coroutine, not externally. > > Instead of tracking tasks (that's what the event loop is for) I would > suggest tracking futures instead. Have start(command1) return a future > (or create a future that it will await on itself) that is not a task. > Whenever a response from the socket is parsed, that code would then > look up the corresponding future and call set_result on it. It might > look something like this: > > class Client: > async def open(self, host, port): > self.reader, self.writer = await asyncio.open_connection(host, port) > asyncio.create_task(self.read_loop()) > > async def read_loop(self): > while not self.reader.at_eof(): > response = self.reader.read() > id = get_response_id(response) > self._futures.pop(id).set_result(response) > > def start(self, command): > future = asyncio.Future() > self._futures[get_command_id(command)] = future > self.writer.write(command) > return future > > In this case start() is not a coroutine but its result is a future and > can be awaited. That is exactly what I was looking for. Thank you very much! -- Russell (My apologies for double posting -- I asked this question again today because I did not think my original question -- this one -- had gone through). -- https://mail.python.org/mailman/listinfo/python-list
