Re: [Python-ideas] Python-ideas Digest, Vol 141, Issue 145
On Wed, 29 Aug 2018 at 13:26, Steven D'Aprano wrote: > > [steve@ando ~]$ pip install numpy > Collecting numpy > /usr/local/lib/python3.5/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:315: > SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject > Name Indication) extension to TLS is not available on this platform. > This may cause the server to present an incorrect TLS certificate, which > can cause validation failures. For more information, see > https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning. > SNIMissingWarning > Could not fetch URL https://pypi.python.org/simple/numpy/: There was a > problem confirming the ssl certificate: [SSL: > TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:645) > - skipping > Could not find a version that satisfies the requirement numpy (from > versions: ) > No matching distribution found for numpy > > > I'm sure pip is great, but honestly I've never been able to get it to > work reliably, ever, on four different machines using four different > Linux distros. >From the "For more information" link above, that seems to be related to your SSL support. The link says it happens with Python older than 2.7.9, but you seem to be getting a Python 3.5 site-packages. Did you build Python yourself? Maybe you have an old version of openssl somewhere. I've not seen this sort of error come up commonly, so I suspect there's something particular to how you have your environment(s) set up. However... > In any case, the answer "just use Numpy" isn't really relevant to the > question about adding new syntax. Indeed. And nor is discussion about pip issues, so I'll leave it there. If you want help getting pip to work, I'd suggest raising an issue on the pip tracker. Paul. ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
Re: [Python-ideas] Python-ideas Digest, Vol 141, Issue 145
On Wed, 29 Aug 2018 at 13:17, Oscar Benjamin wrote: > Scipy (on Windows) is a different story. There are Windows (and other platform) wheels for scipy 1.1.0 on PyPI, so that's easy too :-) Paul ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
Re: [Python-ideas] Python-ideas Digest, Vol 141, Issue 145
On Wed, Aug 29, 2018 at 01:15:46PM +0100, Oscar Benjamin wrote: > On Tue, 28 Aug 2018 at 08:12, Jacco van Dorp wrote: > > > > Op ma 27 aug. 2018 om 23:18 schreef James Lu : > >> > >> > As Matthew points out, you could use numpy.array. Or code your own > >> > class, by providing __add__ and __iadd__ methods. > >> > >> I could, but I don't think that justifies not having this functionality in > >> python > >> standard. From the language experience perspective, numpy is often a > >> pain to install on most systems. > > Numpy is easy to install: > > $ pip install numpy [steve@ando ~]$ pip install numpy Collecting numpy /usr/local/lib/python3.5/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning. SNIMissingWarning Could not fetch URL https://pypi.python.org/simple/numpy/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:645) - skipping Could not find a version that satisfies the requirement numpy (from versions: ) No matching distribution found for numpy I'm sure pip is great, but honestly I've never been able to get it to work reliably, ever, on four different machines using four different Linux distros. In any case, the answer "just use Numpy" isn't really relevant to the question about adding new syntax. -- Steve ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
Re: [Python-ideas] Python-ideas Digest, Vol 141, Issue 145
On Tue, 28 Aug 2018 at 08:12, Jacco van Dorp wrote: > > Op ma 27 aug. 2018 om 23:18 schreef James Lu : >> >> > As Matthew points out, you could use numpy.array. Or code your own >> > class, by providing __add__ and __iadd__ methods. >> >> I could, but I don't think that justifies not having this functionality in >> python >> standard. From the language experience perspective, numpy is often a >> pain to install on most systems. Numpy is easy to install: $ pip install numpy Should work on OSX, Windows and Linux. In all cases this should download a precompiled binary wheel. It used to be more difficult but improvements in packaging (wheels, manylinux etc) and the good work of the numpy folks have made this painless now. Scipy (on Windows) is a different story. -- Oscar ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
Re: [Python-ideas] Python-ideas Digest, Vol 141, Issue 145
Op ma 27 aug. 2018 om 23:18 schreef James Lu : > > As Matthew points out, you could use numpy.array. Or code your own > > class, by providing __add__ and __iadd__ methods. > > > > >>> import numpy > > >>> a = numpy.array([1, 2]) > > >>> b = numpy.array([3, 4]) > > >>> a + b > > array([4, 6]) > > >>> a += b > > >>> a > > array([4, 6]) > > I could, but I don't think that justifies not having this functionality in > python > standard. From the language experience perspective, numpy is often a > pain to install on most systems. If I'm designing card games and I > just want to run a quick monte carlo simulation, the experience should be > as smooth as possible. > > This is something I think most students will expect while learning python, > especially if they're implementing algorithms. > To be really honest, if you want to run it as "smooth as possible" you'll NEED numpy anyway. If you have an algoritmn of any significant mathematical complexity, numpy's Fortran implementation will beat out pure python easily. I don't have any experience with monte carlo simulations myself, but if you're doing this any significant amount of times you'll be better off creating a numpy array. And personally I just grab Anaconda. It knows how to install wherever, and includes numpy and a lot of other things you might need. If you want it smooth, for beginners, that'd be my first recommendation. (Actually, I started using it because I had trouble installing numpy stack on a new system back when I was a noob.) Most students learning python will probably be on windows, so just down loading an installer and clicking through it should be more than familiar for them. ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
Re: [Python-ideas] Python-ideas Digest, Vol 141, Issue 145
> As Matthew points out, you could use numpy.array. Or code your own > class, by providing __add__ and __iadd__ methods. > > >>> import numpy > >>> a = numpy.array([1, 2]) > >>> b = numpy.array([3, 4]) > >>> a + b > array([4, 6]) > >>> a += b > >>> a > array([4, 6]) I could, but I don't think that justifies not having this functionality in python standard. From the language experience perspective, numpy is often a pain to install on most systems. If I'm designing card games and I just want to run a quick monte carlo simulation, the experience should be as smooth as possible. This is something I think most students will expect while learning python, especially if they're implementing algorithms. On Mon, Aug 27, 2018 at 4:24 AM wrote: > Send Python-ideas mailing list submissions to > python-ideas@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://mail.python.org/mailman/listinfo/python-ideas > or, via email, send a message with subject or body 'help' to > python-ideas-requ...@python.org > > You can reach the person managing the list at > python-ideas-ow...@python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Python-ideas digest..." > > > Today's Topics: > >1. Re: Unpacking iterables for augmented assignment (Matthew Einhorn) >2. Re: Unpacking iterables for augmented assignment (Jonathan Fine) >3. Re: Pre-conditions and post-conditions (Jacco van Dorp) >4. Re: Pre-conditions and post-conditions (Ivan Levkivskyi) > > > -- > > Message: 1 > Date: Mon, 27 Aug 2018 01:29:14 -0400 > From: Matthew Einhorn > To: python-ideas@python.org > Subject: Re: [Python-ideas] Unpacking iterables for augmented > assignment > Message-ID: > ymm-fnyw3bza2hjqsgmdgtrvbua...@mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > On Sun, Aug 26, 2018, 9:24 PM James Lu wrote: > > > Hi Johnathan > > > > I echo your points. Indeed, the PEP referenced to refers to a "tuple > > expression" in the grammatical and not the programmatic sense. > > > > Finally, here's something that surprised me a little bit > > > > >>> x = [1, 2]; id(x) > > 140161160364616 > > >>> x += [3, 4]; id(x) > > 140161160364616 > > > > >>> x = (1, 2); id(x) > > 140161159928520 > > >>> x += (3, 4); id(x) > > 140161225906440 > > > > Notice that '+=' creates uses the same object when the object is > > a > > list, but creates a new object. This raises the question: Why and > > how > > does Python behave in this way? > > > > It's because lists are mutable are tuples are immutable. > > There's a dunder iadd method and a dunder add method. > > iadd magic methods, operating on the left hand side, return None and > > modify the object in-place. add magic methods return the result and > > don't modify the object it's called on. > > iadd is mutable add, whereas add is "return a copy with the result > > added" > > > > >>> tuple.__iadd__ > > Traceback (most recent call last): > > File "", line 1, in > > AttributeError: type object 'tuple' has no attribute '__iadd__' > > type object 'tuple' has no attribute '__iadd__' > > >>> tuple.__add__ > > > > >>> list.__iadd__ > > > > >>> list.__add__ > > > > > > > > tuple1 = tuple1.__add__(tuple2) > > > > list1.__iadd__(list2) > > > > > Does it IN PRACTICE bring sufficient benefits to users? > > > > I found myself needing this when I was writing a monte-carlo > > simulation in python that required incrementing a tallying counter > > from a subroutine. > > > > > Wouldn't a numpy array be very suited for this kind of task? > > > > -- next part -- > An HTML attachment was scrubbed... > URL: < > http://mail.python.org/pipermail/python-ideas/attachments/20180827/a1c698af/attachment-0001.html > > > > -- > > Message: 2 > Date: Mon, 27 Aug 2018 07:25:00 +0100 > From: Jonathan Fine > To: python-ideas > Subject: Re: [Python-ideas] Unpacking iterables for augmented > assignment > Message-ID: > yf9b7erxanbvbxz2ybjr4zleyv1tphv7+u3ebo2sw08...@mail.gmail.com> > Content-Type: text/plain; charset="UTF-8" > > James has suggested that Python be enhanced so that > >>> a, b += c, d > is a short-hand for > >>> a += c > >>> b += d > > Myself, James and Matthew wrote > > >> > Does it IN PRACTICE bring sufficient benefits to users? > > >> I found myself needing this when I was writing a monte-carlo > >> simulation in python that required incrementing a tallying counter > >> from a subroutine. > > > Wouldn't a numpy array be very suited for this kind of task? > > Perhaps, James, you might like to refactor your code so that > >>> tally += simulation(args) > does what you want. > > As Matthew points out, you could use numpy.array. Or code your own > class, by providing __add__ and __iadd__ methods. > > >>> import numpy > >>> a = numpy.array([1, 2]) > >>> b =