skip to main | skip to sidebar

Deva's MySQL / Linux blog

Ramblings about MySQL, Linux, scripting languages like Perl, PHP, Bash, Python... What ever I run into at work or play :)

26 August 2005

Python Challenge

Challenge: reverse every word in a text file in place (preserving line breaks and word order)

Answer:

for line in open("file_name").read().split('\n'):
print ' '.join(line[::-1].split()[::-1])
at 5:18 PM

1 comments:

davidhill0023 said...
This comment has been removed by a blog administrator.
Mon Sep 19, 02:57:00 AM PDT

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)
My Photo
Devananda vdv
View my complete profile

Links

  • MyCAT project
  • Planet MySQL
  • MySQL Reference Manual

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Blog Archive

  • ►  2009 (4)
    • ►  April (1)
      • check your my.cnf with "mysqld --help --verbose"
    • ►  February (1)
      • Bug in savepoints getting fixed
    • ►  January (2)
      • Tokutek challenge vs. 128GB RAM
      • Twitter
  • ►  2008 (5)
    • ►  July (5)
      • SAVEPOINTs just got more problematic
      • Error 153 when creating savepoints
      • Mycat beta 0.3.0 released
      • How to replicate LOAD DATA from 4.1 to 5.1
      • Performance of JOIN using columns of different num...
  • ►  2006 (1)
    • ►  January (1)
      • Think I found a bug ....
  • ▼  2005 (8)
    • ►  November (2)
      • Added 'rcall' to mycat project
      • Replication Monitor finished!
    • ►  October (2)
      • Replication Monitor preview posted
      • Open Source
    • ▼  August (4)
      • Python Challenge
      • Distributed database, a few tables at a time
      • Previously, MySQL Cluster
      • Initializing...