Python declarative

Chris Angelico rosuav at gmail.com
Wed Jan 22 21:29:06 EST 2014


On Thu, Jan 23, 2014 at 8:16 AM, Asaf Las <roegltd at gmail.com> wrote:
> i am novice in python, but let me suggest you something:
> it would be beneficial to use json text file to specify
> your gui so composite data structure can be created using
> json and then your program can construct window giving
> its content will be based on simple text file?
> You can add every parameter to json encoded window system
> once your window construction will be using as interpreter
> for that. JSON is very structured and quite presentable for
> such kind of things.
>
> What Gurus do think about this suggestion?

JSON is better than XML for that, but in my opinion, both are
unnecessary. Python code is easy to edit. (See [1] for more on Python
and XML.) When you're writing compiled code, it makes good sense to
drop out of code and use a simple text file when you can; but when
your code *is* a simple text file, why go to the effort of making a
JSON-based window builder? (Unless you already have one. GladeXML may
well be exactly what you want, in which case, go ahead and use it. But
personally, I don't.) JSON is a fantastic format for transmitting
complex objects around the internet; it's compact (unlike XML),
readable in many languages (like XML), easily readable by humans
(UNLIKE XML!), and can represent all the most common data structures
(subtly, XML can't technically do this). It's superb at what it
does... but it doesn't do Python GUIs. For those, use Python itself.

ChrisA

[1] http://dirtsimple.org/2004/12/python-is-not-java.html



More information about the Python-list mailing list