A few questions

J

jay

Hi,

I'm totally new to Python and was hoping someone might be able to
answer a few questions for me:

1. What are your views about Python vs Perl? Do you see one as
better than the other?

2. Is there a good book to start with while learning Python? I'm
currently reading 'Python Essential Reference' by David M. Beazley.
So far it looks like a pretty good book, but would like more
tutorials to work with (I've also been reading through the tutorials
at 'python.org' which has some excellent stuff!).

3. Currently, I write most of my code with Xcode (on the Mac
platform) using Applescript. This gives me GUI capabilities. Is
there anything you'd recommend that I could use for Python that would
give me a GUI interface? I'd like this to be able to work for both
the Mac and Windows platforms. I've been reading a little about
'Claro Graphics Toolkit' and 'PyGUI'... would you recommend either of
those? I'll be writing code on a Mac so I need something that will
run on that system.

Thanks for looking at my questions.

Jay
 
A

Anthony Irwin

jay said:
Hi,

I'm totally new to Python and was hoping someone might be able to answer
a few questions for me:

1. What are your views about Python vs Perl? Do you see one as better
than the other?

I have written some scripts in both perl and python and to me python
feels more like a modern programming language then perl does.

As I am learning both languages I can also say that I was writing
useful python code as I was learning python but had to do more reading
with perl to write similar levels of code but maybe thats just me.
3. Currently, I write most of my code with Xcode (on the Mac platform)
using Applescript. This gives me GUI capabilities. Is there anything
you'd recommend that I could use for Python that would give me a GUI
interface? I'd like this to be able to work for both the Mac and
Windows platforms. I've been reading a little about 'Claro Graphics
Toolkit' and 'PyGUI'... would you recommend either of those? I'll be
writing code on a Mac so I need something that will run on that system.

I have used wxpython and did the tutorial listed in their wiki and ran
it on linux and mac and they looked like native applications in both
and the same is meant to happen in windows but I don't have windows so
have not tried it myself.

To do this on the mac I installed the universal python 2.4 from the
python site and the wxpython mac install and just double clicked a
python file with a .pyw and it executed like a normal app. Originally
I had a .py file extension but that does not execute the python script.

--
Kind Regards,
Anthony Irwin

http://www.irwinresources.com
http://www.makehomebusiness.com
email: anthony at above domains, - www.
 
A

Alex Martelli

jay said:
Hi,

I'm totally new to Python and was hoping someone might be able to
answer a few questions for me:

1. What are your views about Python vs Perl? Do you see one as
better than the other?

Yep: if I didn't find Python more readable, maintainable and
understandable, I obviously wouldn't have switched.

2. Is there a good book to start with while learning Python? I'm
currently reading 'Python Essential Reference' by David M. Beazley.
So far it looks like a pretty good book, but would like more
tutorials to work with (I've also been reading through the tutorials
at 'python.org' which has some excellent stuff!).

Beazley's excellent book, like my direct competitor "Python in a
Nutshell", is mostly meant as a _reference_, not as a tutorial. There
are many "starters' books": try "Dive into Python" (has the advantage
that you can try it for free online, just web search for it), or "Python
for Dummies", "Learning Python", "Core Python", and many more.

3. Currently, I write most of my code with Xcode (on the Mac
platform) using Applescript. This gives me GUI capabilities. Is
there anything you'd recommend that I could use for Python that would
give me a GUI interface? I'd like this to be able to work for both
the Mac and Windows platforms. I've been reading a little about
'Claro Graphics Toolkit' and 'PyGUI'... would you recommend either of
those? I'll be writing code on a Mac so I need something that will
run on that system.

If you wanted to work with exactly the same wonderful GUI Applescript
gives you, you should try PyObjC and use it with your Mac's Cocoa...
however, that doesn't work well on Windows. QT4 with PyQt 4 (with Eric4
as the IDE) is probably the best approach today for such cross-platform
work (haven't tried it yet, but I can vouch for the previous releases --
Qt3, PyQt 3, Eric3). Most popular, however, is no doubt wxWindows --
mostly because you can freely use it to develop SW which you plan to
distribute under closed-source licenses, while Qt &c force you to choose
-- either pay, or, if you even distribute your code, it will have to be
under the GPL. I'm not sure how well wxWindows works on Mac nowadays,
though -- I'm sure somebody else will be able to tell you. For me
personally, nowadays, it's Cocoa for Mac-only apps, while any
non-Mac-only apps I write as web-apps instead.


