join vs instances

Kalle Svensson kalle at gnupung.net
Sun Dec 9 11:24:36 EST 2001


[Brad Bollenbach]
> In article <cw+m7LAfO0E8EwpC at jessikat.fsnet.co.uk>, Robin Becker wrote:
> > I had expected to be able to use things like UserStrings interchangeably
> > with ordinary strings, but 
> 
> You can. If you couldn't, UserString wouldn't serve much purpose.

No, you can't.  There is still a purpose with UserString, before 2.2, but you
can't use UserStrings intarchangeably with ordinary strings.  At least not if
the word "interchangeably" means what I think it means.

For example:
>>> s = "foo"
>>> "".join(["bar", s])
works, but
>>> s = UserString("foo")
>>> "".join(["bar", s])
doesn't.

There is a reason for the type/class unification, after all!

Peace,
  Kalle
-- 
Kalle Svensson (kalle at gnupung.net) - Laziness, impatience, hubris: Pick two!
English: http://www.gnupung.net/  Svenska: http://www.lysator.liu.se/~kalle/
Stuff: ["http://www.%s.org/" % x for x in "gnu debian python emacs".split()]




More information about the Python-list mailing list