473,394 Members | 1,108 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,394 software developers and data experts.

Re: Need formatting suggestion for long strings

On Fri, 5 Sep 2008 14:24:16 -0500, Robert Dailey <rc******@gmail.comwrote:
>Hi,

I find quite often that I'm writing things like this:

raise FatalExcept( "Insufficient number of arguments specified. Exactly {0}
arguments are required. See stage.bat for documentation on accepted
parameters.".format( num_arguments ) )

On my display (Vertical monitor), this exceeds the width of my display, and
to view the entire length of the string I am forced to pan my view left and
right. Is there a special way I can format this string so that it fits
nicely on the screen? Keep in mind that one important factor is that
whitespace is very sensitive, and I do not want line breaks in my script
file to become part of the string itself. I like how C++ handles strings,
like this:

char const* mystring =
"This is a very long string that "
"spans multiple lines and does "
"not include line breaks or tabs "
"from the source file between "
"the strings partitions."
What do you guys prefer? Thanks for reading.
mystring = (
"This is a very long string that "
"spans multiple lines and does "
"not include line breaks or tabs "
"from the source file between "
"the strings partitions.")

Jean-Paul

Sep 5 '08 #1
2 1577
aha
On Sep 5, 3:29*pm, Jean-Paul Calderone <exar...@divmod.comwrote:
On Fri, 5 Sep 2008 14:24:16 -0500, Robert Dailey <rcdai...@gmail.comwrote:
Hi,
I find quite often that I'm writing things like this:
raise FatalExcept( "Insufficient number of arguments specified. Exactly {0}
arguments are required. See stage.bat for documentation on accepted
parameters.".format( num_arguments ) )
On my display (Vertical monitor), this exceeds the width of my display, and
to view the entire length of the string I am forced to pan my view left and
right. Is there a special way I can format this string so that it fits
nicely on the screen? Keep in mind that one important factor is that
whitespace is very sensitive, and I do not want line breaks in my script
file to become part of the string itself. I like how C++ handles strings,
like this:
char const* mystring =
* *"This is a very long string that "
* *"spans multiple lines and does "
* *"not include line breaks or tabs "
* *"from the source file between "
* *"the strings partitions."
What do you guys prefer? Thanks for reading.

mystring = (
* * "This is a very long string that "
* * "spans multiple lines and does "
* * "not include line breaks or tabs "
* * "from the source file between "
* * "the strings partitions.")

Jean-Paul
Can you be more specific? What is the formatting criteria? Are you
talking about formatting the string for display or are you talking
about the source?
Sep 5 '08 #2
I'm concerned about the formatting of the string in that I do not want the
way I split the string up in source code to affect the way the string is
displayed to the console. In other words, in source, if I break up a single
string into multiple lines (using carriage returns), I would expect the
string to still render as a single-line string.

I'm also concerned about the source formatting, because I do not want the
single-line string to run off the edge of my display. I want it to be in
"Paragraph form" in the source code, but remain a single-line when printed.
I think you can also escape the line breaks:
>>mystring = (
.... "This is a very long string that "
.... "spans multiple lines and does "
.... "not include line breaks or tabs "
.... "from the source file between "
.... "the strings partitions.")
>>mystring2 = 'This is a very long string that spans multiple lines and does not include line breaks or tabs from the source file between the strings partitions.'
mystring == mystring2
True
>>mystring3 = 'This is a very long string that \
.... spans multiple lines and does not include line breaks \
.... or tabs from the source file between the strings \
.... partitions.'
>>mystring3 == mystring
True
Sep 5 '08 #3

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

Similar topics

6
by: Al Newton | last post by:
I want to use STL's sort algorithm to sort a string vector. Some of the strings are fairly long (300 to 400 chars) and the vector isn't small (5,000 to 10,000 elements). Naturally, sorting time...
4
by: hope | last post by:
Hi, How can I format a string field using Data Formatting Expression property in datagrid? For example: format last name from BROWN to Brown. Thanks
4
by: Robert Manookian | last post by:
How do you format strings? i.e. In VB6: Format("AB34567", "@@@@@-@@") = "AB345-67" In .Net: ????????
10
by: Coleen | last post by:
Hi all :-) I have a weird formatting problem with an HTML table that I am populating using VB.Net and HTML. Here is the snippet of code for the cell I'm trying to format: Dim...
4
by: | last post by:
I have about 20 MsgBox occurance in by program, which I use to inform the user of the progress of the program, or ask confirmation of an action, or simply to act separators to various parts of the...
1
by: george | last post by:
Hi, I have an app that takes data from a db and maps it to a CSV file. There are multiple maps for different customers which has different formatting rules. For example, some customer wants...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
5
by: Academia | last post by:
As a simple example suppose I want to draw two columns of strings. I know where each column starts and the widths. So before I print a string I measure it and if it is longer than the column...
6
by: Tomasz J | last post by:
Hello developers, I bind my TextBox control specyfying a format stored in my application global ApplicationContext object - it has a static string CurrencyFormat property. The problem - this...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.