Comments (13)
You can use string.printable.replace(' ', '')
or set(string.printable) - {' '}
. This can be easily modified to exclude other undesirable characters (for example I
, l
and 1
can be confused with each other, ''
can be confused with "
or ``
).
string.printable
is a historical artifact. Today it is superseded by the str.isprintable()
methods combined with additional conditions. Every applications has its own conditions. Adding yet one string constant in the string
module which differs only by a character from other string constant will likely confuse people.
from cpython.
If we add something for convenience, it should be both convenient and correct for many users.
While I haven't done the research, use cases I can think of are better served with a slightly different set -- for example, exclude quotes or the backslash, exclude O
/0
and l
/I
/1
for readability, or not limit the set to ASCII. For toy examples, digits
+ ascii_letters
are fine.
from cpython.
this is a good first issue i suppose for people looking to make a PR
from cpython.
Adding yet one string constant in the
string
module which differs only by a character from other string constant will likely confuse people.
i doubt anyone will be confused by a string constant. even if there are workarounds, it's just prettier and quicker to have another constant, helps the read-ability yk.
from cpython.
differs only by a character
By six. Also ASCII 9 to 13.
from cpython.
How would you name the new constant? string.printable_without_space
? Or more accurately string.ascii_printable_without_whitespace
?
from cpython.
How would you name the new constant?
string.printable_without_space
? Or more accuratelystring.ascii_printable_without_whitespace
?
string.visible
from cpython.
Is there a problem with this?
from string import ascii_letters, digits, punctuation
visible = digits + ascii_letters + punctuation
from cpython.
Is there a problem with this?
from string import ascii_letters, digits, punctuation visible = digits + ascii_letters + punctuation
no, but it's less efficient than just having a visible constant which would be useful for a lot of use cases. it's sorta like asking 'why have ascii when you can just add lower and upper ascii?'
from cpython.
For reference here are the constants of the original version:
Lines 6 to 12 in c636014
Only punctuation
& printable
have been added since with the latter being the concatenation of all other strings.
from cpython.
i still think visible is such a logical addition when someone needs all visible symbols fast. id hardly see it as bloat? i fully axknowledge what im suggestinf is just an efficiency / readability optimisation and there are work arounds but i see little reason why not to add it as a constant
from cpython.
i see little reason why not to add it as a constant
The opposite question is relevant: what is the reason to add it? Where would it be useful?
It's easy to add, but that's not a very good reason to add it.
from cpython.
i see little reason why not to add it as a constant
The opposite question is relevant: what is the reason to add it? Where would it be useful? It's easy to add, but that's not a very good reason to add it.
already answered. tl;dr: convenience.
from cpython.
Related Issues (20)
- Add class method Fraction.from_number()
- Add class method Decimal.from_number()
- The new repl sometimes does not show the error location when `SyntaxError` is raised HOT 7
- Segfault in 3.13 when calling `PyEval_SetTrace` from a thread with no Python frames HOT 4
- Add A Howto Page About Using Multiple Interpreters HOT 4
- Typo
- if you unpack a single element tuple containing a string, it thinks you have len(str) elements HOT 3
- argparse behavior when a 'store' arg and a 'store_const' arg both store to the same dest is undefined and inconsistent HOT 3
- Test suite crashes when run single process `--with-pydebug` enabled HOT 24
- Improve `complex` C-API error descriptions
- pip3 install lxml failed when using Python 3.13.0b3 on Windows with MSVC HOT 5
- Improve `PyBytes_FromStringAndSize` test coverage
- RPM version error for python3-3.9.18-3.el9_4.1.x86_64.rpm HOT 1
- Build failure with "--with-address-sanitizer" flag HOT 4
- [C API] Segmentation fault in PyUnicodeWriter when writing nothing and with initial length = 0 HOT 3
- Chess game
- Conceptual Flaw in Python's Iterator Behavior During Collection Modification HOT 11
- Crash on _PyDict_CheckConsistency with an empty instance dict HOT 10
- CMultiplyNested closure crash: Python 3.13 regression HOT 8
- White space causes inconsistent frame traversal in With blocks HOT 19
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpython.