Re: Why does __ne__ exist?
> Let's put it this way. Suppose that __eq__ existed and __ne__ didn't, > just like with __contains__. Go ahead: sell the notion of __ne__. > Pitch it, show why we absolutely need to allow this. Make sure you > mention the potential confusion when subclassing. Be sure to show why > it's okay for "not in" to force to boolean but "==" should allow any > return value. __ne__ and __eq__ are important for building mask arrays in NumPy, which allow complex indexing operations. A lot of NumPy's design was inspired by MATLAB, so being able to index the same way as in MATLAB is a pretty killer feature. Indexing an array using mask arrays like this is idiomatic: some_arr = np.array([-1, 0, 1, 2, 3, 4, 5, 2, -1, 3, -1, 6, 7, 3]) valid = some_arr[some_arr != -1] Anybody with familiarity with NumPy appreciates that this is possible. I imagine that ORMs like Django or SqlAlchemy also override __ne__ to provide nice APIs. Finally (and perhaps least imporant), there is a performance hit if only allowing __eq__ and then taking its inverse. Cody -- https://mail.python.org/mailman/listinfo/python-list
[issue31503] Enhance dir(module) to be informed by __all__ by updating module.__dir__
New submission from Cody Piersall: If a some_module defines __all__, dir(some_module) should only return what is in __all__. This is already a mechanism that Python provides to specify module-level APIs. Currently, dir(some_module) returns some_module.__dict__.keys(). The concern with this enhancement is backwards compatibility. It is conceivable that some library's code would be broken with the different return value of dir(some_module). However, it seems unlikely that any code, other than tests, depends on the current behavior of dir(some_module). If __all__ is not defined in some_module, the old behavior is preserved. -- messages: 302404 nosy: codypiersall priority: normal pull_requests: 3631 severity: normal status: open title: Enhance dir(module) to be informed by __all__ by updating module.__dir__ type: enhancement versions: Python 3.7 ___ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31503> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: fastest way to read a text file in to a numpy array
On Tue, Jun 28, 2016 at 8:45 AM, Heliwrote: > Hi, > > I need to read a file in to a 2d numpy array containing many number of lines. > I was wondering what is the fastest way to do this? > > Is even reading the file in to numpy array the best method or there are > better approaches? > numpy.genfromtxt[1] is a pretty robust function for reading text files. If you're generating the file from a numpy array already, you should use arr.save()[2] and numpy.load()[3]. [1]: http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html [2]: http://docs.scipy.org/doc/numpy/reference/generated/numpy.save.html [3]: http://docs.scipy.org/doc/numpy/reference/generated/numpy.load.html Cody -- https://mail.python.org/mailman/listinfo/python-list
Re: psss...I want to move from Perl to Python
On Fri, Jan 29, 2016 at 2:42 PM, Fillmorewrote: > I actually have a few followup question. > - will iNotebook also work in Python 3? Yes! And just FYI, it's called they Jupyter Notebook now, but pretty much everyone still (colloquially) calls it the IPython Notebook so you're in good company. When you're searching online, you should search for Jupyter though, or you might get obsolete docs. > - What version of Python 3 do you recommend I install on Windows? Might as well go for Python 3.5. > [snip questions I don't know the answer to] > - Is there a good IDE that can be used for debugging? all free IDEs for Perl suck and it would be awesome if Python was better than that. PyCharm is a really good IDE. You can use the community edition for free as long as it's for open source projects or your company makes less than $1 million a year. For bigger projects I use PyCharm, but it's not bad to use just a plain text editor either. If your company is making $1 million a year, presumably they can afford the license fees. Download link: https://www.jetbrains.com/pycharm/download/ Cody -- https://mail.python.org/mailman/listinfo/python-list
Re: Question about how to do something in BeautifulSoup?
On Fri, Jan 22, 2016 at 8:01 AM, inhahewrote: > Say I have the following HTML (I hope this shows up as plain text here > rather than formatting): > > "Is > today the day?" > > And I want to extract the "Is today the day?" part. There are other places > in the document with and , but this is the only place that > uses color #00, so I want to extract anything that's within a color > #00 style, even if it's nested multiple levels deep within that. > > - Sometimes the color is defined as RGB(0, 0, 0) and sometimes it's defined > as #00 > - Sometimes the is within the and sometimes the is > within the . > - There may be other discrepancies I haven't noticed yet > > How can I do this in BeautifulSoup (or is this better done in lxml.html)? I hope this helps you get started: This may help you get started: from bs4 import BeautifulSoup from itertools import chain soup = BeautifulSoup('''\ "Is today the day?" "Is tomorrow the day?"''') # We're going to get all the tags that specify the color, either using hex or RGB. # If you only want to get the span tags, just give the positional argument 'span' to # find_all: # for tag in chain(soup.find_all('span', style='color: #00;'), # soup.find_all('span', style='color: RGB(0, 0, 0);')): for tag in chain(soup.find_all(style='color: #00;'), soup.find_all(style='color: RGB(0, 0, 0);')): try: print(tag.em.strong.text) except AttributeError: try: print(tag.strong.em.text) except AttributeError: print('ooh no no text') Cody -- https://mail.python.org/mailman/listinfo/python-list
Re: Post processing contour plot, how?
Sorry for the short response, but check out this Stack Overflow question/answer http://stackoverflow.com/q/5666056/1612701 On Thu, Jan 14, 2016 at 3:42 PM, Martin Schöönwrote: > I am interested in creating contours but not for printing or > including in a report as an illustration. I want to go on > working on a numerical representation of the contours. > > Creating contour plots using matplotlib is a breeze but I fail > to find a way to export the contours thus created in a numerical > format. Scilab has such a function but I try to reduce the number > of tools I use and I try to focus on Python. > > So, I could write my own find-contours algorithm but I think > there should be a way of extracting the contours created by > matplotlib even if I have failed to find out how. > > Does anyone know how to do this? > > I have found one very manually involved way starting with > saving the figure in svg format and the open that file in > a text editor. > > /Martin > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: licenses
On Fri, Jan 8, 2016 at 1:41 PM, Martinez, Jorge Alberto (GE Aviation) < jorgealberto.marti...@ge.com> wrote: > > Hello > We develop applications here with Python and I want to know if there's issues by using. > We use NumPy, PyDaqMx, Py Visa > > How can we cover this licensing? I am not a lawyer, and this is not legal advice. * NumPy is BSD-licensed, which means you can use NumPy in a commercial product as long as you include its license. * PyDAQmx is BSD-licensed as well. (You can find that information in their GitHub repository's README, https://github.com/clade/PyDAQmx) * Py Visa is MIT licensed (info on their GitHub: https://github.com/hgrecco/pyvisa/blob/master/LICENSE), which means you can also use it in your software as long as you include the license. For summaries of lots of licenses, you can look at tldrlegal.com. * BSD license: https://tldrlegal.com/license/bsd-3-clause-license-(revised) * MIT license: https://tldrlegal.com/license/mit-license It's never a bad idea to consult a lawyer. Since you work for GE, I would imagine there is an army of lawyers happy to answer this question at your disposal. Finding out how to talk to them might be the hard part. Cody -- https://mail.python.org/mailman/listinfo/python-list
Re: Bug in Python 3.5.1
On Wed, Dec 23, 2015 at 6:57 PM,wrote: > Dear Sir, >In the future, can you kindly include numpy, scipy, and pygame as part of >the Python release? >Nick Srinivasan Hello Nick, Any time you want to install a Python package, the first thing you should try is typing "pip install [package-name]". If that doesn't work (and it often doesn't), you should check [Christoph Golke's website] for the package you're trying to install. If you want to download Python and have numpy, scipy, and Python in one installer, I recommend using [Anaconda]. You will still have to download pygame yourself (I think). Anaconda is a pretty big download, but the plus side is that it comes with lots of packages so probably won't have to install as much stuff. There is no way that numpy, scipy, and pygame will become a part of the Python release; that's why redistributors like Anaconda exist. [Anaconda]: https://www.continuum.io/downloads#_windows [Christoph Golke's website]: http://www.lfd.uci.edu/~gohlke/pythonlibs/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Need Help w. PIP!
On Sat, Sep 5, 2015 at 3:14 AM, Thomas 'PointedEars' Lahn < pointede...@web.de> wrote: > > Cody Piersall wrote: > > > Please respond to the list as well as the person you're actually talking > > to. It works out better for everyone that way. (You should just have to > > "reply all" instead of "reply"). > > “Better” as in “getting/reading/downloading the same message *twice*”? > > The rule of thumb is: write here, read here. Some people email the list, but aren't subscribed to it. So I guess a better rule is to just reply-to-all for the OP? Cody -- https://mail.python.org/mailman/listinfo/python-list
Re: Need Help w. PIP!
On Fri, Sep 4, 2015 at 11:04 AM, Steve Burruswrote: > > Well I think that this is a Win 10 "thing" befcause using previous versions of Windows all I had to do was to type in "pip" to get the pip info. but now apparently it's "python -m pip". Can someone please "set me straight" about the path I should be using if I have a "pathing" problem? If you installed Python to the default location, you should be able to find pip at "C:\Python34\Scripts\pip.exe". If you type "C:\Python34\Scripts\pip.exe" at the command prompt, you should be able to find pip. It seems pretty likely that your system path does not include that folder. You need to add that directory to your path if you want to be able to just type "pip". Cody -- https://mail.python.org/mailman/listinfo/python-list
Re: Need Help w. PIP!
On Fri, Sep 4, 2015 at 12:50 PM, Steve Burruswrote: > > "Do you have pip.exe in C:\Python34\Scripts?" well I remember seeing it in thar folder the other day but not now! D oes this mean I have to re-install python or just pip? Please respond to the list as well as the person you're actually talking to. It works out better for everyone that way. (You should just have to "reply all" instead of "reply"). You just need to reinstall pip: type python -m pip install --upgrade pip and you're set. Cody -- https://mail.python.org/mailman/listinfo/python-list
Re: Need Help w. PIP!
On Fri, Sep 4, 2015 at 11:54 AM, Steve Burrus <steveburru...@gmail.com> wrote: > I mcan assure you that the Scripts folder is in both my Users and the System path! I even haVE the folder "C:\Python34\lib\site-packages\django\bin" in the Path. But I still cannot simply type out "pip" without getti ng the usual error message! > > On Fri, Sep 4, 2015 at 11:35 AM, Cody Piersall <cody.piers...@gmail.com> wrote: >> If you installed Python to the default location, you should be able to find pip at "C:\Python34\Scripts\pip.exe". If you type "C:\Python34\Scripts\pip.exe" at the command prompt, you should be able to find pip. It seems pretty likely that your system path does not include that folder. You need to add that directory to your path if you want to be able to just type "pip". >> >> Cody > > (Responding on-list) I know you keep assuring us that your path is great, but we're not going to stop talking about it until you prove it to us, unfortunately. If you do this, you will prove it to us. In cmd, type "echo %PATH%", and then copy and paste both the command and the output. Like this: D:\Dropbox (Univ. of Oklahoma)\toshiba\hail\data>echo %PATH% C:\tools\ConEmu\ConEmu;C:\tools\ConEmu;C:\ProgramData\Oracle\Java\javapath;C:\tools;C:\MinGW\msys\1.0\bin;C:\MinGW\bin;C:\Python34\;C:\Python34\Scripts;C:\Python27\;C:\Python27\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin\;C:\Program Files\IVI Foundation\VISA\Win64\Bin\;C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin;C:\Program Files (x86)\IVI Foundation\IVI\bin;C:\Program Files\IVI Foundation\IVI\bin;C:\Program Files\TortoiseHg\;C:\Program Files (x86)\Git\cmd;C:\Program Files\MATLAB\R2014b\runtime\win64;C:\Program Files\MATLAB\R2014b\bin;C:\HashiCorp\Vagrant\bin;C:\Program Files (x86)\NSIS;C:\MinGW\msys\1.0;;C:\Program Files (x86)\Heroku\bin;C:\Program Files (x86)\git\cmd;C:\Users\pier3595\AppData\Local\atom\bin While you're at it, go ahead and type "pip" and show us the output of that too. Use copy and paste to do it. If you're not sure how to copy and paste with cmd, follow the instructions here: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/windows_dos_copy.mspx?mfr=true -- https://mail.python.org/mailman/listinfo/python-list
Re: Need Help w. PIP!
On Fri, Sep 4, 2015 at 12:40 PM, Steve Burruswrote: > > "C:\Python34\Tools\Scripts>python checkpip.py > The latest version of setuptools on PyPI is 18.2, but ensurepip has 12.0.5 > The latest version of pip on PyPI is 7.1.2, but ensurepip has 6.0.8" > > I ran this pythpon file, checkpip.py, and got the results above. Does that contribute to my inability to type "pip" normally? > Nah, I get the same thing. > On Fri, Sep 4, 2015 at 12:22 PM, Steve Burrus wrote: >> >> well I jhave already done this for Nick [Sarbicki] but here is the result of echo %path% : >> >> "echo %path% >> >> C:\Python34;C:\Python34\python.exe;C:\Python34\Scripts;C:\Python34\Lib\site-packages\django\bin;C:\oraclexe\app\oracle\product\11.2.0\server\bin;C:\ProgramData\Oracle\Java\javapath;C:\Users\SteveB;C:\Users\SteveB;C:\OracleInst\app\oracle\product\11.2.0\server\bin;C:\Program Files\Broadcom\Broadcom 802.11\Driver;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;c:\Program Files (x86)\AMD APP\bin\x86_64;c:\Program Files (x86)\AMD APP\bin\x86;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Common Files\Roxio Shared\12.0\DLLShared\ ;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Go\bin;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files\Google\Cloud SDK\google-cloud-sdk\bin;C:\Users\SteveB\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\bin;C:\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\Brackets\command;C:\Program Files (x86)\Subversion\bin;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5.4 >> >> Steve Burrus Your path looks right to me. Do you have pip.exe in C:\Python34\Scripts? Cody -- https://mail.python.org/mailman/listinfo/python-list
Re: [a,b,c,d] = 1,2,3,4
On Tue, Aug 25, 2015 at 9:16 AM, ast nom...@invalid.com wrote: [a,b,c,d] = 1,2,3,4 a 1 b 2 c 3 d 4 I have never seen this syntax before. Is it documented. Is there a name for that ? thx -- https://mail.python.org/mailman/listinfo/python-list That's called sequence unpacking Cody -- https://mail.python.org/mailman/listinfo/python-list
[issue24679] Windows embeddable Python zip file crashes (cannot find a dll)
Cody Piersall added the comment: Agreed. An ounce of data is worth a pound of theory as the saying goes. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24679] Windows embeddable Python zip file crashes (cannot find a dll)
New submission from Cody Piersall: Whenever I tried to run the embeddable zip file from https://www.python.org/downloads/windows/ for Python 3.5.0b3, the program crashes with the message The program can't start because api-ms-win-crt-math-l1-1-0.dll is missing from your computer. Try reinstalling the program to fix this problem. I suspect that this happens because I don't have any version of Visual Studio on my computer, but I'm not sure what causes it. It happens with both the 32-bit and 64-bit zip file. Steps to reproduce: 1. Download the zip file https://www.python.org/ftp/python/3.5.0/python-3.5.0b3-embed-win32.zip 2. Extract the contents 3. Click on the Python executable 4. Do not have Visual Studio installed on your computer I am running Windows 7 Enterprise, 64-bit I have attached a screenshot of the error message. -- files: bug.PNG messages: 247063 nosy: Cody Piersall, steve.dower priority: normal severity: normal status: open title: Windows embeddable Python zip file crashes (cannot find a dll) Added file: http://bugs.python.org/file39969/bug.PNG ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24679] Windows embeddable Python zip file crashes (cannot find a dll)
Cody Piersall added the comment: Yeah, having embeddable in the name is a good hint, I think. It was almost enough for me to not even try downloading it. Is it possible / even worth the time to give a more helpful error message? I'm not sure that it's possible, based on when the dll is laoded, or if it were possible whether it's worth doing. It might require more code than it's worth to maintain. You'd have to... 1. In the main function in C, check whether you're running the embedded Python (probably with an #ifdef) 2. If so, check that the required CRT is found (which probably requires _another_ #ifdef for 32/64 bit, and maybe Python version) 3. If it isn't found, create a message box using the Windows API explaining the problem. Which may require including the GUI libraries into the Python executable, and I don't think those are small things. I'm not sure if that is either possible or desirable, though. Or if what I explained would even work; I'm not sure if the DLLs are loaded right when the executable starts, or only as needed whenever functions from the DLLs are called. And I have _no_ idea how to check for the presence of the CRT. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24679] Windows embeddable Python zip file crashes (cannot find a dll)
Changes by Cody Piersall cody.piers...@gmail.com: -- components: +Windows nosy: +paul.moore, tim.golden, zach.ware type: - crash ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24679] Windows embeddable Python zip file crashes (cannot find a dll)
Cody Piersall added the comment: Ah! That makes sense. I still think the embeddable Python could be useful, but I don't actually have a vested interest in it at the moment. Mostly I feel like it would be useful if Python is an implementation detail of an application, and you want to make sure that the user of your application doesn't mess up the Python installation. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com