Re: Append some stuff into a file with only the last appended line reserved.

2019-09-03 Thread Hongyi Zhao
On Tue, 03 Sep 2019 08:29:31 +1000, Cameron Simpson wrote: > Please describe this in more detail. Present a little pycurl output and > then explain what portion of it should land in the log file. See the following code from here: http://pycurl.io/docs/latest/callbacks.html#xferinfofunction

Re: Append some stuff into a file with only the last appended line reserved.

2019-09-02 Thread Cameron Simpson
On 01Sep2019 04:13, Hongyi Zhao wrote: I want to append some log of pycurl's downloading info to file, and I only want to reserve the last appended line when write. How to do this? Please describe this in more detail. Present a little pycurl output and then explain what portion of it s

Re: How to create a list and append to list inside a mqtt and GUI program?

2019-09-01 Thread Richard Damon
On 9/1/19 4:02 PM, Spencer Du wrote: > Hi > > I have code for GUI and MQTT. In GUI.py I have "def loadGUI" which loads up a > GUI file if the file exists in current directory. I want to add the file name > to a list when a file is imported and for each subsequent file that is > imported I want

Re: How to create a list and append to list inside a mqtt and GUI program?

2019-09-01 Thread MRAB
On 2019-09-01 21:02, Spencer Du wrote: Hi I have code for GUI and MQTT. In GUI.py I have "def loadGUI" which loads up a GUI file if the file exists in current directory. I want to add the file name to a list when a file is imported and for each subsequent file that is imported I want the file

Re: How to create a list and append to list inside a mqtt and GUI program?

2019-09-01 Thread Sayth Renshaw
On Monday, 2 September 2019 06:02:58 UTC+10, Spencer Du wrote: > Hi > > I have code for GUI and MQTT. In GUI.py I have "def loadGUI" which loads up a > GUI file if the file exists in current directory. I want to add the file name > to a list when a file is imported and for each subsequent file

How to create a list and append to list inside a mqtt and GUI program?

2019-09-01 Thread Spencer Du
Hi I have code for GUI and MQTT. In GUI.py I have "def loadGUI" which loads up a GUI file if the file exists in current directory. I want to add the file name to a list when a file is imported and for each subsequent file that is imported I want the file name to be imported to the same list an

Append some stuff into a file with only the last appended line reserved.

2019-08-31 Thread Hongyi Zhao
Hi: I want to append some log of pycurl's downloading info to file, and I only want to reserve the last appended line when write. How to do this? -- https://mail.python.org/mailman/listinfo/python-list

Re: How to append horizontally the data array from the FOR loop?

2019-05-10 Thread Cameron Simpson
On 10May2019 08:08, Madhavan Bomidi wrote: I have to append requisite data matrix from multiple files into a single variable using FOR loop. outData = []; for file in fileList: allData = # an array of nrows and ncols. outData = [outData; allData] # in MATLAB

Re: How to append horizontally the data array from the FOR loop?

2019-05-10 Thread Rhodri James
On 10/05/2019 16:08, Madhavan Bomidi wrote: Hi, I have to append requisite data matrix from multiple files into a single variable using FOR loop. outData = []; for file in fileList: allData = # an array of nrows and ncols. outData

How to append horizontally the data array from the FOR loop?

2019-05-10 Thread Madhavan Bomidi
Hi, I have to append requisite data matrix from multiple files into a single variable using FOR loop. outData = []; for file in fileList: allData = # an array of nrows and ncols. outData = [outData; allData] # in MATLAB While the ncols are

Re: why it append one more letter after decode?

2017-10-30 Thread ROGER GRAYDON CHRISTMAN
On Sun, Oct 29, 2017 11:06 PM, Ho Yeung Lee wrote: > if run these function to decode in python interactive console, >it can decode correct, > >but when run with a big project, it append a letter Y > > >On Monday, October 30, 2017 at 9:48:36 AM UTC+8, Ho Yeung Lee wrote: &

Re: why it append one more letter after decode?

2017-10-29 Thread Ho Yeung Lee
AM UTC+8, Ho Yeung Lee wrote: > >> if run these function to decode in python interactive console, > >> it can decode correct, > >> > >> but when run with a big project, it append a letter Y > >> > >> > >> On Monday, October 30,

Re: why it append one more letter after decode?

2017-10-29 Thread Igor Korot
nt. Thank you. > > On Monday, October 30, 2017 at 9:51:01 AM UTC+8, Ho Yeung Lee wrote: >> if run these function to decode in python interactive console, >> it can decode correct, >> >> but when run with a big project, it append a letter Y >> >>

Re: why it append one more letter after decode?

