Comments (10)
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.
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.
Related Issues (20)
- `tokenize.generate_tokens()` performance regression in 3.12 HOT 8
- functools.cache treats a named positional argument as a different one from an unnamed one HOT 1
- `asyncio.staggered` is missing `typing` import HOT 4
- The CSV file delimiter found with csv.Sniffer() is interpreted incorrectly HOT 6
- functools.partial placeholders HOT 2
- _PyFrame_Clear can crash in for loop if frame->localsplus is NULL.
- Python -VV should display whether the build is default build or free-threading. HOT 3
- [Enhancement] Expose list.remove() as PyList_Remove(PyObject *) in the C API. HOT 2
- Ncurses Extended Color Pairs incorrectly display as copies of lower 256 color pairs
- Python is not getting location services permission HOT 3
- Update `paths` in `jit.yml`
- Add `asyncio.Queue.__aiter__` HOT 9
- Needs of feature that disabling optimization pipeline in runtime
- Make timeit CLI function available from python HOT 3
- Improve performance of `os.walk()` HOT 1
- [Windows] High DPI causes tkinter turtledemo windows blurry
- `clear` method of `list` class in `multiprocessing.Manager()` is missing HOT 2
- inconsistent bahaviour of `functools.partial` python and C HOT 1
- Implement PEP 649
- [C API] Add an efficient public PyUnicodeWriter API HOT 23
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.