and so i put my perl books aside.....

Oliver Grawert hostmaster at grawert.net
Tue Nov 16 15:22:54 CST 2004


hi,
Am Montag, den 15.11.2004, 15:29 +0100 schrieb Frederic Peters:
> > finally a link:
> > http://www.grawert.net/software/startup-settings/
> 
> Great; patch to get it more pythonic (my taste) attached.
thanks :)
sorry for the late reply ....

there was no need to impress me further......i was already...but your
patch really puts the cherry on the pie :)

i applied your patch and have put up a 0.1.1 version now...

> -               my_uid = apply(getattr(os, 'getuid'), ())
> +               my_uid = os.getuid()
seems in 2000 it has been done like this....
http://www.faqts.com/knowledge_base/view.phtml/aid/4226/fid/538
but your addition is indeed much sweeter

> -       for key in oslist[:]:
> +       for i, title in enumerate(titles):
> Hashes are great; both in Python and Perl.  But oslist was perfect for
> the 'list' type.  enumerate() creates (index, item) couples:
i knew about that and had it in my first draft of the script, but i got
a little worried about the "Other Operatingsystems" entry, i wasnt sure
if there could be other dummy tiles that could get shuffled in... if so,
i couldnt hardly say if the position grub expects confirms with the
enumerate numbering scheme. so i decided to take the safety net with a
hash that keeps the real position. 

> -                       p = re.compile('\n')
> -                       line = p.sub('', line)
> -                       if re.search('^timeout', line):
> +                       line = line.strip()
> +                       if line.startswith('timeout'):
> Two things here: Python programmers don't use regular expressions for
> everything, builtin string functions are more common.
> And relevant to this particular program, grub lines may start with
> spaces, strip() will strip them (as well as new lines or tabulations,
> at the beginning and at the end).
in fact these could be the things that make me fall in love with this
language :)

> Best advice would now be to get used to the standard library.
i am going to train a bit :)

ciao
	oli

-- 
got ubuntu ? --------------> GET UBUNTU !!!
http://www.ubuntulinux.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2125 bytes
Desc: not available
Url : http://lists.ubuntu.com/archives/ubuntu-devel/attachments/20041116/c9bc5768/smime.bin


More information about the ubuntu-devel mailing list