Re: Will file be closed automatically in a "for ... in open..." statement?

2016-02-16 Thread Steven D'Aprano
On Wednesday 17 February 2016 15:04, jf...@ms4.hinet.net wrote: > Thanks for these detailed explanation. Both statements will close file > automatically sooner or later and, when considering the exceptions, "with" > is better. Hope my understanding is right. > > But, just curious, how do you know

Re: I m facing some problem while opening the interpreter. how can I resolve the issue?

2016-02-16 Thread Steven D'Aprano
On Wednesday 17 February 2016 06:55, Chinmaya Choudhury wrote: > Please guide me. > #Chinmay > > Sent from Mail for Windows 10 How can we help you when we don't know what problem you have? Is the computer turned on? Is the mouse plugged in? Are you double-clicking the icon on the desktop? Wh

threading - Doug Hellman stdlib book, Timer() subclassing etc

2016-02-16 Thread Veek. M
In Doug Hellman's book on the stdlib, he does: import threading import logging logging.basicConfig(level=logging.DEBUG, format=ā€™(%(threadName)-10s) %(message)sā€™, ) class MyThreadWithArgs(threading.Thread): def __init__(self, group=None, target=None, name=None, args=(), kwargs=None

Re: Will file be closed automatically in a "for ... in open..." statement?

2016-02-16 Thread Raspberry Aether
On 02/16/2016 11:04 PM, jf...@ms4.hinet.net wrote: > Thanks for these detailed explanation. Both statements will close file > automatically sooner or later and, when considering the exceptions, "with" is > better. Hope my understanding is right. > > But, just curious, how do you know the "for" w

Re: Will file be closed automatically in a "for ... in open..." statement?

2016-02-16 Thread Chris Angelico
On Wed, Feb 17, 2016 at 3:04 PM, wrote: > Thanks for these detailed explanation. Both statements will close file > automatically sooner or later and, when considering the exceptions, "with" is > better. Hope my understanding is right. > > But, just curious, how do you know the "for" will do it?

Re: Will file be closed automatically in a "for ... in open..." statement?

2016-02-16 Thread jfong
Thanks for these detailed explanation. Both statements will close file automatically sooner or later and, when considering the exceptions, "with" is better. Hope my understanding is right. But, just curious, how do you know the "for" will do it? I can't find any document about it from every sou

Re: Make a unique filesystem path, without creating the file

2016-02-16 Thread Alan Bawden
Ben Finney writes: > Cameron Simpson writes: > >> I've been watching this for a few days, and am struggling to >> understand your use case. > > Yes, you're not alone. This surprises me, which is why I'm persisting. > >> Can you elaborate with a concrete example and its purpose which would >> wor

Re: Not intalling

2016-02-16 Thread Ben Finney
SoNu KuMaR writes: > I'm trying to install the latest version of python . First time it > didn't install successfully ,i tried again now it have installed but > not working. What exactly did you try? What details about the host can you describe so we know what may be peculiar to the problem? >

Not intalling

2016-02-16 Thread SoNu KuMaR
I'm trying to install the latest version of python . First time it didn't install successfully ,i tried again now it have installed but not working. I'm sending screenshot and log file. I tried reinstallation again and again but result is same. -- https://mail.python.org/mailman/listinfo/python-li

Passing data across callbacks in ThreadPoolExecutor

2016-02-16 Thread Joseph L. Casale
What is the pattern for chaining execution of tasks with ThreadPoolExecutor? Callbacks is not an adequate facility as each task I have will generate new output. Thanks, jlc -- https://mail.python.org/mailman/listinfo/python-list

Re: [Glitch?] Python has just stopped working

2016-02-16 Thread eryk sun
On Tue, Feb 16, 2016 at 10:19 AM, Theo Hamilton wrote: > Whenever I run python (3.5), I get the following message: > > Fatal Python error: Py_initialize: unable to load the file system codec > ImportError: No module named 'encodings' > > Current thread 0x2168 (most recent call first): The int

Re: I m facing some problem while opening the interpreter. how can I resolve the issue?

