воскресенье, 21 сентября 2014 г.

Writing a great end-user-friendly configuration editor in Python

This python programmers problem stumped me for a time. Then I acquired an inspiration: I'd let fetchmailconf work with fetchmail's own parser! I added a --configdump choice to fetchmail that would parse. Fetchmailrc and dump the results to standard output inside format of any Python initializer. For the file above, the result would look roughly such as Listing 2 (to avoid wasting space, some data not based on the example is usually omitted).

The parser regarding fetchmail's configuration file syntax is very elaborate. It's actually composed in YACC and also Lex, two classic UNIX methods for generating language-parsing value in C. In order for fetchmailconf in order to edit existing setting files, I thought it would have to replicate that elaborate parser in Python. 

I was very reluctant to get this done, partly because of the amount of work involved in addition to partly because When i wasn't sure the best way to ascertain that a couple parsers in a pair of different languages accept exactly the same. The last point I needed was the excess labor of keeping both parsers in synchronization as the configuration language evolved!

This was my first clue that will, in Python, I was actually working with an exceptionally very good design. Most languages have a great deal friction and awkwardness constructed into their design that you simply learn most with their feature set some time before your misstep pace drops anywhere near zero. Python was the very first general-purpose language I'd ever used that reversed this technique.

But my almost all dramatic moment involving discovery lay forward. My design had a difficulty: I could quickly generate configuration files through python freelancer actions, but editing all of them was a a lot harder problem. Or, rather, reading them in to an editable form was a problem.

Not that the item took me very long to learn the particular feature set. I wrote a functional, usable fetchmailconf, with GUI, in six trading days, of which perhaps the equivalent of two days had been spent learning Python per se. This reflects one more useful property from the language: it is compact--you can hold its entire element set (and at least a concept directory of its libraries) in your thoughts. C is a famously compact words. Perl is infamously not; one of the points the notion “There's multiple way to take action! ” costs django consulting will be the possibility of compactness.

When you are writing working rule nearly as fast as you can type and ones misstep rate is near zero, it generally suggests you've achieved mastery with the language. But that didn't sound right, because it had been still day a single and I seemed to be regularly pausing to look up new vocabulary and library characteristics!


.

Комментариев нет:

Отправить комментарий