Re: delete from pattern to pattern if it contains match

2016-04-25 Thread Jussi Piitulainen
harirammano...@gmail.com writes: > Hi Jussi, > > i have seen you have written a definition to fulfill the requirement, > can we do this same thing using xml parser, as i have failed to > implement the thing using xml parser of python if the file is having > the content as below... > > PUBLIC

Writing different sections into a file

2016-04-25 Thread Palpandi
Hi, I need to write different sections into a file. At any point of time, content can be added to any section. I don't want keep each section into a temporary file. What is the better way to store the contents of each section and write them into a file at the end? What is the better datatype to

Re: Optimizing Memory Allocation in a Simple, but Long Function

2016-04-25 Thread Gregory Ewing
Derek Klinge wrote: Also, it seems to me if the goal is to use the smallest value of n to get a particular level of accuracy, changing your guess of N by doubling seems to have a high chance of overshoot. If you want to find the exact n required, once you overshoot you could use a binary search

Re: Optimizing Memory Allocation in a Simple, but Long Function

2016-04-25 Thread Peter Otten
Derek Klinge wrote: > I found that the pattern of an additional digit of accuracy corresponding > to 10*n did not hold as strongly for that value (I can post data if > desired). I also got some results that seem to contradict the mathematical > definition. For example try EulersNumber(10**15).Limi

Re: Writing different sections into a file

2016-04-25 Thread Peter Otten
Palpandi wrote: > I need to write different sections into a file. > At any point of time, content can be added to any section. > > I don't want keep each section into a temporary file. > What is the better way to store the contents of each section and write > them into a file at the end? What is

Re: delete from pattern to pattern if it contains match

2016-04-25 Thread harirammanohar
On Monday, April 25, 2016 at 12:47:14 PM UTC+5:30, Jussi Piitulainen wrote: > harirammano...@gmail.com writes: > > > Hi Jussi, > > > > i have seen you have written a definition to fulfill the requirement, > > can we do this same thing using xml parser, as i have failed to > > implement the thing u

Re: delete from pattern to pattern if it contains match

2016-04-25 Thread harirammanohar
On Monday, April 25, 2016 at 3:19:15 PM UTC+5:30, hariram...@gmail.com wrote: > On Monday, April 25, 2016 at 12:47:14 PM UTC+5:30, Jussi Piitulainen wrote: > > harirammano...@gmail.com writes: > > > > > Hi Jussi, > > > > > > i have seen you have written a definition to fulfill the requirement, > >

Re: Writing different sections into a file

2016-04-25 Thread harirammanohar
On Monday, April 25, 2016 at 1:01:12 PM UTC+5:30, Palpandi wrote: > Hi, > > I need to write different sections into a file. > At any point of time, content can be added to any section. > > I don't want keep each section into a temporary file. > What is the better way to store the contents of each

Re: Writing different sections into a file

2016-04-25 Thread Karim
On 25/04/2016 09:30, Palpandi wrote: Hi, I need to write different sections into a file. At any point of time, content can be added to any section. I don't want keep each section into a temporary file. What is the better way to store the contents of each section and write them into a file at

Re: delete from pattern to pattern if it contains match

2016-04-25 Thread Peter Otten
harirammano...@gmail.com wrote: > Here is the code: Finally ;) > import xml.etree.ElementTree as ET > ET.register_namespace("", "http://xmlns.jcp.org/xml/ns/javaee";) I don't know what this does, but probably not what you expected. > tree = ET.parse('sample.xml') > root = tree.getroot() > > f

Re: delete from pattern to pattern if it contains match

2016-04-25 Thread Jussi Piitulainen
harirammano...@gmail.com writes: > On Monday, April 25, 2016 at 12:47:14 PM UTC+5:30, Jussi Piitulainen wrote: >> harirammano...@gmail.com writes: >> >> > Hi Jussi, >> > >> > i have seen you have written a definition to fulfill the requirement, >> > can we do this same thing using xml parser, as

Re: delete from pattern to pattern if it contains match

2016-04-25 Thread Jussi Piitulainen
Peter Otten writes: > harirammano...@gmail.com wrote: > >> Here is the code: > > Finally ;) :) -- https://mail.python.org/mailman/listinfo/python-list

Re: delete from pattern to pattern if it contains match

