OT Signature quote [was Re: Unrecognized escape sequences in string literals]

MRAB python at mrabarnett.plus.com
Fri Aug 14 18:40:04 CEST 2009


Grant Edwards wrote:
> On 2009-08-14, Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> wrote:
>> On Fri, 14 Aug 2009 07:07:31 -0700, Aahz wrote:
>>
>>> "I saw `cout' being shifted "Hello world" times to the left and stopped
>>> right there."  --Steve Gonedes
>> Assuming that's something real, and not invented for humour, I presume 
>> that's describing something possible in C++. Am I correct?
> 
> Yes.  In C++, the "<<" operator is overloaded.  Judging by the
> context in which I've seen it used, it does something like
> write strings to a stream.
> 
>> What the hell
>> would it actually do???
> 
> IIRC in C++, 
> 
>    cout << "Hello world";
> 
It also returns cout, so you can chain them:

     cout << "Hello, " << name << '\n';

> is equivalent to this in C:
> 
>    printf("Hellow world");
> 
> or this in Python:
> 
>    print "hellow world"
> 




More information about the Python-list mailing list