473,395 Members | 1,649 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Turn off line wrap for lists?

_
(I did google for this, I promise)

How do I get python NOT to insert newlines into string representations
of lists when I do something like this:

strCollector += "%s" % (['a', 'list', 'with', 'lots', 'of', 'elements']
* 100)

?

I would like to set a default never to do this, if possible. (Never mix
formatting with display, or tequila with bourbon -- bad, bad, bad!)

FYI I am using this to export data into tab delimited format, so the
lines can be as long as they need to be, but a newline means a new
record.

FYI (2), this is in web application too, so I am afraid I might have to
set the default in a bunch of different modules.

TIA

Jan 5 '07 #1
2 1118
On Thu, 2007-01-04 at 17:01 -0800, _ wrote:
(I did google for this, I promise)

How do I get python NOT to insert newlines into string representations
of lists when I do something like this:

strCollector += "%s" % (['a', 'list', 'with', 'lots', 'of', 'elements']
* 100)
What makes you think that that inserts newline characters? My python
doesn't do that:
>>a = "%s" % (['a', 'list', 'with', 'lots', 'of', 'elements'] * 100)
"\n" in a
False
FYI I am using this to export data into tab delimited format
You could avoid reinventing the wheel by using the "csv" module.

-Carsten
Jan 5 '07 #2

_ wrote:
(I did google for this, I promise)

How do I get python NOT to insert newlines into string representations
of lists when I do something like this:

strCollector += "%s" % (['a', 'list', 'with', 'lots', 'of', 'elements']
* 100)
It shouldn't and doesn't insert newlines.

######
>>strCollector = "%s" % (['a', 'list', 'with', 'lots', 'of', 'elements'] * 100)
strCollector.split("\n")[0] == strCollector
True
######
mt

Jan 5 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

43
by: dan baker | last post by:
I have a page that gets loaded with a meta-refresh hardcoded so that a few things on the page get updated. its kind of a fake chat board. anyway, what I need to do is turn off the meta-refresh once...
2
by: jtan212 | last post by:
I am a c++ beginner. how can i read a *.sp file which discribe a schematic file,including subcircuits,resistance, capacitance and inductance, and then i need to turn the information i get to a...
11
by: name | last post by:
Here is a first attempt at a line/word wrapping utility. Seems to work okay, but lacks some checking stuff, etc. --------------------------------------------------------- #include <stdio.h>...
2
by: Zanna | last post by:
Hi all! I'm in difficulty with this: I need to know the height of a text line that is written with Graphics.DrawString(). In theory I need just to get the Graphics.MeasureString() result. But...
2
by: Scott | last post by:
I having a problem where I need to turn off the wrapping feature for all columns in my datagrid. Example code would be: <asp:DataGrid id="ResultGrid" runat="server" AutoGenerateColumns="true">...
6
by: Markus Ernst | last post by:
Hi Searching for a possibility to display some text with preserved white space and line breaks, but with long lines being wrapped, I found this CSS declaration, which I found helpful: pre {...
13
by: Haines Brown | last post by:
I have a style for a list: dl { line-height: 1; margin-bottom: 1em; } But the W3C CSS validator says: Line: 124 Context : dl Invalid number : line-height Parse Error -
5
by: jistanidiot | last post by:
We've got some plain text in a DB that we're pulling out and putting it on our website. The problem is it has some lists like this: 1. This text goes on and on forever and eventually it wraps...
7
by: jeddiki | last post by:
Hi, I am using a function called htmlwrap() which states that it does NOT add a "<br>" to the 70 character line so that it forces a line wrap. ( the script safely wraps long words without...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.