Re: should "self" be changed?

2015-06-03 Thread Steven D'Aprano
On Wednesday 03 June 2015 03:19, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Fri, 29 May 2015 12:00 pm, Steven D'Aprano wrote: >> >> [...] >>> in a language where classes are >>> themselves values, there is no reason why a class must be instantiated, >>> particularly if you're only using a

Re: Please help on this sorted function

2015-06-03 Thread Gary Herron
On 06/02/2015 01:20 PM, fl wrote: Hi, I try to learn sorted(). With the tutorial example: ff=sorted({1: 'D', 2: 'B', 3: 'B', 4: 'E', 5: 'A'}) ff [1, 2, 3, 4, 5] I don't see what sorted does in this dictionary, i.e. the sequence of 1..5 is unchanged. Could you explain it to me? Thanks,

Re: Issuing commands using "exec_command()" of paramiko AND also sending commands together

2015-06-03 Thread Sreenathan Nair
Hi, Could you be more specific about your problem? Perhaps an example of something similar to what you're trying to do would be helpful. Usually the process is to instantiate paramiko.SSHCLIENT, use the connect() method with desired parameters and execute commands using the exec_command(). If you

Re: fork/exec & close file descriptors

2015-06-03 Thread Alain Ketterlin
Chris Angelico writes: > On Wed, Jun 3, 2015 at 7:06 AM, Alain Ketterlin > wrote: >> I've no idea what the OP's program was doing, so I'm not going to split >> hairs. I can't imagine why one would like to mass-close an arbitrary set >> of file descriptors, and I think APIs like os.closerange() a

Re: fork/exec & close file descriptors

2015-06-03 Thread Alain Ketterlin
Marko Rauhamaa writes: > Alain Ketterlin : > >> Marko Rauhamaa writes: >>> First, if close() fails, what's a poor program to do? >> >> Warn the user? Not assume everything went well? It all depends on the >> application, and what the file descriptor represents. > > The problem here is in the sys

Re: fork/exec & close file descriptors

2015-06-03 Thread Marko Rauhamaa
Alain Ketterlin : > Marko Rauhamaa writes: >> Maybe close() will fail for ever. > > Your program has to deal with this, something is going wrong, it can't > just close and go on. Here's the deal: the child process is saddled with file descriptors it never wanted in the first place. It can't decl

Re: Everything is an object in python - object class and type class

2015-06-03 Thread Steven D'Aprano
On Wednesday 03 June 2015 03:59, BartC wrote: > Javascript primitives include Number and String. > > What does Python allow to be done with its Number (int, etc) and String > types that can't be done with their Javascript counterparts, that makes > /them/ objects? That's a good question, and I'm

Re: Everything is an object in python - object class and type class

2015-06-03 Thread Steven D'Aprano
On Wednesday 03 June 2015 08:49, Dr. Bigcock wrote: > You need classes for objects. Anything else, and you're confusing > yourself. Not quite. https://en.wikipedia.org/wiki/Prototype-based_programming -- Steve -- https://mail.python.org/mailman/listinfo/python-list

Re: Please help on this sorted function

2015-06-03 Thread Steven D'Aprano
On Wednesday 03 June 2015 06:42, Joonas Liik wrote: > my_dict = {1: 'D', 2: 'B', 3: 'A', 4: 'E', 5: 'B'} > > # dict.items() returns an iterator that returns pairs of (key, value) > # pairs the key argument to sorted tells sorted what to sort by, > operator.itemgetter is a factory function , itemg

Re: Everything is an object in python - object class and type class

2015-06-03 Thread Steven D'Aprano
On Wednesday 03 June 2015 08:33, Marko Rauhamaa wrote: > Grant Edwards : > >> On 2015-06-02, Ian Kelly wrote: >>> Accepting for the sake of argument that "something to be subclassed" >>> is a reasonable definition of object, >> >> Huh? You can't subclass an object. You can subclass a Class. >

Re: Everything is an object in python - object class and type class

2015-06-03 Thread Steven D'Aprano
On Wednesday 03 June 2015 05:31, Jon Ribbens wrote: > On 2015-06-02, Dr. Bigcock wrote: >> On Tuesday, June 2, 2015 at 1:49:03 PM UTC-5, Jon Ribbens wrote: >>> On 2015-06-02, Dr. Bigcock wrote: >>> > It doesn't really do anything. No one uses integers as objects. >>> > (Any dissenters?) >>> >>

Re: Everything is an object in python - object class and type class

2015-06-03 Thread Marko Rauhamaa
Steven D'Aprano : > On Wednesday 03 June 2015 08:33, Marko Rauhamaa wrote: >> In Python, classes are little more than constructor functions. > > [...] > > Classes give you an inheritance hierarchy. That's encapsulated in the constructor. From the class user's point of view, it doesn't matter if t

What sort of data structure to use?

