Re: testing code

2018-07-07 Thread Jim Lee
On 07/07/18 21:21, Sharan Basappa wrote: sorry. there was a copy paste error when i posted. I pasted test_2.py for both the files: here are the files again. The issue remains. [...] output: %run "D:/Projects/Initiatives/machine learning/programs/test_2_test.py" 30 [11:24 PM jlee@kerndev ~

Re: testing code

2018-07-07 Thread Sharan Basappa
On Saturday, 7 July 2018 18:22:23 UTC+5:30, Chris Angelico wrote: > On Sat, Jul 7, 2018 at 10:02 PM, Sharan Basappa > wrote: > > On Friday, 6 July 2018 09:22:31 UTC+5:30, Chris Angelico wrote: > >> On Fri, Jul 6, 2018 at 12:56 PM, Sharan Basappa > >> wrote: > >> > Please let me know if the foll

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-07 Thread Chris Angelico
On Sun, Jul 8, 2018 at 1:58 PM, Steven D'Aprano wrote: > On Sun, 08 Jul 2018 12:23:41 +1000, Chris Angelico wrote: > >>> Some people, when confronted with a problem, say, "I know, I'll use >>> threads". Nothhtwo probw ey ave lems. >> >> Right. Now they have to deal with interleaving, but that's al

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-07 Thread Steven D'Aprano
On Sun, 08 Jul 2018 12:23:41 +1000, Chris Angelico wrote: >> Some people, when confronted with a problem, say, "I know, I'll use >> threads". Nothhtwo probw ey ave lems. > > Right. Now they have to deal with interleaving, but that's all. And > honestly, MOST CODE wouldn't notice interleaving; it'

Re: Generate a static back-of-a-book style index?

2018-07-07 Thread Cameron Simpson
On 07Jul2018 21:57, Tim Chase wrote: On 2018-07-08 12:12, Cameron Simpson wrote: On 07Jul2018 20:11, Skip Montanaro wrote: >> Have you looked at the ptx command? Might be called "gptx" > >Thanks, Cameron. I was unaware of it. Will check it out. BTW, it well predates the GNU coreutils; I used

Re: Matplotlib 3D limitations, please recommend alternative

2018-07-07 Thread John Ladasky
On Saturday, July 7, 2018 at 6:36:16 AM UTC-7, Rick Johnson wrote: > John Ladasky wrote: > > > Back then I wrote: > > > > "I have concluded that Qt, PyQt, and OpenGL are all > > rapidly-evolving, and huge, software packages. There may > > be compatibility problems, and relevant examples with the

Re: Generate a static back-of-a-book style index?

2018-07-07 Thread Tim Chase
On 2018-07-08 12:12, Cameron Simpson wrote: > On 07Jul2018 20:11, Skip Montanaro wrote: > >> Have you looked at the ptx command? Might be called "gptx" > > > >Thanks, Cameron. I was unaware of it. Will check it out. > > BTW, it well predates the GNU coreutils; I used it on V7 UNIX. Interesti

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-07 Thread Chris Angelico
On Sun, Jul 8, 2018 at 12:12 PM, Steven D'Aprano wrote: > On Sun, 08 Jul 2018 11:15:17 +1000, Chris Angelico wrote: > > [...] >> Python threads don't switch only between lines of code, > > As I understand it, there could be a switch between any two byte codes, > or maybe only between certain bytes

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-07 Thread Steven D'Aprano
On Sun, 08 Jul 2018 11:15:17 +1000, Chris Angelico wrote: [...] > Python threads don't switch only between lines of code, As I understand it, there could be a switch between any two byte codes, or maybe only between certain bytes codes. But certain more fine grained than just between lines of

Re: Generate a static back-of-a-book style index?

2018-07-07 Thread Cameron Simpson
On 07Jul2018 20:11, Skip Montanaro wrote: Have you looked at the ptx command? Might be called "gptx" on a system with the GNU coreutils installed with "g" prefixes. Thanks, Cameron. I was unaware of it. Will check it out. BTW, it well predates the GNU coreutils; I used it on V7 UNIX. Nicely,

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-07 Thread Chris Angelico
On Sun, Jul 8, 2018 at 11:04 AM, Steven D'Aprano wrote: >> The only thing Python should guarantee is that the data structures stay >> "coherent" under race conditions. In other words, there cannot be a >> segmentation fault. For example, if two threads executed this code in >> parallel: >> >>

Re: Generate a static back-of-a-book style index?

2018-07-07 Thread Skip Montanaro
> Have you looked at the ptx command? Might be called "gptx" on a system with > the > GNU coreutils installed with "g" prefixes. Thanks, Cameron. I was unaware of it. Will check it out. Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-07 Thread Steven D'Aprano
On Sun, 08 Jul 2018 00:00:26 +0300, Marko Rauhamaa wrote: > Ian Kelly : >> the leaning of the devs seems to be to refrain from documenting it and >> instead document that *no* operations are guaranteed atomic. > > I believe that to be wise. Otherwise, Python would limit its future > implementatio

Re: Generate a static back-of-a-book style index?

2018-07-07 Thread Cameron Simpson
On 07Jul2018 18:24, Skip Montanaro wrote: I just generated a static website which is nothing more than around ten years of email messages from a defunct vintage bike mailing list (170k messages, one per file). Though I've submitted the front page URL to both Google and Bing, I was thinking that

Generate a static back-of-a-book style index?

2018-07-07 Thread Skip Montanaro
I just generated a static website which is nothing more than around ten years of email messages from a defunct vintage bike mailing list (170k messages, one per file). Though I've submitted the front page URL to both Google and Bing, I was thinking that it would be handy to have something like a st

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-07 Thread Marko Rauhamaa
Ian Kelly : > the leaning of the devs seems to be to refrain from documenting it and > instead document that *no* operations are guaranteed atomic. I believe that to be wise. Otherwise, Python would limit its future implementation options. The only thing Python should guarantee is that the data s

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-07 Thread Ethan Furman
On 07/06/2018 10:51 AM, INADA Naoki wrote: > On Sat, Jul 7, 2018 at 2:49 AM Steven D'Aprano wrote: >> I have a dict with string keys: >> >> --> D = {'a': None, 'b': None} >> How do I do a thread-safe insertion if, and only if, the key isn't >> already there? > D.setdefault('c', None) This is

Fwd: SSLContext.load_verify_locations

2018-07-07 Thread Joseph Netti (RIT Student)
Hi, I think I found either a bug in the documentation or a bug in the load_verify_locations function (or I am just using the function wrong). https://docs.python.org/3/library/ssl.html#ssl.SSLContext. load_verify_locations I am trying to use crls with the ssl.py library which according to the do

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-07 Thread Ian Kelly
On Fri, Jul 6, 2018 at 11:56 AM INADA Naoki wrote: > > D.setdefault('c', None) Not guaranteed to be atomic. I think the only safe way to do it is with a Lock. -- https://mail.python.org/mailman/listinfo/python-list

Re: about main()

2018-07-07 Thread Gene Heskett
On Friday 06 July 2018 14:27:16 Grant Edwards wrote: > On 2018-07-06, Gene Heskett wrote: > > In that case, I hate to say it, but your education is sorely lacking > > in the fundamentals. Smelting for instance was discussed at length > > in the high school physics books I was reading by the time

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-07 Thread Devin Jeanpierre
On Sat, Jul 7, 2018 at 6:49 AM Marko Rauhamaa wrote: > Is that guaranteed to be thread-safe? The documentation ( s://docs.python.org/3/library/stdtypes.html#dict.setdefault>) makes no > such promise. It's guaranteed to be thread-safe because all of Python's core containers are thread safe (in as

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-07 Thread Ian Kelly
On Sat, Jul 7, 2018 at 8:03 AM Stefan Behnel wrote: > > Marko Rauhamaa schrieb am 07.07.2018 um 15:41: > > Steven D'Aprano : > >> On Sat, 07 Jul 2018 02:51:41 +0900, INADA Naoki wrote: > >>> D.setdefault('c', None) > >> > >> Oh that's clever! > > > > Is that guaranteed to be thread-safe? The docum

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-07 Thread Stefan Behnel
Marko Rauhamaa schrieb am 07.07.2018 um 15:41: > Steven D'Aprano : >> On Sat, 07 Jul 2018 02:51:41 +0900, INADA Naoki wrote: >>> D.setdefault('c', None) >> >> Oh that's clever! > > Is that guaranteed to be thread-safe? The documentation ( s://docs.python.org/3/library/stdtypes.html#dict.setdefault

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-07 Thread Marko Rauhamaa
Steven D'Aprano : > On Sat, 07 Jul 2018 02:51:41 +0900, INADA Naoki wrote: >> D.setdefault('c', None) > > Oh that's clever! Is that guaranteed to be thread-safe? The documentation () makes no such promise. At least __collectios_abc.py contains this method definition for MutableMapping: def s

Re: testing code

2018-07-07 Thread Chris Angelico
On Sat, Jul 7, 2018 at 10:02 PM, Sharan Basappa wrote: > On Friday, 6 July 2018 09:22:31 UTC+5:30, Chris Angelico wrote: >> On Fri, Jul 6, 2018 at 12:56 PM, Sharan Basappa >> wrote: >> > Please let me know if the following understanding of mine is correct. >> > I need to put the program code in

Re: testing code

2018-07-07 Thread Sharan Basappa
On Friday, 6 July 2018 09:22:31 UTC+5:30, Chris Angelico wrote: > On Fri, Jul 6, 2018 at 12:56 PM, Sharan Basappa > wrote: > > Please let me know if the following understanding of mine is correct. > > I need to put the program code in a separate file and organize every > > executable code in som

Re: SWIG+Distutils - no harmony?

2018-07-07 Thread ruifernqq
Em terça-feira, 15 de janeiro de 2002 21:26:05 UTC+1, Martin Bless escreveu: > Getting courageous I try building 'example.pyd' > from the SWIG 'Simple Example' using SWIG and the Distutils. > Looks promising but doesn't succeed. I didn't > modify 'example.c' and 'example.i'. > > Problems/questio

Re: Looking for a recent quote about dynamic typing, possibly on this list

2018-07-07 Thread Stefan Behnel
Ben Finney schrieb am 07.07.2018 um 03:38: > Steven D'Aprano writes: > >> Somebody gave a quote about dynamic typing, along the lines of >> >> "Just because a language allows a lot of dynamic features, doesn't mean >> people's code uses a lot of dynamism." > > You did refer us to http://lambda-