[Tutor] poll question

Peter van der Does peter at avirtualhome.com
Wed Nov 26 15:39:54 CET 2008

On Wed, 26 Nov 2008 14:22:52 +0100
spir <denis.spir at free.fr> 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:

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 
which returns the true character

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

GetDeb Package Builder/GetDeb Site Coder
http://www.getdeb.net - Software you want for Ubuntu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20081126/e2015d94/attachment.pgp>

More information about the Tutor mailing list