Hi!
Is there a pythonic way of reading - say - mixed integer and char input without reading the whole input at once and without worrying about linebreaks? For example I have a file with whitespace-separated data of which I only know that there are x integers, then y chars and then z more integers. I don't want to assume anything about linebreaks.
I mean something as mindless as the following in C++:
...
int i, buf;
char cbuf;
vector<int> X, Z;
vector<int> Y;
for (i = 0; i < x; i++) {
cin >> buf;
X.push_back(buf);
}
for (i = 0; i < y; i++) {
cin >> cbuf;
Y.push_back(cbuf);
}
for (i = 0; i < z; i++) {
cin >> buf;
Z.push_back(buf);
}
EDIT: i forgot to say that I'd like it to behave well under live input from console as well - i.e. there should be no need to press ctrl+d before getting tokens and the function should be able to return them as soon as a line has been entered. :)
Best regards, Artur Gajowy