Tag Archives: python

View carriage returns, line feeds and tabs within text files

This is a useful Python one-liner for viewing characters that are usually hidden in text files;

  • Carriage returns (shown as \r)
  • Line feeds (shown as \n)
  • Tabs (shown as \t)
python -c "f = open('filename.txt', 'r'); f.seek(0); file = f.readlines(); print file"

Example output:

['Carriage return and line feed: \r\n', 'Line feed: \n', 'Tab: \t\n']

I recently used this script when trying to work out why a shell script was not executing correctly on a Debian machine -- the reason was some carriage returns inserted by a Windows-based editor.

Glen Scott

I’m a freelance software developer with more than 10 years’ professional experience in web development. I specialise in creating tailor-made, web-based systems that can help your business run like clockwork. I am the Managing Director of Yellow Square Development and the founder of FreelanceDevLeads, a service that sources quality freelance leads for developers.

More Posts

Follow Me:
TwitterFacebookLinkedIn

Cal Henderson on Django

Very entertaining talk from Flickr's Cal Henderson on Django's shortcomings.

Glen Scott

I’m a freelance software developer with more than 10 years’ professional experience in web development. I specialise in creating tailor-made, web-based systems that can help your business run like clockwork. I am the Managing Director of Yellow Square Development and the founder of FreelanceDevLeads, a service that sources quality freelance leads for developers.

More Posts

Follow Me:
TwitterFacebookLinkedIn

I've used Rails. It seemed like a good idea at the time.

Interesting article on how Rails features can be more of a hindrance than a help in many situations. Compared here with Django, which can be cleaner and more lightweight.

Some of the bits and pieces that come bundled with Rails are just plain wrong, the Javascript helpers being one example. The abuse of HTTP by default in some of the scaffolding code being another. Oh, and the markup coming out of various helpers as well. In trying to help the application developer Rails gets in the way of the professional webstandards types.

Morethanseven » Why the webstandards world appears to be choosing Django

Glen Scott

I’m a freelance software developer with more than 10 years’ professional experience in web development. I specialise in creating tailor-made, web-based systems that can help your business run like clockwork. I am the Managing Director of Yellow Square Development and the founder of FreelanceDevLeads, a service that sources quality freelance leads for developers.

More Posts

Follow Me:
TwitterFacebookLinkedIn