string bug/oddity?
Oktay Safak
oktay_safak at yahoo.com
Sun Aug 12 16:47:43 EDT 2001
Hi everyboby,
I am new to Python (and programming), so after reading
and studying the tutorial by Guido last night, I
decided to do some hands on experiments with the
interpreter and came across a quite strange behavior.
First I constructed a dictionary a. Here it is:
>>> a
{'yas': 23, 'ad': 'veli', 'soyad': 'guzel'}
>>> for x in a.keys():
if type(a[x])!="string": print x+repr(a[x])
else: print x, a[x]
yas23
ad'veli'
soyad'guzel'
>>> a
{'yas': 23, 'ad': 'veli', 'soyad': 'guzel'}
>>> for x in a.keys():
if type(a[x])!="string": print x+repr(a[x])
else: print x+a[x]
yas23
ad'veli'
soyad'guzel'
I just want to concatenate the two strings without the
quotes as in the last line. This works though:
>>> print x+a[x]
soyadguzel
Well, if you try it after getting rid of the first
entry in the dictionary which is a number then
everything is also OK:
>>> a
{'ad': 'veli', 'soyad': 'guzel'}
>>> for x in a.keys():
print x+a[x]
adveli
soyadguzel
I couldn't understand why this happens.(I tried many
other ways to do it but no success) Is this a bug or
what? I searched the newsgroup archives but couldn't
find anything on this topic. Thanks for any help.
Oktay Safak
__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/
More information about the Python-list
mailing list