[issue35612] Text wrap over text containing tab character

2018-12-29 Thread Devika Sondhi


Devika Sondhi  added the comment:

I wasn't aware of this. Thanks for clarifying

--
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35612] Text wrap over text containing tab character

2018-12-29 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

I think you may be misunderstanding what you are seeing.

The documentation for textwrap.wrap says:

By default, tabs in 'text' are expanded with string.expandtabs()

which converts tabs to one or more spaces, enough to align to some 
multiple of column 8:

py> "He is\tone".expandtabs()
'He is   one'
py> "Her is\tone".expandtabs()
'Her is  one'
py> "Here is\tone".expandtabs()
'Here is one'
py> "THere is\tone".expandtabs()
'THere isone'

Can you confirm that this is the behaviour you are seeing? If so, I 
think it is correct and this bug report can be closed.

--
nosy: +steven.daprano

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35612] Text wrap over text containing tab character

2018-12-29 Thread Devika Sondhi


New submission from Devika Sondhi :

textwrap.wrap does not seem to preserve tab character ('\t') in the text if it 
is not separated from other characters by a space.
Example:
>>> textwrap.wrap("Here is\tone line of text that is going to be wrapped after 
>>> 20 columns.",20)   
['Here is one line of', 'text that is going', 'to be wrapped after', '20 
columns.']
The tab is missing from the above output.
However, for text with \t separated by space, the behavior is as expected 
(shown below).
>>> textwrap.wrap("Here is \t one line of text that is going to be wrapped 
>>> after 20 columns.",20)  
>>>
['Here is  one', 'line of text that is', 'going to be wrapped', 'after 
20 columns.']

--
components: Tests
messages: 332712
nosy: Devika Sondhi
priority: normal
severity: normal
status: open
title: Text wrap over text containing tab character
versions: Python 3.7

___
Python tracker 
<https://bugs.python.org/issue35612>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Tab Character?

2006-02-20 Thread Larry Bates
[EMAIL PROTECTED] wrote:
 How do I make a tab character in code to split a line read with tabs in
 it?
 
 
 Thanks.
 
 Tom
 
You should also take a look at csv module.  If you are reading lines
that contain tab delimeted data the csv module can make splitting very
easy.

-Larry Bates
-- 
http://mail.python.org/mailman/listinfo/python-list


Tab Character?

2006-02-18 Thread [EMAIL PROTECTED]
How do I make a tab character in code to split a line read with tabs in
it?


Thanks.

Tom

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tab Character?

2006-02-18 Thread John Zenger
Tab is \t .  As in:

print coke\tpepsi
tsvline.split(\t)

[EMAIL PROTECTED] wrote:
 How do I make a tab character in code to split a line read with tabs in
 it?
 
 
 Thanks.
 
 Tom
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tab Character?

2006-02-18 Thread Ben Finney
[EMAIL PROTECTED] [EMAIL PROTECTED] writes:
 How do I make a tab character in code to split a line read with tabs in
 it?

For such non-printing characters it's best not to have them literally
in your code, but to use an escape sequence to generate them at
run-time::

 foo = \t
 print foo

 print ord(foo)
9

This is explained in the String literals section of the Python
reference.

URL:http://docs.python.org/dev/ref/strings.html

-- 
 \   A celebrity is one who is known by many people he is glad he |
  `\   doesn't know.  -- Henry L. Mencken |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list