str.split() is so well known, but a simple step beyond leaves a lot of pythonistas lost: how do you split without breaking up embedded strings? How do you split "1 '2 3' 4" into ['1', '2 3', '4']? Why, shlex.split("1 '2 3' 4"), of course! The shlex module is a lexical analyzer and includes this little useful utility for us.
I write here about programming, how to program better, things I think are neat and are related to programming. I might write other things at my personal website.
Saturday, February 17, 2007
- ► 2012 (19)
- ► 2011 (19)
- ► 2010 (32)
- ► 2008 (28)
- Minimal Working Examples: How to, Why, and Who car...
- Standard Gems: SimpleHTTPServer.test()
- Standard Gems: colorsys
- Book Review: Practices of an Agile Developer
- RTFM Not Just a Disgruntled Reply
- Pure Functions in the Python Standard Library?
- PyCon Recordings?
- Standard Gems: shlex.split()
- Standard Gems: calendar.month_name
- Extreme Code - Version Control For One FileYou sho...
- Extreme Code - Examining Software Development Thro...
- ▼ February (11)