KBD

Keith Devens .com

Monday, December 1, 2008 Flag waving
All non-trivial abstractions, to some degree, are leaky. – Joel Spolsky (The Law of Leaky Abstractions)
← Awesome episode of AngelRegex coach →

Daily link icon Wednesday, May 7, 2003

Coolest thing about Python

... is that stuff often works on the first time. Python is the most "comfortable" programming language I've ever used. Stuff usually just works how you expect it to. Extremely well designed language.

Argh! But how do I stop it from printing spaces around shit in my print statements?

← Awesome episode of AngelRegex coach →

Comments XML gif

Adam Vandenberg wrote:

You don't.
Print is a special keyword, not a function or method, and will always rpint a newline or space after itself.

Some people consider this a language wart.

If you want to output with no extra whitespace, it's
sys.stdout.write(some string expression)

Or
write = sys.stdout.write
write(some string expression)

∴ Adam Vandenberg | 8-May-2003 12:17am est | #2020

Matt Croydon (http://postneo.com) wrote:

A language rules when pseudocode works.

∴ Matt Croydon | 8-May-2003 12:18am est | http://postneo.com | #2021

Keith (http://www.keithdevens.com/) wrote:

Awesome, thanks Adam. I knew the trick about the comma after the print statement, but I was surprised when it still put spaces around everything.

Keith | 8-May-2003 1:07am est | http://www.keithdevens.com/ | #2022

Simon Willison (http://simon.incutio.com/) wrote:

Don't forget Python's bult in printf style support:

print "Hello, %s, check this out." % 'simon'

∴ Simon Willison | 8-May-2003 2:06am est | http://simon.incutio.com/ | #2023

Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

December 2008
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
28293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 5 posts

Recent comments XML

new⇒Free image hosting sites

Well, TinyPic has this in its​FAQ:

> Images and videos is in​your accoun...

Keith: Dec 1, 1:13am

Join a NameValueCollection into a querystring in C#

Well with a lamba expression, this​is what I came up​with:

?!code:csharp...

Gustaf Lindqvist: Nov 30, 4:38pm

Why no generic OrderedDictionary?

Check​http://www.codeproject.com/KB/recip​es/GenericOrderedDictionary.aspx?d...

Gabrielk: Nov 27, 6:57am

WhatIsMyIP.com

http://www.thesysteminfo.com is​another good alternate to​whatismp.com... I...

Kripz: Nov 26, 8:51pm

Girls, please don't get breast implants

Actually I think it's sweet when a​man loves a woman whether she's big​or n...

218.186.12.228: Nov 26, 9:40am

Generated in about 0.285s.

(Used 8 db queries)

mobile phone