Re: Why don't stringobjects have methods?

Jim Roskind (
Fri, 1 Apr 1994 11:41:30 +0800

> Date: Fri, 1 Apr 1994 13:34:25 -0500
> From: "Steven D. Majewski" <>
> On Apr 1, 9:54, Jim Roskind wrote:
> > My approach to dealing with this slight misfeature (python's desire to
> > print what remains on a line) is:
> > ...
> >
> > Stats('profile.1').sort_stats(1).print_stats().ignore()
> >
> An alternative, which *I* think is more obvious of intent is:
> >>> Stats('profile.1').sort_stats(1).print_stats() and None
> >>>

Nice hack!!! :-) :-) I think I'll use this as a *better* hack in many
cases, BUT it still does not quite achieve the intent of disposing of
an arbitrary return value. The problem is that sometimes the return
value is not "None", but still evaluates as "false". For example:

0 and None

prints 0 (oops). Hence for an *arbitrary* function,

f(x) and None

won't always go printless :-(. I could write a varargs program:

def trashit(*args):

and then I could always write:


and I would have the most general hack.

Isn't it obvious that what is really needed is another statement in
Python? Note that all the suggestions I've seen or listed have
run-time costs (e.g., look up and invoke "ignore()"; look up and
evaluate "None", then perform an operation; lookup and invoke
"trashit()") ? I think your "and None" hack is the most efficient one
(no function invocation is needed), but it is also not general :-(.


Jim Roskind