[Tutor] Translating R Code to Python-- reading in csv files, writing out to csv files

Martin A. Brown martin at linux-ip.net
Sun May 20 08:42:02 CEST 2012


Benjamin,

 : Thanks Martin-- this is really great.  My major question now is 
 : that I need to transition to Python for a project and I need to 
 : learn how to think in Python instead of in R.  The two strategies 
 : I have used so far are: a) going through the description and 
 : exercises in  http://www.openbookproject.net/thinkcs/python/english2e/
 : and b) trying to convert my R code into Python.

I haven't seen that before, but, of course, there ar scads of 
resources out there for anybody learning these days.

 : On a high-level, do you have any other suggestions for how I 
 : could go about becoming more proficient in Python?

Well, here is my list.  Others probably have some suggestions, too:

  * solve a specific and immediate real problem in Python, but solve 
    the problem as generally as possible; apply

  * lurk here (and on other lists) and watch how experienced Python 
    practitioners help others face a problem in Python; absorb

  * join domain-specific Python groups that discuss libraries,
    tools or techniques that apply in your area of interest; inquire

  * learn Python's common datatypes well, you will encounter them 
    often: str, int, float, list, dict, set; study

  * learn Pythonic programming idioms, and, importantly, learn 
    why they are considered Pythonic (that will give you insight 
    into thinking in Python); gain relevant experience

  * browse the standard library occasionally to learn a new module
    http://docs.python.org/py-modindex.html

  * learn how to make modules; build your code into modules (if 
    appropriate and where possible)

  * read a book (lots of options here); I'm a 'learn by example' 
    sort so I liked the O'Reilly _Python Cookbook_ [0]

  * read PEP 8 http://www.python.org/dev/peps/pep-0008/

Good luck and enjoy Python,

-Martin

 [0] http://shop.oreilly.com/product/9780596007973.do

-- 
Martin A. Brown
http://linux-ip.net/


More information about the Tutor mailing list