Newbie asks(2): How to do this line of C in Py?

David Bolen db3l at fitlinxx.com
Wed Jul 11 21:46:11 CEST 2001


Joe Potter <jm7potter at hotmail.com> writes:

> I have followed these questions with great interest. I hope he keeps
> asking for a while --- and folks here keep answering.
> 
> As a newbie to Python, I find that the one liners in c are easy to
> follow and the translation into Python show me where I am missing
> Python techniques.

There is, however, a risk in this technique as a single line
translation from another language to Python is often a bit too fine
grained to really serve as a good guide for translation, especially
from a language such as C.  The two languages do not necessarily
provide the same functionality per line of code so you risk force
fitting the translation since you don't have any surrounding context.

In these cases so far, it's largely been translating a C library call
into Python library calls so the one-to-one holds better than usual,
but I do think that even newbies will be able to get a better grasp of
the concepts with slightly larger code snippets.  E.g., what you use
strtok or sscanf in a C program for, you might attack quite
differently in a Python program, even if direct translations of strtok
and sscanf exist.  (Then again, you might use the direct translation,
but making that choice is assisted by more original context).

Note I'm certainly not proposing that such requests not be answered,
nor that they can't be helpful, but only that I think more benefit
could be gained (by the original poster as well as other readers) with
some addition information and/or sample code in the translation
requests.

But c.l.p is certainly one of the best communities in which I've
participated in this regard - we'll answer just about anything as well
as possible (even while suggesting better ways to phrase the questions
:-))

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list