Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > assigning multi-line strings to variables

Reply
Thread Tools

assigning multi-line strings to variables

 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      04-30-2010
On 30.04.2010 21:46, * Lie Ryan:
> On 05/01/10 05:43, Lie Ryan wrote:
>> On 05/01/10 03:56, Alf P. Steinbach wrote:
>>>>
>>>> Use triple-quoted, let them flow, done. I've never heard of any text
>>>> editor in current use without text wrapping capability, even Notepad has
>>>> it. And if I've got 5k of text in source code without line breaks I
>>>> wouldn't want that silly string to disturb my view of the code. You
>>>> argument aren't even convincing.
>>>
>>> You'd put a 5K line in your source code, + you're working with text
>>> wrapping in your editor.

>>
>> In the other hand, you'd put a 5K line in your source code, + you're
>> writing, debugging, and running a script to wrap and put various escapes
>> for quotes and newlines, + you need to figure out how to force that
>> script to accept your 5k string.

>
> + now your chunk is in obfuscated form with various quote noise,
> unnecessary escape characters and the like.


Personally, for Python I'd put such text in a separate text file, as I
recommended first of all in the posting you've reacted so negatively to.


Cheers & hth.,

- Alf
 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      04-30-2010
On 30.04.2010 21:40, * Lie Ryan:
> On 05/01/10 04:08, Neil Cerutti wrote:
>> On 2010-04-30, Lie Ryan<> wrote:
>>> Use triple-quoted, let them flow, done. I've never heard of any
>>> text editor in current use without text wrapping capability,
>>> even Notepad has it. And if I've got 5k of text in source code
>>> without line breaks I wouldn't want that silly string to
>>> disturb my view of the code. You argument aren't even
>>> convincing.
>>>
>>> Perhaps you like to do it the hard way, I don't.

>>
>> Arguing about how to write 5k of text into your code is about as
>> sensible as arguing about how to stuff a potato into the tailpipe
>> of your Chevrolet.
>>
>>> The point is, what you're suggesting doesn't save work at all
>>> as you've shown it. There are other ways to do the same thing,
>>> for virtually no work at all.

>>
>> Don't put big text dumps in your program. Problem solved!
>>

>
> Alf suggested it, not me.


On the contrary, I responded to you on the 30th, using a concrete example of
your triple-quote literals rationale posted on the 29th, that ...

<quote author="Lie Ryan">
Yes, apparently my statement that implicit concatenation is an artifact
is erroneous but it doesn't make the important points less true, that
implicit concatenation is not suitable for integrating large chunk of
text into source code.
</quote

.... but I may have misunderstood what you meant by "large".

Anyway, if you read my first posting in this thread you'll see that the first
thing I suggested is to put the text in a separate text file.

I didn't discuss rationales for choosing this or that method because where it
isn't personal preference it's rather obvious.


Cheers & hth,

- Alf
 
Reply With Quote
 
 
 
 
Lie Ryan
Guest
Posts: n/a
 
      04-30-2010
On 05/01/10 07:54, Alf P. Steinbach wrote:
>>>>>
>>>>
>>>> You'd put a 5K line in your source code, + you're working with text
>>>> wrapping in your editor.
>>>
>>> In the other hand, you'd put a 5K line in your source code, + you're
>>> writing, debugging, and running a script to wrap and put various escapes
>>> for quotes and newlines, + you need to figure out how to force that
>>> script to accept your 5k string.

>>
>> + now your chunk is in obfuscated form with various quote noise,
>> unnecessary escape characters and the like.

>
> Personally, for Python I'd put such text in a separate text file, as I
> recommended first of all in the posting you've reacted so negatively to.


Didn't we all already agree that we wouldn't put large chunk of text
directly in source code unless we're too lazy to create a separate file
for a one-off scripts. But your suggested alternative[i.e. quoting
everything, uglily] to the proper way[i.e. creating separate file] is so
distasteful to make it looks like the only clean way of inserting chunk
of text is to create separate file.
 
Reply With Quote
 
Sibylle Koczian
Guest
Posts: n/a
 
      05-02-2010
goldtech schrieb:
> Thank you to posters for help to my question. Seems I had trouble with
> triple quotes strings in the PythonWin shell. But using the Idle shell
> things work as expected. But this is probably another issue...any way,
> w/Idle's shell I got the "action" regarding multiline strings I
> expected.


What PythonWin version? I remember having had such trouble years ago,
probably Python 1.something.

Greetings
Sibylle
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Put variables into member variables or function variables? tjumail@gmail.com C++ 9 03-23-2008 04:03 PM
Assigning methods to objects, and assigning onreadystatechange to an XMLHttpRequest -- an inconsistency? weston Javascript 1 09-22-2006 09:33 AM
Strings, Strings and Damned Strings Ben C Programming 14 06-24-2006 05:09 AM
How to construct new variables in a script from other variables and strings. gerry.brennan@gmail.com Perl Misc 9 05-12-2006 06:00 PM
Need Help: AccessDataSource and Assigning Variables for Data (ASP 2.0) Michael ASP .Net 1 01-30-2006 02:57 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57