Alex
 
J

John Nagle

jay said:
Hi,

I'm totally new to Python and was hoping someone might be able to
answer a few questions for me:

1. What are your views about Python vs Perl? Do you see one as better
than the other?

Python is a much cleaner language than Perl, but not as widely used.
The Python language is in good shape; the libraries vary in quality.
2. Is there a good book to start with while learning Python? I'm
currently reading 'Python Essential Reference' by David M. Beazley. So
far it looks like a pretty good book, but would like more tutorials to
work with (I've also been reading through the tutorials at 'python.org'
which has some excellent stuff!).

They're all reasonably good. Python doesn't have Perl's "There's
more than one way to do it" problem, so all Python books describe
the same language. (Perl books tend to describe the subsections of
the language that particular author likes. It takes about three
different Perl books to cover every language feature.) "Learning
Python" has more tutorials, but the online tutorials at "python.org"
should be sufficient. This just isn't a very difficult language.

If you have a computer science background, here's all you need
to know: Python is a byte-code interpreted untyped procedural dynamic
language with implicit declaration. Syntax is vaguely C-like. Block
structure is determined by indentation. Objects use a class definition/
explicit instantiation/multiple inheritance model. Memory management
is safe and managed by reference counts backed by a garbage collector.
Weak references are supported. Built in data types are numerics, ASCII
and Unicode strings, dynamic arrays, fixed size tuples, and hashes.
Implementation speed is typically 2% of C. That's Python.
3. Currently, I write most of my code with Xcode (on the Mac platform)
using Applescript.

Can't speak to Mac issues. Tkinter will work, although it may be
aesthetically displeasing to Mac users.

John Nagle
 
B

brad

Alex said:
Most popular, however, is no doubt wxWindows --
mostly because you can freely use it to develop SW which you plan to
distribute under closed-source licenses, while Qt &c force you to choose
-- either pay, or, if you even distribute your code, it will have to be
under the GPL. I'm not sure how well wxWindows works on Mac nowadays...

wx Works great on Macs (10.4 at least, maybe others), Linux and Windows.
We've used it for several cross-platform apps that needed GUIs.
 
D

Dave Baum

jay said:
Hi,

I'm totally new to Python and was hoping someone might be able to
answer a few questions for me:

1. What are your views about Python vs Perl? Do you see one as
better than the other?

I introduced Python into my group at work and it has for the most part
supplanted Perl. For short scripts Python tends to be a lot more
readable than Perl. Python also scales better, allowing us to tackle
some larger projects with Python than we would have attempted with Perl.

However, a lot of this depends on your current skill with the languages
and the kind of project you will be working on. A Perl guru is going to
be more productive with Perl than with Python. Text processing programs
are likely to be more concise in Perl than Python. However, as a
general purpose programming language I think Python is an excellent
choice.
2. Is there a good book to start with while learning Python? I'm
currently reading 'Python Essential Reference' by David M. Beazley.
So far it looks like a pretty good book, but would like more
tutorials to work with (I've also been reading through the tutorials
at 'python.org' which has some excellent stuff!).

"Learning Python" is a good book for getting started, although it is a
bit dated by now. It might not be quite what you are looking for with
respect to tutorials, so I'd recommend looking at a copy before buying
it.
3. Currently, I write most of my code with Xcode (on the Mac
platform) using Applescript. This gives me GUI capabilities. Is
there anything you'd recommend that I could use for Python that would
give me a GUI interface? I'd like this to be able to work for both
the Mac and Windows platforms. I've been reading a little about
'Claro Graphics Toolkit' and 'PyGUI'... would you recommend either of
those? I'll be writing code on a Mac so I need something that will
run on that system.

Tkinter is the easiest way to get started with Python GUI programming
because it is part of the default python distribution. However, I
prefer wxPython for GUI development. You'll have to install a few extra
pieces, but in the end wxPython does a better job of being "pythonic"
for the programmer, and resulting in native look and feel for the user.
"wxPython in Action" is an excellent book for learning about wxPython.


Dave
 
C

Christopher Arndt

I have a few quibles with your summary of Python's properties:

