Be gentle with me....

Martijn Faassen m.faassen at vet.uu.nl
Fri Dec 3 11:07:58 EST 1999


ajmayo at my-deja.com wrote:
[snip snip snip]

[Complaints about Perl]
> 1. I hate, oh how I hate, the metacharacter at the front of every
> variable which defines its type.

Ah, Python doesn't have this. :)

> 2. I deeply dislike the inadequate debugging messages. 'missing
> bareword at line 193'? Gimme a break!. Since my code is embedded server-
> side code evaluated at runtime, where *is* line 193. Who knows?

People complain about Python's error messages too. They're exceptions and
propagate up from the line where the error occured; a traceback is produced
and in the traceback you can also see the function where things went wrong.
Still, people generally seem to say that Perl's 'use strict' mode produces
better error messages than Python does. Though apparently some work is being
done on this.

> 3. It doesn't seem to be easy to create the equivalent of C structs
> where member assignments can be checked AT COMPILE TIME (sorry about
> the shouting, there, but I think lists of lists and all that don't
> really hack it, in this context, and objects are simply overkill. I
> just want a goddamn structure).

Python doesn't do many compile time checks at all. Python class instances can
have all kinds of member assignments during run-time and nothing's checked.
That said, Python's OO facilities makes the creation of 'structure' type
objects a lot easier than what I've seen of Perl. Also there's the struct 
module, which I haven't used, so let someone else talk about this. It's mostly
for interfacing with C structs, though.

> Ok, that's perl. Now, Python. Why the interest.... well,I've discovered
> Zope. This looks like a mighty fine piece of work and I am very
> interested..

Zope's quite nice, though you're in for a heck of a learning curve. That is,
fairly basic use of Zope isn't that hard to learn, but there's *lots* to
learn after that. But I like Zope a lot and I'd recommend it.

> but it revolves around Python - sort of a Python 'killer
> app', if you know what I mean. So if I want to buy into Zope, I'm
> buying into Python as a scripting language, unless I want to fight it,
> and what's the point of that?

No point whatsoever. :)

> I already knew about Python and I like what I have seen... except for
> one thing. The indentation that marks block scope. This seems to me a
> really strange idea in that having whitespace be significant is a
> totally alien concept in most modern programming languages.

Most people get used to it within a few days, and then start stumbling over
block delimiters in other languages. What are all those extraneous }s doing
there? That was my experience, at least, and I've seen other people say the
same in this newsgroup. There are a few staunch whitespace resisters in the
group as well who agree with you that the use of delimiters would've been
better for Python, but still like Python for other reasons.

Anyway, give whitespace a try. Emacs with its python-mode is lovely with
it, for instance, though other editors can be used as well.

> Reading some sample Python code, as a complete novice, I like the look
> of the syntax, which appears to be clean and elegant (I like Javascript
> very much for the same reason).

Javascript clean and elegant? :) My main exposure to javascript has been
rape & paste scripts in web pages, full of browser-specific hackery, so
I keep wishing the major browsers lightened up and started to support 
Python as the scripting language. Though I heard one can use Python with
ActiveScripting inside internet explorer, and of course there's JPython as well.

> Apart from the indentation, that is. I had trouble seeing where block
> scope ends.

Do give it a try; I think most people get past their troubles very quickly.

> And if I were dynamically creating code to be runtime
> evaluated, how would I handle this easily - do I *really* have to emit
> tabs and/or the right number of spaces for each line of code.

Why would you be dynamically creating code? Anyway, if you are, you'd have to
emit the right amount of spaces, but that's not really that hard:

def emit_indented(f, lines, indent):
    indent_str = " " * indent
    for line in lines:
        f.write(indent_str)
        f.write(line)
        f.write("\n")

# completely untested code

> What if I
> want to continue a line of code over multiple physical lines?

You use \ (like in C):

a very long\
line

Though if something's in (), {} or [] you don't always have to:

def lotsofarguments(foo,
                    bar,
                    baz):

> So tell me, Python aficionados.

> 1. Will I get over my initial confusion?. (can I use braces, or
> BEGIN/END - I presume not)

There's somekind of tool I believe that allows you to use begin/end 
(don't know its location but I think it's somewhere in the python distribution).
I've never used it, as I got over my initial confusion. :)

> 2. Does the debugger report context as in

> foo=bar + splat
>       ^  undeclared variable bar

> (oh, please tell me it does, even for runtime evaluated code!)

> because if it says

> Syntax error at line 345. Program terminated

> then I will scream....

It tends to produce NameError exceptions at things like this, and gives
a traceback, like this:

Traceback (innermost last):
  File "test.py", line 2, in ?
    foo = bar + 1
NameError: bar

But I thought Perl gave fairly informative error messages as well?

> 3. Can I create something analogous to C structs (and arrays of same)
> without recourse to object overkill. The Javascript approach is fine,
> mind you. It's very elegant, actually. I get the impression Python is a
> bit like that.

I don't know the JavaScript approach myself. You can use the struct and
array modules to construct C like structs and arrays. Generally Python
objects and lists are fine and much nicer to use, though.

> 4. Is anyone here also using Zope. What do you think of it?

I'm using Zope, as reported earlier in my reply. Zope's very very powerful,
extensible and flexible. It is also underdocumented in some areas, though
it does have lots of documentation (and the source as a last recourse). 
Its DTML sometimes gets convoluted when pushed beyond its original domain
of reporting language, but it can be very powerful when used as a reporting
language. Luckily there's always Python to make up for things. Zope's
user community is about as nice as Python's (and there is of course
overlap). Lots of cool stuff is continuously being developed. I believe
Zope has a great future ahead.

> 5. Is there a plug-in scripting language interface from Internet
> Explorer to Python, as there is for perl (ActiveState), so that if I
> wanted I could write client-side Python?.

I believe so, but I'll let the more knowledgable people answer that one. 

> (because I'd really like to
> get down to a single scripting language client and server-side, and
> although that could be perl, frankly, my colleagues don't like the
> taste of it so much).

I wouldn't either if I were your colleague. :)

Good luck!

Was-that-gentle-enough?-ly yours,

Martijn
-- 
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?




More information about the Python-list mailing list