2016-02-16 Thread Igor Korot
On Tue, Feb 16, 2016 at 2:55 PM, Chinmaya Choudhury wrote: > Please guide me. > #Chinmay Dear Cousin Muscle, I have a serious trouble with Tom. Need you help at once, Jerry. (C) > > Sent from Mail for Windows 10 > > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.py

Re: I m facing some problem while opening the interpreter. how can I resolve the issue?

2016-02-16 Thread Alister
On Wed, 17 Feb 2016 01:25:52 +0530, Chinmaya Choudhury wrote: > Please guide me. > #Chinmay > > Sent from Mail for Windows 10 open it correctly -- The temperature of the aqueous content of an unremittingly ogled culinary vessel will not achieve 100 degrees on the Celsius scale. -- https:/

Re: I m facing some problem while opening the interpreter. how can I resolve the issue?

2016-02-16 Thread Mark Lawrence
On 16/02/2016 19:55, Chinmaya Choudhury wrote: Please guide me. #Chinmay Sent from Mail for Windows 10 Please read http://catb.org/~esr/faqs/smart-questions.html and possibly http://www.sscce.org/, then try asking again. -- My fellow Pythonistas, ask not what our language can do for you, a

Re: [Glitch?] Python has just stopped working

2016-02-16 Thread Christian Gollwitzer
Am 16.02.16 um 17:19 schrieb Theo Hamilton: I woke up two days ago to find out that python literally won't work any more. I have looked everywhere, asked multiple Stack Overflow questions, and am ready to give up. Whenever I run python (3.5), I get the following message: Fatal Python error: Py_i

[Glitch?] Python has just stopped working

2016-02-16 Thread Theo Hamilton
I woke up two days ago to find out that python literally won't work any more. I have looked everywhere, asked multiple Stack Overflow questions, and am ready to give up. Whenever I run python (3.5), I get the following message: Fatal Python error: Py_initialize: unable to load the file system code

I m facing some problem while opening the interpreter. how can I resolve the issue?

2016-02-16 Thread Chinmaya Choudhury
Please guide me. #Chinmay Sent from Mail for Windows 10 -- https://mail.python.org/mailman/listinfo/python-list

Re: Make a unique filesystem path, without creating the file

2016-02-16 Thread Ben Finney
Steven D'Aprano writes: > On Tue, 16 Feb 2016 04:56 pm, Ben Finney wrote: > > > names = tempfile._get_candidate_names() > > I'm not sure that calling a private function of the tempfile module is > better than calling a deprecated function. Agreed, which is why I'm seeking a public API that i

Re: Make a unique filesystem path, without creating the file

2016-02-16 Thread Ben Finney
Oscar Benjamin writes: > If you're going to patch open to return a fake file when asked to open > fake_file_path why do you care whether there is a real file of that > name? I don't, and have been saying explicitly many times in this thread that I do not care whether the file exists. Somehow tha

Re: Multiple Assignment a = b = c

2016-02-16 Thread Terry Reedy
On 2/16/2016 7:46 AM, srinivas devaki wrote: Hi, a = b = c as an assignment doesn't return anything, i ruled out a = b = c as chained assignment, like a = (b = c) SO i thought, a = b = c is resolved as a, b = [c, c] https://docs.python.org/3/reference/simple_stmts.html#assignment-statements "

Re: asyncio - run coroutine in the background

2016-02-16 Thread Robin Becker
On 16/02/2016 17:15, Marko Rauhamaa wrote: Marko Rauhamaa : Sure: Sorry for the multiple copies. Marko I thought perhaps background jobs were sending them :) -- Robin Becker -- https://mail.python.org/mailman/listinfo/python-list

Re: Make a unique filesystem path, without creating the file

2016-02-16 Thread Steven D'Aprano
On Tue, 16 Feb 2016 04:56 pm, Ben Finney wrote: > An example:: > > import io > import tempfile > names = tempfile._get_candidate_names() I'm not sure that calling a private function of the tempfile module is better than calling a deprecated function. > def test_frobnicates_con

Re: asyncio - run coroutine in the background

