Gentoo Archives: gentoo-portage-dev

From: Brian Harring <ferringb@g.o>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] python positional args vs optional args
Date: Fri, 27 Aug 2004 03:38:12
Message-Id: 79B2C1F4-F7DA-11D8-BF3A-000A95C08860@gentoo.org
1 -----BEGIN PGP SIGNED MESSAGE-----
2 Hash: SHA1
3
4 Hokay... for those users who are bored, have some time, and feel like
5 hunting through portage's source I've opened bug #61881 (
6 http://bugs.gentoo.org/show_bug.cgi?id=61881 ).
7
8 Basically,
9 def funcx(a,b='',c='',d=''),
10 does not mean you should call it as
11 funcx(1,2,3,4)
12
13 Specifying b, c, and d as optional args is just that- python doesn't
14 require those args, and passing them in as positional is just
15 - --asking-- for a bug that will cause random segments of code to implode
16 as their args are switched around. It's *bad* practice, don't do it.
17
18 Any users looking to chip in, please split patches against either
19 portage-2.0.51_pre20 (currently package.masked), or the most current
20 cvs snapshot in http://dev.gentoo.org/~ferringb/portage-cvs/ . Patches
21 should be attached to bug #61881. Any questions you have regarding the
22 source (fex: what does func xyz of portage.py do?) should be directed
23 here.
24
25 So... in summary, if you're looking for an excuse to familiarize
26 yourself with the portage source, now would be the time, and would be
27 appreciated. The sooner this is taken care of, the better.
28 As is calling a function and specifying an optional arguement via
29 position makes the caller, and the function prototype *very* fragile-
30 prefix a new optional arg, or change the order of optional args in the
31 prototype and the caller no longer is specifying args correctly,
32 leading to bugs down the line.
33 ~brian
34 -----BEGIN PGP SIGNATURE-----
35 Version: GnuPG v1.2.4 (Darwin)
36
37 iD8DBQFBLqyXvdBxRoA3VU0RAkbgAJ4gVX+Dvf3E9SLA1Kxe0PFsSkYYkgCdFLHm
38 Wq9PUq35DHp+PeaS1hvngYI=
39 =4+Gv
40 -----END PGP SIGNATURE-----
41
42
43 --
44 gentoo-portage-dev@g.o mailing list