Coder Social home page Coder Social logo

Comments (10)

serhiy-storchaka avatar serhiy-storchaka commented on July 17, 2024 1

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.

RustoMCSpit avatar RustoMCSpit commented on July 17, 2024

this is a good first issue i suppose for people looking to make a PR

from cpython.

RustoMCSpit avatar RustoMCSpit commented on July 17, 2024

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.

pochmann3 avatar pochmann3 commented on July 17, 2024

differs only by a character

By six. Also ASCII 9 to 13.

from cpython.

serhiy-storchaka avatar serhiy-storchaka commented on July 17, 2024

How would you name the new constant? string.printable_without_space? Or more accurately string.ascii_printable_without_whitespace?

from cpython.

RustoMCSpit avatar RustoMCSpit commented on July 17, 2024

How would you name the new constant? string.printable_without_space? Or more accurately string.ascii_printable_without_whitespace?

string.visible

from cpython.

nineteendo avatar nineteendo commented on July 17, 2024

Is there a problem with this?

from string import ascii_letters, digits, punctuation

visible = digits + ascii_letters + punctuation

from cpython.

RustoMCSpit avatar RustoMCSpit commented on July 17, 2024

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.

nineteendo avatar nineteendo commented on July 17, 2024

For reference here are the constants of the original version:

cpython/Lib/string.py

Lines 6 to 12 in c636014

whitespace = ' \t\n'
lowercase = 'abcdefghijklmnopqrstuvwxyz'
uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
letters = lowercase + uppercase
digits = '0123456789'
hexdigits = digits + 'abcdef' + 'ABCDEF'
octdigits = '01234567'

Only punctuation & printable have been added since with the latter being the concatenation of all other strings.

from cpython.

RustoMCSpit avatar RustoMCSpit commented on July 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.