.split() Qeustion
Duncan Booth
duncan.booth at invalid.invalid
Thu Aug 15 05:15:56 EDT 2013
Joshua Landau <joshua at landau.ws> wrote:
> That's true with this example, but is:
>
> lines = [
> "Developments in high-speed rail, and high-speed",
> "transport more generally, have historically been",
> "impeded by the difficulties in managing friction",
> "and air resistance, both of which become",
> "substantial when vehicles approach high speeds.",
> "The vactrain concept eliminates these obstacles",
> "by employing magnetically levitating trains in",
> "tubes kept at a complete vacuum, allowing for",
> "heoretical speeds of thousands of miles per",
> "hour. The high cost of constructing such a system,",
> "however, and the difficulty of maintaining a",
> "vacuum over large distances, has prevented this",
> "type of system from ever being built. The",
> "Hyperloop can be viewed as a modified vactrain,",
> "employing more cost-effective solutions to the",
> "same problems the latter was designed to solve."
> ]
>
> really more readable than:
>
> lines = """\
> Developments in high-speed rail, and high-speed
> transport more generally, have historically been
> impeded by the difficulties in managing friction
> and air resistance, both of which become
> substantial when vehicles approach high speeds.
> The vactrain concept eliminates these obstacles
> by employing magnetically levitating trains in
> tubes kept at a complete vacuum, allowing for
> heoretical speeds of thousands of miles per
> hour. The high cost of constructing such a system,
> however, and the difficulty of maintaining a
> vacuum over large distances, has prevented this
> type of system from ever being built. The
> Hyperloop can be viewed as a modified vactrain,
> employing more cost-effective solutions to the
> same problems the latter was designed to solve.
> """[1:-1].split("\n")
>
> ?
I suppose the question really is whether the author of the second
example really meant to start with the word 'evelopments'?
If that was a mistake, then the first one is demonstrably less error
prone. If it was intentional then the second one is definitely less
readable.
Either way I think you've proved that the first way of writing it is
more readable.
--
Duncan Booth
More information about the Python-list
mailing list