Thursday, June 11, 2009

Python Yuck

This may just be because I have gotten so used to Perl and so gladly forgotten my Python days, but I just thought I would put a little posting to help others avoid the annoyance of Python's join syntax.

Perl: -

my $str_items = join(',', @ians_array); Gives you a nice string comma separated

Python: -

str_string=""
str_string.join(",",ians_array)

Gives you join() takes exactly one argument (2 given)

Hmm, you think maybe I have to use that dirty syntax I have seen?

str_string=""
str_string+= ''.join(ians_array)

Hmm apparently working but no delimeter, lets make it even uglier

str_string=""
str_string+= ','.join(ians_array)