Python anyone?

Status
Not open for further replies.
I have been programming in Python for about a year. It is the easiest language to learn and use I have ever encountered, having used assembler, Fortran, and Basic as an undergraduate long ago, PL/1 in graduate school, and Basic, Java and Perl later on. Mind you, I am not an expert and ths is a hobby for me, not a job.

However, I am amazed at how pwerful Python is, and it is much easier than Java. I am a little carried away with it, I guess...

Anyway, I am new here and I would like to discuss Python if there is anyone else using it. I also have established a web site that includes links to about 20 different online Python tutorials, 24 book reviews, and lots of other useful Python links at http://www.awaretek.com/plf.html

I believe that programming productivity must be much better for anyone using Python compared to the other languages I have tried. Python was used to write Zope, the object based web server, and is used by Industrial Light and Magic, NASA, Red Hat and many other companies.

Anyone using Python???
 

w.anders

Ars Tribunus Angusticlavius
6,957
Yes, Python is a well-rounded language, although I'm a bit annoyed by the "whitespace matters" design choice. I'm also a bit doubtful about using it in larger projects, since it lacks some of the strictness of, say, Java (this makes it more fun for the small jobs, of course).

I'm on a mission to replace Perl with Python as the scripting language of choice at work, we'll see whether that leads somewhere. :)

Here's a tutorial I don't think you've listed:
How to Think Like a Computer Scientist: Learning with Python
It's a good one, too.
 

EgalitarianBovine

Ars Tribunus Angusticlavius
8,086
Yeah. There are a few other python freaks on this board. I'm one of them. I think jemfinch is one as well, but I'll let him speak for himself ;)

I learned python after giving up on perl because of it's ugliness (I later learned perl anyway, and like it, but I use python quite a bit).

One of the nicest aspects of python, IMHO, is the interactive shell. It lets you test a compenent you're working on immediately and painlessly.

It's clean, both syntaxwise, and designwise, which makes it extremely easy to learn and apply.

-EB
 

dockeen

Ars Tribunus Militum
1,600
And, for the nth time, Wayne will pimp for VPython (the
module formerly known as Visual Python). It adds some
very easy to use graphics, including some powerful 3D
graphics to Python, as well as a good IDE.

www.vpython.org

Python has just about become my gun-to-the-head rapid
problem solver for data analysis and visualization work.

I still use PERL for some other things, and of course
a goodly amount of C++ and some FORTAN. After using a ton
of Ada for 7 years, I am mostly out of that..

:)

Wayne
 
D

Deleted member 5324

Guest
Originally posted by EgalitarianBovine:
Yeah. There are a few other python freaks on this board. I'm one of them. I think jemfinch is one as well, but I'll let him speak for himself ;)

I'm really (by now) a former Python freak :) It's a great language, I love the design, the beauty, and many of the included libraries (some of which I've translated into O'Caml, my language of choice at the moment.)

My only problem, really, and the reason I don't really use it anymore, is the lack of strictness. Everything is checked at runtime. Maybe I'm just a poor programmer (a distinct possibility -- I also program only as a hobby) but I really benefit from as many compile time checks as possible, in particular strict typing. Otherwise, it's an excellent language. If someone ever develops a native code compiler with options for additional strictness, it might be very close to my "perfect language" -- I'm just fairly sure that won't be happening in my lifetime :)

Jeremy
 