2016-02-16 Thread Marko Rauhamaa
"Frank Millman" : > I would love to drive the database asynchronously, but of the three > databases I use, only psycopg2 seems to have asyncio support. Yes, asyncio is at its infancy. There needs to be a moratorium on blocking I/O. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: asyncio - run coroutine in the background

2016-02-16 Thread Marko Rauhamaa
Steven D'Aprano : > On Wed, 17 Feb 2016 01:17 am, Marko Rauhamaa wrote: > >> Ok, yes, but those "background tasks" monopolize the CPU once they are >> scheduled to run. > > Can you show some code demonstrating this? Sure: #

Re: asyncio - run coroutine in the background

2016-02-16 Thread Marko Rauhamaa
Marko Rauhamaa : > Sure: Sorry for the multiple copies. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: asyncio - run coroutine in the background

2016-02-16 Thread Marko Rauhamaa
Steven D'Aprano : > On Wed, 17 Feb 2016 01:17 am, Marko Rauhamaa wrote: > >> Ok, yes, but those "background tasks" monopolize the CPU once they are >> scheduled to run. > > Can you show some code demonstrating this? Sure: #

Re: asyncio - run coroutine in the background

2016-02-16 Thread Marko Rauhamaa
Steven D'Aprano : > On Wed, 17 Feb 2016 01:17 am, Marko Rauhamaa wrote: > >> Ok, yes, but those "background tasks" monopolize the CPU once they are >> scheduled to run. > > Can you show some code demonstrating this? Sure: #

Re: asyncio - run coroutine in the background

2016-02-16 Thread Marko Rauhamaa
Steven D'Aprano : > On Wed, 17 Feb 2016 01:17 am, Marko Rauhamaa wrote: > >> Ok, yes, but those "background tasks" monopolize the CPU once they >> are scheduled to run. > > Can you show some code demonstrating this? Sure: #

Re: Multiple Assignment a = b = c

2016-02-16 Thread srinivas devaki
On Tue, Feb 16, 2016 at 6:35 PM, Sven R. Kunze wrote: > > First, the rhs is evaluated. > Second, the lhs is evaluated from left to right. Great, I will remember these two lines :) On Tue, Feb 16, 2016 at 8:46 PM, Steven D'Aprano wrote: > _temp = c > a = _temp > b = _temp > del _temp > > > except

Re: asyncio - run coroutine in the background

2016-02-16 Thread Frank Millman
"Chris Angelico" wrote in message news:captjjmqmie4groqnyvhwahcn2mwqeyqxt5kvfivotrhqy-s...@mail.gmail.com... On Wed, Feb 17, 2016 at 2:21 AM, Frank Millman wrote: > I would love to drive the database asynchronously, but of the three > databases I use, only psycopg2 seems to have asyncio suppor

Re: asyncio - run coroutine in the background

2016-02-16 Thread Chris Angelico
On Wed, Feb 17, 2016 at 2:21 AM, Frank Millman wrote: > I would love to drive the database asynchronously, but of the three > databases I use, only psycopg2 seems to have asyncio support. As my > home-grown solution (using queues) seems to be working well so far, I am > sticking with that until I

Re: asyncio - run coroutine in the background

2016-02-16 Thread Steven D'Aprano
On Wed, 17 Feb 2016 01:17 am, Marko Rauhamaa wrote: > Ok, yes, but those "background tasks" monopolize the CPU once they are > scheduled to run. Can you show some code demonstrating this? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: asyncio - run coroutine in the background

2016-02-16 Thread Frank Millman
"Kevin Conway" wrote in message news:CAKF=+dhXZ=yax8stawr_gjx3tg8yujprjg-7ym2_brv2kxm...@mail.gmail.com... > My background task does take a long time to run - about 10 seconds - but > most of that time is spent waiting for database responses, which is > handled > in another thread. Something

Re: Multiple Assignment a = b = c

2016-02-16 Thread Steven D'Aprano
On Tue, 16 Feb 2016 11:46 pm, srinivas devaki wrote: > Hi, > > a = b = c > > as an assignment doesn't return anything, i ruled out a = b = c as > chained assignment, like a = (b = c) > SO i thought, a = b = c is resolved as > a, b = [c, c] That is one way of thinking of it. A better way would b

