[Newbies] \n equivalent?

Paul DeBruicker pdebruic at gmail.com
Sun Aug 2 21:20:22 UTC 2009


Hi,

This is all very interesting.

So
'Character cr asciiValue' is 13
'Character lf asciiValue' is 10

and ascii value of the \n character in Python is

>>>  ord('\n')
10


So I want to use 'String lf' inplace of a \n in Python during string
concatenation.


Thanks

Paul




On Sun, Aug 2, 2009 at 2:39 PM, C. David Shaffer<cdshaffer at acm.org> wrote:
> Michael van der Gulik wrote:
>>
>>
>> On Fri, Jul 31, 2009 at 8:48 AM, Paul DeBruicker <pdebruic at gmail.com
>> <mailto:pdebruic at gmail.com>> wrote:
>>
>>    Hi -
>>
>>    What Character or String is equal to \n in C or Python?  Thanks
>>
>>
>>
>> I remember wondering about this when I was first learning Smalltalk too.
>>
>> You do stuff like:
>>
>> s := WriteStream on: (String new: 100).
>> s nextPutAll: 'Hello World'. "Write a string"
>> s nextPut: $!.             "Write a single character"
>> s cr.             "Write a newline character"
>>
>> It's a bit wordy, but I think streams deserve a lot more credit than
>> programmers give them.
>>
>> If you're doing String concatenation:
>>
>> myString := 'Hello, World!', String cr.
>>
>> Alternatively, this is also valid code:
>>
>> myString := 'This
>> is
>> a
>> multi-line
>> String!
>> '.
>>
> Great summary.  I'll add:
>
> 'this\is\a\string' withCRs
>
> which produces
> this
> is
> a
> string
>
> If you look at the source code for withCRs you can probably see how easy it
> would be to write something more to your liking.
>
> David
>
>
> David
>
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>


More information about the Beginners mailing list