If you have a computer science background, here's all you need
to know: Python is a byte-code interpreted untyped

Python is strongly but dynamically typed. The fact that you don't have
to declare which type a variable is, doesn't mean it's untyped.
procedural

In Python you can programm in imperative/procedural, object-oriented
and functional style. It can thus be called a multi-paradigm language.
IMO it is best suited for the object-oriented paradigm.
dynamic language with implicit declaration. Syntax is vaguely C-like.

It shares many syntax rules with C (variable names, literals,
functions, ...) but it doesn't look at all like C (no braces,
semicolons, assignment expressions, pointers, ...).
Block structure is determined by indentation. Objects use a class definition/
explicit instantiation/multiple inheritance model.

Most important, classes are defined at run-time, not compile time,
which makes them highly dynamic.

Furthermore, classes, functions and methods are first-class data-
types, i.e you can pass them (or more correctly, references to them)
around as arguments or assign them to variables.
Memory management
is safe and managed by reference counts backed by a garbage collector.
Weak references are supported. Built in data types are numerics, ASCII
and Unicode strings, dynamic arrays, fixed size tuples, and hashes.

Python lists are much more than arrays. More like a linked list.
You forgot sets. And functions, classes, methods, instances.... (see
above)
Implementation speed is typically 2% of C.

Execution speed is approx. 2% - 150% of C :)


Chris
 
K

Kevin Walzer

jay said:
3. Currently, I write most of my code with Xcode (on the Mac platform)
using Applescript. This gives me GUI capabilities. Is there anything
you'd recommend that I could use for Python that would give me a GUI
interface?

PyObjC allows you to write Cocoa GUI's from Python using Xcode and
Interface Builder, much as AppleScript Studio does. However, that's not
a cross-platform solution.

Tkinter runs on Windows as well as OS X. Out-of-the-box, however,
Tkinter is somewhat limited. To build rich GUI's with Tkinter, you will
need to install several additional Tk libraries and their associated
Python wrappers. Tkinter is my toolkit of choice, and I've released a
Python shareware application on OS X that uses it: see
http://www.codebykevin.com/phynchronicity-running.png for a screenshot.

wxPython is also a very reasonable solution, and will probably give you
more out of the box than Tkinter. My main reason for using Tk is that I
already know it well.
 
J

Josiah Carlson

Christopher said:
I have a few quibles with your summary of Python's properties:


Python lists are much more than arrays. More like a linked list.
You forgot sets. And functions, classes, methods, instances.... (see
above)

Python lists are implemented as C arrays that are resized as necessary.

- Josiah
 
B

Basilisk96

2. Is there a good book to start with while learning Python? I'm
currently reading 'Python Essential Reference' by David M. Beazley.
So far it looks like a pretty good book, but would like more
tutorials to work with (I've also been reading through the tutorials
at 'python.org' which has some excellent stuff!).

Take a walk through the text "How to Think Like a Computer Scientist":
http://www.ibiblio.org/obp/thinkCSpy/
It's medium-paced, well-organized, and - quite importantly IMHO -
builds well on knowledge acquired in the previous chapters as it
progresses. There are plenty of hands-on examples; and really, the
text was written by a high school teacher for a CS curriculum, so it's
structured more like a tutorial. I found it to be priceless when I
first got interested in Python, and I would highly recommend it to any
newbie, whether with previous programming experience or not, but who
has never laid eyes on Python before. As I think back on it, the book
gives you just enough information to make you hungry for more - and
indeed, after reading it I had enough insight to explore Python on my
own and started writing useful programs by myself.
3. Currently, I write most of my code with Xcode (on the Mac
platform) using Applescript. This gives me GUI capabilities. Is
there anything you'd recommend that I could use for Python that would
give me a GUI interface? I'd like this to be able to work for both
the Mac and Windows platforms. I've been reading a little about
'Claro Graphics Toolkit' and 'PyGUI'... would you recommend either of
those? I'll be writing code on a Mac so I need something that will
run on that system.

Try wxPython. I've seen it run on a Mac with OS X and Windows
simultaneously, where the operating systems were switched from one to
the other at the touch of a button, and the GUI had a very native look
in either platform (mind you, the app was running exactly the same
code in both cases!).
I write my code on a win32 box, so I have no further pointers for you
regarding a Mac.

-Basilisk96
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top