2016-04-25 Thread Jussi Piitulainen
harirammano...@gmail.com writes: > On Monday, April 25, 2016 at 3:19:15 PM UTC+5:30, hariram...@gmail.com wrote: [- -] >> Here is the code: >> >> import xml.etree.ElementTree as ET >> ET.register_namespace("", "http://xmlns.jcp.org/xml/ns/javaee";) >> tree = ET.parse('sample.xml') >> root = tre

Re: delete from pattern to pattern if it contains match

2016-04-25 Thread harirammanohar
On Monday, April 25, 2016 at 4:09:26 PM UTC+5:30, Jussi Piitulainen wrote: > Peter Otten writes: > > > harirammano...@gmail.com wrote: > > > >> Here is the code: > > > > Finally ;) > > :) name space issue can be resolved registering name space i have no issue with that, only concern is xml pars

Re: delete from pattern to pattern if it contains match

2016-04-25 Thread Jussi Piitulainen
harirammano...@gmail.com writes: > On Monday, April 25, 2016 at 4:09:26 PM UTC+5:30, Jussi Piitulainen wrote: >> Peter Otten writes: >> >> > harirammano...@gmail.com wrote: >> > >> >> Here is the code: >> > >> > Finally ;) >> >> :) > > name space issue can be resolved registering name space i ha

Re: delete from pattern to pattern if it contains match

2016-04-25 Thread harirammanohar
On Monday, April 25, 2016 at 4:58:15 PM UTC+5:30, Jussi Piitulainen wrote: > harirammano...@gmail.com writes: > > > On Monday, April 25, 2016 at 4:09:26 PM UTC+5:30, Jussi Piitulainen wrote: > >> Peter Otten writes: > >> > >> > harirammano...@gmail.com wrote: > >> > > >> >> Here is the code: > >>

RE: delete from pattern to pattern if it contains match