I am sitting in the Newark airport Singapore airlines lounge typing this on a user station supplied by the lounge. Unfortunately, I am beginning a two week business trip to sevral Asian countries, and I forgot to bring my new (ultra-small)laptop (which is sitting in my new small laptop bag, while my briefcase that normally carried my machine has none ;-(((()))

I can hardly wait until I get back to start experimenting with VPython! Thanks for the tip!

I also appreciate the feedback from all of you. This seems like a very active forum and it's nice to be welcomed ;-))

I woudl appreciate any feedback on my website. It has a new Python script (GPL'ed)to automagically scan "the web" and download any new Python articles, several times a day, and display links to them on the web site. When I get back, I have lots of plans to add to the script and make a useful, user-customizable, news-spider. Any suggestions??? (Source code is available on my web site, the script is called mygale.py).

Ron Stephens, Python City http://www.awaretek.com/plf.html
 
I like Python, too; it's the most Lisp-like of the languages in common
currency, and that, to me, is a good thing. It's got a true REPL
which makes getting results so deliriously easy (compared to the
unspeakable Perl/C mare's nest) that it's far and away the best choice
for simple programming tasks.

Now that it supports lexical scoping, and with the stackless patches,
full continuations, it's a legitimate choice for the types of coding
that I like to do.

I still prefer CL, but that's just an unnatural love for read macros,
I suppose.

Peace,
(jfb)
 

Thank You and Best of Luck!

Ars Legatus Legionis
21,219
Subscriptor
I'm intrigued by some of your guys' dislike for a loosely typed languages. That's always been one of the things I've really enjoyed about ObjectiveC, that it's not a strongly typed language like C and Java. It allows my programs to be a lot more flexible and offers a whole other tier of functionality that's harder to implement in a strongly typed language, especially by comparison to C.

I always find that I'm a bit stiffled when I have to build OpenGL based applications due to their very "standard C" nature, but I do my best to wrap all the OpenGL calls inside some larger object structure with ObjectiveC to make my life as easy as possible :)

-Nathan
 
D

Deleted member 5324

Guest
Originally posted by naschbac:
I'm intrigued by some of your guys' dislike for a loosely typed languages. That's always been one of the things I've really enjoyed about ObjectiveC, that it's not a strongly typed language like C and Java. It allows my programs to be a lot more flexible and offers a whole other tier of functionality that's harder to implement in a strongly typed language, especially by comparison to C.

The flexibility is mostly an illusion caused by poor (read: C/Java) implementations of static typing.

As far as your whole other tier of functionality, I'm sure if you give some examples, me or newton_meter will be happy to tell you how it's done in a statically typed language :)

I like the extra assurance of correctness, and the complete code coverage of static type analysis.

Jeremy
 

EgalitarianBovine

Ars Tribunus Angusticlavius
8,086
Most of the time, the dynamic typing thing is just a fingersaver. I.e., it's good in a situation where you don't want to spend the time specifying type signatures for all your data structures.

But there are other situations where dynamic typing is handy. One instance is the ability to have proxies for remote objects without stub interfaces.

-EB
 
D

Deleted member 5324

Guest
Originally posted by EgalitarianBovine:
Most of the time, the dynamic typing thing is just a fingersaver. I.e., it's good in a situation where you don't want to spend the time specifying type signatures for all your data structures.

This is also an illusion of poor language support for types: consider {S,O'Ca}ML, which don't require any type declarations under the vast majority of circumstances. Type inference is my fingers' friend :)

But there are other situations where dynamic typing is handy. One instance is the ability to have proxies for remote objects without stub interfaces.

Can you expand on this? I'm fairly sure I know what you mean, but before saying that O'Caml/SML do it, I want to make sure I know what you mean entirely :)

Jeremy
 

dockeen

Ars Tribunus Militum
1,600
I tend to use Python for small analysis projects.
They are not generally unrelated, but I do tend
to do code reuse more through cut and paste than
through modular or object oriented.

I am not a bad programmer, I tend to work on
small projects the nature of which tend to make
even functional decomposition somewhat of an
overkill...

As I have mumbled before, I like Python because the
syntax is relatively easy, and I have found the
graphics (Visual and Dislin (which is not unique to
Python btw)) easy to use and powerful.

For the record, much of what I do could be just
as easily done in something like MATLAB, which I
have on my laptop (thanks to the customer). Somehow
I like Python better.

As a complete aside, I work on a technical program
which is written in C++. The author likes using
functional decomposition so much that you have to
follow several trakcs of function calls though 3 / 4
levels of code to find out what the bleep is really
going on. I find that a bleeping pain in the programming
chair... Of coarse, all the degrees after my name
are in Physics, so I am a little off anyway...

Wayne
 
Heh, I have a degree in physics, too; maybe all such folks are attracted to Python ;-))).

Seriously, to answer a post from above asking what sort of projects we do in Python, mine are strcitly hobbyist. I wrote a decision_analysis program that takes user input on (1) alternatives to be decided amongst and (2) criteria to be used to help make the decision and (3) what are the relative importance of each criteria and (4) how does each alternative rate on each criteria...then performs a weighted average and gies a score for each alternative, electing the highest score.

Next, I am taking this generic decision_analysis program and pre-setting the criteria, relative weights and rankings, and various combinations thereof, as sort of an extremely simple "expert system" for subjects in which I am knowledgable (no laughter, please;-)))

