[EMAIL PROTECTED] wrote: > Ben Keshet: >> ...wrong. I thought I should omit the comma and didn't put it. I guess >> that stating the obvious should be the first attempt with beginners like >> me. Thanks for thinking about it (it's running perfect now). > > In CLisp, Scheme etc, lists such commas aren't necessary, but in > Python if you don't separate strings with a comma they become merged > into a single string: > >>>> 'foo', 'bar' > ('foo', 'bar') >>>> 'foo' 'bar' > 'foobar' > > Your mistake is caused by Python not following one of its general > rules: > > Explicit is better than implicit. > > In such case the string concatenation (+) is done implicitly. It's a > little handy feature once in a while (but not for me so far), while it > may cause bugs, so I don't like this little feature of Python and I > may like to see it removed, because it may bite you in similar > situations, where you forgot a comma for mistake: > > parts = ["foo", "bar" "baz"] > > Bye, > bearophile
It's useful when wrapping a line. For lack of better lorem ipsum: whatever = some_function("Your mistake is caused by Python not " "following one of its general rules:\n\n" "Explicit is better than implicit.") You can also use backslashes, and probably even + if you want to, but the implicit concatenation is prettier (IMO, at least ;-). But you do have a point. I have never thought about the problems it could cause. BTW, I could easily be wrong, but I think C behaves the same way as Python. -- -- http://mail.python.org/mailman/listinfo/python-list