2017-10-29 Thread Ho Yeung Lee
> decode(r"\\",1,2) > [[ > > it double > > On Monday, October 30, 2017 at 9:51:01 AM UTC+8, Ho Yeung Lee wrote: > > if run these function to decode in python interactive console, > > it can decode correct, > > > > but when run with a big proje

Re: why it append one more letter after decode?

2017-10-29 Thread Igor Korot
run with a big project, it append a letter Y > > > On Monday, October 30, 2017 at 9:48:36 AM UTC+8, Ho Yeung Lee wrote: >> def leftrotate(l, n): >> return l[n:] + l[:n] >> >> def rightrotate(l, n): >> return l[-n:] + l[:-n] >> >> def encode(

Re: why it append one more letter after decode?

2017-10-29 Thread Ho Yeung Lee
> it can decode correct, > > but when run with a big project, it append a letter Y > > > On Monday, October 30, 2017 at 9:48:36 AM UTC+8, Ho Yeung Lee wrote: > > def leftrotate(l, n): > > return l[n:] + l[:n] > > > > def rightrotate(l, n): > >

Re: why it append one more letter after decode?

2017-10-29 Thread Ho Yeung Lee
if run these function to decode in python interactive console, it can decode correct, but when run with a big project, it append a letter Y On Monday, October 30, 2017 at 9:48:36 AM UTC+8, Ho Yeung Lee wrote: > def leftrotate(l, n): > return l[n:] + l[:n] > > def righ

why it append one more letter after decode?

2017-10-29 Thread Ho Yeung Lee
rn ''.join([chr(i - k) for i in l]) yesterday i add above code and run it with batch file it can decode a correct password then i install cx_freeze to produce executable file but today when i run it, i see the source of encrypted password is correct but the decode one, it append one more

Re: list of the lists - append after search

2017-03-05 Thread gvmcmt
On Thursday, March 2, 2017 at 9:33:14 PM UTC+5:30, Andrew Zyman wrote: > Hello, > please advise. > > I'd like search and append the internal list in the list-of-the-lists. > > Example: > ll =[ [a,1], [b,2], [c,3], [blah, 1000] ] > > i want to search for the

Re: list of the lists - append after search

2017-03-03 Thread Andrew Zyman
On Thursday, March 2, 2017 at 3:53:25 PM UTC-5, Andrew Zyman wrote: > On Thursday, March 2, 2017 at 3:31:36 PM UTC-5, Jussi Piitulainen wrote: > > Andrew Zyman writes: > > > > > On Thursday, March 2, 2017 at 2:57:02 PM UTC-5, Jussi Piitulainen wrote: > > >> Peter Otten <__pete...@web.de> writes: >

Re: list of the lists - append after search

2017-03-02 Thread Andrew Zyman
On Thursday, March 2, 2017 at 3:31:36 PM UTC-5, Jussi Piitulainen wrote: > Andrew Zyman writes: > > > On Thursday, March 2, 2017 at 2:57:02 PM UTC-5, Jussi Piitulainen wrote: > >> Peter Otten <__pete...@web.de> writes: > >> > >> > Andrew Zyman wrote: > >> > > >> >> On Thursday, March 2, 2017 at 1

Re: list of the lists - append after search

2017-03-02 Thread Jussi Piitulainen
Andrew Zyman writes: > On Thursday, March 2, 2017 at 2:57:02 PM UTC-5, Jussi Piitulainen wrote: >> Peter Otten <__pete...@web.de> writes: >> >> > Andrew Zyman wrote: >> > >> >> On Thursday, March 2, 2017 at 11:27:34 AM UTC-5, Peter Otten wrote: >> >>> Andrew Zyman wrote: >> >>> . >> >>> .

Re: list of the lists - append after search

2017-03-02 Thread Andrew Zyman
On Thursday, March 2, 2017 at 2:57:02 PM UTC-5, Jussi Piitulainen wrote: > Peter Otten <__pete...@web.de> writes: > > > Andrew Zyman wrote: > > > >> On Thursday, March 2, 2017 at 11:27:34 AM UTC-5, Peter Otten wrote: > >>> Andrew Zyman wrote: > >>> . > >>> . > >>> > End result: > >>> > ll

Re: list of the lists - append after search

2017-03-02 Thread Jussi Piitulainen
Peter Otten <__pete...@web.de> writes: > Andrew Zyman wrote: > >> On Thursday, March 2, 2017 at 11:27:34 AM UTC-5, Peter Otten wrote: >>> Andrew Zyman wrote: >>> . >>> . >>> > End result: >>> > ll =[ [a,1], [b,2], [c,3], [blah, 1000, 'new value'] ] >>> >>> >>> outer = [["a", 1], ["b", 2]

Re: list of the lists - append after search

2017-03-02 Thread Peter Otten
Andrew Zyman wrote: > On Thursday, March 2, 2017 at 11:27:34 AM UTC-5, Peter Otten wrote: >> Andrew Zyman wrote: >> . >> . >> > End result: >> > ll =[ [a,1], [b,2], [c,3], [blah, 1000, 'new value'] ] >> >> >>> outer = [["a", 1], ["b", 2], ["c", 3], ["blah", 1000]] >> >>> for inner in out

Re: list of the lists - append after search

2017-03-02 Thread Andrew Zyman
On Thursday, March 2, 2017 at 11:27:34 AM UTC-5, Peter Otten wrote: > Andrew Zyman wrote: > . > . > > End result: > > ll =[ [a,1], [b,2], [c,3], [blah, 1000, 'new value'] ] > > >>> outer = [["a", 1], ["b", 2], ["c", 3], ["blah", 1000]] > >>> for inner in outer: > ... if inner[0] == "b

Re: list of the lists - append after search

2017-03-02 Thread Peter Otten
Andrew Zyman wrote: > Hello, > please advise. > > I'd like search and append the internal list in the list-of-the-lists. > > Example: > ll =[ [a,1], [b,2], [c,3], [blah, 1000] ] > > i want to search for the internal [] based on the string field and, if >

list of the lists - append after search

2017-03-02 Thread Andrew Zyman
Hello, please advise. I'd like search and append the internal list in the list-of-the-lists. Example: ll =[ [a,1], [b,2], [c,3], [blah, 1000] ] i want to search for the internal [] based on the string field and, if matches, append that list with a value. if internal_list[0] ==

Re: Find and append file path

2017-01-12 Thread Tim Chase
On 2017-01-12 18:32, Peter Otten wrote: > Why did you add an explicit isdir() check? My understanding is that > the names in dirs are known to be directories. Ah, right. The code I had laying around that did something similar but processes both the dirs and the files, so when the OP asked for jus

Re: Find and append file path

2017-01-12 Thread Peter Otten
Tim Chase wrote: > def dir_iter(root): > for fullpath in ( > os.path.join(path, dir_) > for path, dirs, files in os.walk(root) > for dir_ in dirs > ): > if os.path.isdir(fullpath): > yield fullpath Why did you add an explicit

Re: Find and append file path

2017-01-12 Thread Tim Chase
On 2017-01-12 19:28, Iranna Mathapati wrote: > Example: > CLI Input: /root/user/branches/xyz > > find latest file and append to CLI path: > "/root/user/branches/xyz/Apple" I've used something like the below to find the most recent file in a directory tree (i

Re: Find and append file path

2017-01-12 Thread Rhodri James
On 12/01/17 13:58, Iranna Mathapati wrote: Hi Team, How to append file path and find the latest folder according to the latest date: CLI input :"/root/user/branches/xyz" i want to find latest file within CLI input path and append to given CLI path Example: CLI Input: /root/user/br

Find and append file path

2017-01-12 Thread Iranna Mathapati
Hi Team, How to append file path and find the latest folder according to the latest date: CLI input :"/root/user/branches/xyz" i want to find latest file within CLI input path and append to given CLI path Example: CLI Input: /root/user/branches/xyz find latest file and append t

Re: How to append a modified list into a list?

2016-11-19 Thread jfong
Peter Otten at 2016/11/19 5:40:34PM wrote: > And now for something completely different ;) > > What if you only record the changes to the list? For a long list that would > save space at the expense of calculation time. For example: Excellent! Although not 100% fit into my application, I must st

Re: How to append a modified list into a list?

2016-11-19 Thread Peter Otten
jf...@ms4.hinet.net wrote: > I have a working list 'tbl' and recording list 'm'. I want to append 'tbl' > into 'm' each time when the 'tbl' was modified. I will record the change > by append it through the function 'apl'. &g

Re: How to append a modified list into a list?

2016-11-18 Thread jfong
Oh, I don't know slice well enough:-( So, slice tbl[:] will create a new object (a copy of tbl) which can be passed as a function argument m.append(tbl[:]) or bind to a new name w=tbl[:] or re-bind to itself w[:]=tbl Thanks you, Ian and Steve. Steve D'Aprano at 2016/11/19 11:01:26AM wrote: >

Re: How to append a modified list into a list?

2016-11-18 Thread Steve D'Aprano
On Sat, 19 Nov 2016 12:44 pm, jf...@ms4.hinet.net wrote: > I have a working list 'tbl' and recording list 'm'. I want to append 'tbl' > into 'm' each time when the 'tbl' was modified. I will record the change > by append it through t

Re: How to append a modified list into a list?

2016-11-18 Thread Ian Kelly
On Nov 18, 2016 6:47 PM, wrote: I have a working list 'tbl' and recording list 'm'. I want to append 'tbl' into 'm' each time when the 'tbl' was modified. I will record the change by append it through the function 'apl'. For exampl

How to append a modified list into a list?

2016-11-18 Thread jfong
I have a working list 'tbl' and recording list 'm'. I want to append 'tbl' into 'm' each time when the 'tbl' was modified. I will record the change by append it through the function 'apl'. For example: >>>tbl=[0,0] >&g

Re: how to append to list in list comprehension

2016-09-30 Thread Sayth Renshaw
declaratively (the buzzword FP!) or imperatively. > Python is rather unique in the extent to which it allows both > This also makes it uniquely difficult because its all too easy to garble the > two styles as John's .append inside a LC illustrates. > > And the way to ungar

Re: how to append to list in list comprehension

2016-09-30 Thread Sayth Renshaw
declaratively (the buzzword FP!) or imperatively. > Python is rather unique in the extent to which it allows both > This also makes it uniquely difficult because its all too easy to garble the > two styles as John's .append inside a LC illustrates. > > And the way to ungar

Re: how to append to list in list comprehension

2016-09-30 Thread Rustom Mody
2 its important that you always keep in front of you whether you want to approach a problem declaratively (the buzzword FP!) or imperatively. Python is rather unique in the extent to which it allows both This also makes it uniquely difficult because its all too easy to garble the two styles as Jo

Re: how to append to list in list comprehension

2016-09-30 Thread Sayth Renshaw
> > I want to go threw and for each index error at [4] append a 0. > > You want to append 0 if the list does not have at least 5 items? > > > p = re.compile('\d+') > > fups = p.findall(nomattr['firstup']) > > [x[4] for x in fups if IndexErro

Re: how to append to list in list comprehension

2016-09-30 Thread Rustom Mody
On Saturday, October 1, 2016 at 7:48:19 AM UTC+5:30, John Gordon wrote: > In Sayth Renshaw writes: > > > I want to go threw and for each index error at [4] append a 0. > > You want to append 0 if the list does not have at least 5 items? > > > p = re.compile('\d

Re: how to append to list in list comprehension

2016-09-30 Thread John Gordon
In <534d5506-1810-4a79-ac8f-95a664d17...@googlegroups.com> Sayth Renshaw writes: > I want to go threw and for each index error at [4] append a 0. You want to append 0 if the list does not have at least 5 items? > p = re.compile('\d+') > fups = p.findall(nomattr[&#x

how to append to list in list comprehension

2016-09-30 Thread Sayth Renshaw
['0', '0', '0', '0'] ['0', '0', '0', '0'] ['7', '2', '1', '0', '142647', '00'] ['7', '2', '0', '1', '87080'

Re: is there a concurrent list for append in parallel programming in python? how to pass parameter in this parallel program with pool?

2016-06-21 Thread Ian Kelly
On Thu, Jun 16, 2016 at 2:45 AM, meInvent bbird wrote: > the name in c# is not called concurrent list, it is called > blockingcollection > > dictionary called concurrent dictionary > > thread safe these kind of things > > https://msdn.microsoft.com/en-us/library/dd267312(v=vs.110).aspx > > https:/

Re: is there a concurrent list for append in parallel programming in python? how to pass parameter in this parallel program with pool?

2016-06-16 Thread meInvent bbird
how can list be synchronized when multiprocessor working in it? will one thread updating non-updated version, but another processor updating the version? On Thursday, June 16, 2016 at 4:30:33 PM UTC+8, Steven D'Aprano wrote: > On Thursday 16 June 2016 17:28, meInvent bbird wrote: > > > is there

Re: is there a concurrent list for append in parallel programming in python? how to pass parameter in this parallel program with pool?

2016-06-16 Thread meInvent bbird
the name in c# is not called concurrent list, it is called blockingcollection dictionary called concurrent dictionary thread safe these kind of things https://msdn.microsoft.com/en-us/library/dd267312(v=vs.110).aspx https://msdn.microsoft.com/en-us/library/dd997369(v=vs.110).aspx https://msdn.

Re: is there a concurrent list for append in parallel programming in python? how to pass parameter in this parallel program with pool?

2016-06-16 Thread Steven D'Aprano
On Thursday 16 June 2016 17:28, meInvent bbird wrote: > is there like c# have concurrent list ? What is a concurrent list? Can you link to the C# documentation for this? To me, "concurrent" describes a style of execution flow, and "list" describes a data structure. I am struggling to understan

is there a concurrent list for append in parallel programming in python? how to pass parameter in this parallel program with pool?

2016-06-16 Thread meInvent bbird
is there like c# have concurrent list ? i find something these, but how can it pass an initlist list variable is it doing the same function as itertools.combinations ? def comb(n, initlist): # the argument n is the number of items to select res = list(itertools.combinations(initlist, n))

Re: how to for loop append a list [] when using parallel programming

2016-06-15 Thread meInvent bbird
Gordon wrote: > In meInvent bbird > writes: > > > how to for loop append a list [] when using parallel programming > > items = [] > for item in parallelized_object_factory(): > items.append(item) > > If you want a more specific ans

Re: how to for loop append a list [] when using parallel programming

2016-06-15 Thread John Gordon
In meInvent bbird writes: > how to for loop append a list [] when using parallel programming items = [] for item in parallelized_object_factory(): items.append(item) If you want a more specific answer, ask a more specific question. -- John Gordon A is

how to for loop append a list [] when using parallel programming

2016-06-15 Thread meInvent bbird
how to for loop append a list [] when using parallel programming -- https://mail.python.org/mailman/listinfo/python-list

Re: Python path and append

2016-04-29 Thread Steven D'Aprano
On Sat, 30 Apr 2016 06:26 am, boB Stepp wrote: > On Mon, Apr 25, 2016 at 8:51 PM, Steven D'Aprano > wrote: > >> See here for the *start* of a more professional approach: >> >> http://code.activestate.com/recipes/579097-safely-and-atomically-write-to-a-file/ > > What else would I need to know/co

Re: Python path and append

2016-04-29 Thread boB Stepp
On Mon, Apr 25, 2016 at 8:51 PM, Steven D'Aprano wrote: > See here for the *start* of a more professional approach: > > http://code.activestate.com/recipes/579097-safely-and-atomically-write-to-a-file/ What else would I need to know/consider in order to have a *complete* professional approach?

Re: Python path and append

2016-04-27 Thread Stephen Hansen
On Tue, Apr 26, 2016, at 07:56 PM, Seymore4Head wrote: > On Tue, 26 Apr 2016 11:53:57 +1000, Steven D'Aprano > wrote: > > >On Tue, 26 Apr 2016 08:04 am, Seymore4Head wrote: > > > >> BTW I was trying to use a line like yours that used an output file > >> that didn't exist and was getting an error.

Re: Python path and append

2016-04-26 Thread Chris Angelico
On Wed, Apr 27, 2016 at 12:56 PM, Seymore4Head wrote: > On Tue, 26 Apr 2016 11:53:57 +1000, Steven D'Aprano > wrote: > >>On Tue, 26 Apr 2016 08:04 am, Seymore4Head wrote: >> >>> BTW I was trying to use a line like yours that used an output file >>> that didn't exist and was getting an error. I a

Re: Python path and append

2016-04-26 Thread Seymore4Head
On Tue, 26 Apr 2016 19:16:56 +0100, Michael wrote: >If you want to read an entire file, append a space and asterisk and write it >to another file, this is the code you need: > >infile = open('win.txt', 'r') >text = f.read() >infile.close() >text

Re: Python path and append

2016-04-26 Thread Seymore4Head
On Tue, 26 Apr 2016 11:53:57 +1000, Steven D'Aprano wrote: >On Tue, 26 Apr 2016 08:04 am, Seymore4Head wrote: > >> BTW I was trying to use a line like yours that used an output file >> that didn't exist and was getting an error.  I assume that import os >> fixes that. > > >Why would you assume th

Re: Python path and append

2016-04-26 Thread Michael
If you want to read an entire file, append a space and asterisk and write it to another file, this is the code you need: infile = open('win.txt', 'r') text = f.read() infile.close() text += " *" outfile = open('outfile.txt', 'w') outfile.write

Re: Python path and append

2016-04-25 Thread Gregory Ewing
Steven D'Aprano wrote: (Possible a few very old operating systems on supercomputers from the 1970s or 80s may have supported inserting... I seem to recall that VMS may have allowed that... but don't quote me.) I wouldn't be surprised if VMS provided some sort of indexed random-access file struc

Re: Python path and append

2016-04-25 Thread Dan Sommers
On Tue, 26 Apr 2016 11:51:23 +1000, Steven D'Aprano wrote: > ... (Possible a few very old operating systems on supercomputers from > the 1970s or 80s may have supported inserting... I seem to recall that > VMS may have allowed that... but don't quote me.) Some [non-supercomputer] OSes/filesystems

Re: Python path and append

2016-04-25 Thread Steven D'Aprano
On Tue, 26 Apr 2016 08:04 am, Seymore4Head wrote: > BTW I was trying to use a line like yours that used an output file > that didn't exist and was getting an error.  I assume that import os > fixes that. Why would you assume that? "Doctor, I have a problem with my arm, but I won't tell you wha

Re: Python path and append

2016-04-25 Thread Steven D'Aprano
puters from the 1970s or 80s may have supported inserting... I seem to recall that VMS may have allowed that... but don't quote me.) So you can append to the *end* of a file without disrupting the content, but you cannot insert to the middle or beginning of a file without overwriting. The basi

Re: Python path and append

2016-04-25 Thread Chris Angelico
On Tue, Apr 26, 2016 at 7:26 AM, John Gordon wrote: > It's much easier to create a new file and then rename it afterwards, > instead of rewriting the original file. And more importantly, it's safer. If anything happens to your process while it's doing its work, you'll have a junk file sitting aro

Re: Python path and append

2016-04-25 Thread Seymore4Head
I would like to take the file win.txt and append a space and the * >> symbol. > >> f = open('win.txt', 'r+') >> for line in f: >> f.read(line) >> f.write(line+" *") > >> This doesn't work. Would someone fix it pl

Re: Python path and append

2016-04-25 Thread Peter Otten
Random832 wrote: > On Mon, Apr 25, 2016, at 16:15, Seymore4Head wrote: >> Thanks for the tip. >> >> Still broke. :( >> >> f = open('wout.txt', 'r+') >> for line in f: >> if line=="": >> exit >> line=line[:-1] >> line=line+" *" >> f.write(line) >> print line >> f.clos

Re: Python path and append

2016-04-25 Thread John Gordon
In <27nshbp40p1llr231dqm31p754tvurk...@4ax.com> Seymore4Head writes: > On Tue, 19 Apr 2016 18:29:38 -0400, Seymore4Head > wrote: > I am going to forget using a directory path. > I would like to take the file win.txt and append a space and the * > symbol. > f = ope

Re: Python path and append

2016-04-25 Thread Seymore4Head
removing some other character. It's safer to use >line.rstrip("\n"). > >> -Original Message- >> From: Python-list >> [mailto:python-list-bounces+joaquin.alzola=lebara@python.org] On Behalf >> Of Seymore4Head >> Sent: 25 April 2016 20:01

Re: Python path and append

2016-04-25 Thread Random832
On Mon, Apr 25, 2016, at 16:15, Seymore4Head wrote: > Thanks for the tip. > > Still broke. :( > > f = open('wout.txt', 'r+') > for line in f: > if line=="": > exit > line=line[:-1] > line=line+" *" > f.write(line) > print line > f.close() Your problem is that after y

Re: Python path and append

2016-04-25 Thread Seymore4Head
Thanks for the tip. Still broke. :( f = open('wout.txt', 'r+') for line in f: if line=="": exit line=line[:-1] line=line+" *" f.write(line) print line f.close() I did notice that it wrote the 3 lines of test file but it d

Re: Python path and append

2016-04-25 Thread MRAB
ine ending, so line[:-1] could be removing some other character. It's safer to use line.rstrip("\n"). -Original Message- From: Python-list [mailto:python-list-bounces+joaquin.alzola=lebara@python.org] On Behalf Of Seymore4Head Sent: 25 April 2016 20:01 To: python-list@python

Re: Python path and append

2016-04-25 Thread Rob Gaddi
Seymore4Head wrote: > On Mon, 25 Apr 2016 18:24:02 - (UTC), Rob Gaddi > wrote: > >>Seymore4Head wrote: >> >>> On Tue, 19 Apr 2016 18:29:38 -0400, Seymore4Head >>> wrote: >>> >>> I am going to forget using a directory path. >>>

RE: Python path and append

2016-04-25 Thread Joaquin Alzola
ist [mailto:python-list-bounces+joaquin.alzola=lebara@python.org] On Behalf Of Seymore4Head Sent: 25 April 2016 20:01 To: python-list@python.org Subject: Re: Python path and append On Mon, 25 Apr 2016 18:24:02 - (UTC), Rob Gaddi wrote: >Seymore4Head wrote: > >> On Tue, 19 Apr 2016

Re: Python path and append

2016-04-25 Thread Seymore4Head
On Mon, 25 Apr 2016 18:24:02 - (UTC), Rob Gaddi wrote: >Seymore4Head wrote: > >> On Tue, 19 Apr 2016 18:29:38 -0400, Seymore4Head >> wrote: >> >> I am going to forget using a directory path. >> I would like to take the file win.txt and append a space

Re: Python path and append

2016-04-25 Thread Rob Gaddi
Seymore4Head wrote: > On Tue, 19 Apr 2016 18:29:38 -0400, Seymore4Head > wrote: > > I am going to forget using a directory path. > I would like to take the file win.txt and append a space and the * > symbol. > > f = open('win.txt', 'r+') > for l

Re: Python path and append

2016-04-25 Thread Seymore4Head
On Tue, 19 Apr 2016 18:29:38 -0400, Seymore4Head wrote: I am going to forget using a directory path. I would like to take the file win.txt and append a space and the * symbol. f = open('win.txt', 'r+') for line in f: f.read(line) f.write(line+" *") This do

Re: Python path and append

2016-04-19 Thread Matthew Barnett
n handle = open("\\Winmx\New$\q.txt") IOError: [Errno 2] No such file or directory: '\\Winmx\\New$\\q.txt' What I would like to do is read a plain text file from a hidden network drive and append a space and the * character to the end of each line. Start with this: prin

Re: Python path and append

2016-04-19 Thread Chris Angelico
2, in > handle = open("\\Winmx\New$\q.txt") > IOError: [Errno 2] No such file or directory: '\\Winmx\\New$\\q.txt' > > What I would like to do is read a plain text file from a hidden > network drive and append a space and the * character to the end of > each lin

Python path and append

2016-04-19 Thread Seymore4Head
t;\\Winmx\New$\q.txt") IOError: [Errno 2] No such file or directory: '\\Winmx\\New$\\q.txt' What I would like to do is read a plain text file from a hidden network drive and append a space and the * character to the end of each line. Would someone be so kind as to fill in the

Re: Append/Replace a row in a pandas DataFrame [SOLVED]

2016-04-14 Thread Peter Otten
Paulo da Silva wrote: > Às 21:10 de 13-04-2016, Paulo da Silva escreveu: >> Hi all. > ... > >> [6 rows x 4 columns] >> >>> dft=pd.DataFrame([[1,2,3,4]], >> index=[datetime.date(2016,1,12)],columns=df.columns) >> >>> dft >> A B C D >> 2016-01-12 1 2 3 4 >> >> [1 rows x 4 colu

Re: Append/Replace a row in a pandas DataFrame [SOLVED]

2016-04-13 Thread Paulo da Silva
Às 21:10 de 13-04-2016, Paulo da Silva escreveu: > Hi all. ... > [6 rows x 4 columns] > >> dft=pd.DataFrame([[1,2,3,4]], > index=[datetime.date(2016,1,12)],columns=df.columns) > >> dft > A B C D > 2016-01-12 1 2 3 4 > > [1 rows x 4 columns] > >> pd.concat([df,dft]) > Out[71]

Append/Replace a row in a pandas DataFrame

2016-04-13 Thread Paulo da Silva
Hi all. I am learning pandas DataFrame and I want to add (eventually replace by index) some rows. For adding here is what I tried: >df = pd.DataFrame(np.random.randn(6,4), index=dates, columns=list('ABCD')) >df A B C D 2013-01-01 -0.111621 1.126761 -2.4

Re: In Python 3, how to append a nested dictionary to a shelve file with the added difficulty of using a for loop?

2015-12-22 Thread Peter Otten
Aaron Christensen wrote: > Thanks for the response! Several things you stated definitely got me > thinking. I really appreciate the response. I used what you said and I > am able to accomplish what I needed. Perhaps it becomes clearer when you write two helper functions def read_record(key):

Re: In Python 3, how to append a nested dictionary to a shelve file with the added difficulty of using a for loop?

2015-12-21 Thread Aaron Christensen
gt; Aaron Christensen wrote: > > > Hello, > > > > I am trying to figure out how to populate a shelve file with a nested > > dictionary. > > > > These are my requirements: > > > > -Create shelve file called people.db > > -Append the shelve file with new

Re: In Python 3, how to append a nested dictionary to a shelve file with the added difficulty of using a for loop?

2015-12-21 Thread Peter Otten
Aaron Christensen wrote: > Hello, > > I am trying to figure out how to populate a shelve file with a nested > dictionary. > > These are my requirements: > > -Create shelve file called people.db > -Append the shelve file with new people (person_1, person_2, etc.). &

In Python 3, how to append a nested dictionary to a shelve file with the added difficulty of using a for loop?

2015-12-21 Thread Aaron Christensen
Hello, I am trying to figure out how to populate a shelve file with a nested dictionary. These are my requirements: -Create shelve file called people.db -Append the shelve file with new people (person_1, person_2, etc.). -Use a for loop to iterate through 'attributes' so that I do n

In Python 3, how to append a nested dictionary to a shelve file with the added difficulty of using a for loop?

2015-12-21 Thread Aaron
Hello, I am trying to figure out how to populate a shelve file with a nested dictionary. These are my requirements: -Create shelve file called people.db -Append the shelve file with new people (person_1, person_2, etc.). -Use a for loop to iterate through 'attributes' so that I do n

Re: Partially invalid sys.path - how can I fix it (not append to it)?

2015-09-28 Thread dieter
Pierre Rouleau writes: > On a OS/X 101.10.5 (Yosemite) system, the system Python just got updated to > 2.7.10 but it sys.path is partially invalid. How can I fix that? > ... details removed ... You have found out that the execution of "site.py" inserts the invalid entries to "sys.path". I rememb

Partially invalid sys.path - how can I fix it (not append to it)?

2015-09-28 Thread Pierre Rouleau
Hi, On a OS/X 101.10.5 (Yosemite) system, the system Python just got updated to 2.7.10 but it sys.path is partially invalid. How can I fix that? I don't want to add something in PYTHONPATH. I know I can create a softlink at the invalid location to where the real files are located.I just w

Re: Append a file

2015-03-08 Thread Jason Venneri
Jason; Thank you for your response. I’m just starting out with Python and the tutorials I have done are on 2.7.9. I will looking on to python3. It is preloaded on Mac :-). Jason ___ jv92...@gmail.com 619-227-0927 > On Mar 6, 2015, at 9:37 PM, Jason Friedman w

Re: Append a file

2015-03-06 Thread Jason Friedman
On Fri, Mar 6, 2015 at 2:55 PM, Jason Venneri wrote: > Hello, I'm using the urllib.urlretrieve command to retrieve a couple of lines > of data. I want to combine the two results into one file not two. > > Any suggestions? > > Sample > urllib.urlretrieve('http://www.airplanes.com/data/boeing1.htm

Re: Append a file

2015-03-06 Thread sohcahtoa82
On Friday, March 6, 2015 at 1:55:31 PM UTC-8, Jason Venneri wrote: > Hello, I'm using the urllib.urlretrieve command to retrieve a couple of lines > of data. I want to combine the two results into one file not two. > > Any suggestions? > > Sample > urllib.urlretrieve('http://www.airplanes.com

Append a file

2015-03-06 Thread Jason Venneri
Hello, I'm using the urllib.urlretrieve command to retrieve a couple of lines of data. I want to combine the two results into one file not two. Any suggestions? Sample urllib.urlretrieve('http://www.airplanes.com/data/boeing1.html','B747A.txt') urllib.urlretrieve('http://www.airplanes.com/dat

Re: Why does argparse return None instead of [] if an append action isn't used?

2015-01-26 Thread Ian Kelly
On Mon, Jan 26, 2015 at 11:23 AM, Ian Kelly wrote: > $ python3 -m timeit 't = (1000, 2000, 3000)' > 1 loops, best of 3: 0.0147 usec per loop > $ python3 -m timeit 't = [1000, 2000, 3000]' > 1000 loops, best of 3: 0.0678 usec per loop > $ python3 -m timeit 't = tuple(range(1))' > 10

Re: Why does argparse return None instead of [] if an append action isn't used?

2015-01-26 Thread Ian Kelly
On Mon, Jan 26, 2015 at 10:18 AM, Mark Lawrence wrote: > IIRC, and probably from this list, creating tuples is way faster than > creating lists, but accessing items is slower. Can anybody confirm this for > us? The first seems to be true as long as the tuples are small. $ python3 -m timeit 't =

Re: Why does argparse return None instead of [] if an append action isn't used?

2015-01-26 Thread Mark Lawrence
On 26/01/2015 16:29, Jussi Piitulainen wrote: I've used tuples to convey the intention of immutability, as opposed to using lists. For all I know, collecting a generator (from groupby) into a tuple might be slower than collecting it into a list. I have no intention to measure this. The programs

Re: Why does argparse return None instead of [] if an append action isn't used?

2015-01-26 Thread Jussi Piitulainen
Ian Kelly writes: > On Mon, Jan 26, 2015 at 8:50 AM, Adam Funk wrote: > > On 2015-01-26, Peter Otten wrote: > > > >> Adam Funk wrote: > >> > >>> On 2015-01-09, Ned Batchelder wrote: > for b in options.bar or (): > do_stuff(b) > >>> > >>> Do you mean "for b in options.bar or

Re: Why does argparse return None instead of [] if an append action isn't used?

2015-01-26 Thread Ian Kelly
On Mon, Jan 26, 2015 at 8:50 AM, Adam Funk wrote: > On 2015-01-26, Peter Otten wrote: > >> Adam Funk wrote: >> >>> On 2015-01-09, Ned Batchelder wrote: for b in options.bar or (): do_stuff(b) >>> >>> Do you mean "for b in options.bar or []:" ? >> >> Doesn't matter; in the c

  1   2   3   4   5   6   >