Re: Appending a list's elements to another list using a list comprehension

2007-10-18 Thread Debajit Adhikary
On Oct 18, 9:47 am, [EMAIL PROTECTED] (Alex Martelli) wrote: > Debajit Adhikary <[EMAIL PROTECTED]> wrote: > > > How does "a.extend(b)" compare with "a += b" when it comes to > > performance? Does a + b create a completely new list that it assigns > &

Best way to generate alternate toggling values in a loop?

2007-10-17 Thread Debajit Adhikary
I'm writing this little Python program which will pull values from a database and generate some XHTML. I'm generating a where I would like the alternate 's to be and What is the best way to do this? I wrote a little generator (code snippet follows). Is there a better (more "Pythonic") way to

Re: Appending a list's elements to another list using a list comprehension

2007-10-17 Thread Debajit Adhikary
On Oct 17, 5:40 pm, Paul Hankin <[EMAIL PROTECTED]> wrote: > To answer your question though: a += b is *not* the same as a = a + b. > The latter would create a new list and assign it to a, whereas a += b > updates a in-place. I know I'm being a little finicky here, but how would someone know that

Re: Appending a list's elements to another list using a list comprehension

2007-10-17 Thread Debajit Adhikary
On Oct 17, 4:41 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Wed, 2007-10-17 at 20:27 +, Debajit Adhikary wrote: > > I have two lists: > > > a = [1, 2, 3] > > b = [4, 5, 6] > > > What I'd like to do is append all of the elements of b at the end

Appending a list's elements to another list using a list comprehension

2007-10-17 Thread Debajit Adhikary
I have two lists: a = [1, 2, 3] b = [4, 5, 6] What I'd like to do is append all of the elements of b at the end of a, so that a looks like: a = [1, 2, 3, 4, 5, 6] I can do this using map(a.append, b) How do I do this using a list comprehension? (In general, is using a list comprehension pref

Re: Converting Diff Output to XML?

2007-06-28 Thread Debajit Adhikary
That looks very good :)Thanks a ton! On 6/27/07, Yongjian Xu <[EMAIL PROTECTED]> wrote: gnosis has a converter for ASCII file to xml file, its called txt2dw.py. give it a try. -- Jim On 6/26/07, Debajit Adhikary <[EMAIL PROTECTED]> wrote: > > What would be the best way to c

Converting Diff Output to XML?

2007-06-26 Thread Debajit Adhikary
What would be the best way to convert the regular (unix) diff output into XML? Are there any libraries at all which might help? -- http://mail.python.org/mailman/listinfo/python-list

python-list@python.org

2007-05-22 Thread Debajit Adhikary
I've written a SAX XML parser and cannot seem to be able to parse simple entity references e.g. < abc > It looks the XML parser that i'm using hasn't implemented the startEntity() and endEntity() methods. How do I parse such simple entity references using Python? ---

Cannot parse simple entity references using xml.sax

2007-05-18 Thread Debajit Adhikary
I'm writing a SAX parser using Python and need to parse XML with entity references. <> Only the last entity reference gets parsed. Why are startEntity() and endEntity() never called? I'm using the following code: http://pastie.textmate.org/62610 -- http://mail.python.org/mailman/listinfo/pytho