"Utkarsh Tandon" <[EMAIL PROTECTED]> wrote > Alan Gauld wrote: >> Thats a very long winded and difficult way to do a fairly simple >> Python task. Don't try to write Python like a C programmer. > > I'm really new to python. And I don't have much experience in > programming either
Ok, My mistake. The code you had was very like the way experienced C programmers typically start using Python; as if it was C. That's not a good way. > what kind of approach should I have when coding programs > in Python ? Python is often described as coming "with batteries included" This is because of the 100 plus modules in the standard library that provide tools to do most things more easily. The Pythonic approach is to leverage those modules, plus the higher level data structures within Python to maximum advantage. The best solution for stripping C comments is probably to use a re module's regular expressions. Define a regex that matches a C comment, then replace all occurrences of the regex with an empty string. Of course defining the regex can be a challenge in itself, but it's a different challenge! :-) -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor