iterating over lines in a file
Cliff Crawford
cjc26 at nospam.cornell.edu
Fri Jul 21 18:14:55 EDT 2000
More information about the Python-list mailing list
Fri Jul 21 18:14:55 EDT 2000
- Previous message (by thread): iterating over lines in a file
- Next message (by thread): iterating over lines in a file
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
* nobody <no at bo.dy> menulis: | | now, this newbie has run into another perl idiom he'd like to figure out | how to rewrite in python - "while (<FILE>) { print; }" - and, by extension, | how to get python to print the string i hand it, the whole string i hand it, | and nothing but the string i hand it? Hmm..not quite sure what you mean..maybe you want to use sys.stdout.write() instead? | i despise machines trying to second- | guess my intentions, and silly little print statements trying to be clever | with their arguments are nothing more than that. print doesn't really try to be clever with its arguments, except for printing a space between each one and a newline at the end. Maybe what you're looking for is the format operator? var=14 print "%s=%d" % ("var", var) | even so, python is still worth trying to learn, IMO. its ways of dealing | with regexps and substitution might not be as handy and convenient as | perl's operators, but the re module seems to me to be more "programmable" | somehow, easier to write code around. Been a while since I've done perl, but I seem to remember it being difficult to treat regexps as objects in themselves..for example, it's hard to store a list of them, and then compare a string to each one in the list later. | i like it, i just wish its functions | would be more consistent about what sort of regexps they want - either all | compiled or all not compiled; i'm seeing some wanting one and some the | other, for some reason. might be just my system, i suppose... The two should be interchangable..AFAIK wherever you can use a compiled regexp, you can use an uncompiled one, and vice-versa. -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ Synaesthesia now! icq 68165166
- Previous message (by thread): iterating over lines in a file
- Next message (by thread): iterating over lines in a file
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list