strings and integers?

Ken Seehof kens at sightreader.com
Tue Jun 20 18:47:02 EDT 2000


"Arinté" wrote:

> Is
> x = "txt %(somevar)"%vars()
> the only way to append text to a string?

No.  You can also use the + operator.

  >>> a = "abc"
  >>> b = "def"
  >>> c = a+b
  >>> print c
  abcdef

Also, your syntax for % is wrong.  Reread the chapter on %.

  >>> print "a = %s" % a
  a = abc

  >>> print "1+1 = %d, for sufficiently large values of 1." % 3
  1+1 = 3, for sufficiently large values of 1.

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

The len() function can only be applied to things that have length (number of
items), such as strings, lists and tuples.  The len() function is /not/ the
same as the C function sizeof.

>>> len("hello world.")
12
>>> len([1,2,3,4,5,6])
6
>>> len(5)
Traceback (innermost last):
  File "<interactive input>", line 1, in ?
TypeError: len() of unsized object

> Thanx

--
Ken Seehof
kens at sightreader.com
starship.python.net/crew/seehof
Hi! I'm a .signature virus! copy me into your .signature file to help me
spread!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: kens.vcf
Type: text/x-vcard
Size: 343 bytes
Desc: Card for Ken Seehof
URL: <http://mail.python.org/pipermail/python-list/attachments/20000620/6a8b95d0/attachment.vcf>


More information about the Python-list mailing list