Re: file I/O and arithmetic calculation

2013-05-23 Thread Keira Wilson
not exactly for the homework, but as my starting point of learning thank you so much. -- http://mail.python.org/mailman/listinfo/python-list

RE: file I/O and arithmetic calculation

2013-05-23 Thread Carlos Nepomuceno
> From: denismfmcma...@gmail.com [...] >> Dear all who involved with responding to my question - Thank you so much >> for your nice code which really helped me. > > Hold on a sec? Someone posted code that gave the correct answer to a > homework question? > >

Re: file I/O and arithmetic calculation

2013-05-23 Thread Denis McMahon
On Thu, 23 May 2013 07:17:58 -0700, Keira Wilson wrote: > Dear all who involved with responding to my question - Thank you so much > for your nice code which really helped me. Hold on a sec? Someone posted code that gave the correct answer to a homework question? -- Denis McMahon, denismfmcma.

Re: file I/O and arithmetic calculation

2013-05-23 Thread Keira Wilson
Dear all who involved with responding to my question - Thank you so much for your nice code which really helped me. -- http://mail.python.org/mailman/listinfo/python-list

Re: file I/O and arithmetic calculation

2013-05-23 Thread Chris Angelico
On Thu, May 23, 2013 at 10:37 AM, Carlos Nepomuceno wrote: > >> From: oscar.j.benja...@gmail.com >> Date: Thu, 23 May 2013 01:34:37 +0100 >> Subject: Re: file I/O and arithmetic calculation >> To: carlosnepomuc...@outlook.com &g

Re: file I/O and arithmetic calculation

