Odd listcomp behaviour

E

Emile van Sebille

Does anyone else consider this a bug?

Python 2.6.2 (r262:71600, Jun 16 2009, 11:09:39)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-10)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

---1---
>>> skippedords = '1,2,3,4,5'
>>> ['10%s' % ii for ii in skippedords.split(',')]
['101', '102', '103', '104', '105']

---2---
>>> skippedords = ''
>>> ['10%s' % ii for ii in skippedords.split(',')]
['10']

---3---
>>> test = ''
>>> ['%s' % ii for ii in test.split() ]
[]


I got stung because I expected ---2--- to do what ---3--- did.

Emile
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top