[pythonvis] Python tip of the day

  • From: "Jeffrey Thompson" <jthomp@xxxxxxxxxxx>
  • To: <pythonvis@xxxxxxxxxxxxx>
  • Date: Fri, 16 May 2014 23:09:28 -0400

Python Tip of the Day

 

In Python you can make a long character sequence fairly easily. 

This can be useful and save time and code.

                This is how: you multiply a short character sequence and
produce a longer sequence.

                For example:

                ("-" * 60)

 

which produces a character sequence of 60 "-" characters.

 

                But wait, there's more ...

 

                This multiplication can also be done with words or phrases

                ("love It" * 1000)

 

will produce a sequence of 1,000 "love It" strung together.

 

                In theory one may use any large number should you need to
...

So one could go over to a friend's laptop,

get into python and type

                "I've been hijacked!" * 1000000)

and you will ty up his machine for several minutes or

until he finds out how to make the display stop.

 

Though there can be practical uses as well.

 

                If you go to the command line in Windows or terminal on the
Mac,

you can see for yourself how this works.

                Although this tip is not used every day,

                it can be used effectivly every once in a while.

 

                Jet (Jeffrey Thompson)

Other related posts:

  • » [pythonvis] Python tip of the day - Jeffrey Thompson