Re: asyncio - run coroutine in the background

2016-02-16 Thread Kevin Conway
> Ok, yes, but those "background tasks" monopolize the CPU once they are scheduled to run. This is true if the coroutines are cpu bound. If that is the case then a coroutine is likely the wrong choice for that code to begin with. Coroutines, in asyncio land, are primarily designed for io bound wor

Re: asyncio - run coroutine in the background

2016-02-16 Thread Frank Millman
"Marko Rauhamaa" wrote in message news:87d1rwpwo2@elektro.pacujo.net... Kevin Conway : > If you're handling coroutines there is an asyncio facility for > "background tasks". The ensure_future [1] will take a coroutine, > attach it to a Task, and return a future to you that resolves when th

Re: asyncio - run coroutine in the background

2016-02-16 Thread Marko Rauhamaa
Kevin Conway : > If you're handling coroutines there is an asyncio facility for > "background tasks". The ensure_future [1] will take a coroutine, > attach it to a Task, and return a future to you that resolves when the > coroutine is complete. Ok, yes, but those "background tasks" monopolize the

Re: asyncio - run coroutine in the background

2016-02-16 Thread Frank Millman
"Kevin Conway" wrote in message news:CAKF=+dim8wzprvm86_v2w5-xsopcchvgm0hy8r4xehdyzy_...@mail.gmail.com... If you're handling coroutines there is an asyncio facility for "background tasks". The ensure_future [1] will take a coroutine, attach it to a Task, and return a future to you that resolve

Re: extending PATH on Windows?

2016-02-16 Thread Thorsten Kampe
* Ulli Horlacher (Tue, 16 Feb 2016 12:38:44 + (UTC)) By the way: there is a script called `win_add2path.py` in your Python distribution which "is a simple script to add Python to the Windows search path. It modifies the current user (HKCU) tree of the registry.". That should do most of what

Re: extending PATH on Windows?

2016-02-16 Thread Thorsten Kampe
* Ulli Horlacher (Tue, 16 Feb 2016 12:38:44 + (UTC)) > > Thorsten Kampe wrote: > > * Ulli Horlacher (Tue, 16 Feb 2016 08:30:59 + (UTC)) > > > I need to extend the PATH environment variable on Windows. > > > > 1. Add the path component yourself into HKEY_CURRENT_USER and make > > sure it

Re: asyncio - run coroutine in the background

2016-02-16 Thread Kevin Conway
If you're handling coroutines there is an asyncio facility for "background tasks". The ensure_future [1] will take a coroutine, attach it to a Task, and return a future to you that resolves when the coroutine is complete. The coroutine you schedule with that function will not cause your current cor

Re: extending PATH on Windows?

2016-02-16 Thread eryk sun
On Tue, Feb 16, 2016 at 2:30 AM, Ulli Horlacher wrote: > > So far, I use: > >system('setx PATH "%PATH%;'+bindir+'"') > > The problem: In a new process (cmd.exe) PATH contains a lot of double > elements. As far as I have understood, Windows builds the PATH > environment variable from a system c

Re: Multiple Assignment a = b = c

