On 2010-06-18, Steven D'Aprano st...@remove-this-cybersource.com.au wrote:
On Thu, 17 Jun 2010 20:03:42 +, Neil Cerutti wrote:
I'm currently using the following without problems, while
reading a data file. One of the fields is a comma separated
list, and may be empty.
f = rec['codes']
On 17 June, 21:03, Neil Cerutti ne...@norwich.edu wrote:
On 2010-06-17, Robert Kern robert.k...@gmail.com wrote:
On 6/17/10 2:08 PM, Neil Cerutti wrote:
On 2010-06-17, Ian Kellyian.g.ke...@gmail.com wrote:
On Thu, Jun 17, 2010 at 11:45 AM, Neil Cerutti
ne...@norwich.edu wrote:
What's
On 2010-06-18, Jon Clements jon...@googlemail.com wrote:
I just wondered if something smoother was available.
In terms of behaviour and 'safety', I'd go for:
rec = { 'code1': '1,2,3', 'code2': '' }
next(csv.reader([rec['code1']]))
['1', '2', '3']
next(csv.reader([rec['code2']]))
[]
What's the best way to do the inverse operation of the .join
function?
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
Neil Cerutti wrote:
What's the best way to do the inverse operation of the .join
function?
--
Neil Cerutti
split
--
http://mail.python.org/mailman/listinfo/python-list
Neil Cerutti wrote:
What's the best way to do the inverse operation of the .join
function?
.split, possibly, although there will be problems if the string contains
other occurrences of the separator.
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Jun 17, 2010 at 11:45 AM, Neil Cerutti ne...@norwich.edu wrote:
What's the best way to do the inverse operation of the .join
function?
Use the str.split method?
--
http://mail.python.org/mailman/listinfo/python-list
On 2010-06-17, Ian Kelly ian.g.ke...@gmail.com wrote:
On Thu, Jun 17, 2010 at 11:45 AM, Neil Cerutti
ne...@norwich.edu wrote:
What's the best way to do the inverse operation of the .join
function?
Use the str.split method?
split is perfect except for what happens with an empty string.
--
Neil Cerutti wrote:
On 2010-06-17, Ian Kelly ian.g.ke...@gmail.com wrote:
On Thu, Jun 17, 2010 at 11:45 AM, Neil Cerutti
ne...@norwich.edu wrote:
What's the best way to do the inverse operation of the .join
function?
Use the str.split method?
split is perfect except for what happens with an
On 6/17/10 2:08 PM, Neil Cerutti wrote:
On 2010-06-17, Ian Kellyian.g.ke...@gmail.com wrote:
On Thu, Jun 17, 2010 at 11:45 AM, Neil Cerutti
ne...@norwich.edu wrote:
What's the best way to do the inverse operation of the .join
function?
Use the str.split method?
split is perfect except
On 6/17/10 12:44 PM, MRAB wrote:
Neil Cerutti wrote:
On 2010-06-17, Ian Kelly ian.g.ke...@gmail.com wrote:
On Thu, Jun 17, 2010 at 11:45 AM, Neil Cerutti
ne...@norwich.edu wrote:
What's the best way to do the inverse operation of the .join
function?
Use the str.split method?
split is
On 2010-06-17, Robert Kern robert.k...@gmail.com wrote:
On 6/17/10 2:08 PM, Neil Cerutti wrote:
On 2010-06-17, Ian Kellyian.g.ke...@gmail.com wrote:
On Thu, Jun 17, 2010 at 11:45 AM, Neil Cerutti
ne...@norwich.edu wrote:
What's the best way to do the inverse operation of the .join
On 6/17/10 3:03 PM, Neil Cerutti wrote:
On 2010-06-17, Robert Kernrobert.k...@gmail.com wrote:
On 6/17/10 2:08 PM, Neil Cerutti wrote:
On 2010-06-17, Ian Kellyian.g.ke...@gmail.com wrote:
On Thu, Jun 17, 2010 at 11:45 AM, Neil Cerutti
ne...@norwich.edu wrote:
What's the best way to do
On Thu, 17 Jun 2010 17:45:41 +, Neil Cerutti wrote:
What's the best way to do the inverse operation of the .join function?
str.join is a many-to-one function, and so it doesn't have an inverse.
You can't always get the input back unchanged:
L = [a, b, c|d, e]
s = '|'.join(L)
s
On Thu, 17 Jun 2010 20:44:41 +0100, MRAB wrote:
Should .split grow an addition keyword argument to specify the desired
behaviour?
Please no.
(Although it's simple enough to define your own function.)
Exactly.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, 17 Jun 2010 20:03:42 +, Neil Cerutti wrote:
I'm currently using the following without problems, while reading a data
file. One of the fields is a comma separated list, and may be empty.
f = rec['codes']
if f == :
f = []
else:
f = f.split(,)
I just wondered if
16 matches
Mail list logo