Thinking about "print >>"

Tim Hammerquist tim at degree.ath.cx
Wed Sep 20 14:15:11 EDT 2000


Arno Paehler <paehler at gol.com> wrote:
> C'ish fprint isn't bad either, but at least 'print >>'
> probably is better than C++ (was that cout << or cout >>,
> C++ is quite-counterintuitive here I think)

C++'s in/out streams _are_ ugly, but not really counterintuitive to my
mind.  Conceptually, cout is a "stream", specifically an ostream, to
which you direct your output using the << operator.  You can also open
a file as a stream and write to it the same way.  cin is an "istream",
from which you direct (divert?) input to variables.  I thought of cout
as kind of a drain to which I fed data.  It flowed (<<) into the
"stream" (cout).  Well, that's just an overly detailed mnemonic that
helped me get the hang of it.  I didn't really use these if I didn't
have to, though.  Mostly just to pass my C++ course.

There's no problem (generally) with using printf(), etc.  iostreams hold
an advantage in that they are passable to functions/methods and are
often interchangeable with file streams.

-- 
-Tim Hammerquist <timmy at cpan.org>
Usenet is essentially a HUGE group of
people passing notes in class.
	-- R. Kadel



More information about the Python-list mailing list