2016-02-16 Thread Sven R. Kunze
On 16.02.2016 14:05, Sven R. Kunze wrote: Hi Srinivas, I think the tuple assignment you showed basically nails it. First, the rhs is evaluated. Second, the lhs is evaluated from left to right. Completely wrong? Best, Sven As you mentioned swapping. The following two statements do the same (

Re: Multiple Assignment a = b = c

2016-02-16 Thread Sven R. Kunze
Hi Srinivas, On 16.02.2016 13:46, srinivas devaki wrote: Hi, a = b = c as an assignment doesn't return anything, i ruled out a = b = c as chained assignment, like a = (b = c) SO i thought, a = b = c is resolved as a, b = [c, c] at-least i fixed in my mind that every assignment like operation

Installation error, compiling from source on Oracle Linux

2016-02-16 Thread John D. Gwinner
I'm installing an app that requires Carbon and some other Python 2.7 features. The version of Oracle Linux we're using comes with 2.6. I've read that it is not a good idea to directly update the O/S as it "may break things" so I'm doing make altinstall. I've downloaded Python-2.7.11 Downloaded

Multiple Assignment a = b = c

2016-02-16 Thread srinivas devaki
Hi, a = b = c as an assignment doesn't return anything, i ruled out a = b = c as chained assignment, like a = (b = c) SO i thought, a = b = c is resolved as a, b = [c, c] at-least i fixed in my mind that every assignment like operation in python is done with references and then the references a

Re: Unable to insert data into MongoDB.

2016-02-16 Thread Arjun Srivatsa
Thanks a lot. Will implement that. Although I am able to do using just 2 scripts as well. On Monday, February 15, 2016 at 5:34:08 PM UTC+1, Peter Otten wrote: > Arjun Srivatsa wrote: > > > Hi Peter. > > > > Thank you for the reply. > > > > This is the read_server code: > > > > import socket

Re: extending PATH on Windows?

2016-02-16 Thread Ulli Horlacher
Thorsten Kampe wrote: > * Ulli Horlacher (Tue, 16 Feb 2016 08:30:59 + (UTC)) > > I need to extend the PATH environment variable on Windows. > > 1. Add the path component yourself into HKEY_CURRENT_USER and make > sure it's not there already (pure Python). Preferred! What is HKEY_CURRENT_USE

Re: extending PATH on Windows?

2016-02-16 Thread Thorsten Kampe
* Ulli Horlacher (Tue, 16 Feb 2016 08:30:59 + (UTC)) > I need to extend the PATH environment variable on Windows. > > So far, I use: > >system('setx PATH "%PATH%;'+bindir+'"') > > The problem: In a new process (cmd.exe) PATH contains a lot of double > elements. As far as I have understoo

Re: Will file be closed automatically in a "for ... in open..." statement?

2016-02-16 Thread Terry Reedy
On 2/16/2016 3:39 AM, jf...@ms4.hinet.net wrote: I know with open('foo.txt') as f: ...do something... will close the file automatically when the "with" block ends. I also saw codes in a book: for line in open('foo.txt'): ...do something... Some books were original

Re: Will file be closed automatically in a "for ... in open..." statement?

2016-02-16 Thread Cameron Simpson
On 16Feb2016 00:39, jf...@ms4.hinet.net wrote: I know with open('foo.txt') as f: ...do something... will close the file automatically when the "with" block ends. Yes, because open is a context manager - they're great for reliably tidying up in the face of exceptions or "direct" de

Re: Will file be closed automatically in a "for ... in open..." statement?

2016-02-16 Thread Chris Angelico
On Tue, Feb 16, 2016 at 7:39 PM, wrote: > I know > > with open('foo.txt') as f: > ...do something... > > will close the file automatically when the "with" block ends. > > I also saw codes in a book: > > for line in open('foo.txt'): > ...do something... > > but it didn't me

Will file be closed automatically in a "for ... in open..." statement?

2016-02-16 Thread jfong
I know with open('foo.txt') as f: ...do something... will close the file automatically when the "with" block ends. I also saw codes in a book: for line in open('foo.txt'): ...do something... but it didn't mention if the file will be closed automatically or not when the

Re: Make a unique filesystem path, without creating the file

2016-02-16 Thread Oscar Benjamin
On 16 Feb 2016 05:57, "Ben Finney" wrote: > > Cameron Simpson writes: > > > I've been watching this for a few days, and am struggling to > > understand your use case. > > Yes, you're not alone. This surprises me, which is why I'm persisting. > > > Can you elaborate with a concrete example and its

extending PATH on Windows?

2016-02-16 Thread Ulli Horlacher
I need to extend the PATH environment variable on Windows. So far, I use: system('setx PATH "%PATH%;'+bindir+'"') The problem: In a new process (cmd.exe) PATH contains a lot of double elements. As far as I have understood, Windows builds the PATH environment variable from a system component a