Allowing Arbitrary Indentation in Python

G

Gary

Hi, Gary. Welcome to Python. I hope you will take some of the reaction
you got as initiatory ribbing.

Thanks, Terry, and absolutely! You guys are quite tame compared to
some of the lions whose dens I've stumbled into on usenet. You're also
all well-spoken, passionate, and informative. I'm thinking of sticking
around in here while the learning's good.
Anyone who loves Python obvious likes the idea of meaningful indentation.
The problem with your suggestion and example is with mixing two meanings in
the same hierarchy. Hence the suggestion that you separate program text
and declarative text.

It would seem that's been the biggest stumbling block - my wanton
mixing of imperative and declarative styles. I did do my best to
separate them geographically in my scripts - with the UI bits always
coming at the end :) I've made my justifications above - namely that
"Hey, it always worked fine!" and "Sorry, but there wasn't much in the
way of options," - but I'm quite ready to do things cleanly, properly,
extensibly, and Pythonically.

| I'm not sure exactly what you mean by this, but I'm not really asking
| for the language to be changed.

You fooled me as well as others.

Sorry about that. I most definitely didn't want to have Python fork,
or change into some version compatible with my mind. I was mostly
stamping my feet, and whining about how all the options for doing what
I must do all the time seemed so overly complicated in comparison to
what I've already been doing. The full separation of the declarative
portion is the right answer to my problem, though, and requires no
changes, except to my methodology, and in that, only for the better.
A reasonable question would be something like this. "I currently do gui
layout with MEL [what is that?] and like this but not that. I am looking
at Python because of X. How do people express gui layout within or in
conjuction with Python code?"

Fair enough. Of course, if I'd actually posted to this newsgroup in
the first place, I probably would have stated it in a very similar
way. I'm quite polite, and descriptive in newsgroups, usually. This
was cross-posted to here from my LJ by my online friend, Sam, as an
unintended surprise gift to me :) Really, he was just curious about
what this group would have to say about my problems, and when he told
me of his crosspost, I was immediately quite interested as well. It
worked out for me, too, because now I have a better sense of the right
ways to go about a task I must do too often not to do intelligently.

Thanks for your help, Terry.
-g
 
G

Gary

Hi, Gary. Welcome to Python. I hope you will take some of the reaction
you got as initiatory ribbing.

Thanks, Terry, and absolutely! You guys are quite tame compared to
some of the lions whose dens I've stumbled into on usenet. You're also
all well-spoken, passionate, and informative. I'm thinking of sticking
around in here while the learning's good.
Anyone who loves Python obvious likes the idea of meaningful indentation.
The problem with your suggestion and example is with mixing two meanings in
the same hierarchy. Hence the suggestion that you separate program text
and declarative text.

It would seem that's been the biggest stumbling block - my wanton
mixing of imperative and declarative styles. I did do my best to
separate them geographically in my scripts - with the UI bits always
coming at the end :) I've made my justifications above - namely that
"Hey, it always worked fine!" and "Sorry, but there wasn't much in the
way of options," - but I'm quite ready to do things cleanly, properly,
extensibly, and Pythonically.

| I'm not sure exactly what you mean by this, but I'm not really asking
| for the language to be changed.

You fooled me as well as others.

Sorry about that. I most definitely didn't want to have Python fork,
or change into some version compatible with my mind. I was mostly
stamping my feet, and whining about how all the options for doing what
I must do all the time seemed so overly complicated in comparison to
what I've already been doing. The full separation of the declarative
portion is the right answer to my problem, though, and requires no
changes, except to my methodology, and in that, only for the better.
A reasonable question would be something like this. "I currently do gui
layout with MEL [what is that?] and like this but not that. I am looking
at Python because of X. How do people express gui layout within or in
conjuction with Python code?"

Fair enough. Of course, if I'd actually posted to this newsgroup in
the first place, I probably would have stated it in a very similar
way. I'm quite polite, and descriptive in newsgroups, usually. This
was cross-posted to here from my LJ by my online friend, Sam, as an
unintended surprise gift to me :) Really, he was just curious about
what this group would have to say about my problems, and when he told
me of his crosspost, I was immediately quite interested as well. It
worked out for me, too, because now I have a better sense of the right
ways to go about a task I must do too often not to do intelligently.

Thanks for your help, Terry.
-g
 
G

Gabriel Genellina

1) Is it best/more standard to read in, and parse the XML into some
kind of Python hierarchy first, and then build the UI out of the data
in that structure, or call out UI commands as say, callbacks from the
parser live - as it wades through the data? I lean toward the former,
as it means having one standard set of functions to read in, and parse
the XML data, which can then be used for anything, like displaying the
UI to the client, or creating an editable version of the UI in the UI
build tool. The modified version can then be saved back out as well.

ElementTree is a good candidate for processing xml:
http://effbot.org/zone/element.htm
It provides a "natural" way to access elements and attributes, instead of
writing the same handler again and again or using slow DOM functions of
gigantic names.
2) Is XML fairly standard for this in Python? I recently learned about/
was frightened by pickling. Is that worth learning? Does anyone bother
with it?

Pickle is good for storing data that will be loaded again by (the same, or
another) Python program. The format isn't portable to other languages, it
isn't readable, may have security issues. But it's extensible and much
more flexible than the other builtin alternative, marshal. You can use
pickle as a serializer if you're aware of its limitations.
 
G

Gary

ElementTree is a good candidate for processing xml: http://effbot.org/zone/element.htm
It provides a "natural" way to access elements and attributes, instead of
writing the same handler again and again or using slow DOM functions of
gigantic names.

That does look pretty easy. I'll look into it after I get back from
the holidays.

Thanks, Gabriel.
-g
 
G

Gary

ElementTree is a good candidate for processing xml: http://effbot.org/zone/element.htm
It provides a "natural" way to access elements and attributes, instead of
writing the same handler again and again or using slow DOM functions of
gigantic names.

That does look pretty easy. I'll look into it after I get back from
the holidays.

Thanks, Gabriel.
-g
 

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,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top