[Yum] another Oooops in archwork.py

Vladimir Bormotov bor at vb.dn.ua
Tue Nov 5 01:08:04 UTC 2002


                Hi!

=====
 def bestarch(archlist):
-    currentarch = 'garbage'
-    for arch in archlist:
-        if currentarch == None:
-            currentarch = betterarch('garbage', arch)
-        else:
-            currentarch = betterarch(currentarch, arch)
-    return currentarch
+    # rewrite this with reduce()
+    _cur_arch = archlist[0]
+    for arch in archlist[1:]:
+        _cur_arch = betterarch(_cur_arch, arch)
+    return _cur_arch
=====

 1. currentarch never None
 2. why we must make extra iteration with 'garbage' value?
 3. this nice example where reduce() is 'best practice'
 
 
 also, I extract archdict initialisation from availablearchs().   
 Why we at every call init constants?  
 
 and getArch() can be called once, with module import...
 
-- 
		Bor.



More information about the Yum mailing list