Re: mixing set and list operations

2015-04-30 Thread Tim
On Thursday, April 30, 2015 at 1:05:05 PM UTC-4, Ben Finney wrote: > Tim writes: > > You can use 'extend' to add set elements to a list and use 'update' to > > add list elements to a set. > > And you can use both of those methods to add items from a file:: > > >>> foo = ['one', 'two'] > >

Re: mixing set and list operations

2015-04-30 Thread Ben Finney
Tim writes: > You can use 'extend' to add set elements to a list and use 'update' to > add list elements to a set. And you can use both of those methods to add items from a file:: >>> foo = ['one', 'two'] >>> bar = open('/usr/share/common-licenses/GPL-3') >>> foo.extend(bar) >>>

Re: mixing set and list operations

2015-04-30 Thread Carl Meyer
Hi Tim, On 04/30/2015 10:07 AM, Tim wrote: > I noticed this today, using Python2.7 or 3.4, and wondered if it is > implementation dependent: > > You can use 'extend' to add set elements to a list and use 'update' to add > list elements to a set. > m = ['one', 'two'] p = set(['three',

Re: mixing set and list operations

2015-04-30 Thread Ian Kelly
On Thu, Apr 30, 2015 at 10:07 AM, Tim wrote: > I noticed this today, using Python2.7 or 3.4, and wondered if it is > implementation dependent: > > You can use 'extend' to add set elements to a list and use 'update' to add > list elements to a set. It's not implementation dependent. Both methods