Another program I did takes user questions in plain English, any question, and then goes out and does web queries and google searches and uses some basic statistics to pick an answer to the user's question. Next step is to research the answer itself on the web automatially using Python's librairies and google and coming back with a sophisticated answer. This is a work in progress, but I call it AskMerlin and it gives the user a sense of AI, even though its a quick hack by a clueless newbie hobbyist ;-)))

Another script was written by an online friend for me, after I asked about ideas for creating a web spider to automatically search the web and keep an updated list of news articles about Python on a web site. He did a great job, the updated list is always current on my web site. I am now doing additions, modifications and hopefully improvements to make the web spider more discriminating jn its searches, as well as more general in that it will ask for user input on what subject to be the object of its search, so one can create an automatically updated list of such articles on any desired subject. Oh yeah, the web site is automatically updated with another Python script that runs the program four times a day and then automatically FTP's the updated file to my web site.

All of these scritps are on my web site with full source code and I certainly welcome modifications!!! They are works in progress and hacks, but sort of fun. That's what Python is used for by me.
But before I got into Python one year ago, I was fooling around with Java but the "overhead" of type and class declarations just got to be too much. I work a demanding job in the electronics industry (hardware) and travel world wide about 50% of the time; I need an efficient programming language that doesn't get in my way, and Python provides that.

By the way, I am typing this at the Business Center of the Pan Pacific hotel in Singapore. I just got in at 6:30 AM and its 11:00 am now (I guess 10 PM New York Time).

Greetings!

http://www.awaretek.com.plf.html is my webstioe and I welcome critques and re-hacks of my "prgrams". Byt he way

I am curious why I, even though I am brain dead, cant get a standard html link to appear correctly on thsi great BBS software? Am I tyoping it wrong???

Python City

It keeps messign up ...sigh I know I'm dumb but I don't get it ;-)))

Anyway, Python for me is fun. It's easy to do things without spending endless hours worrying about syntax. The Python syntax (for the core language, not including the numerous libraries) is the first programming language syntax that I have found that I can keep entirely in my head, so that I can just sit down and type out programs.

Literally, if one knows any programming langauge already, one can probably become more or less able to program in Python after only a couple of days of doing online tutorials: it's really easy and intuitive syntax, at least for me. Still, its a powerful language. What's not to like??? It's just nice to have a language that doesn't get in the way, that just allows a person to program one's ideas without worrying too much about the syntax, and without having to spend all one's time studying the language itself.
 

dockeen

Ars Tribunus Militum
1,600
Having worked both sides of the street in a sense, I can
see the value of different languages in different places.

For the stuff I do, which I refer to as widgets, a language
like Python is great.

Having worked SIV&V for a missile program, which we can
refer to as "mission critical" software, I see the value
of languages which make you dot the t's and cross the i's.

The program I worked on, the software was in Ada, though
you can fill in the blank with others such as Eiffel, and
presumably ML stuff.

On a historical note, I went on to other things when the
missile system in question successfully completed Dem/Val.
For the next phase of the program, they are switching to
C++. We shall see.

:)

Wayne
 
Hey, Jimfinch, do you live in Cincinnati? I was just looking at the html source of this trhead (in order to try to figure out how come others can get Python City type of links to show up correctly as links) when I noticed you listed as Tribus Cincinantus??

Both my wife an I were born and reaised in Cincinnati Ohio. I miss it!!! How are the Bearcats doing? What I really , really miss, is Skyline Chili. I can't get three ways or five ways since I left town in 1988 and that hurts! I used to eat three ways for breakfast, lunch, and dinner, all in the same day sometimes!!

;-)))

Now, I must sleep. I've been up for 30 hours straight (24 hour killer flight from Newark to Singapore, via Amsterdam) maybe that's why I can't type correctly.. ;-)))
 

EgalitarianBovine

Ars Tribunus Angusticlavius
8,086
Can you expand on this? I'm fairly sure I know what you mean, but before saying that O'Caml/SML do it, I want to make sure I know what you mean entirely :)

Jeremy

I'm talking about remote method invocation. Having references to objects that exist in other processes, or across a network. These are generally handled by proxy stub objects on the local machine which perform the necessary marshaling and serialization to make a call to an object doesn't exist inside the executing process memory space.

