tags:

views:

544

answers:

1

In Perl, I can replicate strings with the 'x' operator:

$str = "x" x 5;

Can I do something similar in Python?

+26  A: 
>>> "blah" * 5
'blahblahblahblahblah'
Dustin
Why not 5*"RTFM"?
S.Lott
@S.Lott: So right. SO is quickly becoming the lazy programmer's alternative to reading any documentation.
davidavr
I agree, but I don't see the harm in that. (I had to chuckle when I saw S.Lott's example!)
j_random_hacker
"Dumb programming questions, answered by dumb programmers." A Google search for 'python equivalent perl x' now finds this page followed by Dustin's friendfeed, then nothing. I couldn't find the right search terms for the documentation.
Mat
I've also noted that I get more reputation points from asking dumb questions, than from complicated ones that require a bit of thought. I guess its just a flaw in the reputation system.
Mat
@Mat: Note, I didn't say it was a dumb question. By "lazy programmer" I meant that people aren't looking very hard or experimenting in the interpreter very much before they post to SO. Maybe that's a good thing because it shows that SO is very effective at answering straightforward questions.
davidavr