This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients mark.dickinson
Date 2011-09-20.13:44:06
SpamBayes Score 7.694772e-08
Marked as misclassified No
Message-id <1316526247.48.0.14583848283.issue13012@psf.upfronthosting.co.za>
In-reply-to
Content
The docstring of str.splitlines says:

splitlines(...)
    S.splitlines([keepends]) -> list of strings
    
    Return a list of the lines in S, breaking at line boundaries.
    Line breaks are not included in the resulting list unless keepends
    is given and true.

Currently the optional argument can only be specified positionally.  What do people think about also allowing this argument to be specified by keyword?  (And applying the same change to bytes.splitlines.)

The main motivation here is readability:  in

   long_string.splitlines(keepends=True)

it's fairly clear what the boolean argument is doing.  But in

   long_string.splitlines(True)

it's much less clear.  (This came up during a Python training class that I was running recently.)  I'm not advocating making the argument keyword-only;  just allowing those who want to specify it by keyword to do so.

There are many other str methods that don't accept keyword arguments, but it's only this one where I think readability would really benefit.
History
Date User Action Args
2011-09-20 13:44:07mark.dickinsonsetrecipients: + mark.dickinson
2011-09-20 13:44:07mark.dickinsonsetmessageid: <1316526247.48.0.14583848283.issue13012@psf.upfronthosting.co.za>
2011-09-20 13:44:06mark.dickinsonlinkissue13012 messages
2011-09-20 13:44:06mark.dickinsoncreate