beginner, idiomatic python

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Aug 24 00:14:04 EDT 2007


En Thu, 23 Aug 2007 23:54:14 -0300, bambam <david at asdf.asdf> escribi�:

> After examining your suggestion, I realised that another thing
> I am interested in could be generalised: I want the complement
> of the set of ports in pages, given a universal set in tempList.
> Ignoring the break condition for the moment, and my problem
> with int(port)/str(port), would you have offered a different solution
> if I had asked for the relative complement of a small set?
>
> a= ['a','b','c']
> b= ['b']
> c= a-b #set theoretic difference, a\b, a.~b, ['a','c']

If you want a set - just use a set:

py> a = set(['a','b','c'])
py> b = set(['b'])
py> c = a-b
py> c
set(['a', 'c'])

-- 
Gabriel Genellina




More information about the Python-list mailing list