strings and integers?

Stephen Hansen stephen at cerebralmaelstrom.com
Thu Jun 22 14:34:26 EDT 2000


Arinté <shouldbe at message.com> wrote in message
news:8it0j0$1du6$1 at news2atm.raleigh.ibm.com...
> Sorry,  I wasn't clear in last post.  I was in a hurry and frustrated with
> embedding python in my app.  If I had time I would probably go with COM
for
> the application and us python to talk to it.  Anyhow I don't even know
COM.
> > > Is
> > > x = "txt %(somevar)"%vars()
> > > the only way to append text to a string?
> What I meant to ask here was, Is this the only way to append integers to a
> string?

    My *personal* opinion is that it's the best way. I've said it before, I
*love* the modulo-printf-ish-operator... but, you can also use the '+'

    e.g. text = "Some String" + str(YourNumber)

    You have to stick 'str' in there, otherwise it'll raise a TypeError

> > > Also, why do I get a len() of unsized object errors?  Do I need to
> rebuild
> > > the python dlls? Download 1.6?
> >
> > No.  It is very unlikely that you have found a python bug.  Show me an
> > example.  When asking a question, always show an example.
>
> This question was my example.
> xrt = 8
> print'ioctl %d <---' %xrt
> Python will print "ioctl 8 <----", but it will still give an error of
len()
> of unsized object on the corresponding  line of code.

    This works perfectly for me. What version are you using? Do you have any
nasty 'from module import *'s laying aroudn? Dunno, it seems to me that
whenever something behaves totally /oddly/ that one of those is to blame. :)

--S






More information about the Python-list mailing list