FAQ
print function: built-in space between string and variable:

The below python code,

length = 5
print('Length is', length)

gives an output of

Length is 5

Even though we have not specified a space between 'Length is' and the variable length, Python puts it for us so that we
get a clean nice output and the program is much more readable this way (since we don't need to worry about spacing in
the strings we use for output). This is surely an example of how Python makes life easy for the programmer.

input function: built-in space between string and user-input:

However, the below python code,

guess = int(input('Enter an integer'))

gives an output of

Enter an integer7

[Note: Assume 7 is entered by the user.]

Suggestion: Similar to the printf function, for the input function also, it will be nice to have the Python put a space
between string and user-input, so that the output in the above case will be more readable as below.

Enter an integer 7

Thanks and Regards,
Suriaprakash M,
Principal Engineer - Software,
Standard Microsystems India Pvt. Ltd.,
Module 1, 4th Floor, Block A, SP Infocity,
#40, MGR Salai, Perungudi,
Chennai - 600 096, Tamil Nadu, INDIA.
Email: Suriaprakash.Mariappan at smsc.com
Mobile :+919381453832
Skype ID: msuriaprakash
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20120515/8becade3/attachment.html>

Search Discussions

  • Terry Reedy at May 15, 2012 at 9:19 pm

    On 5/15/2012 6:46 AM, Suriaprakash.Mariappan at smsc.com wrote:
    *_print function: built-in space between string and variable:_*

    The below python code,

    */length = 5/*
    */print('Length is', length)/*

    gives an output of

    */Length is 5/*
    The */.../* and *_..._* bracketing makes you post harder to read.
    Perhaps this is used in India, but not elsewhere. Omit next time.
    Even though we have not specified a space between 'Length is' and the
    variable length, Python puts it for us so that we get a clean nice
    output and the program is much more readable this way (since we don't
    need to worry about spacing in the strings we use for output). This is
    surely an example of how Python makes life easy for the programmer.

    *_input function: built-in space between string and user-input:_*

    However, the below python code,

    */guess = int(input('Enter an integer'))/*

    gives an output of

    */Enter an integer7/*

    [Note: Assume 7 is entered by the user.]

    *Suggestion: *Similar to the printf function, for the input function
    also, it will be nice to have the Python put a space between string and
    user-input, so that the output in the above case will be more readable
    as below.

    */Enter an integer 7/*
    print() converts objects to strings and adds separators and a terminator
    before writing to outfile.write(). In 3.x, the separator, terminator,
    and outfile can all be changed from the default. The user is stuck with
    the fact that str(obj) is what it is, so it is handy to automatically
    tack something on.

    input() directly writes a prompt string with sys.stdout.write.
    There is no need to to augment that as the user can make the prompt
    string be whatever they want. In any case, a change would break
    back-compatibility.

    --
    Terry Jan Reedy
  • Michael Foord at May 16, 2012 at 9:28 am

    On 15 May 2012 22:19, Terry Reedy wrote:

    On 5/15/2012 6:46 AM, Suriaprakash.Mariappan at smsc.**comwrote:
    *_print function: built-in space between string and variable:_*

    The below python code,

    */length = 5/*
    */print('Length is', length)/*

    gives an output of

    */Length is 5/*
    The */.../* and *_..._* bracketing makes you post harder to read. Perhaps
    this is used in India, but not elsewhere. Omit next time.

    They weren't present in the version I read. Probably a consequence of your
    mail client not being able to display formatted emails.

    Michael

    Even though we have not specified a space between 'Length is' and the
    variable length, Python puts it for us so that we get a clean nice
    output and the program is much more readable this way (since we don't
    need to worry about spacing in the strings we use for output). This is
    surely an example of how Python makes life easy for the programmer.

    *_input function: built-in space between string and user-input:_*


    However, the below python code,

    */guess = int(input('Enter an integer'))/*

    gives an output of

    */Enter an integer7/*


    [Note: Assume 7 is entered by the user.]

    *Suggestion: *Similar to the printf function, for the input function

    also, it will be nice to have the Python put a space between string and
    user-input, so that the output in the above case will be more readable
    as below.

    */Enter an integer 7/*
    print() converts objects to strings and adds separators and a terminator
    before writing to outfile.write(). In 3.x, the separator, terminator, and
    outfile can all be changed from the default. The user is stuck with the
    fact that str(obj) is what it is, so it is handy to automatically tack
    something on.

    input() directly writes a prompt string with sys.stdout.write.
    There is no need to to augment that as the user can make the prompt string
    be whatever they want. In any case, a change would break back-compatibility.

    --
    Terry Jan Reedy

    ______________________________**_________________
    Python-ideas mailing list
    Python-ideas at python.org
    http://mail.python.org/**mailman/listinfo/python-ideas<http://mail.python.org/mailman/listinfo/python-ideas>


    --

    http://www.voidspace.org.uk/

    May you do good and not evil
    May you find forgiveness for yourself and forgive others
    May you share freely, never taking more than you give.
    -- the sqlite blessing http://www.sqlite.org/different.html
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-ideas/attachments/20120516/4f84da1a/attachment.html>
  • Ned Batchelder at May 16, 2012 at 10:27 am

    On 5/15/2012 5:19 PM, Terry Reedy wrote:
    On 5/15/2012 6:46 AM, Suriaprakash.Mariappan at smsc.com wrote:
    *_print function: built-in space between string and variable:_*

    The below python code,

    */length = 5/*
    */print('Length is', length)/*

    gives an output of

    */Length is 5/*
    The */.../* and *_..._* bracketing makes you post harder to read.
    Perhaps this is used in India, but not elsewhere. Omit next time.
    That's your mail client's rendering of bold-italic and bold-underscored
    text from the HTML version of the original email.

    --Ned.
  • Terry Reedy at May 16, 2012 at 10:53 pm

    On 5/16/2012 6:27 AM, Ned Batchelder wrote:
    On 5/15/2012 5:19 PM, Terry Reedy wrote:
    On 5/15/2012 6:46 AM,
    Suriaprakash.Mariappan at smsc.com wrote:
    *_print function: built-in space between string and variable:_*

    The below python code,

    */length = 5/*
    */print('Length is', length)/*

    gives an output of

    */Length is 5/*
    The */.../* and *_..._* bracketing makes you post harder to read.
    Perhaps this is used in India, but not elsewhere. Omit next time.
    That's your mail client's rendering of bold-italic and bold-underscored
    text from the HTML version of the original email.
    I am reading the Gmane newsgroup mirror with Thunderbird. I have not
    seen it do anything similar with other mixed text/plain and text/html
    messages. So let me re-phrase by advice.

    "The Python mailings lists and newsgroups are, as usual, intended for
    plain text. Posting html or plaintext and html can have strange and
    unpredictable effects with various mail and news readers. So if you want
    people to see what you send, just use plain text, without tab characters."

    --
    Terry Jan Reedy

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-ideas @
categoriespython
postedMay 15, '12 at 10:46a
activeMay 16, '12 at 10:53p
posts5
users4
websitepython.org

People

Translate

site design / logo © 2018 Grokbase