473,788 Members | 2,896 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: How to write verbose scripts


Steven D'Aprano <stev...bersour ce.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
0 772

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1556
by: el_roachmeister | last post by:
I wonder do most php coders use ftp or ssh (terminal login) to write php scripts? I use ssh because my host offers it, but I notice most hosts that charge less than $10/month don't offer ssh. Are there are any tools one can use to write long scripts (>5000 lines of code)?
1
2366
by: Phil Powell | last post by:
I have CF MX 6.1 with JRun running in the background. I want to be able to write JSP scripts as well as ColdFusion, however, I don't know how to do this (I can write JSP, but how to do it within ColdFusion framework is beyond me). Suggestions on where I can turn? I'm also interested in applying BSF tags; I downloaded the JAR and TLD files and placed them accordingly within my CF framework and added the <taglib> tags in web.xml - what...
9
2767
by: Chad Smith | last post by:
Hello, I'm relatively new to the database world so please forgive me in advance for my ignorance. I have recently been tasked at my job with finding a tool that will perform the following tasks: 1) extract schemas from a db, 2) produce a difference report between schemas from two databases, and 3) synchronize two schemas. The purpose is for product upgrades during which an existing database schema will need to be synchronized with a...
0
1566
by: bootleggersplayr | last post by:
anyone who can write some scripts for me for this online game would be an lifesaver pm me!
3
4072
by: mast2as | last post by:
In the same vein as the topic that I started on exception handling ;-) .... If I have read (not all of them though) the documents that you guys pointed me to, the try/throw/catch mechanism should really be kept for exception handling (basically errors whevere they are critical or not). Now, while I am developing this application, so far I used std::cout quite a lot to check that the code was doing the right thing (writing out to the...
2
1561
by: realxpdc | last post by:
someone can help me how to write autohide scripts in javascripts
2
3506
by: raghunadhs | last post by:
Hi All, i have some simple scripts( which may have some insert statements, update statements etc). these scripts were written in Sql server 2000. now i want to use the same scripts in Access. (since the data is same in both Access, Sql server databases). can i write the scripts in Access-2003? if so please help me. Actually i tried with simple examples. it is working fine for insert, update statements. but it is not working for "If" state...
11
2841
by: Steven D'Aprano | last post by:
I find myself writing command line tools in Python where I wish to include "verbose" output to stdout. I start with a helper function: def print_(obj, level=0): if _verbosity >= level: print obj
0
669
by: =?ISO-8859-1?Q?BJ=F6rn_Lindqvist?= | last post by:
2008/9/3 Hendrik van Rooyen <mail@microcorp.co.za>: One big downside with that approach is that it becomes much harder to grep for the log message. Usually when I go through logs, I don't care what exactly the message says, just that it is easily googleable (uses some kind of identifying text) and that it is unique so I can know exactly where it was emitted. --
0
10172
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9967
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.