Be gentle with me....

Preston Landers prestonlanders at my-deja.com
Fri Dec 3 11:19:04 EST 1999


In article <828n3e$8kp$1 at nnrp1.deja.com>,
  ajmayo at my-deja.com wrote:

> I know you are all tired of newbies asking what Python is like as a
> scripting language, so I won't come at you from that track. No, after

PLEASE HELP ME LEARN TO PROGRAM! D00DZ! ;-)

> Apart from the indentation, that is. I had trouble seeing where block
> scope ends. 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. What ifI
> want to continue a line of code over multiple physical lines?

x = "This is a \
  line of code \
  spanning multiple \
  lines"

As far as dynamically generating code, yes, AFAIK you do have to
produce the correct indentation.  I haven't played around much with
dynamically generated code, someone else on the newsgroup could
probably tell you more.  There may be module libraries to help you in
generating complex code.  Like I said I haven't played with this much.

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

I think you will get over your confusion if you actually sit down and
produce a little working code.  You're right, braces and BEGIN/END are
not part of the language.  When I first came to Python from a C
background, more than a year ago, I was also thrown off by indentation
being syntactically significant.  However, I soon came to like it.  It
really does make the code *look* good, nice and clear and
understandable in my opinion.  Overall, I think it is a good thing.

That you're even thinking about these issues shows that you have the
capacity to adjust, I think.

BTW If you use a 'real' editor like (X)Emacs then the editor's python
mode will largely keep track of indentation issues; it will know to
dedent after typing a return statement, for instance.

>
> 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!)

Yes, it does.  A simple example:

planders at gandalf:~$ python
Python 1.5.2 (#11, Apr 22 1999, 09:00:30)  [GCC egcs-2.91.57 19980901
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> def foo():
...     prin "z"
  File "<stdin>", line 2
    prin "z"

It prints the file, line number and offending text.

> 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.

Well, you can certainly approximate it:

class my_struct:
  pass

instance = my_struct()

instance.name = "bill"
instance.cheese = "feta"

If you want to enforce rigid type checking, you're using the wrong
language.

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

I'm just getting started with Zope myself.  I don't have an honest
evaluation of it yet.  It seems very good and very powerful.  In the
next few months I'm going to be developing some serious web content in
Zope.

> 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?. (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).

No, sorry, not as far as I know.  There may or may not be some
commercial product that implements this.

---Preston

--
|| Preston Landers <prestonlanders at my-deja.com> ||


Sent via Deja.com http://www.deja.com/
Before you buy.




More information about the Python-list mailing list