2016-04-25 Thread Joaquin Alzola
I put some code I did before for the xmlns: xml_root = ET.ElementTree(ET.fromstring(xml_decoded)).getroot() for elem in xml_root.getiterator(): if('{http://request.messagepush.interfaces.comv

Re: delete from pattern to pattern if it contains match

2016-04-25 Thread Jussi Piitulainen
harirammano...@gmail.com writes: > On Monday, April 25, 2016 at 4:58:15 PM UTC+5:30, Jussi Piitulainen wrote: >> harirammano...@gmail.com writes: >> >> > On Monday, April 25, 2016 at 4:09:26 PM UTC+5:30, Jussi Piitulainen wrote: >> >> Peter Otten writes: >> >> >> >> > harirammano...@gmail.com wr

Re: delete from pattern to pattern if it contains match

2016-04-25 Thread Peter Otten
harirammano...@gmail.com wrote: >> tree.write('output.xml') > > yup its working well if i include register namespace, else i am getting > ns:0 in every line of output.xml. > > But its removing top line > The write() method allows you to specify an encoding and/or require an xml declaration:

Re: Optimizing Memory Allocation in a Simple, but Long Function

2016-04-25 Thread Oscar Benjamin
On 25 April 2016 at 08:39, Gregory Ewing wrote: > Derek Klinge wrote: >> >> Also, it seems to me if the goal is to use the smallest value of n to get >> a >> particular level of accuracy, changing your guess of N by doubling seems >> to >> have a high chance of overshoot. > > > If you want to find

what is the difference between one-line-operation and 2-line-operation

2016-04-25 Thread oyster
for a simple code [code] vexList = [1, 2, 3] print('vexList', list(vexList)) vexList=map(lambda e: e+1, vexList) print('vexList', list(vexList)) vexList = list(vexList) print('vexList', list(vexList)) vexList=map(lambda e: e*2,vexList) print('vexList', list(vexList)) [/code] py27 says [quote]

Re: Optimizing Memory Allocation in a Simple, but Long Function

2016-04-25 Thread Derek Klinge
A couple thoughts. I think my original approach would be faster than binary search for finding the minimum value of N needed to get a decimal level of absolute accuracy from Euler's number. Here is my reasoning: EulerlersNumber(13).LimitMethod() - math.e < .1 and EulersNumber(135).LimitMethod - mat

Re: Scraping email to make invoice

2016-04-25 Thread Grant Edwards
On 2016-04-24, Michael Torrie wrote: > On 04/24/2016 12:58 PM, CM wrote: > >> 1. INPUT: What's the best way to scrape an email like this? The >>email is to a Gmail account, and the content shows up in the >>email as a series of basically 6x7 tables (HTML?), one table per >>PO number/ta

Re: what is the difference between one-line-operation and 2-line-operation

2016-04-25 Thread Jussi Piitulainen
oyster writes: - - > I found > type(map(lambda e: e, vexList)) is in py2 > type(map(lambda e: e, vexList)) is in py3 > > so, what produces this difference between py2 and py3 in nature? is > there more examples? where can I find the text abiut his difference? Yes, there are more ways obtain o

Re: what is the difference between one-line-operation and 2-line-operation

2016-04-25 Thread Michael Torrie
On 04/25/2016 08:13 AM, oyster wrote: > so, what produces this difference between py2 and py3 in nature? is > there more examples? where can I find the text abiut his difference? One thing I see is that both your py2 and py3 examples are treating print as a function. It's only a function in Py3.

Re: Writing different sections into a file

2016-04-25 Thread Grant Edwards
On 2016-04-25, Palpandi wrote: > Hi, > > I need to write different sections into a file. At any point of > time, content can be added to any section. > > I don't want keep each section into a temporary file. What is the > better way to store the contents of each section and write them into > a f

Question on List processing

2016-04-25 Thread subhabangalore
Dear Group, I have a list of tuples, as follows, list1=[u"('koteeswaram/BHPERSN engaged/NA himself/NA in/NA various/NA philanthropic/NA activities/NA ','class1')", u"('koteeswaram/BHPERSN is/NA a/NA very/NA nice/NA person/NA ','class1')", u"('koteeswaram/BHPERSN came/NA to/NA mumbai/LOC but/

Re: Writing different sections into a file

2016-04-25 Thread justin walters
On Mon, Apr 25, 2016 at 3:04 AM, Karim wrote: > > > On 25/04/2016 09:30, Palpandi wrote: > >> Hi, >> >> I need to write different sections into a file. >> At any point of time, content can be added to any section. >> >> I don't want keep each section into a temporary file. >> What is the better w

Re: Writing different sections into a file

2016-04-25 Thread Karim
On 25/04/2016 17:00, justin walters wrote: On Mon, Apr 25, 2016 at 3:04 AM, Karim wrote: On 25/04/2016 09:30, Palpandi wrote: Hi, I need to write different sections into a file. At any point of time, content can be added to any section. I don't want keep each section into a temporary fi

encoding issue help

2016-04-25 Thread 李洋
hi: i want to decompress the string "\x1F\x8B\x08\x00\x00\x00\x00\x00\x00\x00UP]k\xC3 \x14\xFD+\xC3\xE7\xCD\xA8\xF9X\xE2\xEBX\xA1\x0CF\x1F\xBA\xEE%\x10\xAC\xB1\xAD\xC4h\x88f%\x8C\xFD\xF7]\x1B\xDA\xAD\xF8\xE29\xE7z\xEE9~#\xE7\x11G\xAF\xBB\x1C=\x22\xDFv_j\x04H+@\xBAW\x1A\xEEe\x91>SF\x18+i\x9Ef\x0

how to set nth bit of large binary file.

2016-04-25 Thread srinivas devaki
I use aria2c to download files, aria2c has this feature of allocating the memory to file before downloading the file and then it will download using multiple connections so filling the data into this file concurrently. So i wonder how to do it. I found a way to do that from here http://stackoverfl

Re: what is the difference between one-line-operation and 2-line-operation

2016-04-25 Thread Gary Herron
On 04/25/2016 07:13 AM, oyster wrote: for a simple code [code] vexList = [1, 2, 3] print('vexList', list(vexList)) vexList=map(lambda e: e+1, vexList) print('vexList', list(vexList)) vexList = list(vexList) print('vexList', list(vexList)) vexList=map(lambda e: e*2,vexList) print('vexList', lis

HOT REQ Closable Position :Websphere message broker at Edison, NJ

2016-04-25 Thread sourav524 . itscient
Hello Associates, Please go through the below job description and let me know your interest. Please revert me: soura...@itscient.com or sourav524.itsci...@gmail.com. Position: Websphere Message Broker Location:Edison , NJ Duration: 6+ MONTHS Requisition Details: Engineer with experience on w

Re: Question on List processing

2016-04-25 Thread Steven D'Aprano
On Tue, 26 Apr 2016 12:56 am, subhabangal...@gmail.com wrote: > Dear Group, > > I have a list of tuples, as follows, > > list1=[u"('koteeswaram/BHPERSN engaged/NA himself/NA in/NA various/NA [... 17 more lines of data ...] Hi Subhabrata, and thanks for the question. Please remember that we are

Re: Scraping email to make invoice

2016-04-25 Thread Michael Torrie
On 04/25/2016 08:39 AM, Grant Edwards wrote: > Your normal gmail password is used for IMAP. Actually, no, unless you explicitly tell Google to allow "less-secure" authentication. Otherwise you are required to set up a special, application-specific password. https://support.google.com/accounts/an

Re: Scraping email to make invoice

2016-04-25 Thread Grant Edwards
On 2016-04-25, Michael Torrie wrote: > On 04/25/2016 08:39 AM, Grant Edwards wrote: >> Your normal gmail password is used for IMAP. > > Actually, no, unless you explicitly tell Google to allow "less-secure" > authentication. Otherwise you are required to set up a special, > application-specific p

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 doesn't work. Would someone fix

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 line in f: > f.read(line) > f.write(line+" *"

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 and the * >> symbol. >> >> f = open('win.

RE: Python path and append

2016-04-25 Thread Joaquin Alzola
Strip() = white spaces. Description The method strip() returns a copy of the string in which all chars have been stripped from the beginning and the end of the string (default whitespace characters). Use to remove return carriage--> line[:-1] -Original Message- From: Python-list [mailt

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. >>> I would like to take the file win.txt and append a space and the

Re: Python path and append

2016-04-25 Thread MRAB
On 2016-04-25 20:08, Joaquin Alzola wrote: Strip() = white spaces. Description The method strip() returns a copy of the string in which all chars have been stripped from the beginning and the end of the string (default whitespace characters). Use to remove return carriage--> line[:-1] 1. In

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 didn't append the * after the third entry and

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: Question on List processing

2016-04-25 Thread Matt Wheeler
On Mon, 25 Apr 2016 15:56 , wrote: > Dear Group, > > I have a list of tuples, as follows, > > list1=[u"('koteeswaram/BHPERSN engaged/NA himself/NA in/NA various/NA > philanthropic/NA activities/NA ','class1')", u"('koteeswaram/BHPERSN is/NA > a/NA very/NA nice/NA person/NA ','class1')", u"('kot

Re: Python path and append

2016-04-25 Thread Seymore4Head
I am using a test file that is only 3 lines: Punjabi .Mp3 Big Lake (DVD) SWV.avi Blue Balloon.AHC.RH.mkv The program correctly appends an * to the end of the line, but then it goes into a loop printing random looking stuff. f = open('wout.txt', 'r+') for line in f: if line=="": exit

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 = open('win.txt', 'r+') > for line

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 Seymore4Head
On Mon, 25 Apr 2016 21:26:34 + (UTC), John Gordon wrote: >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 app

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 Steven D'Aprano
On Tue, 26 Apr 2016 05:00 am, Seymore4Head wrote: > I was reading that. I have read it before. I don't use python enough > to even remember the simple stuff. Then when I try to use if for > something simple I forget how. It is perfectly fine to forget things that you read weeks or months befor

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 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

Python email issues

2016-04-25 Thread pannis2013
Hi, I am trying send email through smtplib import smtplib import os from libs import send_mail_status send_mail_status('test', False, 'ABCD', os.getcwd()) libs.py has a function as below: def send_status_mail(name, success, id, dir): #SERVER = "localhost" FROM = "localhost" TO = ["a.

def __init__(self):

2016-04-25 Thread San
Hi All, Pls let me why " def __init__(self): " declaration required, what's the use of this one.Pls explain me in details. Thanks in advance. -- https://mail.python.org/mailman/listinfo/python-list

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: def __init__(self):

2016-04-25 Thread Ben Finney
San writes: > Pls let me why […] declaration required, what's the use of this one. Welcome to Python! Congratulations on beginning to learn this language. > Pls explain me in details. You should participate in our collaborative tutoring forum, ‘tutor’ https://mail.python.org/mailman/listinfo/