By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,200 Members | 1,725 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,200 IT Pros & Developers. It's quick & easy.

Re: How to write verbose scripts

P: n/a

Steven D'Aprano <stev...bersource.com.auwrote:
>Is there a better way of doing this than the way I am going about it?
Not sure if its "better", but I would keep the messages in a table or dict and
have different tables or dicts for different levels of verbosity, and write a
displayer that knows about the verbosity - This approach has the advantage that
you can write in English and have different verbosities in different languages
too, if the displayer knows about the language.

Verbosity level and language can be display class attributes, and then you can
simply write something like:

display.display("squawk")

and get one of:

squawk
squawk, squawk, squawk
squawk - help the bastards are trying to nail me to my perch!

or the equivalent in Icelandic or Norwegian.

It works, but its a PITA to implement because you have to formally construct the
stuff, and keep them all in sync, across languages and levels of verbosity.

This of course will only work for static messages - If you compute what you
display, I guess you need to either keep the computation in the displayer, or
pass it in, or something - gets messy.

Keeps the code clear though, as it splits what you display away from the
decision of saying something.

I try to avoid it if I can.

- Hendrik

Sep 3 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.