I try to edit and find data from a text file with python 2.7 (data from stock market)

2018-09-07 Thread alon . najman
hi, I try to edit a text file with python 2.7: * AAPL * Date: September 07 2018 Time: 14:10:52 Price: ,068,407 Ask: None High: None Low: None Previous Close: ,068,407 Volume: $ 227.35 / $ 221.30 Market Cap: 20.23 but when I write it to a file I get: {'previous_close': ',068,407', 'volume

I need help to put the output from terminal in a csv file

2018-09-07 Thread catanaangelo
HI! I need help putting the output from terminal in a csv file. I work on linux and I have python 2.7.15. I am running a python program which also runs some shell scripts. I need to capture the output from the .sh scripts and put it nicely in a csv table. I am using "commands.getoutput('bash ex

Re: Any SML coders able to translate this to Python?

2018-09-07 Thread Steven D'Aprano
On Thu, 06 Sep 2018 13:48:54 +0300, Marko Rauhamaa wrote: > Chris Angelico : >> The request was to translate this into Python, not to slavishly imitate >> every possible semantic difference even if it won't actually affect >> behaviour. > > I trust Steven to be able to refactor the code into some

Re: Any SML coders able to translate this to Python?

2018-09-07 Thread Paul Moore
On Fri, 7 Sep 2018 at 14:06, Steven D'Aprano wrote: > > On Thu, 06 Sep 2018 13:48:54 +0300, Marko Rauhamaa wrote: > > > Chris Angelico : > >> The request was to translate this into Python, not to slavishly imitate > >> every possible semantic difference even if it won't actually affect > >> behavi

Re: I need help to put the output from terminal in a csv file

2018-09-07 Thread Brian Oney via Python-list
Please study the following to get you started. It looks like JSON output that you are dealing, which is good. I added a ", to the "body"-line, because I assume that you botched that when giving an example. ```python #!/usr/bin/env python import json output = ''' {    "error" : {   "body"

Re: Any SML coders able to translate this to Python?

2018-09-07 Thread Neil Cerutti
On 2018-09-07, Steven D'Aprano wrote: > On Thu, 06 Sep 2018 13:48:54 +0300, Marko Rauhamaa wrote: > >> Chris Angelico : >>> The request was to translate this into Python, not to slavishly imitate >>> every possible semantic difference even if it won't actually affect >>> behaviour. >> >> I trust

Re: I need help to put the output from terminal in a csv file

2018-09-07 Thread Rhodri James
On 07/09/18 13:55, catanaang...@gmail.com wrote: HI! I need help putting the output from terminal in a csv file. I work on linux and I have python 2.7.15. I am running a python program which also runs some shell scripts. I need to capture the output from the .sh scripts and put it nicely in a

Re: ModuleNotFoundError: No module named 'encodings'

2018-09-07 Thread Jason Qian via Python-list
Thanks Thomas, You are right, this seems the Python home configuration issue. One more question. Is there a way I can catch the error ( Fatal Python error: initfsencoding: ..) as exception in the c code ? try{ Py_Initialize(); }catch(xxx) { } Thanks On Thu, Sep 6, 2018 at 5:29 PM, Tho

RE: Why emumerated list is empty on 2nd round of print?

2018-09-07 Thread Schachner, Joseph
The question "If I do this "aList = enumerate(numList)", isn't it stored permanently in aList now? I see your point to use it directly, but just in case I do need to hang onto it from one loop to another, then how is that done?" Reflects that you are thinking in a C++ kind of way I think. Whe

Re: I try to edit and find data from a text file with python 2.7 (data from stock market)

2018-09-07 Thread Peter Otten
alon.naj...@gmail.com wrote: > hi, > > I try to edit a text file with python 2.7: > > * AAPL * > Date: September 07 2018 > Time: 14:10:52 > Price: ,068,407 > Ask: None > High: None > Low: None > Previous Close: ,068,407 > Volume: $ 227.35 / $ 221.30 > Market Cap: 20.23 It looks like the

Re: Any SML coders able to translate this to Python?

2018-09-07 Thread Paul Moore
On Fri, 7 Sep 2018 at 15:10, Paul Moore wrote: > > On Fri, 7 Sep 2018 at 14:06, Steven D'Aprano > wrote: > > > > On Thu, 06 Sep 2018 13:48:54 +0300, Marko Rauhamaa wrote: > > > > > Chris Angelico : > > >> The request was to translate this into Python, not to slavishly imitate > > >> every possibl

Re: ModuleNotFoundError: No module named 'encodings'

2018-09-07 Thread Thomas Jollans
On 2018-09-07 17:13, Jason Qian via Python-list wrote: > Thanks Thomas, > > You are right, this seems the Python home configuration issue. > > One more question. > > Is there a way I can catch the error ( Fatal Python error: initfsencoding: > ..) as exception in the c code ? It's a fatal error,

Re: Any SML coders able to translate this to Python?

2018-09-07 Thread Marko Rauhamaa
Paul Moore : > On Fri, 7 Sep 2018 at 15:10, Paul Moore wrote: >> >> On Fri, 7 Sep 2018 at 14:06, Steven D'Aprano >> wrote: >> > However I have a follow up question. Why the "let" construct in the >> > first place? Is this just a matter of principle, "put everything in >> > its own scope as a mat

Re: don't quite understand mailing list

2018-09-07 Thread Mark Lawrence
On 07/09/18 03:40, Steven D'Aprano wrote: On Thu, 06 Sep 2018 13:06:22 -0700, Ethan Furman wrote: On 09/06/2018 12:42 PM, Reto Brunner wrote: What do you think the link, which is attached to every email you receive from the list, is for? Listinfo sounds very promising, doesn't it? And if you

Re: I need help to put the output from terminal in a csv file

2018-09-07 Thread catanaangelo
Thanks a lot, I've managed to make it work they way I wanted -- https://mail.python.org/mailman/listinfo/python-list

Re: Why emumerated list is empty on 2nd round of print?

2018-09-07 Thread Oscar Benjamin
On Fri, 7 Sep 2018 at 16:25, Schachner, Joseph wrote: >... > Now, on to the second part: the problem you showed - that you can only loop > through aList:print(i,j) once - is BECAUSE you hung onto it from one loop to > another. Once the iterator is exhausted, it's exhausted. > > Think of another

Re: Any SML coders able to translate this to Python?

2018-09-07 Thread Marko Rauhamaa
Marko Rauhamaa : > def f(n): > def auxf1(sum, m, i): > if i == n: > return sum > else: > def auxf2(sum, m, i): > if sum % m == 0: > return auxf1(sum, m + 1, i) > else

Re: Object-oriented philosophy

2018-09-07 Thread Michael F. Stemper
On 2018-09-06 16:00, MRAB wrote: > On 2018-09-06 21:24, Michael F. Stemper wrote: >> On 2018-09-06 09:35, Rhodri James wrote: >>> Is it worth creating the superclass in Python?  It sounds like it's a >>> bit marginal in your case.  I'm not that seasoned in object-oriented >>> design either, but my

Re: Object-oriented philosophy

2018-09-07 Thread Michael F. Stemper
On 2018-09-07 14:51, Michael F. Stemper wrote: > On 2018-09-06 16:00, MRAB wrote: >> On 2018-09-06 21:24, Michael F. Stemper wrote: >> A word of advice: don't use a "bare" except, i.e. one that doesn't >> specify what exception(s) it should catch. > In another case where I had a "bare exception",

Re: Object-oriented philosophy

2018-09-07 Thread MRAB
On 2018-09-07 20:51, Michael F. Stemper wrote: On 2018-09-06 16:00, MRAB wrote: On 2018-09-06 21:24, Michael F. Stemper wrote: On 2018-09-06 09:35, Rhodri James wrote: Is it worth creating the superclass in Python?  It sounds like it's a bit marginal in your case.  I'm not that seasoned in o

Re: Object-oriented philosophy

2018-09-07 Thread MRAB
On 2018-09-07 21:08, Michael F. Stemper wrote: On 2018-09-07 14:51, Michael F. Stemper wrote: On 2018-09-06 16:00, MRAB wrote: On 2018-09-06 21:24, Michael F. Stemper wrote: A word of advice: don't use a "bare" except, i.e. one that doesn't specify what exception(s) it should catch. In an

Re: Object-oriented philosophy

2018-09-07 Thread Michael F. Stemper
On 2018-09-07 15:39, MRAB wrote: > On 2018-09-07 20:51, Michael F. Stemper wrote: >> On 2018-09-06 16:00, MRAB wrote: >>> A word of advice: don't use a "bare" except, i.e. one that doesn't >>> specify what exception(s) it should catch. >> >> Given that I moved the first line ("P_0s = ...") out of

Re: Object-oriented philosophy

2018-09-07 Thread Steven D'Aprano
On Fri, 07 Sep 2018 16:07:06 -0500, Michael F. Stemper wrote: >>> In another case where I had a "bare exception", I was using it to see >>> if something was defined and substitute a default value if it wasn't. >>> Have I cleaned this up properly? >>> >>>   try >>>     id = xmlmodel.attrib['name']

Re: don't quite understand mailing list

2018-09-07 Thread Steven D'Aprano
On Fri, 07 Sep 2018 07:39:33 +0300, Marko Rauhamaa wrote: > I'm with Ethan on this one. > > There was nothing in the original posting that merited ridicule. Then its a good thing there was nothing in the response that was ridicule. (A mild rebuke for a mild social faux pas is not ridicule.) -

Re: Any SML coders able to translate this to Python?

2018-09-07 Thread Steven D'Aprano
On Fri, 07 Sep 2018 15:10:10 +0100, Paul Moore wrote: > On Fri, 7 Sep 2018 at 14:06, Steven D'Aprano > wrote: [...] >> However I have a follow up question. Why the "let" construct in the >> first place? Is this just a matter of principle, "put everything in its >> own scope as a matter of precau