Re: [Tutor] reading files in Python 3

2017-03-30 Thread eryk sun
On Thu, Mar 30, 2017 at 8:47 PM, Zachary Ware wrote: > In this case, the problem is the bogus Unicode escape that you > inadvertently included in your path: `\Us...`. To fix it, either use a > 'raw' string (`r"C:\Users\..."`) or use forward slashes rather than > backslashes, which Windows is happ

Re: [Tutor] subprocess.Popen / proc.communicate issue

2017-03-30 Thread eryk sun
On Thu, Mar 30, 2017 at 10:51 PM, Cameron Simpson wrote: > This suggests that .communicate uses Threads to send and to gather data > independently, and that therefore the deadlock situation may not arise. For Unix, communicate() uses select or poll. It uses threads on Windows. Either way it avoid

Re: [Tutor] test

2017-03-30 Thread boB Stepp
On Thu, Mar 30, 2017 at 4:11 PM, bruce wrote: > sent a question earlier.. and got a reply saying it was in the > moderation process??? You've made it through the process. See the bottom of https://mail.python.org/pipermail/tutor/2017-March/thread.html to see your original question and the answ

Re: [Tutor] subprocess.Popen / proc.communicate issue

2017-03-30 Thread Cameron Simpson
I wrote a long description of how .communicate can deadlock. Then I read the doco more carefully and saw this: Warning: Use communicate() rather than .stdin.write, .stdout.read or .stderr.read to avoid deadlocks due to any of the other OS pipe buffers filling up and blocking the child process

Re: [Tutor] subprocess.Popen / proc.communicate issue

2017-03-30 Thread Cameron Simpson
On 30Mar2017 13:51, bruce wrote: Trying to understand the "correct" way to run a sys command ("curl") and to get the potential stderr. Checking Stackoverflow (SO), implies that I should be able to use a raw/text cmd, with "shell=true". I strongly recommend avoiding shell=True if you can. It ha

[Tutor] test

2017-03-30 Thread bruce
sent a question earlier.. and got a reply saying it was in the moderation process??? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] reading files in Python 3

2017-03-30 Thread Zachary Ware
On Mar 30, 2017 15:07, "Rafael Knuth" wrote: I can read files like this (relative path): with open("Testfile_B.txt") as file_object: contents = file_object.read() print(contents) But how do I read files if I want to specify the location (absolute path): file_path = "C:\Users\Rafael\Tes

Re: [Tutor] super constructor usage

2017-03-30 Thread Alan Gauld via Tutor
On 30/03/17 12:39, Rafael Knuth wrote: I am trying to wrap my head around the super constructor. > > Is it possible to embed a super constructor into an if / elif > statement within the child class? Of course, the __init__ methods are special in any way the normal coding mechanisms all work.

[Tutor] reading files in Python 3

2017-03-30 Thread Rafael Knuth
I can read files like this (relative path): with open("Testfile_B.txt") as file_object: contents = file_object.read() print(contents) But how do I read files if I want to specify the location (absolute path): file_path = "C:\Users\Rafael\Testfile.txt" with open(file_path) as file_object:

Re: [Tutor] super constructor usage

2017-03-30 Thread Rafael Knuth
>> > I am trying to wrap my head around the super constructor. Is it possible to embed a super constructor into an if / elif statement within the child class? if message == "string A": return X elif: return Y How should I modify my code below? (I couldn't solve that by myself) class A: def

[Tutor] python gtk serial loop thread readind data close

2017-03-30 Thread Alexandru Achim via Tutor
Dear users, I had a problem regarding Threads in python and Gtk3. I want to stop a while loop in Gtk , a loop starded with a thread. I want to control a delay timer laser board with give me ,when I send a command by serial connection, give back continuous status values ; but I want to stop this

[Tutor] subprocess.Popen / proc.communicate issue

2017-03-30 Thread bruce
Trying to understand the "correct" way to run a sys command ("curl") and to get the potential stderr. Checking Stackoverflow (SO), implies that I should be able to use a raw/text cmd, with "shell=true". If I leave the stderr out, and just use s=proc.communicate() the test works... Any pointe

Re: [Tutor] Merge Sort Algorithm

2017-03-30 Thread Neil Cerutti
On 2017-03-30, Elo Okonkwo wrote: > Thanks so much everyone. > > I've figured it out. It was the recursive bit that got me > confused, its a bit difficult debugging recursive functions. It doesn't have to be! I recommend debugging recursive functions with small, easy-to-think-about test cases, a

Re: [Tutor] list of functions

2017-03-30 Thread Alan Gauld via Tutor
On 29/03/17 22:23, kay Cee wrote: > func_list = ('func1', 'func2', 'func3') > > for f in func_list: > eval(f)() Instead of using strings just use the functions directly: func_list = (func1, func2, func3) for f in func_list: f() That avoids the potentially insecure eval and will be faster t

[Tutor] list of functions

2017-03-30 Thread kay Cee
Greetings all, I would like to use a list of functions for an automation project, and this is the prototype I came up with ### def func1(): print('func1') def func2(): print('func2') def func3(): print('func3') func_list = ('func1', 'func2', 'func3') for f in func_list

Re: [Tutor] how to redirect input from pipe

2017-03-30 Thread Yosef Levy
Thank you, it was very helpful. בתאריך 23 במרץ 2017 02:39,‏ "Peter Otten" <__pete...@web.de> כתב: > Yosef Levy wrote: > > > Hello All, > > > > I am running with Python 2.7 > > I have to run script that could have get arguments in two ways: > > 1. argument + file name. > > 2. argument + input from

Re: [Tutor] super constructor usage

2017-03-30 Thread Mats Wichmann
On 03/29/2017 08:33 AM, Rafael Knuth wrote: > class A: > def __init__(self, message): > self.message = message > print(message) > > I then modified the child class B like this: > > class B(A): > def __init__(self, message): > print("This is the message from your p

Re: [Tutor] super constructor usage

2017-03-30 Thread Mats Wichmann
On 03/29/2017 04:02 PM, Mats Wichmann wrote: > On 03/29/2017 08:33 AM, Rafael Knuth wrote: > >> class A: >> def __init__(self, message): >> self.message = message >> print(message) >> >> I then modified the child class B like this: >> >> class B(A): >> def __init__(self,

Re: [Tutor] Merge Sort Algorithm

2017-03-30 Thread Elo Okonkwo
Thanks so much everyone. I've figured it out. It was the recursive bit that got me confused, its a bit difficult debugging recursive functions. On Wed, Mar 29, 2017 at 1:36 AM, Steven D'Aprano wrote: > On Tue, Mar 28, 2017 at 03:56:16PM +0100, Elo Okonkwo wrote: > > Can someone pls explain th