string question. difference between string.split(str, ":") and str.split(":")

Ignacio Vazquez-Abrams ignacio at openservices.net
Thu Oct 25 05:57:59 EDT 2001


On Thu, 25 Oct 2001, Markus Jais wrote:

> hello
>
> what is the difference between
>
> import string
> str = "one:two:three"
> a, b, c = string.split(str, ":")
>
> and
>
> str = "one:two:three"
> a, b, c = str.split(":")
>
>
> except for the import statement in the first example.
>
> I prefer the 2nd version because it looks more oop
> (like Ruby) and less like Perl or C.
>
> but is there any difference,  for example in performance???

Not in performance, but definitely in compatibility/portability. The second
will only work with Python 2.0 or later.

-- 
Ignacio Vazquez-Abrams  <ignacio at openservices.net>

   "As far as I can tell / It doesn't matter who you are /
    If you can believe there's something worth fighting for."
       - "Parade", Garbage





More information about the Python-list mailing list