2015-06-03 Thread David Aldrich
Hi I have written a Python utility that performs a certain activity on some predefined sets of files. Here is the outline of what I have written: # File Set A pathA = 'pathA' fileListA = ['fileA1.txt', 'fileA2.txt'] # File Set B pathB = 'pathB' fileListB = ['fileB1.txt', 'fileB2.txt', 'fileB3.

Re: What sort of data structure to use?

2015-06-03 Thread David Palao
2015-06-03 10:19 GMT+02:00 David Aldrich : > Hi > > > > I have written a Python utility that performs a certain activity on some > predefined sets of files. Here is the outline of what I have written: > > > > # File Set A > > pathA = ‘pathA’ > > fileListA = [‘fileA1.txt’, ‘fileA2.txt’] > > > > # F

Re: What sort of data structure to use?

2015-06-03 Thread Cameron Simpson
On 03Jun2015 08:19, David Aldrich wrote: I have written a Python utility that performs a certain activity on some predefined sets of files. Here is the outline of what I have written: # File Set A pathA = 'pathA' fileListA = ['fileA1.txt', 'fileA2.txt'] # File Set B pathB = 'pathB' fileListB

Re: What sort of data structure to use?

2015-06-03 Thread David Palao
2015-06-03 10:19 GMT+02:00 David Aldrich : > Hi > > > > I have written a Python utility that performs a certain activity on some > predefined sets of files. Here is the outline of what I have written: > > > > # File Set A > > pathA = ‘pathA’ > > fileListA = [‘fileA1.txt’, ‘fileA2.txt’] > > > > # F

Re: fork/exec & close file descriptors

2015-06-03 Thread alister
On Wed, 03 Jun 2015 10:41:44 +0300, Marko Rauhamaa wrote: > Alain Ketterlin : > >> Marko Rauhamaa writes: >>> Maybe close() will fail for ever. >> >> Your program has to deal with this, something is going wrong, it can't >> just close and go on. > > Here's the deal: the child process is saddled

Calling Python Script from an SQL Proceudre

2015-06-03 Thread Amit Goutham
Hi All, I am trying to search on the Internet if i can call a Python Script from an SQL Procedure. All the information found on Internet is about connecting to a database from Python through a Python script.But, i want the other way round. Any Help will be appreciated -- Thanks and Regards, Amit

Re: Everything is an object in python - object class and type class

2015-06-03 Thread BartC
On 03/06/2015 05:16, Eddilbert Macharia wrote: On Tuesday, June 2, 2015 at 2:27:31 PM UTC+3, Steven D'Aprano wrote: Eddilbert, have you programmed in any other languages? It would help you understand if you have. Sadly yes i have worked with java, and that is what is causing me so much grie

Re: Calling Python Script from an SQL Proceudre

2015-06-03 Thread Kushal Kumaran
Amit Goutham writes: > Hi All, > I am trying to search on the Internet if i can call a Python Script from an > SQL Procedure. > All the information found on Internet is about connecting to a database > from Python through a Python script.But, i want the other way round. > > Any Help will be appre

Re: Everything is an object in python - object class and type class