2013-05-23 Thread Oscar Benjamin
On 23 May 2013 04:15, Carlos Nepomuceno wrote: > The last line of my noob piece can be improved. So this is it: Most of it can be improved. > filenames = ['1.txt', '2.txt', '3.txt', '4.txt', '5.txt'] > contents = [[[int(z) for z in y.split(',')] for y in open(x).read().split()] > for x in file

RE: file I/O and arithmetic calculation

2013-05-22 Thread Carlos Nepomuceno
The last line of my noob piece can be improved. So this is it: ### 1strow_average.py ### #Assuming you have CSV (comma separated values) files such as: #1.txt = '0,1,2,3,4,5,6,7,8,9\n' \ #    '10,11,12,13,14,15,16,17,18,19\n' \ #    '20,21,22,23,24,25,26,27,28,29\n' ... # # Usage: contents

RE: file I/O and arithmetic calculation

2013-05-22 Thread Carlos Nepomuceno
> From: oscar.j.benja...@gmail.com > Date: Thu, 23 May 2013 01:34:37 +0100 > Subject: Re: file I/O and arithmetic calculation > To: carlosnepomuc...@outlook.com > CC: python-list@python.org > > On 23 May 2013 00:49, Carlos Nepomuceno

Re: file I/O and arithmetic calculation

2013-05-22 Thread Oscar Benjamin
On 23 May 2013 00:49, Carlos Nepomuceno wrote: > > The code is pretty obvious to me, I mean there's no obfuscation at all. I honestly can't tell if you're joking. -- http://mail.python.org/mailman/listinfo/python-list

RE: file I/O and arithmetic calculation

2013-05-22 Thread Carlos Nepomuceno
> From: denismfmcma...@gmail.com [...] > > import re > def v(s): > l=len(s) > t=0. > for i in range(l): > t=t+(abs(ord(s[i]))*1.) > return t/(l*1.) > for n in range(5): > m="c:/test/"+str(n+1)+".txt" > f=open(m,"r") > d=[] > t=0. > for l in range(10): > d=d+

Re: file I/O and arithmetic calculation

2013-05-22 Thread Denis McMahon
On Thu, 23 May 2013 01:13:19 +0900, Keira Wilson wrote: > I would appreciate if someone could write a simple python code for the > purpose below: Didn't have your data, so couldn't verify it completely, but try this: import re def v(s): l=len(s) t=0. for i in range(l): t=t+(abs(ord(s[i]))*1

RE: file I/O and arithmetic calculation

2013-05-22 Thread Carlos Nepomuceno
># contents[3][4][5] : 6th column of 5th row of file '4.txt' BTW, it should read # contents[3][4][5] : 6th value of 5th row of file '4.txt' -- http://mail.python.org/mailman/listinfo/python-list

RE: file I/O and arithmetic calculation

2013-05-22 Thread Carlos Nepomuceno
> From: oscar.j.benja...@gmail.com [...] > > Do you find this code easy to read? I wouldn't write something like > this and I certainly wouldn't use it when explaining something to a > beginner. > > Rather than repeated list comprehensions you should conside

Re: file I/O and arithmetic calculation

2013-05-22 Thread Oscar Benjamin
On 22 May 2013 22:05, Carlos Nepomuceno wrote: > > filenames = ['1.txt', '2.txt', '3.txt', '4.txt', '5.txt'] > contents = [[[int(z) for z in y.split(',')] for y in open(x).read().split()] > for x in filenames] > s1c = [sum([r[0] for r in f]) for f in contents] > a1r = [sum(f[0])/float(len(f[0]

RE: file I/O and arithmetic calculation

2013-05-22 Thread Carlos Nepomuceno
ormat(n,a1r[i]) if s1c[i]==50 else '' for i,n in enumerate(filenames)] if x]) > From: wilke...@gmail.com > Date: Thu, 23 May 2013 01:13:19 +0900 > Subject: file I/O and arithmetic calculation > To: python-list@python.org > > > D

Re: file I/O and arithmetic calculation

2013-05-22 Thread Mark Lawrence
On 22/05/2013 17:13, Keira Wilson wrote: Dear all, I would appreciate if someone could write a simple python code for the purpose below: I have five text files each of 10 columns by 10 rows as follows: |file_one= 'C:/test/1.txt' file_two= 'C:/test/2.txt' . . . file_five= 'C:/test/5.txt'|

file I/O and arithmetic calculation

2013-05-22 Thread Keira Wilson
Dear all, I would appreciate if someone could write a simple python code for the purpose below: I have five text files each of 10 columns by 10 rows as follows: file_one = 'C:/test/1.txt' file_two = 'C:/test/2.txt' . . . file_five = 'C:/test/5.txt' I want to calculate the mean of first row (10

Re: Instant File I/O

2011-03-24 Thread Jordan Meyer
That did the trick! Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: Instant File I/O

2011-03-24 Thread Charles
"jam1991" wrote in message news:c0c76bc4-8923-4a46-9c36-6e1a0375f...@l11g2000yqb.googlegroups.com... [snip] > they sign into the program with; however, this information doesn't > appear in the file until after the program has closed. This poses a > problem for retrieving the up-to-date statistic

Re: Instant File I/O

2011-03-23 Thread Dan Stromberg
I'm not familiar with linecache.clearcache(), but did you flush the data to the filesystem with file_.flush() ? On Wed, Mar 23, 2011 at 9:53 PM, jam1991 wrote: > I'm trying to build a feature on to a text-based game that I've been > working on that would allow users to view their stats. Informat

Instant File I/O

2011-03-23 Thread jam1991
I'm trying to build a feature on to a text-based game that I've been working on that would allow users to view their stats. Information is stored in a flat text database file that is given the same name that they sign into the program with; however, this information doesn't appear in the file until

Re: Safe file I/O to shared file (or SQLite) from multi-threaded web server

2010-01-04 Thread Diez B. Roggisch
Lawrence D'Oliveiro schrieb: In message , Steve Holden wrote: Yes, but not to MySQL, please. Particularly since there is a sword of Damocles hanging over its head while the Oracle takeover of Sun is pending. Ah, I see the FUDsters are crawling out of the woodwork here, as well. I’ve got new

Re: Safe file I/O to shared file (or SQLite) from multi-threaded web server

2010-01-03 Thread Steve Holden
Lawrence D'Oliveiro wrote: > In message , Steve > Holden wrote: > >> Yes, but not to MySQL, please. Particularly since there is a sword of >> Damocles hanging over its head while the Oracle takeover of Sun is >> pending. > > Ah, I see the FUDsters are crawling out of the woodwork here, as well.

Re: Safe file I/O to shared file (or SQLite) from multi-threaded web server

2010-01-03 Thread Lawrence D'Oliveiro
In message , Steve Holden wrote: > Yes, but not to MySQL, please. Particularly since there is a sword of > Damocles hanging over its head while the Oracle takeover of Sun is > pending. Ah, I see the FUDsters are crawling out of the woodwork here, as well. I’ve got news for you: MySQL is an open

Re: Safe file I/O to shared file (or SQLite) from multi-threaded web server

2010-01-03 Thread Steve Holden
John Nagle wrote: > pyt...@bdurham.com wrote: >> I'm looking for the best practice way for a multi-threaded python web >> server application to read/write to a shared file or a SQLite database. >> >> What do I need to do (if anything) to make sure my writes to a regular >> file on disk or to a SQLi

Re: Safe file I/O to shared file (or SQLite) from multi-threaded web server

2010-01-02 Thread John Nagle
pyt...@bdurham.com wrote: I'm looking for the best practice way for a multi-threaded python web server application to read/write to a shared file or a SQLite database. What do I need to do (if anything) to make sure my writes to a regular file on disk or to a SQLite database are atomic in nature

Re: Safe file I/O to shared file (or SQLite) from multi-threaded web server

2010-01-01 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Diez B. Roggisch wrote: > AFAIK, sqlite ensures process-serialization via locking, and threads > synchronize themselves as well. SQLite versions prior to 3.5 did not support using the same connection or cursors in different threads. (You needed to al

Re: Safe file I/O to shared file (or SQLite) from multi-threaded web server

2010-01-01 Thread Diez B. Roggisch
pyt...@bdurham.com schrieb: I'm looking for the best practice way for a multi-threaded python web server application to read/write to a shared file or a SQLite database. What do I need to do (if anything) to make sure my writes to a regular file on disk or to a SQLite database are atomic in natu

Safe file I/O to shared file (or SQLite) from multi-threaded web server

2010-01-01 Thread python
I'm looking for the best practice way for a multi-threaded python web server application to read/write to a shared file or a SQLite database. What do I need to do (if anything) to make sure my writes to a regular file on disk or to a SQLite database are atomic in nature when multiple clients post

Re: Popen File I/O

2009-05-27 Thread D'Arcy J.M. Cain
On Wed, 27 May 2009 19:39:21 -0500 Eric Pruitt wrote: > I am creating a file-like interface for Popen. Do I need to return True or > False for "isatty()"? I am thinking True but I am not familiar with the > semantics of what defines a tty. >>> import os >>> x = os.popen("ls") >>> type(x)

Popen File I/O

2009-05-27 Thread Eric Pruitt
Hello, I am creating a file-like interface for Popen. Do I need to return True or False for "isatty()"? I am thinking True but I am not familiar with the semantics of what defines a tty. Thanks, Eric -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiprocessing and file I/O

2009-05-25 Thread Infinity77
Hi Paul & All, On May 24, 4:16 pm, Paul Boddie wrote: > On 24 Mai, 16:13, Infinity77 wrote: > > > > > No, the processing of the data is fast enough, as it is very simple. > > What I was asking is if anyone could share an example of using > > multiprocessing to read a file, along the lines I desc

Re: Multiprocessing and file I/O

2009-05-24 Thread Paul Boddie
On 24 Mai, 16:13, Infinity77 wrote: > > No, the processing of the data is fast enough, as it is very simple. > What I was asking is if anyone could share an example of using > multiprocessing to read a file, along the lines I described above. Take a look at this section in an article about multi-

Re: Multiprocessing and file I/O

2009-05-24 Thread Infinity77
Hi Igor, On May 24, 1:10 pm, Igor Katson wrote: > Infinity77 wrote: > > Hi All, > > >     I am trying to speed up some code which reads a bunch of data from > > a disk file. Just for the fun of it, I thought to try and use parallel > > I/O to split the reading of the file between multiple process

Re: Multiprocessing and file I/O

2009-05-24 Thread Igor Katson
Infinity77 wrote: Hi All, I am trying to speed up some code which reads a bunch of data from a disk file. Just for the fun of it, I thought to try and use parallel I/O to split the reading of the file between multiple processes. Although I have been warned that concurrent access by multiple

Multiprocessing and file I/O

2009-05-24 Thread Infinity77
Hi All, I am trying to speed up some code which reads a bunch of data from a disk file. Just for the fun of it, I thought to try and use parallel I/O to split the reading of the file between multiple processes. Although I have been warned that concurrent access by multiple processes to the sam

Re: Unexpected timing results with file I/O

2008-02-04 Thread Marc 'BlackJack' Rintsch
On Mon, 04 Feb 2008 21:58:46 +, Steven D'Aprano wrote: > On Mon, 04 Feb 2008 17:08:02 +, Marc 'BlackJack' Rintsch wrote: > >>> Surprisingly, Method 2 is a smidgen faster, by about half a second over >>> 500,000 open-write-close cycles. It's not much faster, but it's >>> consistent, over m

Re: Unexpected timing results with file I/O

2008-02-04 Thread Steven D'Aprano
On Mon, 04 Feb 2008 17:08:02 +, Marc 'BlackJack' Rintsch wrote: >> Surprisingly, Method 2 is a smidgen faster, by about half a second over >> 500,000 open-write-close cycles. It's not much faster, but it's >> consistent, over many tests, changing many of the parameters (e.g. the >> number of f

Re: Unexpected timing results with file I/O

2008-02-04 Thread Marc 'BlackJack' Rintsch
On Mon, 04 Feb 2008 10:48:32 -0800, rdahlstrom wrote: > It doesn't matter how many doors opening and closing there are, it > matters the order in which the opening, walking through, and closing > are done. That's my point. In the second example, all of the disk > operations are done at the same

Re: Unexpected timing results with file I/O

2008-02-04 Thread rdahlstrom
It doesn't matter how many doors opening and closing there are, it matters the order in which the opening, walking through, and closing are done. That's my point. In the second example, all of the disk operations are done at the same time. That's what I meant by people going through the doors.

Re: Unexpected timing results with file I/O

2008-02-04 Thread Marc 'BlackJack' Rintsch
On Mon, 04 Feb 2008 10:18:39 -0800, rdahlstrom wrote: > On Feb 4, 1:12 pm, Carl Banks <[EMAIL PROTECTED]> wrote: >> On Feb 4, 12:53 pm, rdahlstrom <[EMAIL PROTECTED]> wrote: >> > You have 500,000 people to fit through a door. Here are your options: >> >> > 1. For each person, open the door, walk

Re: Unexpected timing results with file I/O

2008-02-04 Thread rdahlstrom
On Feb 4, 1:12 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > On Feb 4, 12:53 pm, rdahlstrom <[EMAIL PROTECTED]> wrote: > > > > > On Feb 4, 10:17 am, Steven D'Aprano <[EMAIL PROTECTED] > > > cybersource.com.au> wrote: > > > After reading an earlier thread about opening and closing lots of files, > > >

Re: Unexpected timing results with file I/O

2008-02-04 Thread Carl Banks
On Feb 4, 12:53 pm, rdahlstrom <[EMAIL PROTECTED]> wrote: > On Feb 4, 10:17 am, Steven D'Aprano <[EMAIL PROTECTED] > > > > cybersource.com.au> wrote: > > After reading an earlier thread about opening and closing lots of files, > > I thought I'd do a little experiment. > > > Suppose you have a whole

Re: Unexpected timing results with file I/O

2008-02-04 Thread Gabriel Genellina
En Mon, 04 Feb 2008 15:53:11 -0200, rdahlstrom <[EMAIL PROTECTED]> escribi�: > On Feb 4, 10:17 am, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: >> >> Suppose you have a whole lot of files, and you need to open each one, >> append a string, then close them. There's two obvious

Re: Unexpected timing results with file I/O

2008-02-04 Thread rdahlstrom
On Feb 4, 10:17 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > After reading an earlier thread about opening and closing lots of files, > I thought I'd do a little experiment. > > Suppose you have a whole lot of files, and you need to open each one, > append a string, then clos

Re: Unexpected timing results with file I/O

2008-02-04 Thread Marc 'BlackJack' Rintsch
On Mon, 04 Feb 2008 15:17:18 +, Steven D'Aprano wrote: > # Method one: grouped by file. > for each file: > open the file, append the string, then close it > > > # Method two: grouped by procedure. > for each file: > open the file > for each open file: > append the string > for ea

Re: Unexpected timing results with file I/O

2008-02-04 Thread Christian Heimes
Steven D'Aprano wrote: > So, what's going on? Can anyone explain why the code which does more work > takes less time? Short answer: CPU and RAM are much faster than hard disks. The three loops and the creation of a list costs only a few CPU cycles compared to flushing the new data to disk. Chri

Unexpected timing results with file I/O

2008-02-04 Thread Steven D'Aprano
After reading an earlier thread about opening and closing lots of files, I thought I'd do a little experiment. Suppose you have a whole lot of files, and you need to open each one, append a string, then close them. There's two obvious ways to do it: group your code by file, or group your code b

Re: File I/O

2007-05-09 Thread Klaas
On May 9, 2:43 pm, HMS Surprise <[EMAIL PROTECTED]> wrote: > > [lst.append(list(line.split())) for line in file] > > Thanks, this is the direction I wanted to go, BUT I must use v2.2 so > the line above gives me the error: > > AttributeError: __getitem__ > > But the write format will be helpful. (

Re: File I/O

2007-05-09 Thread HMS Surprise
> [lst.append(list(line.split())) for line in file] Thanks, this is the direction I wanted to go, BUT I must use v2.2 so the line above gives me the error: AttributeError: __getitem__ But the write format will be helpful. Thanks again, jh -- http://mail.python.org/mailman/listinfo/python-l

Re: File I/O

2007-05-09 Thread half . italian
On May 9, 2:13 pm, HMS Surprise <[EMAIL PROTECTED]> wrote: > If one has a list of lists such as > > lst = [['a','1'],['b','2']] > > is there a standard python idiom for writing and reading the pairs to/ > from a file? > > Thanks, > > jh These work. Assuming you can choose the format. Or you coul

Re: File I/O

2007-05-09 Thread Sönmez Kartal
Hi, As far as I know, Python doesn't have a specific thing to handle this. You could write a tiny function that would interpre element type of list's elements. It checks type, if it is a list then get that pair manually... If list is going like that 'a' - '1', 'b' - '2', you should use dictiona

File I/O

2007-05-09 Thread HMS Surprise
If one has a list of lists such as lst = [['a','1'],['b','2']] is there a standard python idiom for writing and reading the pairs to/ from a file? Thanks, jh -- http://mail.python.org/mailman/listinfo/python-list

Re: python noob, multiple file i/o

2007-03-16 Thread hiro
Thanks a lot for the help guys, I'm at work right now and I will go over your suggestions one by one this weekend. Being more alert now, taking a look at the examples you posted, I now see how to approach this problem. The thing with python that I'm starting to realize is that there are a million

Re: python noob, multiple file i/o

2007-03-16 Thread hiro
Thanks a lot for the help guys, I'm at work right now and I will go over your suggestions one by one this weekend. Being more alert now, taking a look at the examples you posted, I now see how to approach this problem. The thing with python that I'm starting to realize is that there are a million

Re: python noob, multiple file i/o

2007-03-16 Thread 7stud
On Mar 16, 9:38 am, "7stud" <[EMAIL PROTECTED]> wrote: > - > import os > > filepath = "./change_files" > > li = os.listdir(filepath) > for name in li: > fullpath = filepath + "/" + name > if os.path.isfile(fullpath): > infile = open(fullpath, 'r') > >

Re: python noob, multiple file i/o

2007-03-16 Thread 7stud
The general idiom for altering lines in a file is to open the original file and write the alterations to a temp file. After you are done writing to the temp file, delete the original file, and change the temp file name to the original file name. If instead you were to read the whole file into a va

Re: python noob, multiple file i/o

2007-03-16 Thread Jordan
On Mar 16, 7:09 am, Laurent Rahuel <[EMAIL PROTECTED]> wrote: > Maybe the walk method in os module is what you > needhttp://docs.python.org/lib/os-file-dir.html > > Regards > > Jon Clements wrote: > > On 16 Mar, 09:02, "Jon Clements" <[EMAIL PROTECTED]> wrote: > >> On 16 Mar, 03:56, "hiro" <[EMAIL

Re: python noob, multiple file i/o

2007-03-16 Thread Laurent Rahuel
Maybe the walk method in os module is what you need http://docs.python.org/lib/os-file-dir.html Regards Jon Clements wrote: > On 16 Mar, 09:02, "Jon Clements" <[EMAIL PROTECTED]> wrote: >> On 16 Mar, 03:56, "hiro" <[EMAIL PROTECTED]> wrote: >> >> >> >> >> >> > Hi there, >> >> > I'm very new to p

Re: python noob, multiple file i/o

2007-03-16 Thread Jon Clements
On 16 Mar, 09:02, "Jon Clements" <[EMAIL PROTECTED]> wrote: > On 16 Mar, 03:56, "hiro" <[EMAIL PROTECTED]> wrote: > > > > > > > Hi there, > > > I'm very new to python, the problem I need to solve is whats the "best/ > > simplest/cleanest" way to read in multiple files (ascii), do stuff to > > them,

Re: python noob, multiple file i/o

2007-03-16 Thread Jon Clements
On 16 Mar, 03:56, "hiro" <[EMAIL PROTECTED]> wrote: > Hi there, > > I'm very new to python, the problem I need to solve is whats the "best/ > simplest/cleanest" way to read in multiple files (ascii), do stuff to > them, and write them out(ascii). > > -- > import os > > filePath = ('O:/spam/eggs/')

python noob, multiple file i/o

2007-03-15 Thread hiro
Hi there, I'm very new to python, the problem I need to solve is whats the "best/ simplest/cleanest" way to read in multiple files (ascii), do stuff to them, and write them out(ascii). -- import os filePath = ('O:/spam/eggs/') for file in os.listdir(filePath): #straight from docs # iterate

Re: File I/O

2006-10-06 Thread uche . ogbuji
Ant wrote: > Kirt wrote: > ... > > i dont wanna parse the xml file.. > > > > Just open the file as: > > > > f=open('test.xml','a') > > > > and append a line "abc" before tag > > The other guys are right - you should look at something like > ElementTree which makes this sort of thing pretty easy,

Re: File I/O

2006-09-30 Thread Ant
Kirt wrote: ... > i dont wanna parse the xml file.. > > Just open the file as: > > f=open('test.xml','a') > > and append a line "abc" before tag The other guys are right - you should look at something like ElementTree which makes this sort of thing pretty easy, and is robust. But if you are sur

Re: File I/O

2006-09-30 Thread MonkeeSage
Diez B. Roggisch wrote: > Good to know that you can get drunk under any circumstances. +(++)1 heh! > I have seen a bazillion bad xml/html parsing-hacks using regexes and the > like, which stopped working after somehow the xml came all in one line, or > some other implicit assumption about its lay

Re: File I/O

2006-09-29 Thread Diez B. Roggisch
jimburton wrote: > > Diez B. Roggisch wrote: >> Kirt wrote: >> >> > >> > jimburton wrote: >> >> Kirt wrote: >> >> > Hi! I need some help in file I/O >> >> > >> >> > I have an xml file.. >> >

Re: File I/O

2006-09-29 Thread jimburton
Diez B. Roggisch wrote: > Kirt wrote: > > > > > jimburton wrote: > >> Kirt wrote: > >> > Hi! I need some help in file I/O > >> > > >> > I have an xml file.. > >> [snip] > >> See http://diveintopython.org/xml_pro

Re: File I/O

2006-09-29 Thread Diez B. Roggisch
Kirt wrote: > > jimburton wrote: >> Kirt wrote: >> > Hi! I need some help in file I/O >> > >> > I have an xml file.. >> [snip] >> See http://diveintopython.org/xml_processing/ > > i dont wanna parse the xml file.. If you play soccer, d

Re: File I/O

2006-09-29 Thread jimburton
Kirt wrote: > i dont wanna parse the xml file.. > > Just open the file as: > > f=open('test.xml','a') > > and append a line "abc" before tag Use a regex to split the contents and insert new stuff, eg import re prog = prog = re.compile('^(.*)()', re.DOTALL) m = prog.search(f.read()) then m.gro

Re: File I/O

2006-09-29 Thread Kirt
jimburton wrote: > Kirt wrote: > > Hi! I need some help in file I/O > > > > I have an xml file.. > [snip] > See http://diveintopython.org/xml_processing/ i dont wanna parse the xml file.. Just open the file as: f=open('test.xml','a')

Re: File I/O

2006-09-29 Thread Kirt
jimburton wrote: > Kirt wrote: > > Hi! I need some help in file I/O > > > > I have an xml file.. > [snip] > See http://diveintopython.org/xml_processing/ i dont wanna parse the xml file.. Just open the file as: f=open('test.xml','a') and write

Re: File I/O

2006-09-29 Thread jimburton
Kirt wrote: > Hi! I need some help in file I/O > > I have an xml file.. [snip] See http://diveintopython.org/xml_processing/ -- http://mail.python.org/mailman/listinfo/python-list

File I/O

2006-09-29 Thread Kirt
Hi! I need some help in file I/O I have an xml file.. xyz I want to open these file in append mode and add the line abd Such that i have: xyz xyz can anyone show me the way to achieve this?? thanx -- http://mail.python.org/mailman/listinfo/python-list

Re: Pickle vs XML for file I/O

2006-08-02 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, crystalattice wrote: > One other question though (hope it doesn't sound silly/stupid). Your > suggestion to "pickle a party" using a list has me thinking: can a > list store class instances? Yes of course you can store class instances in lists. > For example, if I wante

Re: Pickle vs XML for file I/O

2006-08-02 Thread crystalattice
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, crystalattice > wrote: > > >> What are the problems you fear when using `shelve` by the way? > >> > > The ideas I got about shelve are mostly due to this thread: > > http://tinyurl.com/lueok. There weren't any other threads > > contradictin

Re: Pickle vs XML for file I/O

2006-08-01 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, crystalattice wrote: >> What are the problems you fear when using `shelve` by the way? >> > The ideas I got about shelve are mostly due to this thread: > http://tinyurl.com/lueok. There weren't any other threads > contradicting the information so I figured it has merit. M

Re: Pickle vs XML for file I/O

2006-08-01 Thread crystalattice
Simon Hibbs wrote: > I've recently gone through a similar evaluation of my options for > persisting data. Object serialization to pickles or XML is a very easy, > quick way of persisting data but it does have drawbacks. I'm not a > professional developer, so if there are errors in my analysis, I'd

Re: Pickle vs XML for file I/O

2006-08-01 Thread crystalattice
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, crystalattice wrote: > > > On Mon, 31 Jul 2006 14:35:39 -1000, Simon Forman <[EMAIL PROTECTED]> > > wrote: > > > >> What kind of trouble were you having with pickle? > > > > It's mostly a combination of things (I hope you can follow my logi

Re: Pickle vs XML for file I/O

2006-08-01 Thread Simon Hibbs
I've recently gone through a similar evaluation of my options for persisting data. Object serialization to pickles or XML is a very easy, quick way of persisting data but it does have drawbacks. I'm not a professional developer, so if there are errors in my analysis, I'd love to be corrected. Sup

Re: Pickle vs XML for file I/O

2006-07-31 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, crystalattice wrote: > On Mon, 31 Jul 2006 14:35:39 -1000, Simon Forman <[EMAIL PROTECTED]> > wrote: > >> What kind of trouble were you having with pickle? > > It's mostly a combination of things (I hope you can follow my logic). > First, to use "good programming prac

Re: Pickle vs XML for file I/O

2006-07-31 Thread John Machin
crystalattice wrote: > > Plus, to modify data in a class I presume the word "instance" is missing here ... > do I have to unpickle the whole thing > first or is there a way to modify the data while it's pickled? Actually, > I think I can answer that last question: a character instance, having

Re: Pickle vs XML for file I/O

2006-07-31 Thread crystalattice
On Mon, 31 Jul 2006 14:35:39 -1000, Simon Forman <[EMAIL PROTECTED]> wrote: > crystalattice wrote: >> I'm creating an RPG for experience and practice. I've finished a >> character creation module and I'm trying to figure out how to get the >> fil

Re: Pickle vs XML for file I/O

2006-07-31 Thread Simon Forman
crystalattice wrote: > I'm creating an RPG for experience and practice. I've finished a > character creation module and I'm trying to figure out how to get the > file I/O to work. > > I've read through the python newsgroup and it appears that shelve > prob

Pickle vs XML for file I/O

2006-07-31 Thread crystalattice
I'm creating an RPG for experience and practice. I've finished a character creation module and I'm trying to figure out how to get the file I/O to work. I've read through the python newsgroup and it appears that shelve probably isn't the best option for various reas

Re: Linux > python > file-I/O ?

2005-12-25 Thread Steve Horsley
[EMAIL PROTECTED] wrote: > I've just started to test/learn python. > I've got Linux > mandrake9 > python & documentation. > What I'll initially want to be doing needs file I/O, so I > wanted to confirm file I/O early in my tests. > > Following the

Re: Linux > python > file-I/O ?

2005-12-24 Thread gene tani
[EMAIL PROTECTED] wrote: > I've just started to test/learn python. > I've got Linux > mandrake9 > python & documentation. > What I'll initially want to be doing needs file I/O, so I > wanted to confirm file I/O early in my tests. > > Following the

Re: Linux > python > file-I/O ?

2005-12-24 Thread Grant Edwards
On 2005-12-24, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: f.read(size) > Traceback (most recent call last): > File "", line 1, in ? > NameError: name 'size' is not defined <-- ?? Obj-method unknown ?? > > > What's wrong ? You haven't defined anything named "size". Assuming you want to

Re: Linux > python > file-I/O ?

2005-12-24 Thread David Wahler
[EMAIL PROTECTED] wrote: > I've just started to test/learn python. > I've got Linux > mandrake9 > python & documentation. > What I'll initially want to be doing needs file I/O, so I > wanted to confirm file I/O early in my tests. > > Following the

Linux > python > file-I/O ?

2005-12-24 Thread news
I've just started to test/learn python. I've got Linux > mandrake9 > python & documentation. What I'll initially want to be doing needs file I/O, so I wanted to confirm file I/O early in my tests. Following the examples : >>> f=open('/tmp/workfile',

Re: socket + file i/o question

2005-08-07 Thread John
I found the problem. There was a recv that was not from an open socket... Sorry abt the trouble, --j -- http://mail.python.org/mailman/listinfo/python-list

Re: socket + file i/o question

2005-08-07 Thread John
Here is what the send and recieved number of bytes show up as: Filesize being sent = 507450 Server sending file to client... (total size sent , buffer size) ... 491520 4096 495616 4096 499712 4096 503808 3642 ./server.py: (107, 'Transport endpoint is not connected') On the client side, the bytes

socket + file i/o question

2005-08-07 Thread John
I am sending a file on a tcp socket using the following code while 1: buf = os.read(fd, 4096) if not buf: break print total, len(buf) conn.send(b