The Artima Developer Community
Sponsored Link

Python Answers Forum
Just getting started

6 replies on 1 page. Most recent reply: Jul 25, 2003 6:34 AM by Merriodoc Brandybuck

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 6 replies on 1 page
Merriodoc Brandybuck

Posts: 225
Nickname: brandybuck
Registered: Mar, 2003

Just getting started Posted: Jul 8, 2003 10:42 AM
Reply to this message Reply
Advertisement
I'm just getting started learning Python. I've already got the O'Reilly programming python on Win32 (The company I work for is a MS shop) and that's been helpful, and I've gone through most of the online docs I can find. Can anybody recommend any books for learning the language and getting a leg up on using it? I've developed in C/C++, VB, VBScript, Javascript, C# and have used a bit of AWK and some simple Python scripts to help with my development work.

So far I've had the best luck with O'Reilly books in picking up new things. They have a plethora of Python books available and in searching the bookstores and online I've found a whole bunch more. I haven't ever liked the "Learn language X in 21 days" kind of books because I've never found one that has shown me anything useful. The examples are simplistic and they don't go into enough detail to tell you what the language can really do. Anything anybody can suggest would be most appreciated.

As I said above, the most I've done with python so far is to put together little scripts to help me with my development work. Here's a sample of one I put together for adding error logging to all of the functions or subs in a vb file. This was so simple to whip up in Python it made my head spin. I've attempted similar things in other languages, but usually the results aren't worth the effort. This one had almost immediate payback.


def AddLogging(fcnfile):
print '**** ',fcnfile,' ****'
print

filenamepat = re.search(r'(.*?)(\w+)\.\w*$',fcnfile)
filename = filenamepat.group(2)
currfile = file(fcnfile,'r')
outputfile = file(fcnfile + "log",'w')

currline = currfile.readline()
fcnpat = re.compile(r'(Function|Sub)\s+(\w+)\(')
while (currline != ''):
fcnmatch = fcnpat.search(currline)
outputfile.write(currline)
if (fcnmatch != None):
print filename + "." + fcnmatch.group(2)
outputfile.write('\n\'Adding logging capability\nif bVBLog then\n')
outputfile.write('\tVBLogFile.AddLog \"' + filename + "." + fcnmatch.group(2) + '\"\n')
outputfile.write('end if\n\n')
currline = currfile.readline()
print
print
currfile.close()
outputfile.close()


And then I call it like this to get all the files in a directory


import VBFunctionHelp
import glob
map(VBFunctionHelp.AddLogging,glob.glob('C:\projectdir\VBFiles\*.cls'))


Like I said, simplistic but so helpful. Logging added to hundreds of functions in seconds. After this is run you just throw in a boolean telling you if you are doing logging and add a VBLogFile class and it's good to go.

Also, I find myself typing pythong a lot. Does anybody else do this, or am I the only one who has things other than programming on his mind sometimes?


Andrew Sukirtharaj

Posts: 1
Nickname: moondance
Registered: Jul, 2003

Re: Just getting started Posted: Jul 11, 2003 3:02 AM
Reply to this message Reply
Hi Mike,

I have been using Python for abt 3 months now and besides the books that you mentioned, the one by Steve Holden titled Python Web Programming is another good one.


Are you thinking of a python in thongs ? Maybe you find the programming language sexy...

Simon Percivall

Posts: 4
Nickname: percivall
Registered: Jul, 2003

Re: Just getting started Posted: Jul 20, 2003 11:40 PM
Reply to this message Reply
I've got two really general recommendations:

As reference, Python in a Nutshell is really good. There are examples; maybe not many, but good. Primarily, you use it to study some issue you couldn't really understand before.

Then there's the Python Cookbook which I haven't read myself; it has gotten good reviews though. If you head over to aspn.activestate.com you'll find the same recipes.

Both the above books are O'Reilly books, so you should be happy!

Alexandru Ruse

Posts: 6
Nickname: jfrosty
Registered: Jul, 2003

Re: Just getting started Posted: Jul 24, 2003 3:22 PM
Reply to this message Reply
"Dive Into Python" is also a great book, in my opinion. It's freely available on the web, and it has that "Thinking in ..." style. BTW, I can't wait for Bruce Eckel to finish up Thinking in Python. I have a feeling it's going to be a very appreciated book.

Merriodoc Brandybuck

Posts: 225
Nickname: brandybuck
Registered: Mar, 2003

Re: Just getting started Posted: Jul 24, 2003 4:21 PM
Reply to this message Reply
I like the way Bruce writes. I might wait for his Thinking in Python book. Granted he is in love with Python, but if it is of the same quality and fashion as his other writing, it should provide some good coverage and insight.

Vincent O'Sullivan

Posts: 724
Nickname: vincent
Registered: Nov, 2002

Re: Just getting started Posted: Jul 25, 2003 12:57 AM
Reply to this message Reply
> As reference, Python in a Nutshell is really good.

I too bought Python in a Nutshell and agree with Simon that it is a very good reference book. Unfortunately, I bought it to learn from (because most of the time I can learn what I want from a reference book, as much as from tutorial book - but not in this case).

Recently, I have just purchased Magnus Lie Hetland's Practical Python as a tutorial book and am about a third of the way through it. I would recommend this book particularly to new or intermediate programmers, since it (usually) assumes you are learning Python as a first language, rather than a second or third.

I just wish I had more time, what with learning Python, getting my head around Java's Generics and Aspects, doing my day job of VB coding (plus simultaneously learning/coding PL/SQL), battling through the intermediate levels or Warcraft III and trying to convince my wife and kids that I'm not some sort of computer freak. Oh and I've got to buy another PC, too (because the kids are beginning to crowd me off mine) which means we'll be needing a domestic network, so we can share files, printers, internet access...

Vince.

Merriodoc Brandybuck

Posts: 225
Nickname: brandybuck
Registered: Mar, 2003

Re: Just getting started Posted: Jul 25, 2003 6:34 AM
Reply to this message Reply
> I just wish I had more time, what with learning Python,
> getting my head around Java's Generics and Aspects, doing
> my day job of VB coding (plus simultaneously
> learning/coding PL/SQL), battling through the intermediate
> levels or Warcraft III and trying to convince my wife and
> kids that I'm not some sort of computer freak. Oh and
> I've got to buy another PC, too (because the kids are
> beginning to crowd me off mine) which means we'll be
> needing a domestic network, so we can share files,
> printers, internet access...
>
> Vince.

Thanks for the feedback. And just to set the record straight, you're a computer freak. ;-) It's ok. You're amongst fellow freaks here.

Flat View: This topic has 6 replies on 1 page
Topic: Code Snippets Previous Topic   Next Topic Topic: about mailer programmes

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use