[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#571443: Support using "in" operator to test whether a package is in the cache



Package: python-apt
Version: 0.7.93.1
Severity: wishlist

Hi,

I'm using python-apt's apt_pkg.Cache class to determine which packages
are installed.  I have to use a try...except statement to check
whether a package is in the cache first, though, since using the "in"
operator to do so generates an exception:

 Python 2.5.5 (r255:77872, Feb  1 2010, 19:53:42) 
 [GCC 4.4.3] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import apt_pkg
 >>> apt_pkg.init()
 >>> cache = apt_pkg.Cache()
 Reading package lists... Done
 Building dependency tree       
 Reading state information... Done
 >>> 'foo' in cache
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
 TypeError: argument of type 'apt_pkg.Cache' is not iterable
 >>> 

I wish that this worked.

-- 
Matt                                            http://ftbfs.org/kraai



Reply to: