[issue12914] Add cram function to textwrap

2011-09-12 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

 if the API were to be expanded, perhaps it should be as a part of a
 focuse[d], thoughtful effort to provide a more generic set of text
 formatting transformations perhaps modeled on deep experiences with
 similar modules in other languages. (as opposed to piecemeal additions
 that weren't designed with a coherent vision).

That’s a very strong point.

Thanks for the opinions.

--
stage:  - committed/rejected

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12914
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12914] Add cram function to textwrap

2011-09-11 Thread Raymond Hettinger

Changes by Raymond Hettinger raymond.hettin...@gmail.com:


--
resolution:  - rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12914
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12914] Add cram function to textwrap

2011-09-10 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

This pretty well summarizes my vague feelings. I originally used a size 30 in 
my example, getting 'This sentence...made available' and then realized that it 
was a complete accident that I got complete words. If anything were made 
publicly available, I might like a more sophisticated algorithm. I think other 
things in pydoc are more worth of consideration. So I am now -.5 or more and 
would not mind closing this one of the four new pydoc exposure issues.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12914
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12914] Add cram function to textwrap

2011-09-09 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

It is already available:
 import pydoc
 pydoc.cram('This sentence is too long to fit the space I have made 
 available', 28)
'This sentenc...ade available'

def cram(text, maxlen):
Omit part of a string if needed to make it fit in a maximum length.
if len(text)  maxlen:
pre = max(0, (maxlen-3)//2)
post = max(0, maxlen-3-pre)
return text[:pre] + '...' + text[len(text)-post:]
return text

It could be documented in place, or moved and imported into pydoc. I am +0 at 
the moment.

--
nosy: +terry.reedy

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12914
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12914] Add cram function to textwrap

2011-09-09 Thread Raymond Hettinger

Changes by Raymond Hettinger raymond.hettin...@gmail.com:


--
assignee:  - rhettinger
nosy: +rhettinger

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12914
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12914] Add cram function to textwrap

2011-09-09 Thread Raymond Hettinger

Raymond Hettinger raymond.hettin...@gmail.com added the comment:

A few thoughts:
* no one has ever made a request for this
* different people may want to do it in different ways 
  (the formulas are hard-wired).
* the '...' connector is hardwired
  (perhaps ' ... ' would look less odd).
* we should have a preference for keeping APIs small
  (more to learn and remember)
* this is dirt simple string processing and not hard
  for people to roll their own if the need arises
* if the API were to be expanded, perhaps it should
  be as a part of a focuses, thoughtful effort to
  provide a more generic set of text formatting
  transformations perhaps modeled on deep experiences
  with similar modules in other languages.
  (as opposed to piecemeal additions that weren't 
  designed with a coherent vision).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12914
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12914] Add cram function to textwrap

2011-09-06 Thread Éric Araujo

New submission from Éric Araujo mer...@netwok.org:

The pydoc module has a cram function that could be useful to Python authors, if 
we made it public (textwrap sounds like a great place).

--
components: Library (Lib)
messages: 143625
nosy: eric.araujo
priority: normal
severity: normal
status: open
title: Add cram function to textwrap
type: feature request
versions: Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12914
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com