With dynamic typing, you don't have to worry about specifying stub interfaces beforehand. With languages like python, you can even create a generic proxy object that does the necessary marshalling regardless of the type of the object it's serving as a proxy for.

-EB
 
Python gains power by being both a true object oriented language as well as, or alternatively, a functional programming language somewhat like Lisp or Scheme. Pick you paradigm. I believe that these aspects of Python are a large part of what makes it so powerful for writing large complex programs. In particular, Python's object orientedness promotes the creation of easy to use modules, Thus contributing to the vast array of useful library modules that exist for Python.

Myself, as a hobbyist hacker, the truth is I really don't need or use most of these "high-end" features of Python in my day to day programming. But Python does not "enforce" object oriented or functional styles on the programmer, one can use a regular old procedureal style if one chooses. So Python is extremely easy for newbie or part time programmers to use, with the higher order capabilities still waiting there for when you need them.

But if Python didn't have the features that make it more useful for writing bigger or more complex programs, then I would not have available to me the many great libraries that I have. In particular, it is Python's well thought out object oritentation that, I suspect, helped convinve the real experts to write all those libraries. And I do use the libraries, extensively, and they help me a lot.

There are other really good object oriented and functional langauges, but to my knowledge, I think Python is by far the easiest to learn and use, for the regular hacker; and this sets it apart in my mind.

Power for the gurus, simplicty for the newbies, something for eeryone.

Unlike many other suceessful languages, Python is hard to compartmentalize in any one niche; Sure, it is good for scripts, CGI, text processing, GUI's, etc, but its capabilites are more generally good for all kinds of programming. Perl may be better for text processing, LISP for highly recursive programs, Java for servlets, PHP for web site scripting, but Python can do all those things well enough, without being pigeon-holed.

Zope is the premier example of a large and complex system programmed entirely in Python. Red Hat uses Python to write their installation scripts. Industrial Light and Magic uses Python to script some of their special effects. Python is sort of a general purpose tool.

Ron Stephems, Python City, http://www.awaretek.com/plf.html
 

EgalitarianBovine

Ars Tribunus Angusticlavius
8,086
Unlike many other suceessful languages, Python is hard to compartmentalize in any one niche; Sure, it is good for scripts, CGI, text processing, GUI's, etc, but its capabilites are more generally good for all kinds of programming. Perl may be better for text processing, LISP for highly recursive programs, Java for servlets, PHP for web site scripting, but Python can do all those things well enough, without being pigeon-holed

This is very good point. Python is extremely hard to "peg" into a particular mode of programming. It's a really nice, simple, easy general-purpose programming language.

The things I've used python for are not nearly as advanced as a lot of people...

The first major code I wrote, incidentally in python, was in 9th grade. It was a program to browse my rather vast collection of pornography. See, I had it categorized extremely well. With each series directory containing a text file that described certain characteristics - some boolean, some integer (image quality, my 1-10 rating, professional/amateur, hardcore/softcore, cartoon, hentai, blowjob, asian, etc.). As an introverted geek kid, I spent quite a bit of time on IRC porn fserves pulling down images. So I wrote a reasonably large interactive program in python that would crawl my porn directory and allow me to specify searches on the images, so I could quickly find images that matched the fserve's upload requirements.

quality>6 and hardcore and males=0 and females>=2

would find a high quality hardcore series with more than two girls (essentially a high quality lesbian series).

My first great programming accomplishment, and I couldn't even show my parents.... ;)

-EB
 

dockeen

Ars Tribunus Militum
1,600
Hmmm, my first big programming project was, well
a little different than yours...

:rolleyes:

Of coarse, I am an OLD fart. An AGE-ed Ars
veteran....

Wayne

my first big project was the classic of the indians
selling Manhattan for 26$ in whenever. If they earned
5% annual interest, how much moeny would the have
now. Done in BASIC on an IBM selectric typewritter
configured as a terminal connected to a mainframe
in Albany. BASIC - line numbers and everyhing.
 
Ok, now I'm really curious, how much would the Indians have today at 5% interest on the $26 sale of Manhattan some-what-300-400 years ago????

I might want my share, since my mother always said we were part Cherokee...

And EgalitarianBovine..I am quite impressed! I'm always hoping my 12 year old son will do some programming...but maybe not precisely of the same sort you mention ;-))))
 

