[omaha] String Concatenation
newz at bearfruit.org
Sun Jun 8 19:08:18 CEST 2008
On 6/7/08, Matt Harriger <mharriger at gmail.com> wrote:
> On Sat, Jun 7, 2008 at 4:12 PM, freeav8r <freeav8r at yahoo.com> wrote:
> > When you type in a form on a web page, any non ascii characters get
> > converted to their &#; equivalent. As an example,, the capital D with a
> > horizontal line gets converted to Đ.
> > Is there a python module out there that will do this for unicode characters
> > with no ascii equivalent?
> ord(uchar) (where uchar is a unicode string of length 1) will return the
> unicode codepoint for the given char, so ord(Đ) returns 272. "&#" +
> str(ord(uchar)) would give you the full HTML entity representation for that
One of my first real python programs was incredibly slow because I
used a lot of string concatenation. (Since strings are immutable in
python changing them is slow)
Now, whenever possible, I use the equiv of:
d = ["hello", "world"]
s = ' '.join(d)
Is doing what Matt H suggested above (i.e. s = a + b + c) the slow
kind of concatenation or is this fast since it's not actually
modifying a string (i.e. s += b)?
newz2000 on freenode
More information about the Omaha