Re: While, If, Count Statements
On Tuesday, November 28, 2017 at 6:09:17 AM UTC+8, Ned Batchelder wrote: > On 11/27/17 7:54 AM, Cai Gengyang wrote: > > Input : > > > > count = 0 > > > > if count < 5: > >print "Hello, I am an if statement and count is", count > > > > while count < 10: > >print "Hello, I am a while and count is", count > >count += 1 > > > > Output : > > > > Hello, I am an if statement and count is 0 > > Hello, I am a while and count is 0 > > Hello, I am a while and count is 1 > > Hello, I am a while and count is 2 > > Hello, I am a while and count is 3 > > Hello, I am a while and count is 4 > > Hello, I am a while and count is 5 > > Hello, I am a while and count is 6 > > Hello, I am a while and count is 7 > > Hello, I am a while and count is 8 > > Hello, I am a while and count is 9 > > > > The above input gives the output below. Why isn't the output instead : > > > > Hello, I am an if statement and count is 0 > > Hello, I am a while and count is 0 > > Hello, I am an if statement and count is 1 > > Hello, I am a while and count is 1 > > Hello, I am an if statement and count is 2 > > Hello, I am a while and count is 2 > > Hello, I am an if statement and count is 3 > > Hello, I am a while and count is 3 > > Hello, I am an if statement and count is 4 > > Hello, I am a while and count is 4 > > Hello, I am a while and count is 5 > > Hello, I am a while and count is 6 > > Hello, I am a while and count is 7 > > Hello, I am a while and count is 8 > > Hello, I am a while and count is 9 > > It's easy to imagine that this sets up a rule that remains in effect for the > rest of the program: > > â â â if count < 5: > â â â â â â â print "Hello, I am an if statement and count is", count > > But that's not how Python (and most other programming languages) works.â > Python > reads statements one after another, and executes them as it encounters > them.â > When it finds the if-statement, it evaluates the condition, and if it is true > *at that moment*, it executes the contained statements.â Then it forgets all > about that if-statement, and moves on to the next statement. > > --Ned. Sure, so how would the code look like if I want the "if" statement to be nested inside the "while" loop and give me the result : Hello, I am an if statement and count is 0 Hello, I am a while and count is 0 Hello, I am an if statement and count is 1 Hello, I am a while and count is 1 Hello, I am an if statement and count is 2 Hello, I am a while and count is 2 Hello, I am an if statement and count is 3 Hello, I am a while and count is 3 Hello, I am an if statement and count is 4 Hello, I am a while and count is 4 Hello, I am a while and count is 5 Hello, I am a while and count is 6 Hello, I am a while and count is 7 Hello, I am a while and count is 8 Hello, I am a while and count is 9 -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I send keystrokes to a console window in Windows XP?
On Saturday, July 16, 2005 at 2:46:34 PM UTC+2, Benji York wrote: > googlegro...@garringer.net wrote: > > How do I use Python to send keystrokes to a console window in Windows > > XP? > > import win32com.client > > shell = win32com.client.Dispatch("WScript.Shell") > shell.AppActivate("Command Prompt") > > shell.SendKeys("cls{ENTER}") > shell.SendKeys("dir{ENTER}") > shell.SendKeys("echo Hi There{ENTER}") > -- > Benji York Hey! Do you have any idea on how to open 2 command panels at the same time and that every command would write to 1 command panel and other command to 2 command panel, when i tried to do something like this: shell.run("cmd") shell2.run("cmd") shell.AppActivate("cmd") time.sleep(5) shell.SendKeys('ffmpeg -y -f dshow -i video="Logitech HD Webcam C270" kamera'+datestring+'.mp4') shell2.SendKeys("xxxc{ENTER}") time.sleep(1) shell.SendKeys("{ENTER}") time.sleep(2) ffmpeg -y -f dshow -i ffmpeg -y -f dshow -i video="Logitech HD Webcam C270" kamera.mp4video="Logitech HD Webcam C270" kamera.mp4 shell.SendKeys('^c') time.sleep(2) shell.SendKeys('exit') time.sleep(1) shell.SendKeys("{ENTER}")''' everything gets in random places -- https://mail.python.org/mailman/listinfo/python-list
Re: While, If, Count Statements
"Cai Gengyang" wrote in message news:c2dfc9c4-3e16-480c-aebf-553081775...@googlegroups.com... Sure, so how would the code look like if I want the "if" statement to be nested inside the "while" loop Have you tried putting the 'if' statement inside the 'while' loop? If not, give it a shot and see what happens. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list
Re: Increasing the diversity of people who write Python (was: Benefits of unicode identifiers)
On 27 November 2017 at 19:05, Paul Moore wrote: > On 27 November 2017 at 18:13, Skip Montanaro wrote: >>> If you have a Windows key, you can assign it to be >>> the Compose key. >> >> Would this be true on a machine running Windows? My work environment >> has me developing on Linux, with a Windows desktop. It's not clear to >> me that any sort of xmodmap shennanigans would work. Won't Windows >> itself always gobble up that key? > > Programs can access the Windows key. IIRC, there is a utility that > provides compose-key functionality on Windows. I can't recall the name > right now and it's on my other PC, not this one, but I'll try to > remember to post the name tomorrow... WinCompose was the program - https://github.com/samhocevar/wincompose Paul -- https://mail.python.org/mailman/listinfo/python-list
Re: Increasing the diversity of people who write Python
On 28/11/2017 08:41, Paul Moore wrote: On 27 November 2017 at 19:05, Paul Moore wrote: On 27 November 2017 at 18:13, Skip Montanaro wrote: If you have a Windows key, you can assign it to be the Compose key. Would this be true on a machine running Windows? My work environment has me developing on Linux, with a Windows desktop. It's not clear to me that any sort of xmodmap shennanigans would work. Won't Windows itself always gobble up that key? Programs can access the Windows key. IIRC, there is a utility that provides compose-key functionality on Windows. I can't recall the name right now and it's on my other PC, not this one, but I'll try to remember to post the name tomorrow... WinCompose was the program - https://github.com/samhocevar/wincompose And, if you wanted a Python-y solution: http://timgolden.me.uk/python/win32_how_do_i/catch_system_wide_hotkeys.html TJG -- https://mail.python.org/mailman/listinfo/python-list
python training in chennai & bangalore
Besant Technologies Chennai & Bangalore you will be able to get vast experience by transforming your ideas into actual new application and software controls for the websites and the entire computing enterprise. To make it easier for you Besant Technologies at Chennai & Bangalore is visualizing all the materials you want.Start brightening your career with us https://www.besanttechnologies.com/training-courses/python-training-institute-in-bangalore https://www.besanttechnologies.com/training-courses/python-training-institute-in-chennai -- https://mail.python.org/mailman/listinfo/python-list
Re: How to shut down a TCPServer serve_forever() loop?
On Tue, Nov 28, 2017 at 5:04 PM, Marko Rauhamaa wrote: > Ian Kelly : > >> On Sat, Nov 25, 2017 at 7:10 AM, John Pote >> wrote: >>> The issue is that if I press a key on the keyboard the key is >>> immediately shown on the screen but then the shutdown() call blocks >>> until another TCP connection is made, text is echoed back and only >>> then does serve_forever()return followed by shutdown()returning as >>> can be seen from the console session, >> [...] >> Make a connection to the server after calling shutdown to wake up the >> server's event loop? I'm guessing it only checks the shutdown flag >> after responding to an event, so there's probably not much else you >> could do. > > Seems to be one of the fundamental multithreading issues: each thread is > blocked on precisely one event. Asyncio is more flexible: you can > multiplex on a number of events. Not really, no. Unless select() counts as "precisely one event", of course. http://man7.org/linux/man-pages/man2/select.2.html https://en.wikipedia.org/wiki/Select_(Unix) That's the normal way for a thread to block on multiple events on a Unix system. Windows has its own approximate equivalent. Surprise, surprise, that's also how event loops often implemented. Including ones used in packages like asyncio. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Increasing the diversity of people who write Python (was: Benefits of unicode identifiers)
On 2017-11-24 17:41, Skip Montanaro wrote: > Perhaps for my next computer I should choose a > non-ASCII keyboard option when configuring it. > > Skip > I'm quite fond of the US international keyboard layout. It lets you type most Latin-lettered languages with relative ease (including, obviously, the few accented letters used in English). It's conveniently available (and almost identical) on all (major) operating systems, but alas Windows only has a dead-keys variant built in. (But I believe you can download a no-dead-keys variant somewhere) It's nice because (with a no-dead-keys version) unless you press AltGr, everything's the same as with a traditional US keyboard (which is not entirely suitable for the English language on its own). On Windows machines I only use occasionally (and may not have admin rights on) I tend to set up both "US" and "US international" keyboard layouts and switch between them depending on what I'm typing. It's not ideal, but it's better than either programming being a pain in the arse (with all the dead keys) or not being able to type natural-language words properly. -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list
Re: nospam ** infinity?
On 2017-11-28 02:14, Skip Montanaro wrote: >> I'm 99.5% certain it's not gate_news. > > A funny thing. All messages I have looked at so far with the "nospam" > thing have a Message-ID from binkp.net. (They are also all Usenet > posts.) For example: > > Newsgroups: comp.lang.python > Subject: Re: I have anaconda, but Pycharm can't find it > Date: Sun, 26 Nov 2017 22:40:00 +1200 > Organization: Agency BBS, Dunedin - New Zealand | bbs.geek.nz > Message-ID: <1783215...@f38.n261.z1.binkp.net> > Mime-Version: 1.0 > > Any ideas how to investigate further? No, but with this information they should be relatively easy to filter out at the mail/news boundary, right? (It's not ideal, I know) -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list
Re: nospam ** infinity?
On Tuesday, November 28, 2017 at 1:14:51 AM UTC, Skip Montanaro wrote: > > I'm 99.5% certain it's not gate_news. > > A funny thing. All messages I have looked at so far with the "nospam" > thing have a Message-ID from binkp.net. (They are also all Usenet > posts.) For example: > > Newsgroups: comp.lang.python > Subject: Re: I have anaconda, but Pycharm can't find it > Date: Sun, 26 Nov 2017 22:40:00 +1200 > Organization: Agency BBS, Dunedin - New Zealand | bbs.geek.nz > Message-ID: <1783215...@f38.n261.z1.binkp.net> > Mime-Version: 1.0 > > Any ideas how to investigate further? Sorry, hardly my area of expertise :-( > > Skip If it's any help there's now a message on the announce list/group subject "TatSu v4.2.5. released" with a nospam entry. -- Kindest regards. Mark Lawrence. -- https://mail.python.org/mailman/listinfo/python-list
Re: nospam ** infinity?
On 28/11/2017 10:17, Thomas Jollans wrote: On 2017-11-28 02:14, Skip Montanaro wrote: I'm 99.5% certain it's not gate_news. A funny thing. All messages I have looked at so far with the "nospam" thing have a Message-ID from binkp.net. (They are also all Usenet posts.) For example: Newsgroups: comp.lang.python Subject: Re: I have anaconda, but Pycharm can't find it Date: Sun, 26 Nov 2017 22:40:00 +1200 Organization: Agency BBS, Dunedin - New Zealand | bbs.geek.nz Message-ID: <1783215...@f38.n261.z1.binkp.net> Mime-Version: 1.0 Any ideas how to investigate further? No, but with this information they should be relatively easy to filter out at the mail/news boundary, right? (It's not ideal, I know) I've just added a block with a regex; they seem to come in batches, so I won't know until the next batch arrives whether I've been successful. TJG -- https://mail.python.org/mailman/listinfo/python-list
Re: nospam ** infinity?
Skip Montanaro wrote: >> I'm 99.5% certain it's not gate_news. > > A funny thing. All messages I have looked at so far with the "nospam" > thing have a Message-ID from binkp.net. (They are also all Usenet > posts.) For example: > > Newsgroups: comp.lang.python > Subject: Re: I have anaconda, but Pycharm can't find it > Date: Sun, 26 Nov 2017 22:40:00 +1200 > Organization: Agency BBS, Dunedin - New Zealand | bbs.geek.nz > Message-ID: <1783215...@f38.n261.z1.binkp.net> > Mime-Version: 1.0 > > Any ideas how to investigate further? Try to contact them, or, more likely him. They seem to be into retro-computing, and there is a line X-MailConverter: SoupGate-Win32 v1.05 According to http://software.tomsweb.net/soupgate.html development of that software ended around 2000. There is a bugfix """ * Fixed bug in SoupGate that would cause hosted mailing list messages and commands to be processed normally even if they were detected as being junk mail; this could cause quite an interesting game of virtual tennis between SoupGate and "Mail Delivery Subsystem"... """ While not exactly the same, "virtual tennis" seems to be a good description of what we see now, only 17 years later... -- https://mail.python.org/mailman/listinfo/python-list
Re: While, If, Count Statements
On Tuesday, November 28, 2017 at 4:18:04 PM UTC+8, Frank Millman wrote: > "Cai Gengyang" wrote in message > news:c2dfc9c4-3e16-480c-aebf-553081775...@googlegroups.com... > > > Sure, so how would the code look like if I want the "if" statement to be > > nested inside the "while" loop > > Have you tried putting the 'if' statement inside the 'while' loop? > > If not, give it a shot and see what happens. > > Frank Millman I tried this : count = 0 while count < 10: if count < 5: print "Hello, I am an if statement and count is", count print "Hello, I am a while and count is", count count += 1 but it gives an "indentation error: expected an indented block" with an arrow pointing at the count after the 3rd statement. Indentation error is supposed to be an error about tabs and spaces right ? But I can't find any mistakes with it ... -- https://mail.python.org/mailman/listinfo/python-list
Re: While, If, Count Statements
"Cai Gengyang" wrote in message news:a8335d2c-1fb9-4ba9-b752-418d19e57...@googlegroups.com... On Tuesday, November 28, 2017 at 4:18:04 PM UTC+8, Frank Millman wrote: > "Cai Gengyang" wrote in message > news:c2dfc9c4-3e16-480c-aebf-553081775...@googlegroups.com... > > > Sure, so how would the code look like if I want the "if" statement to > > be > > nested inside the "while" loop > > Have you tried putting the 'if' statement inside the 'while' loop? > > If not, give it a shot and see what happens. > > Frank Millman I tried this : count = 0 while count < 10: if count < 5: print "Hello, I am an if statement and count is", count print "Hello, I am a while and count is", count count += 1 but it gives an "indentation error: expected an indented block" with an arrow pointing at the count after the 3rd statement. Indentation error is supposed to be an error about tabs and spaces right ? But I can't find any mistakes with it ... You are almost there. An 'if' statement always requires that the following statements are indented. This applies even if you are already at one level of indentation. You could have, for example - if a == 'something': if b == 'something else': if c == 'and another one': do_something_if_a_and_b_and_c_are_true() Or in your case - while condition: if a == 'something': do_something_if_a_is_true() continue with while clause Indentation is fundamental to the way Python works, so if anything above is not clear, query it now. It is essential that you have a firm grasp of this. HTH Frank -- https://mail.python.org/mailman/listinfo/python-list
Re: How to shut down a TCPServer serve_forever() loop?
Chris Angelico : > On Tue, Nov 28, 2017 at 5:04 PM, Marko Rauhamaa wrote: >> Seems to be one of the fundamental multithreading issues: each thread >> is blocked on precisely one event. Asyncio is more flexible: you can >> multiplex on a number of events. > > Not really, no. Unless select() counts as "precisely one event", of > course. Select() counts as asyncio. > That's the normal way for a thread to block on multiple events on a > Unix system. Windows has its own approximate equivalent. > > Surprise, surprise, that's also how event loops often implemented. > Including ones used in packages like asyncio. The original poster's problem seems to be caused by blocking APIs that cannot be multiplexed using select(). A good many Python facilities are the same way. Such blocknoxious APIs are at the core of the multithreading programming paradigm. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: How to shut down a TCPServer serve_forever() loop?
On Tue, Nov 28, 2017 at 11:52 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Tue, Nov 28, 2017 at 5:04 PM, Marko Rauhamaa wrote: >>> Seems to be one of the fundamental multithreading issues: each thread >>> is blocked on precisely one event. Asyncio is more flexible: you can >>> multiplex on a number of events. >> >> Not really, no. Unless select() counts as "precisely one event", of >> course. > > Select() counts as asyncio. Hmm. So what DOESN'T count as asyncio? Because I can use multithreading with select, and in fact have done so on many occasions. It's a perfectly normal Unix kernel function. >> That's the normal way for a thread to block on multiple events on a >> Unix system. Windows has its own approximate equivalent. >> >> Surprise, surprise, that's also how event loops often implemented. >> Including ones used in packages like asyncio. > > The original poster's problem seems to be caused by blocking APIs that > cannot be multiplexed using select(). A good many Python facilities are > the same way. > > Such blocknoxious APIs are at the core of the multithreading programming > paradigm. Some things are fundamentally not multiplexable, at the lower levels. (On Linux, and I believe most other Unix-like operating systems, there's no non-blocking way to open a file, nor to gethostbyname.) How do you propose to solve those in Python? Do you have one thread that uses select() and another that does a blocking call? Do you spin off a thread to do the blocking call and then have that thread notify your main thread via a file descriptor? I don't understand why you keep insisting that asyncio and threads are somehow incompatible, or that they're a dichotomy. They're not. They work together very nicely. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: While, If, Count Statements
On Tuesday, November 28, 2017 at 8:12:09 PM UTC+8, Frank Millman wrote: > "Cai Gengyang" wrote in message > news:a8335d2c-1fb9-4ba9-b752-418d19e57...@googlegroups.com... > > > > On Tuesday, November 28, 2017 at 4:18:04 PM UTC+8, Frank Millman wrote: > > > "Cai Gengyang" wrote in message > > > news:c2dfc9c4-3e16-480c-aebf-553081775...@googlegroups.com... > > > > > > > Sure, so how would the code look like if I want the "if" statement to > > > > be > > > > nested inside the "while" loop > > > > > > Have you tried putting the 'if' statement inside the 'while' loop? > > > > > > If not, give it a shot and see what happens. > > > > > > Frank Millman > > > > I tried this : > > > > count = 0 > > > > while count < 10: > > if count < 5: > > print "Hello, I am an if statement and count is", count > > print "Hello, I am a while and count is", count > > count += 1 > > > > but it gives an "indentation error: expected an indented block" with an > > arrow pointing at the count after the 3rd statement. Indentation error is > > supposed to be an error about tabs and spaces right ? But I can't find any > > mistakes with it ... > > You are almost there. > > An 'if' statement always requires that the following statements are > indented. This applies even if you are already at one level of indentation. > > You could have, for example - > > if a == 'something': > if b == 'something else': > if c == 'and another one': > do_something_if_a_and_b_and_c_are_true() > > Or in your case - > > while condition: > if a == 'something': > do_something_if_a_is_true() > continue with while clause > > Indentation is fundamental to the way Python works, so if anything above is > not clear, query it now. It is essential that you have a firm grasp of this. > > HTH > > Frank It works now ! All I had to shift the 2nd "print" statement up a few spaces and it worked --- This is my code: count = 0 while count < 10: if count < 5: print "Hello, I am an if statement and count is", count print "Hello, I am a while and count is", count count += 1 Output : Hello, I am an if statement and count is 0 Hello, I am a while and count is 0 Hello, I am an if statement and count is 1 Hello, I am a while and count is 1 Hello, I am an if statement and count is 2 Hello, I am a while and count is 2 Hello, I am an if statement and count is 3 Hello, I am a while and count is 3 Hello, I am an if statement and count is 4 Hello, I am a while and count is 4 Hello, I am a while and count is 5 Hello, I am a while and count is 6 Hello, I am a while and count is 7 Hello, I am a while and count is 8 Hello, I am a while and count is 9 -- https://mail.python.org/mailman/listinfo/python-list
asyncio loop.call_soon()
Hello Python's doc says about loop.call_soon(callback, *arg): Arrange for a callback to be called as soon as possible. The callback is called after call_soon() returns, when control returns to the event loop. But it doesn't seem to be true; see this program: import asyncio async def task_func(): print("Entering task_func") def callback(): print("Entering callback") async def main(): print("Entering main") task = loop.create_task(task_func()) loop.call_soon(callback) await task loop = asyncio.get_event_loop() loop.run_until_complete(main()) Execution provides following output: Entering main Entering task_func Entering callback callback is executed AFTER task_func, I expected it to be executed BEFORE. When "main()" coroutine reach line "await task", it let the control to the event loop, and it seems that the loop starts to execute task instead of callback. Then, when task is over the loop runs callback This is not what the doc says: callback should be called as soon as possible when the loop has control, with a priority over other tasks pending in the loop -- https://mail.python.org/mailman/listinfo/python-list
Re: asyncio loop.call_soon()
On Tue, Nov 28, 2017 at 8:30 AM, ast wrote: > Hello > > Python's doc says about loop.call_soon(callback, *arg): > > Arrange for a callback to be called as soon as possible. The callback is > called after call_soon() returns, when control returns to the event loop. > > But it doesn't seem to be true; see this program: > > import asyncio > > async def task_func(): >print("Entering task_func") > > def callback(): >print("Entering callback") > > async def main(): >print("Entering main") >task = loop.create_task(task_func()) >loop.call_soon(callback) >await task > > loop = asyncio.get_event_loop() > loop.run_until_complete(main()) > > Execution provides following output: > > Entering main > Entering task_func > Entering callback > > callback is executed AFTER task_func, I expected it > to be executed BEFORE. > > When "main()" coroutine reach line "await task", it let the control to the > event loop, and it seems that the loop starts to execute task instead of > callback. Then, when task is over the loop runs callback > > This is not what the doc says: callback should be called as soon > as possible when the loop has control, with a priority over other > tasks pending in the loop You omitted this part of the documentation: "This operates as a FIFO queue, callbacks are called in the order in which they are registered. Each callback will be called exactly once." This documents the ordering of call_soon callbacks. It doesn't say anything about how the callback will be ordered with respect to tasks or other events that are also immediately ready to be handled. Also, if you look at the implementation of create_task, it invokes call_soon. This is therefore consistent with the doc, as call_soon was actually called twice: first for task_func(), and then for callback. -- https://mail.python.org/mailman/listinfo/python-list
Has anyone worked on docker with windows
Hi, what am i trying to achieve is, container of windows with an application like slack on it. Does window container has an UI? Has anyone worked on it, is it feasible? -- https://mail.python.org/mailman/listinfo/python-list
Re: How to shut down a TCPServer serve_forever() loop?
Chris Angelico : > On Tue, Nov 28, 2017 at 11:52 PM, Marko Rauhamaa wrote: >> The original poster's problem seems to be caused by blocking APIs that >> cannot be multiplexed using select(). A good many Python facilities are >> the same way. >> >> Such blocknoxious APIs are at the core of the multithreading programming >> paradigm. > > Some things are fundamentally not multiplexable, at the lower levels. Said function is not. Neither are, say, database methods or web operations. Yet, they are commonly implemented in a blocking fashion. > (On Linux, and I believe most other Unix-like operating systems, > there's no non-blocking way to open a file, nor to gethostbyname.) The file access problem is a fundamental glitch in Linux, but gethostbyname() is just a silly POSIX API. > How do you propose to solve those in Python? I have solved the gethostbyname() problem by implementing the DNS protocol myself (in Python). The file access issue is philosophically somewhat deep; Linux essentially treats files as memory and vice versa. If it became an issue, I'd have to launch a file server process. > I don't understand why you keep insisting that asyncio and threads are > somehow incompatible, Where did I say that? Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: How to shut down a TCPServer serve_forever() loop?
On Wed, Nov 29, 2017 at 4:22 AM, Marko Rauhamaa wrote: > I have solved the gethostbyname() problem by implementing the DNS > protocol myself (in Python). Do you respect /etc/nsswitch.conf? >> I don't understand why you keep insisting that asyncio and threads are >> somehow incompatible, > > Where did I say that? You talk about them as if they're fundamentally different. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: How to shut down a TCPServer serve_forever() loop?
Chris Angelico : > On Wed, Nov 29, 2017 at 4:22 AM, Marko Rauhamaa wrote: >> I have solved the gethostbyname() problem by implementing the DNS >> protocol myself (in Python). > > Do you respect /etc/nsswitch.conf? No, but I don't need to. >>> I don't understand why you keep insisting that asyncio and threads >>> are somehow incompatible, >> >> Where did I say that? > > You talk about them as if they're fundamentally different. In this discussion I was referring to the fact that you can interrupt a coroutine while that is generally not possible to do to a blocking thread. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: How to shut down a TCPServer serve_forever() loop?
On Wed, Nov 29, 2017 at 5:03 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Wed, Nov 29, 2017 at 4:22 AM, Marko Rauhamaa wrote: >>> I have solved the gethostbyname() problem by implementing the DNS >>> protocol myself (in Python). >> >> Do you respect /etc/nsswitch.conf? > > No, but I don't need to. Ah, right. Until the day you're wrestling with "why doesn't /etc/hosts apply to this program". Yep, you totally don't need nsswitch. I don't understand why you keep insisting that asyncio and threads are somehow incompatible, >>> >>> Where did I say that? >> >> You talk about them as if they're fundamentally different. > > In this discussion I was referring to the fact that you can interrupt a > coroutine while that is generally not possible to do to a blocking > thread. I'm not sure what you mean by a "blocking thread". Whether it's a coroutine or not, you can't interrupt gethostbyname(); and whether it's a coroutine or not, you CAN interrupt any syscall that responds to signals (that's the whole point of EINTR). ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: How to shut down a TCPServer serve_forever() loop?
Chris Angelico : > On Wed, Nov 29, 2017 at 5:03 AM, Marko Rauhamaa wrote: >> Chris Angelico : >>> Do you respect /etc/nsswitch.conf? >> >> No, but I don't need to. > > Ah, right. Until the day you're wrestling with "why doesn't /etc/hosts > apply to this program". Yep, you totally don't need nsswitch. Don't you worry about my programs. >> In this discussion I was referring to the fact that you can interrupt >> a coroutine while that is generally not possible to do to a blocking >> thread. > > I'm not sure what you mean by a "blocking thread". Whether it's a > coroutine or not, you can't interrupt gethostbyname(); and whether > it's a coroutine or not, you CAN interrupt any syscall that responds > to signals (that's the whole point of EINTR). Please reread the original poster's question. It was about a blocking TCP listener call that another thread couldn't interrupt. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: How to shut down a TCPServer serve_forever() loop?
On Wed, Nov 29, 2017 at 5:32 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Wed, Nov 29, 2017 at 5:03 AM, Marko Rauhamaa wrote: >>> Chris Angelico : Do you respect /etc/nsswitch.conf? >>> >>> No, but I don't need to. >> >> Ah, right. Until the day you're wrestling with "why doesn't /etc/hosts >> apply to this program". Yep, you totally don't need nsswitch. > > Don't you worry about my programs. Okay, but you can't claim that problems are solvable if you cheat them. >>> In this discussion I was referring to the fact that you can interrupt >>> a coroutine while that is generally not possible to do to a blocking >>> thread. >> >> I'm not sure what you mean by a "blocking thread". Whether it's a >> coroutine or not, you can't interrupt gethostbyname(); and whether >> it's a coroutine or not, you CAN interrupt any syscall that responds >> to signals (that's the whole point of EINTR). > > Please reread the original poster's question. It was about a blocking > TCP listener call that another thread couldn't interrupt. Yet a SIGINT would successfully interrupt it. I'm not sure what your point is. Would the OP have been trivially able to switch to asyncio? Maybe. Would the OP have been trivially able to send a signal to the process? Yes. I'm done arguing. You're clearly not listening. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: How to shut down a TCPServer serve_forever() loop?
Chris Angelico : > On Wed, Nov 29, 2017 at 5:32 AM, Marko Rauhamaa wrote: >> Don't you worry about my programs. > > Okay, but you can't claim that problems are solvable if you cheat them. What I'm saying is that there's no particular reason why glibc couldn't offer a solution. There *is* getaddrinfo_a(), but that's suboptimal because it uses signals and (probably) a subsidiary thread. Instead, it should offer a file descriptor for the application to monitor. >> Please reread the original poster's question. It was about a blocking >> TCP listener call that another thread couldn't interrupt. > > Yet a SIGINT would successfully interrupt it. A keyboard interrupt? That your magic bullet? How does that work in practice? > Would the OP have been trivially able to send a signal to the > process? Yes. Python signal handlers are always executed in the main Python thread, even if the signal was received in another thread. This means that signals can’t be used as a means of inter-thread communication. https://docs.python.org/3/library/signal.html#signals-and-threads> Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: How to shut down a TCPServer serve_forever() loop?
On Tue, Nov 28, 2017 at 11:54 AM, Marko Rauhamaa wrote: > Chris Angelico : >> Would the OP have been trivially able to send a signal to the >> process? Yes. > >Python signal handlers are always executed in the main Python thread, >even if the signal was received in another thread. This means that >signals can’t be used as a means of inter-thread communication. > >https://docs.python.org/3/library/signal.html#signals-and-threads> Being received in the other thread, it would still interrupt the system call however, wouldn't it? Quoting from the doc: "However, if the target thread is executing the Python interpreter, the Python signal handlers will be executed by the main thread. Therefore, the only point of sending a signal to a particular Python thread would be to force a running system call to fail with InterruptedError." -- https://mail.python.org/mailman/listinfo/python-list
Re: asyncio loop.call_soon()
On 11/28/2017 11:02 AM, Ian Kelly wrote: On Tue, Nov 28, 2017 at 8:30 AM, ast wrote: Hello Python's doc says about loop.call_soon(callback, *arg): Arrange for a callback to be called as soon as possible. The callback is called after call_soon() returns, when control returns to the event loop. But it doesn't seem to be true; see this program: import asyncio async def task_func(): print("Entering task_func") def callback(): print("Entering callback") async def main(): print("Entering main") task = loop.create_task(task_func()) loop.call_soon(callback) await task loop = asyncio.get_event_loop() loop.run_until_complete(main()) Execution provides following output: Entering main Entering task_func Entering callback callback is executed AFTER task_func, I expected it to be executed BEFORE. When "main()" coroutine reach line "await task", it let the control to the event loop, and it seems that the loop starts to execute task instead of callback. Then, when task is over the loop runs callback This is not what the doc says: callback should be called as soon as possible when the loop has control, with a priority over other tasks pending in the loop You omitted this part of the documentation: "This operates as a FIFO queue, callbacks are called in the order in which they are registered. Each callback will be called exactly once." This documents the ordering of call_soon callbacks. It doesn't say anything about how the callback will be ordered with respect to tasks or other events that are also immediately ready to be handled. Also, if you look at the implementation of create_task, it invokes call_soon. This is therefore consistent with the doc, as call_soon was actually called twice: first for task_func(), and then for callback. I believe that this means that any code in the coroutine *before* the first await is run immediately. This is what I experienced in my experiments yesterday. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Pros and cons of Python sources?
Den 2017-11-27 skrev Cameron Simpson : > > But if the package is mainstream you're probably ok? You could just live with > it and do no more damage. > > Otherwise, look to see what python packages are installed which you think you > may have pipped, and reinstall those. But also, pip tends not to install > things > that are already present, so you might be fine. > The reason I think all is not well is the fact that pip list no only results in a list of packages but at the end of the list (which does not look complete) there is a bunch of error messages. Running Python scripts has worked without issues so far. /Martin -- https://mail.python.org/mailman/listinfo/python-list
Re: Pros and cons of Python sources?
On 28Nov2017 21:23, Martin Schöön wrote: Den 2017-11-27 skrev Cameron Simpson : But if the package is mainstream you're probably ok? You could just live with it and do no more damage. Otherwise, look to see what python packages are installed which you think you may have pipped, and reinstall those. But also, pip tends not to install things that are already present, so you might be fine. The reason I think all is not well is the fact that pip list no only results in a list of packages but at the end of the list (which does not look complete) there is a bunch of error messages. Please post them. Maybe someone has some insight. (Also post the pip command itself producing the messages.) Running Python scripts has worked without issues so far. Fingers crossed. Cheers, Cameron Simpson (formerly c...@zip.com.au) Real computer scientists don't comment their code. The identifiers are so long they can't afford the disk space. -- https://mail.python.org/mailman/listinfo/python-list
Re: Increasing the diversity of people who write Python
Chris Angelico wrote: Heh, you mean the term "Windows key"? It's not appropriate on keyboards that don't have an actual Windows logo on it. There are other names for it, but I figured the easiest way was to describe its location :D That doesn't work for all keyboards, though. The one I'm using right now doesn't have any key between the left alt and left control keys. (It does have another key just to the right of the alt key that might have roughly analogous functionality in some circumstances.) -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Increasing the diversity of people who write Python
On Wed, Nov 29, 2017 at 3:44 PM, Gregory Ewing wrote: > Chris Angelico wrote: >> >> Heh, you mean the term "Windows key"? It's not appropriate on >> keyboards that don't have an actual Windows logo on it. There are >> other names for it, but I figured the easiest way was to describe its >> location :D > > > That doesn't work for all keyboards, though. The one I'm using > right now doesn't have any key between the left alt and left > control keys. (It does have another key just to the right of > the alt key that might have roughly analogous functionality in > some circumstances.) > Yeah, which is why it's completely configurable. I was just saying which key *I* use, on my particular layout. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Increasing the diversity of people who write Python
Am 28.11.17 um 20:24 schrieb wxjmfa...@gmail.com: Le mardi 28 novembre 2017 04:44:51 UTC+1, Rustom Mody a écrit : ... Unicode codepoint names are (evidently) ALLCAPS-ASCII Are you sure ? ;-) ; Standard Unicode 10.0.0 ou ; Norme internationale ISO/CEI 10646:2017 ... 00FFLETTRE MINUSCULE LATINE Y TRÉMA WTF is this? The character is correctly called "LATIN SMALL LETTER Y WITH DIAERESIS". There is no non-ASCII character in this description. Of course, if I translated the Unicode mapping to Polish, there would be an even larger number of non-ASCII letters - but what good would that be for an IT standard, if the identifiers were written in different languages? Christian -- https://mail.python.org/mailman/listinfo/python-list
Re: Has anyone worked on docker with windows
On 28-Nov-2017, Robert Clove wrote (in article): > Hi, > > what am i trying to achieve is, container of windows with an application > like slack on it. > Does window container has an UI? > > Has anyone worked on it, is it feasible? AFAIK, docker is linux/CoreOS only. Ask docker.com this question. AFAIK, the only way to get docker to run on Windows is to run docker-machine with virtual box. That's a coreOS VM. -- https://mail.python.org/mailman/listinfo/python-list
Re: Has anyone worked on docker with windows
i was also of the same opinion , but docker is available on windows too https://www.docker.com/docker-windows On Wed, Nov 29, 2017 at 12:22 PM, Percival John Hackworth wrote: > On 28-Nov-2017, Robert Clove wrote > (in article): > > > Hi, > > > > what am i trying to achieve is, container of windows with an application > > like slack on it. > > Does window container has an UI? > > > > Has anyone worked on it, is it feasible? > > AFAIK, docker is linux/CoreOS only. Ask docker.com this question. AFAIK, > the > only way to get docker to run on Windows is to run docker-machine with > virtual box. That's a coreOS VM. > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Increasing the diversity of people who write Python
Christian Gollwitzer : > Am 28.11.17 um 20:24 schrieb wxjmfa...@gmail.com: >> 00FF LETTRE MINUSCULE LATINE Y TRÉMA > > WTF is this? The character is correctly called > "LATIN SMALL LETTER Y WITH DIAERESIS". There is no non-ASCII character > in this description. Of course, if I translated the Unicode mapping to > Polish, there would be an even larger number of non-ASCII letters - > but what good would that be for an IT standard, if the identifiers > were written in different languages? The ISO/IEC standards are issued in many languages. French and English have the strongest footing; French is maybe slightly more primary than English. http://www.iec.ch/tcnews/restricted/2009june/Directives-IECSup-Ed5-1.pdf> Marko -- https://mail.python.org/mailman/listinfo/python-list