On Wed, 26 Nov 2008 14:22:52 +0100
spir <[EMAIL PROTECTED]> wrote:

> Hello pythonistas,
> 
> I need some information about a topic. A list like python tutor is
> the proper place to get it. Take this as a (stupid) game: would you
> like to answer the following question?
> 
> Imagine you are writing code. Then, you realise you need a tool
> function you have not yet written. You don't want to stop coding now,
> rather plan to write the func later. So that your code will hold some
> calls to a not yet defined function. Right? The function is a very
> short and simple one, indeed: it will return a character range, in
> form of a string such as "0123456789", when passed ASCII ordinals as
> parameters. How would you call this function? e.g. digits =
> char_range(...) In other words: which is, for you personly, the most
> practicle or natural way of calling this func? Would you give me one
> or more calling example(s)?  Below a list of ASCII characters.
> 
> Note: Yes, this is trivial ;-) But there is no trick, no trap. I
> cannot tell the purpose now, because it would invalid the results. I
> will explain it in 3 or 4 days when I have some data. Additional
> question if you wish: You may try and guess the point of this. But do
> it after answering...
> 
> Thank you very much.
> Denis

I would split it up in two functions:
The main function would be:
getStringFromOrd(list,what-ord)

You'll loop through the passed parameter, a list delimited by comma.
what-ord defines what you are using (dec, octal, hex)

For each value in the list you call 
getCharFromOrd(ord,what-ord)
which returns the true character

Examples:
MyName = getStringFromOrd((80,101,116,101,114),'Dec')
MyName = getStringFromOrd((0x50,0x65,0x74,0x65,0x72),'hex')


-- 
Peter van der Does

GPG key: E77E8E98

WordPress Plugin Developer
http://blog.avirtualhome.com

GetDeb Package Builder/GetDeb Site Coder
http://www.getdeb.net - Software you want for Ubuntu

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to