dockeen

Ars Tribunus Militum
1,600
In line with what I was mumbling about earlier about
how I use Python, I have not really played with Zope.
From what I have seen in the "headlines" it does seem
to be a hot commodity in terms of skills.

Is this true, or is it just hype?

Do you develop Zope in Python like syntax, or
put more simply, what is it?

Small words for a physicist please!

Wayne
 

dmcnaught

Ars Scholae Palatinae
684
Zope is a web application and publishing framework. All folders, pages and scripts are stored in an object database rather than in the filesystem. There is a nice fine-grained user and permissions model so you can delegate tasks safely. It's open source, written in Python with a little C, and you can program it in DTML (which is roughly equivalent to PHP or JSP) and Python, all managed and edited through the web (though you can also use WebDAV or FTP with your favorite editor). It can talk to SQL databases easily, and you can write extensions to it in Python (and there are a lot of existing extensions out there).

It's kind of hard to explain how cool it is--I'm only starting to scratch the surface myself. There is definitely a learning curve though.
 
I just saw an article by Jerry Pournelle over at www.byte.com ( or more directly at http://www.byte.com/documents/s=7026/byt1014845192039/0304_pournelle.html ) if that link works. He includes a nice short piece about his use of Python in the middle of the column.

While I object in general that Jerry P. is too Windows-centric, I appreciate his mention of using Python because of its ease of use.

By the way, he mentions one other thing that hasn't been mentioned yet in this thread: It is extremely easy to read Python programs, whether they were written by someone else, or by you, years ago. In fact, if you know any programming langauge, even before you study Python you might try reading someone else's program written in Python, and you may be able to read it easily, enough to understand its inner workings?

This readability makes it much easier to maintain Python programs.
 

iceburn

Wise, Aged Ars Veteran
195
Subscriptor
Originally posted by Ursus Maximus:
I am considering buying the Black Adder IDE package from theKompany that uses the PyQt toolkit.

Does anyone have any experience with PyQt or Black Adder? How about Qt 3.0???

I've tried BlackAdder. You can find a trial version on thekompany's website for both Windows & Linux (as well as links to the noncommercial verson of QT & PyQT for both). I don't care for it very much, but that's just me. QT, however, is very nice. I don't have much experience with PyQT, but the regular C++ QT is well organized and easy to use, as well as having the best docs I have ever seen. I assume PyQT is nicely laid out as well, but I'm not sure about the docs... You may want to take a look at Activestate Komodo [link] if you are thinking about spending a few $. It has great pricing for personal/educational use, and its not too bad. Demo is available for that beasty as well.
 
PyQt is in my opinion incredible.

It's an almost 100% complete python interface to the qt libraries. The reason you're having a hard time finding documentation is because PyQt is so complete, and the transition from the c++ interface to python so obvious, that the author only provides documentation for differences or dificencies in the python interface.

Also PyQt is completely free and if you're not using it in a professional environment Qt is free as well. If not Qt is pretty pricey but ...

futang
 

inkedmn

Seniorius Lurkius
41
what's a python thread without some code?

ok, i'm very n00b, so don't flame me to hard if this code sucks.

code:<HR>
Code:
from socket import gethostbyname, gethostbyaddr, error
import string

#!/usr/bin/env python

print '\n'
print "Welcome to PyResolve!"
quit = 1
try:
   while quit == 1:
       print '\n'
       print "1. Get a domain name for an IP address."
       print "2. Get an IP address for a host."
       print "3. Buggar off..."
       x = int(raw_input())
       if x == 1:
           IP = raw_input("Enter IP address: ")
           host = gethostbyaddr(IP)[0]
           print "The domain name for %s is %s" % (IP, host) 
           quit = 0
       elif x == 2:
           addr = raw_input("Enter domain name: ")
           IP = gethostbyname(addr)
           print "The IP for %s is %s" % (addr, IP)
           quit = 0
       elif x == 3:
           print "Fine, didn't want to help you anyway..."
           quit = 0
       else:
           print "1, 2, or 3, buddy. This ain't rocket science..."
           print '\n'
           quit = 1
except ValueError: 
   print "ValueError: these aren't hard questions, really..."
except error:
   print "Couldn't resolve that host"
except:
   print "something pretty bad happened, but i have no idea what it is..."

:D
 
Status
Not open for further replies.