Re: [Tutor] Sets question

2017-04-27 Thread Phil
On Thu, 27 Apr 2017 11:49:55 +0200 Peter Otten <__pete...@web.de> wrote: > I'd like to bring to your attention the discard() method > > >>> s = {1, 2, 3} > >>> s.discard(int(v)) > >>> s > {2, 3} > > which allows you to avoid building the throwaway single-entry set. Thank you Peter. I have been

Re: [Tutor] Sets question

2017-04-27 Thread Peter Otten
Phil wrote: > Another question I'm afraid. > > If I want to remove 1 from a set then this is the answer: > > set([1,2,3]) - set([1]) > > I had this method working perfectly until I made a change to cure another > bug. > > So, I have a set represented in the debugger as {1,2,3} and again I want

Re: [Tutor] Sets question

2017-04-27 Thread Mats Wichmann
On 04/26/2017 06:33 PM, Phil wrote: > Another question I'm afraid. > > If I want to remove 1 from a set then this is the answer: > > set([1,2,3]) - set([1]) > > I had this method working perfectly until I made a change to cure another bug. > > So, I have a set represented in the debugger as {1,

Re: [Tutor] Sets question

2017-04-26 Thread Phil
On Thu, 27 Apr 2017 01:58:39 + eryk sun wrote: > That exception indicates you probably used set(int(num)) instead of > either {int(num)} or set([int(num)]). Thank you Eryl, you are correct. Problem solved. -- Regards, Phil ___ Tutor maillist -

Re: [Tutor] Sets question

2017-04-26 Thread boB Stepp
On Wed, Apr 26, 2017 at 8:34 PM, Phil wrote: > On Wed, 26 Apr 2017 18:56:40 -0600 > Mats Wichmann wrote: > >> On 04/26/2017 06:33 PM, Phil wrote: >> > Another question I'm afraid. >> > >> > If I want to remove 1 from a set then this is the answer: >> > >> > set([1,2,3]) - set([1]) >> > >> > I had

Re: [Tutor] Sets question

2017-04-26 Thread eryk sun
On Thu, Apr 27, 2017 at 1:34 AM, Phil wrote: > I did try {int(num)} but that resulted in an error that said something along > the lines of int not being iterable. I'll have another look at that idea. That exception indicates you probably used set(int(num)) instead of either {int(num)} or set([int

Re: [Tutor] Sets question

2017-04-26 Thread Phil
On Wed, 26 Apr 2017 18:56:40 -0600 Mats Wichmann wrote: > On 04/26/2017 06:33 PM, Phil wrote: > > Another question I'm afraid. > > > > If I want to remove 1 from a set then this is the answer: > > > > set([1,2,3]) - set([1]) > > > > I had this method working perfectly until I made a change to

Re: [Tutor] Sets question

2017-04-26 Thread eryk sun
On Thu, Apr 27, 2017 at 12:33 AM, Phil wrote: > Another question I'm afraid. > > If I want to remove 1 from a set then this is the answer: > > set([1,2,3]) - set([1]) You can also use set literals here, with the caveat that {} is ambiguous, and Python chooses to make it an empty dict instead of a

Re: [Tutor] Sets question

2017-04-26 Thread boB Stepp
On Wed, Apr 26, 2017 at 7:33 PM, Phil wrote: > Another question I'm afraid. > > If I want to remove 1 from a set then this is the answer: > > set([1,2,3]) - set([1]) > > I had this method working perfectly until I made a change to cure another bug. > > So, I have a set represented in the debugger

[Tutor] Sets question

2017-04-26 Thread Phil
Another question I'm afraid. If I want to remove 1 from a set then this is the answer: set([1,2,3]) - set([1]) I had this method working perfectly until I made a change to cure another bug. So, I have a set represented in the debugger as {1,2,3} and again I want to remove the one. Only this ti