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.
Created on 2011年07月05日 03:03 by parent5446, last changed 2022年04月11日 14:57 by admin.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| textwrap.py-widthfunction-2011年07月04日_22-57-49_r71219+.diff | parent5446, 2011年07月05日 03:03 | Addition of custom width function to textwrap.py. | ||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 28136 | open | xi2, 2021年09月03日 08:13 | |
| Messages (6) | |||
|---|---|---|---|
| msg139828 - (view) | Author: Tyler Romeo (parent5446) | Date: 2011年07月05日 03:03 | |
Originally from http://bugs.python.org/issue12485 but separated. The textwrap modules uses len to determine the length of text, but in many (if not most) fonts, the width of a character differs depending on the letter, so it would be useful to have an option to pass a custom function that returns the width of a given string of text. |
|||
| msg139829 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2011年07月05日 06:10 | |
About the patch: the function should not be passed to the constructor, it could be a regular method that can be overridden in subclasses. |
|||
| msg139881 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2011年07月05日 15:44 | |
Amaury, do you think it’s more common to subclass TextWrapper than just instantiate it? I find the proposed API (an argument to __init__) very intuitive. |
|||
| msg139894 - (view) | Author: Tyler Romeo (parent5446) | Date: 2011年07月05日 16:17 | |
Normally I would have just added it as a function to be overloaded, but because of the nature of the textwrap.wrap function (all kwargs are passed to the TextWrapper constructor) I thought it made a lot more sense to keep it as an argument to __init__. |
|||
| msg231092 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年11月12日 20:52 | |
Both approaches can be combined. It could be a regular overridable method, and it could be overridded for an instance if corresponding argument is specified. See the default method and parameter of JSON encoder. I slightly hesitate about the name. Is "width_func" the best of names? |
|||
| msg401011 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2021年09月03日 18:32 | |
A PR was opened for this. `text_len` is used as param/attribute name. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:19 | admin | set | github: 56708 |
| 2021年09月03日 18:32:07 | eric.araujo | set | messages:
+ msg401011 versions: + Python 3.11, - Python 3.5 |
| 2021年09月03日 08:13:33 | xi2 | set | pull_requests: + pull_request26574 |
| 2021年09月03日 08:11:12 | xi2 | set | nosy:
+ xi2 |
| 2018年07月09日 08:58:24 | methane | unlink | issue24665 dependencies |
| 2017年02月15日 07:44:17 | serhiy.storchaka | link | issue24665 dependencies |
| 2014年11月12日 20:52:31 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg231092 versions: + Python 3.5, - Python 3.3 |
| 2011年07月05日 16:17:24 | parent5446 | set | messages: + msg139894 |
| 2011年07月05日 15:44:29 | eric.araujo | set | nosy:
+ georg.brandl, eric.araujo messages: + msg139881 keywords: + needs review stage: patch review |
| 2011年07月05日 06:10:03 | amaury.forgeotdarc | set | nosy:
+ amaury.forgeotdarc messages: + msg139829 |
| 2011年07月05日 03:03:24 | parent5446 | create | |