Re: A small quiz

2020-01-24 Thread Mario R. Osorio
On Thursday, January 23, 2020 at 3:54:56 AM UTC-5, Z wrote: > what is PLR? PLR: Private Label Rights (https://en.wikipedia.org/wiki/Private_label_rights) -- https://mail.python.org/mailman/listinfo/python-list

Re: Friday Finking: Enum by gum

2020-01-24 Thread Rhodri James
On 24/01/2020 04:26, DL Neil via Python-list wrote: Questions: Have I made proper sense of this? (please don't laugh too much) Um. My basic take on enums is that they provide a convenient namespace to collect together related constants. API flags and opcodes are an obvious example of relat

Threading

2020-01-24 Thread Matt
I am using this example for threading in Python: from threading import Thread def start_test( address, port ): print address, port sleep(1) for line in big_list: t = Thread(target=start_test, args=(line, 80)) t.start() But say big_list has thousands of items and I only want to h

Re: Threading

2020-01-24 Thread Chris Angelico
On Sat, Jan 25, 2020 at 7:35 AM Matt wrote: > > I am using this example for threading in Python: > > from threading import Thread > > def start_test( address, port ): > print address, port > sleep(1) > > for line in big_list: > t = Thread(target=start_test, args=(line, 80)) > t.sta

Re: Threading

2020-01-24 Thread Dan Sommers
On Sat, 25 Jan 2020 07:43:49 +1100 Chris Angelico wrote: > On Sat, Jan 25, 2020 at 7:35 AM Matt wrote: > > > > I am using this example for threading in Python: > > > > from threading import Thread > > > > def start_test( address, port ): > > print address, port > > sleep(1) > > > > for l

Re: Threading

2020-01-24 Thread Matt
So I would create 10 threads. And each would pop items off list like so? def start_test(): while big_list: list_item = big_list.pop() print list_item, port sleep(1) port = 80 for i = 1 to 10 t = Thread(target=start_test) t.start() t.join() Would that be t

Re: Threading

2020-01-24 Thread MRAB
On 2020-01-24 21:33, Matt wrote: So I would create 10 threads. And each would pop items off list like so? def start_test(): while big_list: list_item = big_list.pop() print list_item, port sleep(1) port = 80 for i = 1 to 10 t = Thread(target=start_test)

Re: Threading

2020-01-24 Thread Matt
Created this example and it runs. import time import threading big_list = [] for i in range(1, 200): big_list.append(i) def start_test(): while big_list: #is this list_item = big_list.pop() #and this thread safe print list_item, port time.sleep(1) print

Re: Threading

2020-01-24 Thread Chris Angelico
On Sat, Jan 25, 2020 at 9:05 AM Matt wrote: > > Created this example and it runs. > > import time > import threading > > big_list = [] > > for i in range(1, 200): > big_list.append(i) > > def start_test(): > while big_list: #is this > list_item = big_list.pop() #and this thread

Re: Threading

2020-01-24 Thread Cameron Simpson
First come remarks, then a different suggestion about your capacity problem (no more than 10). Details below. On 24Jan2020 16:03, Matt wrote: Created this example and it runs. [...] big_list = [] for i in range(1, 200): big_list.append(i) You can just go: big_list.extend(range(1,200

Re: Threading

2020-01-24 Thread Matt
> Not quite. > > 1. Create a list of threads. > > 2. Put the items into a _queue_, not a list. > > 3. Start the threads. > > 4. Iterate over the list of threads, using .join() on each. > > If you're going to start the threads before you've put all of the items > into the queue, you can also put a

Re: A small quiz

2020-01-24 Thread boB Stepp
On Thu, Jan 23, 2020 at 2:57 AM Z wrote: > > what is PLR? Python Language Reference? https://docs.python.org/3/reference/index.html Or, perhaps, Python Library Reference? https://docs.python.org/3/library/index.html -- boB -- https://mail.python.org/mailman/listinfo/python-list