2015-06-03 Thread Chris Angelico
On Wed, Jun 3, 2015 at 8:20 PM, BartC wrote: > I have a lot of trouble with this stuff too, as my ideas are decidedly > old-fashioned. (Also I'm developing a language with some OO aspects without > ever having used OO!) > > But, it is mostly just jargon. If you go back to using 'variable' and > 't

Re: What sort of data structure to use?

2015-06-03 Thread Peter Otten
David Aldrich wrote: > Hi > > I have written a Python utility that performs a certain activity on some > predefined sets of files. Here is the outline of what I have written: > > # File Set A > pathA = 'pathA' > fileListA = ['fileA1.txt', 'fileA2.txt'] > > # File Set B > pathB = 'pathB' > file

Re: Everything is an object in python - object class and type class

2015-06-03 Thread BartC
On 03/06/2015 11:38, Chris Angelico wrote: On Wed, Jun 3, 2015 at 8:20 PM, BartC wrote: I have a lot of trouble with this stuff too, as my ideas are decidedly old-fashioned. (Also I'm developing a language with some OO aspects without ever having used OO!) But, it is mostly just jargon. If you

Re: Everything is an object in python - object class and type class

2015-06-03 Thread BartC
On 03/06/2015 11:20, BartC wrote: 'genfield' is a field (attribute) that can't be resolved, but the possibilities have been reduced to a small, finite set which is resolved at load-time (in Python, the attribute could be anything, and you don't even know at runtime what it might be until you ac

Re: fork/exec & close file descriptors

2015-06-03 Thread Steven D'Aprano
On Wed, 3 Jun 2015 07:38 pm, alister wrote: > On Wed, 03 Jun 2015 10:41:44 +0300, Marko Rauhamaa wrote: [...] >> Here's the deal: the child process is saddled with file descriptors it >> never wanted in the first place. It can't decline them. Now you're >> saying it can't even dispose of them. >>

Re: Everything is an object in python - object class and type class

2015-06-03 Thread Marko Rauhamaa
BartC : > To 'variable' and 'type', you might need to add 'value' to make it more > complete. 'Value' and 'object' are indeed synonymous as long as you keep in mind that: >>> -12 == -12 True >>> -12 is -12 False IOW, the literal expression -12 happens to construct a fresh value/

RE: What sort of data structure to use?

2015-06-03 Thread David Aldrich
Thanks very much for all the answers given to my question. They help me to think about the problem pythonically. Best regards David > -Original Message- > From: Python-list [mailto:python-list- > bounces+david.aldrich=emea.nec@python.org] On Behalf Of Peter > Otten > Sent: 03 June 2

Re: Everything is an object in python - object class and type class

2015-06-03 Thread Chris Angelico
On Wed, Jun 3, 2015 at 9:08 PM, BartC wrote: > On 03/06/2015 11:38, Chris Angelico wrote: >> >> On Wed, Jun 3, 2015 at 8:20 PM, BartC wrote: >>> >>> I have a lot of trouble with this stuff too, as my ideas are decidedly >>> old-fashioned. (Also I'm developing a language with some OO aspects >>> w

Re: fork/exec & close file descriptors

2015-06-03 Thread alister
On Wed, 03 Jun 2015 22:07:47 +1000, Steven D'Aprano wrote: > On Wed, 3 Jun 2015 07:38 pm, alister wrote: > >> On Wed, 03 Jun 2015 10:41:44 +0300, Marko Rauhamaa wrote: > [...] >>> Here's the deal: the child process is saddled with file descriptors it >>> never wanted in the first place. It can't

Re: fork/exec & close file descriptors

2015-06-03 Thread random832
On Wed, Jun 3, 2015, at 03:11, Alain Ketterlin wrote: > Thank you, I know this. What I mean is: what are the reasons that you > cannot access your file descriptors one by one? To me closing a range of > descriptors has absolutely no meaning, simply because ranges have no > meaning for file descript

Re: fork/exec & close file descriptors

2015-06-03 Thread Marko Rauhamaa
Steven D'Aprano : > How does the child process know what action didn't complete? What > error message are you going to display to the user? > > "Error when closing file descriptor 123456" > > What action do you think the user can take on seeing this error > message? Besides, even if you wanted to

Re: fork/exec & close file descriptors

2015-06-03 Thread Marko Rauhamaa
alister : > from the scenario Marco is reporting I get the impression that he is > having to interact with a system that is fundamentally flawed from the > ground up. Well, yes. It's called linux, but it's not all bad. I just think that man page was being sanctimonious. Marko -- https://mail.p

Retrying to send message

2015-06-03 Thread Cecil Westerhof
I am using libturpial to post messages on Twitter. Sometimes I get a libturpial.exceptions.ServiceOverCapacity. It is a good idea to try it again then. For this I wrote the following function: def send_message(account_id, message, max_tries, terminate_program): error_msg = 'Something

Re: fork/exec & close file descriptors

2015-06-03 Thread random832
On Wed, Jun 3, 2015, at 08:25, Marko Rauhamaa wrote: > Steven D'Aprano : > > > How does the child process know what action didn't complete? What > > error message are you going to display to the user? > > You definitely must not use sys.stderr from the child process nor are > you allowed to exit

Re: fork/exec & close file descriptors

2015-06-03 Thread alister
On Wed, 03 Jun 2015 15:27:19 +0300, Marko Rauhamaa wrote: > alister : > >> from the scenario Marco is reporting I get the impression that he is >> having to interact with a system that is fundamentally flawed from the >> ground up. > > Well, yes. It's called linux, but it's not all bad. I just t

Re: Issuing commands using "exec_command()" of paramiko AND also sending commands together

2015-06-03 Thread KR
Hi Sreenathan Nair: import os, sys, import connectlibs as ssh s = ssh.connect("xxx.xx.xx.xxx", "Admin", "Admin") channel = s.invoke_shell() channel.send("net use F: xyz.xy.xc.xa\\dir\n") >>>32 channel.send("net use\n") >>>7 channel.recv(500) 'Last login: Tue Jun 2 23:52:29 2015 from xxx.xx.

Re: Everything is an object in python - object class and type class

2015-06-03 Thread Marco Buttu
On 03/06/2015 13:08, BartC wrote: Come on, we're trying to keep this simple. If we really want to keep it simple, we can take this starting point: http://en.wikipedia.org/wiki/Object_(computer_science) If we agree with the Wikipedia definition: ``In the class-based object-oriented programmi

Re: fork/exec & close file descriptors

2015-06-03 Thread Marko Rauhamaa
random...@fastmail.us: > Why does the child process need to report the error at all? The parent > process will find out naturally when *it* tries to close the same file > descriptor. That's not how it goes. File descriptors are reference counted in the Linux kernel. Closes are no-ops except for

Re: fork/exec & close file descriptors

2015-06-03 Thread Alain Ketterlin
random...@fastmail.us writes: > On Wed, Jun 3, 2015, at 03:11, Alain Ketterlin wrote: >> Thank you, I know this. What I mean is: what are the reasons that you >> cannot access your file descriptors one by one? To me closing a range of >> descriptors has absolutely no meaning, simply because ranges

Re: fork/exec & close file descriptors

2015-06-03 Thread random832
On Wed, Jun 3, 2015, at 09:08, Marko Rauhamaa wrote: > random...@fastmail.us: > > > Why does the child process need to report the error at all? The parent > > process will find out naturally when *it* tries to close the same file > > descriptor. > > That's not how it goes. > > File descriptors a

Re: Everything is an object in python - object class and type class

2015-06-03 Thread Eddilbert Macharia
Hello guys, After i read http://python-history.blogspot.com/2009/02/first-class-everything.html . where Guidos says "One of my goals for Python was to make it so that all objects were "first class." By this, I meant that I wanted all objects that could be named in the language (e.g., integers

Re: Retrying to send message

2015-06-03 Thread Chris Angelico
On Wed, Jun 3, 2015 at 10:27 PM, Cecil Westerhof wrote: > def send_message(account_id, message, max_tries, terminate_program): > error_msg = 'Something went wrong with: ' + message > not_send= True > tries = 0 > while not_send: > try: >

Re: fork/exec & close file descriptors

2015-06-03 Thread Chris Angelico
On Wed, Jun 3, 2015 at 11:21 PM, wrote: > On Wed, Jun 3, 2015, at 09:08, Marko Rauhamaa wrote: >> random...@fastmail.us: >> >> > Why does the child process need to report the error at all? The parent >> > process will find out naturally when *it* tries to close the same file >> > descriptor. >> >

Re: fork/exec & close file descriptors

2015-06-03 Thread Marko Rauhamaa
Marko Rauhamaa : > random...@fastmail.us: > >> Why does the child process need to report the error at all? The parent >> process will find out naturally when *it* tries to close the same file >> descriptor. > > That's not how it goes. > > File descriptors are reference counted in the Linux kernel.

Re: Everything is an object in python - object class and type class

2015-06-03 Thread Ian Kelly
On Wed, Jun 3, 2015 at 2:57 AM, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Wednesday 03 June 2015 08:33, Marko Rauhamaa wrote: >>> In Python, classes are little more than constructor functions. >> >> [...] >> >> Classes give you an inheritance hierarchy. > > That's encapsulated in the const

Re: Can Python function return multiple data?

2015-06-03 Thread Thomas Rachel
Am 03.06.2015 um 01:56 schrieb Chris Angelico: and it's pretty convenient. In C, the nearest equivalent is passing a number of pointers as parameters, and having the function fill out values. Python's model is a lot closer to what you're saying than C's model is :) At least, C functions can re

Re: python 3.4 use python-gcm can't import

2015-06-03 Thread dav . kuhn
Le vendredi 29 août 2014 10:35:29 UTC+2, Frank Liou a écrit : > and body is "b'" .is empty > > i'm so confused.don't know it work or not Hi, you should read() before you close() the connection. conn = http.client.HTTPConnection('android.googleapis.com') conn.request('POST', '/gcm/send', jqs

Re: for...else

2015-06-03 Thread Rustom Mody
On Tuesday, June 2, 2015 at 4:56:57 PM UTC+5:30, acdr wrote: > Hi, > > Currently, in various places in my code, I have the equivalent of: > > for x in it: > if complicated_calculation_1(): > cleanup() > break > complicated_calculation_2() > if complicated_calculation_3

Re: fork/exec & close file descriptors

2015-06-03 Thread Marko Rauhamaa
Marko Rauhamaa : > So the strategy you proposed is the right one: have the child process > ignore any possible errors from os.close(). The parent will have an > opportunity to deal with them. > > And now Linux is back in the good graces, only the man page is > misleading. However, the child proce

Re: fork/exec & close file descriptors

2015-06-03 Thread Marko Rauhamaa
alister : > I meant the program that is supplying your app with file handles > willy- nilly without caring what happens to them You seem to be advocating a strategy whereby the application keeps close track of all file descriptors and closes them individually as needed. Thing is, processes can b

most ambiguous line of code ever written?

2015-06-03 Thread Mark Lawrence
I wanted a piece of code to write alternatively to the left and right sides of a deque. I remembered a stackoverflow question about toggling with an excellent answer from Raymond Hettinger. So I now have this. right = not right Isn't that just beautiful? -- My fellow Pythonistas, ask not wh

Re: Everything is an object in python - object class and type class

2015-06-03 Thread BartC
On 03/06/2015 13:08, Marko Rauhamaa wrote: BartC : To 'variable' and 'type', you might need to add 'value' to make it more complete. 'Value' and 'object' are indeed synonymous as long as you keep in mind that: >>> -12 == -12 True >>> -12 is -12 False IOW, the literal exp

Re: Calling Python Script from an SQL Proceudre

2015-06-03 Thread Laura Creighton
In a message of Wed, 03 Jun 2015 15:17:16 +0530, Amit Goutham writes: >Hi All, >I am trying to search on the Internet if i can call a Python Script from an >SQL Procedure. >All the information found on Internet is about connecting to a database >from Python through a Python script.But, i want the o

Re: Everything is an object in python - object class and type class

2015-06-03 Thread Mark Lawrence
On 03/06/2015 17:00, BartC wrote: On 03/06/2015 13:08, Marko Rauhamaa wrote: BartC : To 'variable' and 'type', you might need to add 'value' to make it more complete. 'Value' and 'object' are indeed synonymous as long as you keep in mind that: >>> -12 == -12 True >>> -12 is -

Re: Everything is an object in python - object class and type class

2015-06-03 Thread Michael Torrie
On 06/03/2015 10:00 AM, BartC wrote: > The others all give True in all cases. It seems that older Python > versions have a purer object model. No. It's just an under-the-hood optimization that the interpreter is making. It's an implementation detail that you should never rely on. It says nothin

Re: Retrying to send message

2015-06-03 Thread Cecil Westerhof
Op Wednesday 3 Jun 2015 15:29 CEST schreef Chris Angelico: > On Wed, Jun 3, 2015 at 10:27 PM, Cecil Westerhof wrote: >> def send_message(account_id, message, max_tries, >> terminate_program): error_msg = 'Something went wrong with: ' + >> message not_send = True tries = 0 while not_send: try: >>

Re: for...else

2015-06-03 Thread Laura Creighton
Are you looking for Knuth's paper Structured Programming with Goto Statements? http://c2.com/cgi/wiki?StructuredProgrammingWithGoToStatements I don't remember a theorem in there, but I haven't read it for decades, so ... Laura -- https://mail.python.org/mailman/listinfo/python-list

Re: Everything is an object in python - object class and type class

2015-06-03 Thread Terry Reedy
On 6/3/2015 6:20 AM, BartC wrote: But, it is mostly just jargon. If you go back to using 'variable' and 'type', then it becomes a bit easier: * A variable is an instance of some type. That is clear enough in itself, but be aware that many people use 'variable' as a synonym for typeless names

Re: most ambiguous line of code ever written?

2015-06-03 Thread John Ladasky
On Wednesday, June 3, 2015 at 8:21:43 AM UTC-7, Mark Lawrence wrote: > right = not right > > Isn't that just beautiful? A few weeks ago, we were discussing the fact that, in Python 2, True = False, and False = True, were both legal statements in Python. I remarked: "every politician's dream!"

Re: Everything is an object in python - object class and type class

2015-06-03 Thread Terry Reedy
On 6/3/2015 12:00 PM, BartC wrote: That's a different matter. However, you appear to be wrong. print (-12 is -12) gives True. As does ("abc" is "abc"). I assume constructions for immutable values will do the same (([10,20,30] is [10,20,30]) gives False because the constructs are mutable, altho

Re: Everything is an object in python - object class and type class

2015-06-03 Thread BartC
On 03/06/2015 17:36, Michael Torrie wrote: On 06/03/2015 10:00 AM, BartC wrote: The others all give True in all cases. It seems that older Python versions have a purer object model. No. It's just an under-the-hood optimization that the interpreter is making. It's an implementation detail tha

Re: Retrying to send message

2015-06-03 Thread MRAB
On 2015-06-03 17:15, Cecil Westerhof wrote: Op Wednesday 3 Jun 2015 15:29 CEST schreef Chris Angelico: On Wed, Jun 3, 2015 at 10:27 PM, Cecil Westerhof wrote: def send_message(account_id, message, max_tries, terminate_program): error_msg = 'Something went wrong with: ' + message not_send = Tr

Keypress Input

2015-06-03 Thread John McKenzie
Hello. Very new to Python and looking for some basic help. Would like a set-up where something happens when a key is pressed. Not propose a question, have the user type something, then hit return, then something happens, but just the R key is pressed, something happens, then something else

Re: Retrying to send message

2015-06-03 Thread Ethan Furman
On 06/03/2015 09:15 AM, Cecil Westerhof wrote: I kept the except. I like to see the message that went wrong. ;-) That's fine, but then add a `raise` after you print the error so you can see the reason that message failed. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list

Re: Keypress Input

2015-06-03 Thread Laura Creighton
Tkinter runs on raspberry pi. Get it installed, and then run this program. from Tkinter import * root = Tk() prompt = 'Press any key. Remember to keep your mouse in the cyan box. ' lab = Label(root, text=prompt, width=len(prompt), bg='cyan') lab.pack() def key(event): msg = 'event.char is %r

Re: Everything is an object in python - object class and type class

2015-06-03 Thread BartC
On 03/06/2015 17:29, Mark Lawrence wrote: On 03/06/2015 17:00, BartC wrote: On 03/06/2015 13:08, Marko Rauhamaa wrote: BartC : To 'variable' and 'type', you might need to add 'value' to make it more complete. 'Value' and 'object' are indeed synonymous as long as you keep in mind that:

Re: Keypress Input

2015-06-03 Thread Gary Herron
On 06/03/2015 11:22 AM, John McKenzie wrote: Hello. Very new to Python and looking for some basic help. Would like a set-up where something happens when a key is pressed. Not propose a question, have the user type something, then hit return, then something happens, but just the R key is p

Re: Keypress Input

2015-06-03 Thread Gary Herron
On 06/03/2015 11:22 AM, John McKenzie wrote: Hello. Very new to Python and looking for some basic help. Would like a set-up where something happens when a key is pressed. Not propose a question, have the user type something, then hit return, then something happens, but just the R key is p

Re: fork/exec & close file descriptors

2015-06-03 Thread random832
On Wed, Jun 3, 2015, at 09:32, Chris Angelico wrote: > Write an editor that opens a file and holds it open until the user's > done with it. Have something that lets you shell out for whatever > reason. Then trigger the shell-out, and instantly SIGSTOP the child > process, before it does its work -

Re: fork/exec & close file descriptors

2015-06-03 Thread random832
On Wed, Jun 3, 2015, at 10:43, Marko Rauhamaa wrote: > However, the child process needs to be prepared for os.close() to block > indefinitely because of an NFS problem or because SO_LINGER has been > specified by the parent, for example. Setting the close-on-exec flag > doesn't help there. Out of

Re: Retrying to send message

2015-06-03 Thread Mark Lawrence
On 03/06/2015 19:28, Ethan Furman wrote: On 06/03/2015 09:15 AM, Cecil Westerhof wrote: I kept the except. I like to see the message that went wrong. ;-) That's fine, but then add a `raise` after you print the error so you can see the reason that message failed. -- ~Ethan~ Why bother in th

Multiple thread program problem

2015-06-03 Thread Mohan Mohta
Hello I am trying to create multiple thread through the below program but I am getting an error #! /usr/bin/python import os import subprocess import thread import threading from thread import start_new_thread def proc(f) : com1="ssh -B " com2=line.strip('\n') com3= " un

Re: Everything is an object in python - object class and type class

2015-06-03 Thread Mark Lawrence
On 03/06/2015 19:59, BartC wrote: Does anyone need to understand CPython for anything? No you (plural) don't. If people were to spend more time writing code and less time on hypothetical claptrap the amount of noise on this list would probably be reduced by 99%. Then knock out those who

Re: Multiple thread program problem

2015-06-03 Thread MRAB
On 2015-06-03 21:41, Mohan Mohta wrote: Hello I am trying to create multiple thread through the below program but I am getting an error #! /usr/bin/python import os import subprocess import thread import threading from thread import start_new_thread def proc(f) : com1="ssh -B "

Re: How to access the low digits of a list

2015-06-03 Thread Rustom Mody
On Tuesday, June 2, 2015 at 7:50:58 PM UTC+5:30, Ian wrote: > On Tue, Jun 2, 2015 at 6:35 AM, Rustom Mody wrote: > > For that matter even this works > > But I am not sure whats happening or that I like it > > > [x[-2:] for x in lines] > > ['12', '42', '49', '56', '25', '36', '49', '64', '81'

Re: fork/exec & close file descriptors

2015-06-03 Thread Marko Rauhamaa
random...@fastmail.us: > On Wed, Jun 3, 2015, at 10:43, Marko Rauhamaa wrote: >> However, the child process needs to be prepared for os.close() to >> block indefinitely because of an NFS problem or because SO_LINGER has >> been specified by the parent, for example. Setting the close-on-exec >> fla

Re: Let's make Python into LISP

2015-06-03 Thread Rustom Mody
On Wednesday, June 3, 2015 at 4:27:39 AM UTC+5:30, Dr. Bigcock wrote: > We can make Python like LISP: > > 1. Make EVERYTHING the same kind of thing (call it "object"). > 2. Let's make a lot of meta functions like super, instead of judicious use > of interpreter impositions. > 3. Forget *practic

Re: Everything is an object in python - object class and type class

2015-06-03 Thread BartC
On 03/06/2015 21:58, Mark Lawrence wrote: On 03/06/2015 19:59, BartC wrote: Does anyone need to understand CPython for anything? No you (plural) don't. If people were to spend more time writing code and less time on hypothetical claptrap the amount of noise on this list would probably be r

Re: Can Python function return multiple data?

2015-06-03 Thread Chris Angelico
On Wed, Jun 3, 2015 at 11:56 PM, Thomas Rachel wrote: > Am 03.06.2015 um 01:56 schrieb Chris Angelico: > >> and it's pretty convenient. In C, the nearest equivalent is passing a >> number of pointers as parameters, and having the function fill out >> values. Python's model is a lot closer to what

Re: How to access the low digits of a list

2015-06-03 Thread Mark Lawrence
On 03/06/2015 22:08, Rustom Mody wrote: On Tuesday, June 2, 2015 at 7:50:58 PM UTC+5:30, Ian wrote: On Tue, Jun 2, 2015 at 6:35 AM, Rustom Mody wrote: For that matter even this works But I am not sure whats happening or that I like it [x[-2:] for x in lines] ['12', '42', '49', '56', '25',

Re: Everything is an object in python - object class and type class

2015-06-03 Thread Mark Lawrence
On 03/06/2015 22:33, BartC wrote: On 03/06/2015 21:58, Mark Lawrence wrote: Not so hypothetical in my case as I have to implement a lot of this stuff. I'm also quite interested in how Python does things. If it's a good idea I'll copy it, if not I'll try and avoid it! Which implementation, cPy

Re: Let's make Python into LISP

2015-06-03 Thread Mark Lawrence
On 03/06/2015 22:22, Rustom Mody wrote: On Wednesday, June 3, 2015 at 4:27:39 AM UTC+5:30, Dr. Bigcock wrote: We can make Python like LISP: 1. Make EVERYTHING the same kind of thing (call it "object"). 2. Let's make a lot of meta functions like super, instead of judicious use of interpreter

Re: Can Python function return multiple data?

2015-06-03 Thread Mark Lawrence
On 03/06/2015 22:35, Chris Angelico wrote: On Wed, Jun 3, 2015 at 11:56 PM, Thomas Rachel wrote: Am 03.06.2015 um 01:56 schrieb Chris Angelico: and it's pretty convenient. In C, the nearest equivalent is passing a number of pointers as parameters, and having the function fill out values. Pyth

Re: Retrying to send message

2015-06-03 Thread Chris Angelico
On Thu, Jun 4, 2015 at 2:15 AM, Cecil Westerhof wrote: >> And I'd also skip the bare except clause. If you get any sort of >> exception, whether it's a bug, a failure from libturpial, a network >> error, or anything else, your code will just terminate with a bland >> and useless message. Much bett

Re: Multiple thread program problem

2015-06-03 Thread Mohan Mohta
On Wednesday, June 3, 2015 at 4:01:13 PM UTC-5, Sam Raker wrote: > proc(f) isn't a callable, it's whatever it returns. IIRC, you need to do > something like 'start_new_thread(proc, (f,))' If I execute something like t=thread.start_new_thread(proc,(f)) I get: Traceback (most recent call last):

Re: fork/exec & close file descriptors

2015-06-03 Thread Chris Angelico
On Thu, Jun 4, 2015 at 6:07 AM, wrote: > On Wed, Jun 3, 2015, at 09:32, Chris Angelico wrote: >> Write an editor that opens a file and holds it open until the user's >> done with it. Have something that lets you shell out for whatever >> reason. Then trigger the shell-out, and instantly SIGSTOP t

Re: Can Python function return multiple data?

2015-06-03 Thread sohcahtoa82
On Wednesday, June 3, 2015 at 2:57:00 PM UTC-7, Mark Lawrence wrote: > On 03/06/2015 22:35, Chris Angelico wrote: > > On Wed, Jun 3, 2015 at 11:56 PM, Thomas Rachel > > > > wrote: > >> Am 03.06.2015 um 01:56 schrieb Chris Angelico: > >> > >>> and it's pretty convenient. In C, the nearest equivalen

Re: Multiple thread program problem

2015-06-03 Thread Joonas Liik
You think "(f)" makes a tuple, but it does not. the parentesis is not the tuple constructor, the comma is try: t=thread.start_new_thread(proc,(f,)) -- https://mail.python.org/mailman/listinfo/python-list

Re: How to access the low digits of a list

2015-06-03 Thread Ian Kelly
On Wed, Jun 3, 2015 at 3:08 PM, Rustom Mody wrote: > On Tuesday, June 2, 2015 at 7:50:58 PM UTC+5:30, Ian wrote: >> On Tue, Jun 2, 2015 at 6:35 AM, Rustom Mody wrote: >> > For that matter even this works >> > But I am not sure whats happening or that I like it >> > >> [x[-2:] for x in lines

Re: Everything is an object in python - object class and type class

2015-06-03 Thread BartC
On 03/06/2015 22:49, Mark Lawrence wrote: On 03/06/2015 22:33, BartC wrote: On 03/06/2015 21:58, Mark Lawrence wrote: Not so hypothetical in my case as I have to implement a lot of this stuff. I'm also quite interested in how Python does things. If it's a good idea I'll copy it, if not I'll tr

Re: Retrying to send message

2015-06-03 Thread Ethan Furman
On 06/03/2015 01:37 PM, Mark Lawrence wrote: On 03/06/2015 19:28, Ethan Furman wrote: On 06/03/2015 09:15 AM, Cecil Westerhof wrote: I kept the except. I like to see the message that went wrong. ;-) That's fine, but then add a `raise` after you print the error so you can see the reason that

Re: Multiple thread program problem

2015-06-03 Thread Mohan Mohta
On Wednesday, June 3, 2015 at 5:34:31 PM UTC-5, Waffle wrote: > You think "(f)" makes a tuple, but it does not. > the parentesis is not the tuple constructor, the comma is > try: > t=thread.start_new_thread(proc,(f,)) Thanks for the pointer waffle. The program executes now but still not the way I

Re: Multiple thread program problem

2015-06-03 Thread sohcahtoa82
On Wednesday, June 3, 2015 at 4:45:52 PM UTC-7, M2 wrote: > On Wednesday, June 3, 2015 at 5:34:31 PM UTC-5, Waffle wrote: > > You think "(f)" makes a tuple, but it does not. > > the parentesis is not the tuple constructor, the comma is > > try: > > t=thread.start_new_thread(proc,(f,)) > > Thanks f

Re: Multiple thread program problem

2015-06-03 Thread M2
On Wednesday, June 3, 2015 at 6:56:47 PM UTC-5, sohca...@gmail.com wrote: > On Wednesday, June 3, 2015 at 4:45:52 PM UTC-7, M2 wrote: > > On Wednesday, June 3, 2015 at 5:34:31 PM UTC-5, Waffle wrote: > > > You think "(f)" makes a tuple, but it does not. > > > the parentesis is not the tuple constru

Re: Multiple thread program problem

2015-06-03 Thread Cameron Simpson
On 03Jun2015 17:04, M2 wrote: On Wednesday, June 3, 2015 at 6:56:47 PM UTC-5, sohca...@gmail.com wrote: On Wednesday, June 3, 2015 at 4:45:52 PM UTC-7, M2 wrote: > On Wednesday, June 3, 2015 at 5:34:31 PM UTC-5, Waffle wrote: > > You think "(f)" makes a tuple, but it does not. > > the parentesi

Re: Can Python function return multiple data?

2015-06-03 Thread Chris Angelico
On Thu, Jun 4, 2015 at 11:30 AM, Dennis Lee Bieber wrote: > On Wed, 3 Jun 2015 15:28:56 -0700 (PDT), sohcahto...@gmail.com declaimed > the following: > >> >>People actually argue that Python passes by value? This is easily proven >>wrong by passing a mutable object to a function and changing it

Re: Let's make Python into LISP

2015-06-03 Thread Ned Batchelder
On Wednesday, June 3, 2015 at 5:50:24 PM UTC-4, Mark Lawrence wrote: > On 03/06/2015 22:22, Rustom Mody wrote: > > On Wednesday, June 3, 2015 at 4:27:39 AM UTC+5:30, Dr. Bigcock wrote: > >> We can make Python like LISP: > >> > >> 1. Make EVERYTHING the same kind of thing (call it "object"). > >> 2

Re: Multiple thread program problem

2015-06-03 Thread M2
On Wednesday, June 3, 2015 at 7:38:22 PM UTC-5, Cameron Simpson wrote: > On 03Jun2015 17:04, M2 wrote: > >On Wednesday, June 3, 2015 at 6:56:47 PM UTC-5, sohca...@gmail.com wrote: > >> On Wednesday, June 3, 2015 at 4:45:52 PM UTC-7, M2 wrote: > >> > On Wednesday, June 3, 2015 at 5:34:31 PM UTC-5,

Re: Let's make Python into LISP

2015-06-03 Thread Rustom Mody
On Thursday, June 4, 2015 at 7:24:19 AM UTC+5:30, Ned Batchelder wrote: > On Wednesday, June 3, 2015 at 5:50:24 PM UTC-4, Mark Lawrence wrote: > > On 03/06/2015 22:22, Rustom Mody wrote: > > > On Wednesday, June 3, 2015 at 4:27:39 AM UTC+5:30, Dr. Bigcock wrote: > > >> We can make Python like LISP:

Re: Find in ipython3

2015-06-03 Thread Cameron Simpson
On 02Jun2015 18:13, Cecil Westerhof wrote: I am thinking about using ipython3 instead of bash. When I want to find a file I can do the following: !find ~ -iname '*python*.pdf' but is there a python way? That succinct? Not out of the box, but something can easily be built on top of the os.w

  1   2   >