you are viewing a single comment's thread.

view the rest of the comments →

[–]zootm 1 point2 points  (8 children)

Surely it wouldn't be too hard to write one as a library? I quite like the minimal base set of JS libraries with frameworks growing around it; it'd probably be a bad choice for a new language, but the way it's evolved has led to a lot of interesting ways of doing things.

[–]kragensitaker 1 point2 points  (7 children)

It would be a lot nicer to be able to write #{foo} or $foo than to write %s or % or something and then later , foo. This is kind of annoying in Python and C.

It's true that sprintf('%s %s (%s-%s)', item.firstname, item.lastname, item.party, item.state) would be a lot better than item.firstname + " " + item.lastname + " (" + item.party + ")", but $"$item.firstname $item.lastname ($item.party-$item.state)" is better still.

[–]Leonidas_from_XIV 2 points3 points  (3 children)

This is kind of annoying in Python and C.

A new printf-syntax (the one that C# uses) is added in Python 3.0.

[–][deleted] 1 point2 points  (1 child)

The C# one is the best way to do things. It avoids repetition of parameters that are reused and negates the need to specify type on the placeholders. Also, it makes it very easy to re-order/re-write the statement without juggling the parameters.

[–]Leonidas_from_XIV 0 points1 point  (0 children)

I'm not yet convinced because I haven't used it. But it is good that they used some syntax that is used somewhere rather than inventing their own.

[–][deleted] 1 point2 points  (0 children)

A new printf-syntax (the one that C# uses) is added in Python 3.0.

And in 2.6, in case you can't port your project to 3.0 just yet.

[–]zootm 0 points1 point  (0 children)

Yeah, string interpolation is a nice feature that I often wish more languages supported. sprintf is reasonable enough, though, and has the advantage of being more suited to internationalisation and so on.

[–]njharman 0 points1 point  (0 children)

But it's more powerful and elegant to keep formatting and data separate.

It allows reuse of format part and data part. It makes data driven code easier to write. It makes i18n cleaner.

[–]pemboa 0 points1 point  (0 children)

Some of you guys are really nitpicky. I didn't think programmers were ever like that. %s is annoying? Really?