numpy array operation
Is there a numpy operation that does the following to the array? 1 2 == 4 3 3 4 2 1 Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: numpy array operation
C. Ng wrote: Is there a numpy operation that does the following to the array? 1 2 == 4 3 3 4 2 1 How about a array([[1, 2], [3, 4]]) a[::-1].transpose()[::-1].transpose() array([[4, 3], [2, 1]]) Or did you mean a.reshape((4,))[::-1].reshape((2,2)) array([[4, 3], [2, 1]]) Or even -a + 5 array([[4, 3], [2, 1]]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Further evidence that Python may be the best language forever
hi Stefan, * Stefan Behnel stefan...@behnel.de [2013-01-29 08:00]: Michael Torrie, 29.01.2013 02:15: On 01/28/2013 03:46 PM, Malcolm McCrimmon wrote: My company recently hosted a programming competition for schools across the country. One team made it to the finals using the Python client, one of the four default clients provided (I wrote it). Most of the other teams were using Java or C#. Guess which team won? http://www.windward.net/codewar/2013_01/finals.html We did a similar (although way smaller) contest once at a university. The task was to write a network simulator. We had a C team, a Java team and a Python team, four people each. The Java and C people knew their language, the Python team just started learning it. The C team ended up getting totally lost and failed. The Java team got most things working ok and passed. The Python team got everything working, but additionally implemented a web interface for the simulator that monitored and visualised its current state. They said it helped them with debugging. quite interesting! I'd liked to see the code is it available for 'download'? thx Michael What language was the web page hosted in? It comes up completely blank for me. :) Yep, same here. Hidden behind a flash wall, it seems. Stefan -- http://mail.python.org/mailman/listinfo/python-list -- Michael Poeltl Computational Materials Physics voice: +43-1-4277-51409 Univ. Wien, Sensengasse 8/12 fax: +43-1-4277-9514 (or 9513) A-1090 Wien, AUSTRIA cmp.mpi.univie.ac.at --- slackware-13.37 | vim-7.3 | python-3.2.3 | mutt-1.5.21 | elinks-0.12 --- -- http://mail.python.org/mailman/listinfo/python-list
Re: numpy array operation
On Tuesday, January 29, 2013 3:41:54 AM UTC-5, C. Ng wrote: Is there a numpy operation that does the following to the array? 1 2 == 4 3 3 4 2 1 Thanks in advance. import numpy as np a=np.array([[1,2],[3,4]]) a array([[1, 2], [3, 4]]) np.fliplr(np.flipud(a)) array([[4, 3], [2, 1]]) -- http://mail.python.org/mailman/listinfo/python-list
[os.path.join(r'E:\Python', name) for name in []] returns []
why [os.path.join(r'E:\Python', name) for name in []] returns [] ? please explain it in detail ! -- http://mail.python.org/mailman/listinfo/python-list
Re: [os.path.join(r'E:\Python', name) for name in []] returns []
On Wed, Jan 30, 2013 at 12:21 AM, iMath redstone-c...@163.com wrote: why [os.path.join(r'E:\Python', name) for name in []] returns [] ? please explain it in detail ! That's a list comprehension. If you're familiar with functional programming, it's like a map operation. Since the input list (near the end of the comprehension, just inside its square brackets) is empty, so is the result list, and os.path.join is never called. I've given you a massive oversimplification. The docs are here: http://docs.python.org/3.3/tutorial/datastructures.html#list-comprehensions Pro tip: The docs are there before you ask the question, too. You might find it faster to search them than to ask and wait for an answer :) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: [os.path.join(r'E:\Python', name) for name in []] returns []
- Original Message - why [os.path.join(r'E:\Python', name) for name in []] returns [] ? please explain it in detail ! -- http://mail.python.org/mailman/listinfo/python-list You're mapping an empty list. for name in [] JM -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: [os.path.join(r'E:\Python', name) for name in []] returns []
iMath wrote: why [os.path.join(r'E:\Python', name) for name in []] returns [] ? Because you are iterating over an empty list, []. That list comprehension is the equivalent of: result = [] for name in []: result.append( os.path.join(r'E:\Python', name) ) Since you iterate over an empty list, the body of the loop never executes, and the result list remains empty. What did you expect it to do? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: [os.path.join(r'E:\Python', name) for name in []] returns []
On 01/29/2013 08:21 AM, iMath wrote: why [os.path.join(r'E:\Python', name) for name in []] returns [] ? please explain it in detail ! [ os.path.join(r'E:\Python', name) for name in [] ] It'd be nice if you would explain what part of it bothers you. Do you know what a list comprehension is? Do you know how to decompose a list comprehension into a for-loop? Do you know that [] is an empty list object? res = [] for name in []: res.append( ) Since the for loop doesn't loop even once, the result is the initial value, the empty loop. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: environment fingerprint
On 2013.01.29 07:18, Jabba Laci wrote: Hi, I have a script that I want to run in different environments: on Linux, on Windows, on my home machine, at my workplace, in virtualbox, etc. In each environment I want to use different configurations. For instance the temp. directory on Linux would be /tmp, on Windows c:\temp, etc. When the script starts, I want to test the environment and load the corresponding config. settings. How to get an OS-independent fingerprint of the environment? http://docs.python.org/3.3/library/platform.html http://docs.python.org/3.3/library/os.html#os.environ -- CPython 3.3.0 | Windows NT 6.2.9200.16461 / FreeBSD 9.1-RELEASE -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixxx DJ app and Python
On Mon, Jan 28, 2013 at 10:10 AM, mikp...@gmail.com wrote: Hi guys, I am thinking of driving a DJ application from Python. I am running Linux and I found the Mixxx app. Does anyone know if there are python bindings, or if this is possible at all? or does anyone have experience with another software that does the same DJ thing? I have also found the pymixxx module that I could install... but I didn't find any documentation so far or example code that could help me start (I'm keeping on searching). Finally maybe that there is any DJ app that could be driven by pygame.midi? Any idea appreciated. Sorry to fail to be more specific. I'd just go with a command line app that triggered a .wav file at certain points using time.sleep(x) Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixxx DJ app and Python
On Tue, Jan 29, 2013 at 11:06 AM, David Hutto dwightdhu...@gmail.com wrote: On Mon, Jan 28, 2013 at 10:10 AM, mikp...@gmail.com wrote: Hi guys, I am thinking of driving a DJ application from Python. I am running Linux and I found the Mixxx app. Does anyone know if there are python bindings, or if this is possible at all? or does anyone have experience with another software that does the same DJ thing? Hydrogen, and audacity work perfectly together. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixxx DJ app and Python
Does anyone know if there are python bindings, or if this is possible at all? or does anyone have experience with another software that does the same DJ thing? Hydrogen, and audacity work perfectly together. What I was about to do is take the mic, get the soundtrack/beat to the song going, and then plug it into audacity for further modification, or you can roll your own. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixxx DJ app and Python
On Tue, Jan 29, 2013 at 11:16 AM, David Hutto dwightdhu...@gmail.com wrote: Does anyone know if there are python bindings, or if this is possible at all? or does anyone have experience with another software that does the same DJ thing? Hydrogen, and audacity work perfectly together. What I was about to do is take the output to the headphones, get the soundtrack/beat to the song going, and then plug it into audacity(mic) for further modification, or you can roll your own. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: I have issues installing pycrypto (and thus fabric) with pip
Thanks. I've gotten everything working now. For anyone else who comes along, 'sudo apt-get install python-dev' did the job. Note that Fabric is useful for much, MUCH more than this. I look forward to finding out :) Off-topic: why is your virtualenv/project name so weird? Noted. It's the naming pattern that I use for my projects. I should use something better but I'm using this because I usually restart something several times before I'm happy with it. I was reading up on branching with git earlier. It looks like that will put an end to this bad practice. -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixxx DJ app and Python
On Tuesday, January 29, 2013 4:13:09 PM UTC, David Hutto wrote: [..] or does anyone have experience with another software that does the same DJ thing? Hydrogen, and audacity work perfectly together. Hi David, thanks for your reply. I am not sure though that this is going to help me. We have built a kind of basic controller that sends commands via bluetooth. Then I should have some device (like a linux pc or raspberry Pi) where I have my applications that listen for these bluetooth commands and drives a DJ application accordingly (like mixing two sounds, sync them etc). Obviously to write the whole application will take ages and I saw that the Mixxx one does everything I want. So I am searching for a way to interface to it programatically. Do you mean that Hydrogen and Audacity would replace the Mixxx app and I can call their functionality from Python? Or were you thinking about something else? Thanks, Mik -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixxx DJ app and Python
On Tue, Jan 29, 2013 at 11:18 AM, mikp...@gmail.com wrote: On Tuesday, January 29, 2013 4:13:09 PM UTC, David Hutto wrote: [..] or does anyone have experience with another software that does the same DJ thing? Hydrogen, and audacity work perfectly together. Hi David, thanks for your reply. I am not sure though that this is going to help me. We have built a kind of basic controller that sends commands via bluetooth. Then I should have some device (like a linux pc or raspberry Pi) where I have my applications that listen for these bluetooth commands and drives a DJ application accordingly (like mixing two sounds, sync them etc). Obviously to write the whole application will take ages and I saw that the Mixxx one does everything I want. So I am searching for a way to interface to it programatically. Well you can just use their(Mixx's) source code that they used from another wav form manipulation library(more than likely), after the trigger from the bluetooth. If you're talking voice, and music to sync, then either go with transmitting at the same, or take two receivers(one for each transmitter), and run them in unison on different frequencies, after they've been received.. I've never tried this, but it seems logical. Do you mean that Hydrogen and Audacity would replace the Mixxx app and I can call their functionality from Python? Or were you thinking about something else? Thanks, Mik -- http://mail.python.org/mailman/listinfo/python-list -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixxx DJ app and Python
This may not be too helpful, but I built a TCP server into the Mixxx application (in C++). I placed the server in ratecontroller (as I needed to vary the rate remotely). I then could send and receive TCP packets with a single board computer that ran a python client. It wasn't too bad. If you want I can see if I can release the server code. On Tuesday, January 29, 2013 11:19:34 AM UTC-5, David Hutto wrote: On Tue, Jan 29, 2013 at 11:16 AM, David Hutto dwightdhu...@gmail.com wrote: Does anyone know if there are python bindings, or if this is possible at all? or does anyone have experience with another software that does the same DJ thing? Hydrogen, and audacity work perfectly together. What I was about to do is take the output to the headphones, get the soundtrack/beat to the song going, and then plug it into audacity(mic) for further modification, or you can roll your own. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixxx DJ app and Python
On Tue, Jan 29, 2013 at 11:45 AM, Ben bungi...@gmail.com wrote: This may not be too helpful, but I built a TCP server into the Mixxx application (in C++). I placed the server in ratecontroller (as I needed to vary the rate remotely). I then could send and receive TCP packets with a single board computer that ran a python client. So you used a digital buffer region for your wave forms? How did you handle the rest of the data; allocate memory, or delete if the data became too lengthy? -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Split string data have ,
Hi All Python 2.6.2 on AIX 5.3 How to using split o y = 'abc.p,zip.p,a,b' print y abc.p,zip.p,a,b k= y.split(,) print k[0] abc.p Need Result, First element is abc.p,zip.p -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixxx DJ app and Python
On Tuesday, January 29, 2013 4:45:18 PM UTC, Ben wrote: This may not be too helpful, but I built a TCP server into the Mixxx application (in C++). I placed the server in ratecontroller (as I needed to vary the rate remotely). I then could send and receive TCP packets with a single board computer that ran a python client. Hi Ben, this would be actually interesting to look at. If you are not going to face problems, please send me the code. Thanks, Mik -- http://mail.python.org/mailman/listinfo/python-list
RE: Split string first data have ,
y = 'abc.p,zip.p,a,b' print y abc.p,zip.p,a,b x = what is your question?? print x I'm guessing that you want to split on ,, but want the quoted section to be a single token? Have you looked at the CSV module (http://docs.python.org/3/library/csv.html)? If my guess is wrong, or you're having difficulties with the csv module, a more specific question will help you get the answer you're looking for. -Nick Cash -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixxx DJ app and Python
On Tuesday, January 29, 2013 4:42:07 PM UTC, David Hutto wrote: [..] Well you can just use their(Mixx's) source code that they used from another wav form manipulation library(more than likely), after the trigger from the bluetooth. If you're talking voice, and music to sync, then either go with transmitting at the same, or take two receivers(one for each transmitter), and run them in unison on different frequencies, after they've been received.. I've never tried this, but it seems logical. Thanks David. It seems that the code is in C++ so I should write Python wrappers myself, which could be interesting, but given the time frame I have is just not possible, Pity :-( However I was not going to transmit sounds, but just commands to mix the sounds that are already in the same machine were the Mixxx is going to run. I hope I will have time to come back to it in future. Thanks. Mik -- http://mail.python.org/mailman/listinfo/python-list
Re: Split string data have ,
On Tue, 29 moonhkt moon...@gmail.com wrote: y = 'abc.p,zip.p,a,b' print y abc.p,zip.p,a,b k= y.split(,) print k[0] abc.p Need Result, First element is abc.p,zip.p The csv module should handle this nicely: import csv y = 'abc.p,zip.p,a,b' print y abc.p,zip.p,a,b r = csv.reader([y]) print r.next() ['abc.p,zip.p', 'a', 'b'] -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixxx DJ app and Python
Thanks David. It seems that the code is in C++ so I should write Python wrappers myself, Or ctypes. which could be interesting, but given the time frame I have is just not possible, Pity :-( However I was not going to transmit sounds, but just commands to mix the sounds that are already in the same machine were the Mixxx is going to run. A filter is minutia in comparison of code so it was always going to be a comand line app, with a python GUI, to perform alterations on the wave forms?. I hope I will have time to come back to it in future. Just a little practice, that makes every programmer listening scramble. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Split string data have ,
On Jan 29, 2013 9:05 AM, moonhkt moon...@gmail.com wrote: Hi All Python 2.6.2 on AIX 5.3 How to using split o y = 'abc.p,zip.p,a,b' print y abc.p,zip.p,a,b k= y.split(,) print k[0] abc.p Need Result, First element is abc.p,zip.p Try the csv module or the shlex module. -- http://mail.python.org/mailman/listinfo/python-list
Re: ] returns []
On Jan 29, 6:22 pm, iMath redstone-c...@163.com wrote: 在 2013年1月29日星期二UTC+8下午9时21分16秒,iMath写道: why [os.path.join(r'E:\Python', name) for name in []] returns [] ? please explain it in detail ! [os.path.join(r'E:\Python', name) for name in []] [] [Small algebra lesson] In algebra there is the concept of identity and absorbent. For example, 1 is the identity for multiply and 0 is the absorbent. ie for all x: 1 * x = x and 0 * x = 0 [end algebra lesson] In the case of lists, [] is an identity for ++ but behaves like an absorbent for comprehensions. Modern terminology for 'absorbent' is 'zero-element'. I personally find the older terminology more useful. Others have pointed out why operationally [] behaves like an absorbent in comprehensions. Ive seen even experienced programmers trip up on this so I believe its good to know it as an algebraic law in addition to the operational explanation. -- http://mail.python.org/mailman/listinfo/python-list
Re: Further evidence that Python may be the best language forever
Sure! I don't think we've publicly posted the teams' implementations, but the original client code is all up here--http://www.windward.net/codewar/2013_01/windwardopolis.php The issue with the original link may be if you're running Firefox--it's a Vimeo video, and I know they have some ongoing issues with Firefox that prevent their videos from displaying or playing back. On Tuesday, January 29, 2013 3:31:05 AM UTC-7, Michael Poeltl wrote: hi Stefan, * Stefan Behnel stefan...@behnel.de [2013-01-29 08:00]: Michael Torrie, 29.01.2013 02:15: On 01/28/2013 03:46 PM, Malcolm McCrimmon wrote: My company recently hosted a programming competition for schools across the country. One team made it to the finals using the Python client, one of the four default clients provided (I wrote it). Most of the other teams were using Java or C#. Guess which team won? http://www.windward.net/codewar/2013_01/finals.html We did a similar (although way smaller) contest once at a university. The task was to write a network simulator. We had a C team, a Java team and a Python team, four people each. The Java and C people knew their language, the Python team just started learning it. The C team ended up getting totally lost and failed. The Java team got most things working ok and passed. The Python team got everything working, but additionally implemented a web interface for the simulator that monitored and visualised its current state. They said it helped them with debugging. quite interesting! I'd liked to see the code is it available for 'download'? thx Michael What language was the web page hosted in? It comes up completely blank for me. :) Yep, same here. Hidden behind a flash wall, it seems. Stefan -- http://mail.python.org/mailman/listinfo/python-list -- Michael Poeltl Computational Materials Physics voice: +43-1-4277-51409 Univ. Wien, Sensengasse 8/12 fax: +43-1-4277-9514 (or 9513) A-1090 Wien, AUSTRIA cmp.mpi.univie.ac.at --- slackware-13.37 | vim-7.3 | python-3.2.3 | mutt-1.5.21 | elinks-0.12 --- -- http://mail.python.org/mailman/listinfo/python-list
Re: The best, friendly and easy use Python Editor.
On Jan 25, 10:35 pm, Leonard, Arah arah.leon...@bruker-axs.com wrote: It's just a text file after all. True indeed, let's not worry about trivial issues like indentation, mixing tabs and spaces or whatever. Notepad anybody? :) Hey, I didn't say Notepad was the *best* tool for the job, just that Python scripts are merely text files. text files ok. Merely text files needs some rebuttal http://blog.languager.org/2012/10/html-is-why-mess-in-programming-syntax.html Yeah its a bit tongue-in-cheek and does not directly answer the OP (to which anyway I said: interpreter is more important than editor) -- http://mail.python.org/mailman/listinfo/python-list
Galry, a high-performance interactive visualization package in Python
Dear all, I'm making available today a first pre-release of Galry http://rossant.github.com/galry/, a BSD-licensed high performance interactive visualization toolbox in Python based on OpenGL. Its matplotlib-like high-level interface allows to interactively visualize plots with tens of millions of points. Galry is highly flexible and natively supports 2D plots, 3D meshes, text, planar graphs, images, custom shaders, etc. The low-level interface can be used to write graphical interfaces in Qt with efficient visualization widgets. The goal of this beta pre-release is to ensure that Galry can work on the widest possible range of systems and graphics cards (OpenGL v2+ is required). If you're interested, please feel free to give it a try! Also, I'd very much appreciate if you could fill in a really short form on the webpage to indicate what you'd like to do with this package. Your feedback will be invaluable in the future development of Galry. Best regards, Cyrille Rossant -- http://mail.python.org/mailman/listinfo/python-list
Re: numpy array operation
On Tue, 29 Jan 2013 00:41:54 -0800, C. Ng wrote: Is there a numpy operation that does the following to the array? 1 2 == 4 3 3 4 2 1 Thanks in advance. How about: import numpy as np a = np.array([[1,2],[3,4]]) a array([[1, 2], [3, 4]]) a[::-1, ::-1] array([[4, 3], [2, 1]]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Galry, a high-performance interactive visualization package in Python
On 1/29/2013 1:23 PM, Cyrille Rossant wrote: The goal of this beta pre-release is to ensure that Galry can work on the widest possible range of systems and graphics cards (OpenGL v2+ is required). http://rossant.github.com/galry/ From that site: Mandatory dependencies include Python 2.7, For a new, still-beta package, this is somewhat sad. 2.7 is 3.5 years old and has only 1.5 years of semi-normal maintainance left. It will be more like 1 year when you get to your final release. If you are not supporting anything before 2.7, it should not be hard to make your python code also support 3.x. Use the future imports for print and unicode. Others have written more guidelines. Numpy, either PyQt4 or PySide, PyOpenGL, matplotlib These all support 3.2,3.3 (PyOpenGl says 'experimental'). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: numpy array operation
On 1/29/2013 1:49 PM, Alok Singhal wrote: On Tue, 29 Jan 2013 00:41:54 -0800, C. Ng wrote: Is there a numpy operation that does the following to the array? 1 2 == 4 3 3 4 2 1 Thanks in advance. How about: import numpy as np a = np.array([[1,2],[3,4]]) a array([[1, 2], [3, 4]]) a[::-1, ::-1] array([[4, 3], [2, 1]]) Nice. The regular Python equivalent is a = [[1,2],[3,4]] print([row[::-1] for row in a[::-1]]) [[4, 3], [2, 1]] The second slice can be replaced with reversed(a), which returns an iterator, to get [row[::-1] for row in reversed(a)] The first slice would have to be list(reversed(a)) to get the same result. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Quepy, transform questions in natural language into queries in a DB language using python
We are sharing an open source framework that we made here at Machinalis: Quepy https://github.com/machinalis/quepy Quepy is a Python framework to transform questions in natural language into queries in a database language. It can be easily adapted to different types of questions in natural language, so that with little code you can build your own interface to a database in natural language. Currently, Quepy supports only the SPARQL query language, but in future versions and with the collaboration of the community we are planning to extend it to other database query languages. You are invited to participate and collaborate with the project. We leave here links to the documentation [0], the source code [1], and also a Pypi package [2]. Also, as an example, we have an online instance of Quepy the interacts with DBpedia available [3]. Source code for this example instance is available within the Quepy package so you can kickstart your project from an existing, working example. If you like it, or if you have suggestions: Tell us about it! We're just an email away [4]. Cheers! [0] https://github.com/machinalis/quepy [1] http://quepy.readthedocs.org/ [2] http://pypi.python.org/pypi/quepy/ [3] quepy.machinalis.com (Don't expect a QA system, it's an example) [4] quepyproject[(at)]machinalis.com We're doing an online hangout to show example code and answer questions about the project: Hangout event on Wed, January 30 at 14:00 UTC or Hangout event on Wed, January 30 at 19:00 UTC Also we invite you to try the new user interface: http://quepy.machinalis.com/ Regards Elías -- http://mail.python.org/mailman/listinfo/python-list
GeoBases: data services and visualization
This new project provides tools to play with geographical data. It also works with non-geographical data, except for map visualizations :). There are embedded data sources in the project, but you can easily play with your own data in addition to the available ones. Files containing data about airports, train stations, countries, ... are loaded, then you can: - performs various types of queries ( find this key, or find keys with this property) - fuzzy searches based on string distance ( find things roughly named like this) - geographical searches ( find things next to this place) - get results on a map, or export it as csv data, or as a Python object This is entirely written in Python. The core part is a Python package, but there is a command line tool as well! For tutorials and documentation, check out http://opentraveldata.github.com/geobases/ -- http://mail.python.org/mailman/listinfo/python-list
Ways to apply while learning....
Hello, I am learning programming as a spare time hobby and learning python through codecademy. Today I have downloaded and installed aptana, and found out that although I have been progressing for some time now but I do not remember how to code and I have to look everything up. I want to know what is the best way to learn python and some small projects that I can make using console(I know there is a long way to develop something for the desktop) Thank you. ps: I am coming from vb6 paradigm. -- http://mail.python.org/mailman/listinfo/python-list
Re: Ways to apply while learning....
On Tue, Jan 29, 2013 at 5:57 PM, agamal...@gmail.com wrote: Hello, I am learning programming as a spare time hobby and learning python through codecademy. Today I have downloaded and installed aptana, and found out that although I have been progressing for some time now but I do not remember how to code and I have to look everything up. When using different languages to mean client needs,this will be a necessity. I want to know what is the best way to learn python and some small projects that I can make using console you might need to utilize subrocess, but many ahve their preference. (I know there is a long way to develop something for the desktop) Do you mean command line app, or with a GUI? Thank you. ps: I am coming from vb6 paradigm. -- http://mail.python.org/mailman/listinfo/python-list -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: environment fingerprint
Hi, Thanks for the tip. I came up with the solution below. For my purposes the short fingerprint is enough. Laszlo == import platform as p import uuid import hashlib def get_fingerprint(md5=False): Fingerprint of the current operating system/platform. If md5 is True, a digital fingerprint is returned. sb = [] sb.append(p.node()) sb.append(p.architecture()[0]) sb.append(p.architecture()[1]) sb.append(p.machine()) sb.append(p.processor()) sb.append(p.system()) sb.append(str(uuid.getnode())) # MAC address text = '#'.join(sb) if md5: md5 = hashlib.md5() md5.update(text) return md5.hexdigest() else: return text def get_short_fingerprint(length=6): A short digital fingerprint of the current operating system/platform. Length should be at least 6 characters. assert 6 = length = 32 # return get_fingerprint(md5=True)[-length:] On Tue, Jan 29, 2013 at 2:43 PM, Andrew Berg bahamutzero8...@gmail.com wrote: On 2013.01.29 07:18, Jabba Laci wrote: Hi, I have a script that I want to run in different environments: on Linux, on Windows, on my home machine, at my workplace, in virtualbox, etc. In each environment I want to use different configurations. For instance the temp. directory on Linux would be /tmp, on Windows c:\temp, etc. When the script starts, I want to test the environment and load the corresponding config. settings. How to get an OS-independent fingerprint of the environment? http://docs.python.org/3.3/library/platform.html http://docs.python.org/3.3/library/os.html#os.environ -- CPython 3.3.0 | Windows NT 6.2.9200.16461 / FreeBSD 9.1-RELEASE -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: environment fingerprint
On Wed, Jan 30, 2013 at 10:33 AM, Jabba Laci jabba.l...@gmail.com wrote: if md5: md5 = hashlib.md5() md5.update(text) return md5.hexdigest() Simpler: if md5: return hashlib.md5(text).hexdigest() ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: ] returns []
MUSATOV -- http://mail.python.org/mailman/listinfo/python-list
Re: [os.path.join(r'E:\Python', name) for name in []] returns []
在 2013年1月29日星期二UTC+8下午9时33分26秒,Steven D'Aprano写道: iMath wrote: why [os.path.join(r'E:\Python', name) for name in []] returns [] ? Because you are iterating over an empty list, []. That list comprehension is the equivalent of: result = [] for name in []: result.append( os.path.join(r'E:\Python', name) ) Since you iterate over an empty list, the body of the loop never executes, and the result list remains empty. What did you expect it to do? -- Steven just in order to get the full path name of each file . -- http://mail.python.org/mailman/listinfo/python-list
Re: [os.path.join(r'E:\Python', name) for name in []] returns []
On Wed, Jan 30, 2013 at 12:56 PM, iMath redstone-c...@163.com wrote: 在 2013年1月29日星期二UTC+8下午9时33分26秒,Steven D'Aprano写道: iMath wrote: why [os.path.join(r'E:\Python', name) for name in []] returns [] ? Because you are iterating over an empty list, []. That list comprehension is the equivalent of: result = [] for name in []: result.append( os.path.join(r'E:\Python', name) ) Since you iterate over an empty list, the body of the loop never executes, and the result list remains empty. What did you expect it to do? -- Steven just in order to get the full path name of each file . Then it's done exactly what it should. It's given you the full path of all of your list of zero files. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Split string data have ,
On Jan 30, 1:08 am, Chris Rebert c...@rebertia.com wrote: On Jan 29, 2013 9:05 AM, moonhkt moon...@gmail.com wrote: Hi All Python 2.6.2 on AIX 5.3 How to using split o y = 'abc.p,zip.p,a,b' print y abc.p,zip.p,a,b k= y.split(,) print k[0] abc.p Need Result, First element is abc.p,zip.p Try the csv module or the shlex module. Thank a lot, Using csv is good for me. -- http://mail.python.org/mailman/listinfo/python-list
Please provide a better explanation of tuples and dictionaries
Hi all, I have recently started learning Python (2.7.3) but need a better explanation of how to use tuples and dictionaries. I am currently using Learning Python by Mark Lutz and David Ascher, published by O'Reilly (ISBN 1-56592-464-9)--but I find the explanations insufficient and the number of examples to be sparse. I do understand some ANSI C programming in addition to Python (and the book often wanders off into a comparison of C and Python in its numerous footnotes), but I need a better real-world example of how tuples and dictionaries are being used in actual Python code. Any recommendations of a better book that doesn't try to write such compact and clever code for a learning book? Or, can an anyone provide an example of more than a three-line example of a tuple or dictionary? The purpose of my learning Python in this case is not for enterprise level or web-based application level testing at this point. I initially intend to use it for Software QA Test Automation purposes. Thanks in advance for any replies. -- http://mail.python.org/mailman/listinfo/python-list
Re: simple tkinter battery monitor
Thank you very much! fixed with w.after Here is the code, works under Linux for those who have acpi. My output of acpi -V is the following, the code is parsing the first line of the output. Any improvements are appreciated. $ acpi -V Battery 0: Discharging, 12%, 00:10:59 remaining Battery 0: design capacity 2200 mAh, last full capacity 1349 mAh = 61% Adapter 0: off-line Thermal 0: ok, 40.0 degrees C Thermal 0: trip point 0 switches to mode critical at temperature 98.0 degrees C Thermal 0: trip point 1 switches to mode passive at temperature 93.0 degrees C Cooling 0: Processor 0 of 10 Cooling 1: Processor 0 of 10 Cooling 2: Processor 0 of 10 Cooling 3: Processor 0 of 10 Cooling 4: LCD 0 of 9 -- -- -- #!/usr/bin/python3.2 from re import findall, search from threading import Thread from time import sleep from subprocess import Popen, call, PIPE, STDOUT from tkinter import Tk, Label, StringVar def runProcess(exe): p=Popen(exe, stdout=PIPE, stderr=STDOUT) while True: retcode=p.poll() line=p.stdout.readline() yield line if retcode is not None: break class BatteryMonitor: def __init__(self): root = Tk() root.configure(padx=1, pady=1, bg=#555753) root.geometry(-0+0) root.overrideredirect(True) root.wm_attributes(-topmost, True) self.batteryExtendedStringVar = StringVar() self.batteryPercentStringVar = StringVar() self.batteryExtendedLabel = Label(root, textvariable=self.batteryExtendedStringVar, font=(fixed, 9), bg=#3e4446, fg=#d3d7cf, padx=10, pady=-1) self.batteryPercentLabel = Label(root, textvariable=self.batteryPercentStringVar, font=(fixed, 9), width=4, bg=#3e4446, fg=#d3d7cf, padx=-1, pady=-1) self.batteryPercentLabel.grid() t = Thread(target=self.update_battery_level_loop) t.start() root.bind(Button-1, self.display_details) self.root = root root.mainloop() def display_details(self, event): # displays a message about details of battery status # i.e. on-line or charging, 20 min left and so on self.batteryPercentLabel.grid_remove() self.batteryExtendedLabel.grid() self.batteryExtendedLabel.after(1000, self.batteryExtendedLabel.grid_remove) self.batteryPercentLabel.after(1000, self.batteryPercentLabel.grid) def read_battery_level(self): # dummy function used just to test the GUI for line in runProcess([acpi, -V]): if line[11:-1]!=bon-line: self.level = findall(b\d\d?, line[11:])[0] else: self.level = b0 return line[11:-1] def update_battery_level_loop(self): # threaded function, should constantly update the battery level self.read_battery_level() while True: self.batteryPercentStringVar.set(str(self.level)[2:-1]+%) self.batteryExtendedStringVar.set(self.read_battery_level()) if self.level == 2: runProcess([shutdown, -h, now]) return sleep(5) ## # # main BatteryMonitor() -- http://mail.python.org/mailman/listinfo/python-list
Re: Please provide a better explanation of tuples and dictionaries
On Wed, Jan 30, 2013 at 1:55 PM, Daniel W. Rouse Jr. dwrousejr@nethere.comnospam wrote: I am currently using Learning Python by Mark Lutz and David Ascher, published by O'Reilly (ISBN 1-56592-464-9)--but I find the explanations insufficient and the number of examples to be sparse. I do understand some ANSI C programming in addition to Python (and the book often wanders off into a comparison of C and Python in its numerous footnotes), but I need a better real-world example of how tuples and dictionaries are being used in actual Python code. Have you checked out the online documentation at http://docs.python.org/ ? That might have what you're looking for. By the way, you may want to consider learning and using Python 3.3 instead of the older branch 2.7; new features are only being added to the 3.x branch now, with 2.7 getting bugfixes and such for a couple of years, but ultimately it's not going anywhere. Obviously if you're supporting existing code, you'll need to learn the language that it was written in, but if this is all new code, go with the recent version. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
struggling with these problems
1.Given that worst_offenders has been defined as a list with at least 6 elements, write a statement that defines lesser_offenders to be a new list that contains all the elements from index 5 of worst_offenders and beyond. Do not modify worst_offenders . I tried this but it didn't work: lesser_offenders = worst_offenders[5:6] 2.Given a variable temps that refers to a list, all of whose elements refer to values of type float , representing temperature data, compute the average temperature and assign it to a variable named avg_temp . Besides temps and avg_temp , you may use two other variables -- k and total . I'm not sure about this one but this is what I have: for k in range(len(temps)): total += temps[k] avg_temp = total / len(temps) 3.Associate the sum of the non-negative values in the list numbers with the variable sum . is it this: for numbers in sum: if sum +=? I'm confused at #3 the most i'm not doing it in python 3.2.3 it's called Myprogramminglab. -- http://mail.python.org/mailman/listinfo/python-list
Re: Please provide a better explanation of tuples and dictionaries
Chris Angelico ros...@gmail.com wrote in message news:mailman.1197.1359515470.2939.python-l...@python.org... On Wed, Jan 30, 2013 at 1:55 PM, Daniel W. Rouse Jr. dwrousejr@nethere.comnospam wrote: I am currently using Learning Python by Mark Lutz and David Ascher, published by O'Reilly (ISBN 1-56592-464-9)--but I find the explanations insufficient and the number of examples to be sparse. I do understand some ANSI C programming in addition to Python (and the book often wanders off into a comparison of C and Python in its numerous footnotes), but I need a better real-world example of how tuples and dictionaries are being used in actual Python code. Have you checked out the online documentation at http://docs.python.org/ ? That might have what you're looking for. I'll check the online documentation but I was really seeking a book recommendation or other offline resource. I am not always online, and often times when I code I prefer local machine documentation or a book. I do also have the .chm format help file in the Windows version of Python. By the way, you may want to consider learning and using Python 3.3 instead of the older branch 2.7; new features are only being added to the 3.x branch now, with 2.7 getting bugfixes and such for a couple of years, but ultimately it's not going anywhere. Obviously if you're supporting existing code, you'll need to learn the language that it was written in, but if this is all new code, go with the recent version. Honestly, I don't know what code is being supported. I've just seen enough test automation requirements calling for Python (in addition to C# and perl) in some of the latest job listings that I figured I better get some working knowledge of Python to avoid becoming obsolete should I ever need to find another job. -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixxx DJ app and Python
On Jan 29, 1:10 am, mikp...@gmail.com wrote: I am thinking of driving a DJ application from Python. I am running Linux and I found the Mixxx app. Does anyone know if there are python bindings, or if this is possible at all? or does anyone have experience with another software that does the same DJ thing? The simplest way I think would be to control Mixxx via midi, using something like pyPortMidi: http://alumni.media.mit.edu/~harrison/code.html If that doesn't give you the full range of control you're after, perhaps you could use ctypes to wrap Mixxx's code libraries? -- http://mail.python.org/mailman/listinfo/python-list
Re: Please provide a better explanation of tuples and dictionaries
On Wed, Jan 30, 2013 at 2:42 PM, Daniel W. Rouse Jr. dwrousejr@nethere.comnospam wrote: Chris Angelico ros...@gmail.com wrote in message news:mailman.1197.1359515470.2939.python-l...@python.org... Have you checked out the online documentation at http://docs.python.org/ ? That might have what you're looking for. I'll check the online documentation but I was really seeking a book recommendation or other offline resource. I am not always online, and often times when I code I prefer local machine documentation or a book. I do also have the .chm format help file in the Windows version of Python. Ah. I think the tutorial's in the chm file, but I'm not certain. But for actual books, I can't point to any; I learned from online info only, never actually sought a book (in fact, the last time I used dead-tree reference books was for C and C++). Sorry! By the way, you may want to consider learning and using Python 3.3 instead of the older branch 2.7... Honestly, I don't know what code is being supported. I've just seen enough test automation requirements calling for Python (in addition to C# and perl) in some of the latest job listings that I figured I better get some working knowledge of Python to avoid becoming obsolete should I ever need to find another job. A fair point. In that case, it's probably worth learning both; they're very similar. Learn either one first, then master the differences. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: struggling with these problems
On 2013-01-30 03:26, su29090 wrote: 1.Given that worst_offenders has been defined as a list with at least 6 elements, write a statement that defines lesser_offenders to be a new list that contains all the elements from index 5 of worst_offenders and beyond. Do not modify worst_offenders . I tried this but it didn't work: lesser_offenders = worst_offenders[5:6] Python uses half-open ranges (and counts from 0), which means that the start index is included and the end index is excluded. Therefore, worst_offenders[5:6] means the slice from index 5 up to, but excluding, index 6; in other words, an empty list. The question says and beyond; in Python you can just omit the end index to indicate everything up to the end. 2.Given a variable temps that refers to a list, all of whose elements refer to values of type float , representing temperature data, compute the average temperature and assign it to a variable named avg_temp . Besides temps and avg_temp , you may use two other variables -- k and total . I'm not sure about this one but this is what I have: for k in range(len(temps)): total += temps[k] avg_temp = total / len(temps) You didn't set the initial value of total, which is 0. 3.Associate the sum of the non-negative values in the list numbers with the variable sum . is it this: for numbers in sum: if sum +=? I'm confused at #3 the most Well, that's not valid Python. What you want to do is to add each number from the list to the sum only if it's non-negative, i.e. greater than or equal to 0. i'm not doing it in python 3.2.3 it's called Myprogramminglab. Have a look at Dive Into Python: http://www.diveintopython.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Please provide a better explanation of tuples and dictionaries
On 01/29/2013 09:55 PM, Daniel W. Rouse Jr. wrote: Hi all, I have recently started learning Python (2.7.3) but need a better explanation of how to use tuples and dictionaries. I am currently using Learning Python by Mark Lutz and David Ascher, published by O'Reilly (ISBN 1-56592-464-9)--but I find the explanations insufficient and the number of examples to be sparse. I do understand some ANSI C programming in addition to Python (and the book often wanders off into a comparison of C and Python in its numerous footnotes), but I need a better real-world example of how tuples and dictionaries are being used in actual Python code. Any recommendations of a better book that doesn't try to write such compact and clever code for a learning book? Or, can an anyone provide an example of more than a three-line example of a tuple or dictionary? The purpose of my learning Python in this case is not for enterprise level or web-based application level testing at this point. I initially intend to use it for Software QA Test Automation purposes. Thanks in advance for any replies. It's not finished yet, but you may find my text-movie tutorial on dicts useful: http://lightbird.net/larks/tmovies/dicts.html -m -- Lark's Tongue Guide to Python: http://lightbird.net/larks/ Idleness is the mother of psychology. Friedrich Nietzsche -- http://mail.python.org/mailman/listinfo/python-list
Re: struggling with these problems
On Wed, 30 Jan 2013 03:59:32 +, MRAB wrote: Python uses half-open ranges (and counts from 0), which means that the start index is included and the end index is excluded. Therefore, worst_offenders[5:6] means the slice from index 5 up to, but excluding, index 6; in other words, an empty list. Er, no. It's a one-element list: index 5 is included, index 6 is excluded. py L = list(abcdefgh) py L[5:6] ['f'] -- Steven -- http://mail.python.org/mailman/listinfo/python-list
security quirk
I read Wall Street Journal, and occasionally check articles on their Web site. It's mostly free, with some items available to subscribers only. It seems random, which ones they block, about 20%. Anywho, sometimes I use their search utility, the usual author or title search, and it blocks, then I look it up on Google, and link from there, and it loads! ok, Web gurus, what's going on? -- Rich -- http://mail.python.org/mailman/listinfo/python-list
Signal versus noise (was: security quirk)
RichD r_delaney2...@yahoo.com writes: Anywho, sometimes I use their search utility, the usual author or title search, and it blocks, then I look it up on Google, and link from there, and it loads! ok, Web gurus, what's going on? That evidently has nothing in particular to do with the topic of this forum: the Python programming language. If you want to just comment on arbitrary things with the internet at large, you have many other forums available. Please at least try to keep this forum on-topic. -- \ “Outside of a dog, a book is man's best friend. Inside of a | `\dog, it's too dark to read.” —Groucho Marx | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: security quirk
On Tue, Jan 29, 2013 at 11:55 PM, RichD r_delaney2...@yahoo.com wrote: I read Wall Street Journal, and occasionally check articles on their Web site. It's mostly free, with some items available to subscribers only. It seems random, which ones they block, about 20%. Anywho, sometimes I use their search utility, the usual author or title search, and it blocks, then I look it up on Google, and link from there, and it loads! ok, Web gurus, what's going on? Its Gremlins! I tell you Gremlins!!! -- Rich -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: security quirk
On Tue, Jan 29, 2013 at 8:55 PM, RichD r_delaney2...@yahoo.com wrote: I read Wall Street Journal, and occasionally check articles on their Web site. It's mostly free, with some items available to subscribers only. It seems random, which ones they block, about 20%. Anywho, sometimes I use their search utility, the usual author or title search, and it blocks, then I look it up on Google, and link from there, and it loads! ok, Web gurus, what's going on? http://www.google.com/search?btnG=1pws=0q=first+click+free BTW, this has absolutely jack squat to do with Python. Please direct similar future inquiries to a more relevant forum. Regards, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Please provide a better explanation of tuples and dictionaries
In hkcdnwgroqkwfpxmnz2dnuvz_qadn...@o1.com Daniel W. Rouse Jr. dwrousejr@nethere.comNOSPAM writes: I have recently started learning Python (2.7.3) but need a better explanation of how to use tuples and dictionaries. A tuple is a linear sequence of items, accessed via subscripts that start at zero. Tuples are read-only; items cannot be added, removed, nor replaced. Items in a tuple need not be the same type. Example: my_tuple = (1, 5, 'hello', 9.) print my_tuple[0] 1 print my_tuple[2] hello A dictionary is a mapping type; it allows you to access items via a meaningful name (usually a string.) Dictionaries do not preserve the order in which items are created (but there is a class in newer python versions, collections.OrderedDict, which does preserve order.) Example: person = {} # start with an empty dictionary person['name'] = 'John' person['age'] = 40 person['occupation'] = 'Programmer' print person['age'] 40 Dictionaries can also be created with some initial values, like so: person = { 'name': 'John', 'age': 40, 'occupation' : 'Programmer' } -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies -- http://mail.python.org/mailman/listinfo/python-list
Re: Please provide a better explanation of tuples and dictionaries
John Gordon gor...@panix.com wrote in message news:keaa9v$1ru$1...@reader1.panix.com... In hkcdnwgroqkwfpxmnz2dnuvz_qadn...@o1.com Daniel W. Rouse Jr. dwrousejr@nethere.comNOSPAM writes: I have recently started learning Python (2.7.3) but need a better explanation of how to use tuples and dictionaries. A tuple is a linear sequence of items, accessed via subscripts that start at zero. Tuples are read-only; items cannot be added, removed, nor replaced. Items in a tuple need not be the same type. Example: my_tuple = (1, 5, 'hello', 9.) print my_tuple[0] 1 print my_tuple[2] hello To me, this looks like an array. Is tuple just the Python name for an array? A dictionary is a mapping type; it allows you to access items via a meaningful name (usually a string.) Dictionaries do not preserve the order in which items are created (but there is a class in newer python versions, collections.OrderedDict, which does preserve order.) Example: person = {} # start with an empty dictionary person['name'] = 'John' person['age'] = 40 person['occupation'] = 'Programmer' print person['age'] 40 Dictionaries can also be created with some initial values, like so: person = { 'name': 'John', 'age': 40, 'occupation' : 'Programmer' } Thank you, I understand it better it is kind of like a hash table. -- http://mail.python.org/mailman/listinfo/python-list
Re: Please provide a better explanation of tuples and dictionaries
On Wed, Jan 30, 2013 at 5:14 PM, Daniel W. Rouse Jr. dwrousejr@nethere.comnospam wrote: To me, this looks like an array. Is tuple just the Python name for an array? Not quite. An array is closer to a Python list - a tuple can be thought of as a frozen list, if you like. Lists can be added to, removed from, and changed in many ways; tuples are what they are, and there's no changing them (the objects inside it could be changed, but WHAT objects are in it won't). Python has no strict match to a C-style array with a fixed size and changeable members; a Python list is closest to a C++ std::vector, if that helps at all. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Please provide a better explanation of tuples and dictionaries
On Tue, 29 Jan 2013 22:14:42 -0800, Daniel W. Rouse Jr. wrote: John Gordon gor...@panix.com wrote in message news:keaa9v$1ru$1...@reader1.panix.com... A tuple is a linear sequence of items, accessed via subscripts that start at zero. Tuples are read-only; items cannot be added, removed, nor replaced. Items in a tuple need not be the same type. Example: my_tuple = (1, 5, 'hello', 9.) print my_tuple[0] 1 print my_tuple[2] hello To me, this looks like an array. Is tuple just the Python name for an array? Absolutely not. Arrays can be modified in place. Tuples cannot. Arrays can be resized (depending on the language). Tuples cannot. Arrays are normally limited to a single data type. Tuples are not. Python lists are closer to arrays, although the array type found in the array module is even closer still. You create lists either with the list() function, or list builder notation using [ ]. Tuples are intended to be the equivalent of a C struct or Pascal record. Lists are very roughly intended to be somewhat close to an array, although as I said the array.py module is even closer. A dictionary is a mapping type; it allows you to access items via a meaningful name (usually a string.) [...] Thank you, I understand it better it is kind of like a hash table. Correct. Also known as associative array. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
[issue14018] OS X installer does not detect bad symlinks created by Xcode 3.2.6
Roundup Robot added the comment: New changeset c2830debb15a by Ned Deily in branch '2.7': Issue #14018: Backport OS X installer updates from 3.3. http://hg.python.org/cpython/rev/c2830debb15a New changeset d54330c8daaa by Ned Deily in branch '3.2': Issue #14018: Backport OS X installer updates from 3.3. http://hg.python.org/cpython/rev/d54330c8daaa New changeset 6e6a76166c47 by Ned Deily in branch '3.3': Issue #14018: merge to 3.3 http://hg.python.org/cpython/rev/6e6a76166c47 New changeset 888590641c49 by Ned Deily in branch 'default': Issue #14018: merge to default http://hg.python.org/cpython/rev/888590641c49 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14018 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17028] launcher does not read shebang line when arguments are given
Thomas Heller added the comment: Hope it is ok to assign this to you, vinay. -- assignee: - vinay.sajip nosy: +vinay.sajip ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17028 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16979] Broken error handling in codecs.unicode_escape_decode()
Roundup Robot added the comment: New changeset a242ac99161f by Serhiy Storchaka in branch '2.7': Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. http://hg.python.org/cpython/rev/a242ac99161f New changeset 084bec5443d6 by Serhiy Storchaka in branch '3.2': Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. http://hg.python.org/cpython/rev/084bec5443d6 New changeset 086defaf16fe by Serhiy Storchaka in branch '3.3': Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. http://hg.python.org/cpython/rev/086defaf16fe New changeset 218da678bb8b by Serhiy Storchaka in branch 'default': Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. http://hg.python.org/cpython/rev/218da678bb8b -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16979 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16979] Broken error handling in codecs.unicode_escape_decode()
Serhiy Storchaka added the comment: Until subtests added an explicit call looks better to me. And when subtests will be added we will just add subtest inside the helper function. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16979 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16980] SystemError in codecs.unicode_escape_decode()
Changes by Serhiy Storchaka storch...@gmail.com: -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16980 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16979] Broken error handling in codecs.unicode_escape_decode()
Changes by Serhiy Storchaka storch...@gmail.com: -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16979 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16975] Broken error handling in codecs.escape_decode()
Changes by Serhiy Storchaka storch...@gmail.com: -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16975 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16971] Refleaks in charmap decoder
Roundup Robot added the comment: New changeset 625c397a7283 by Serhiy Storchaka in branch '3.3': Issue #16971: Fix a refleak in the charmap decoder. http://hg.python.org/cpython/rev/625c397a7283 New changeset 02c4ecc87f74 by Serhiy Storchaka in branch 'default': Issue #16971: Fix a refleak in the charmap decoder. http://hg.python.org/cpython/rev/02c4ecc87f74 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16971 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16971] Refleaks in charmap decoder
Changes by Serhiy Storchaka storch...@gmail.com: -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16971 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16997] subtests
Nick Coghlan added the comment: I like the idea of the subTest API being something like: def subTest(self, _id, *, **params): However, I'd still factor that in to the reported test ID, not into the exception message. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16997 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17069] HTTP result code in urllib2.urlopen() file object undocumented
New submission from Tuure Laurinolli: As per documentation at http://docs.python.org/2/library/urllib2.html the file-like object returned by urllib2.urlopen() should have methods geturl() and info(). It actually also has getcode(), which appears to do the same as getcode() on urllib.urlopen() responses. This should be a documented feature of urllib2. -- components: Library (Lib) messages: 180900 nosy: tazle priority: normal severity: normal status: open title: HTTP result code in urllib2.urlopen() file object undocumented versions: Python 2.6, Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17069 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12707] Deprecate addinfourl getters
Petri Lehtinen added the comment: +1 for the documentation changes, which should be applied to 2.7 as well. The deprecation is the only thing to go to 3.4 only, if it's done at all. -- nosy: +petri.lehtinen versions: +Python 2.7, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12707 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12707] Deprecate addinfourl getters
Petri Lehtinen added the comment: Also note that getcode() is already documented in urllib (not urllib2) documentation: http://docs.python.org/2/library/urllib.html#urllib.urlopen -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12707 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17036] Implementation of the PEP 433: Easier suppression of file descriptor inheritance
STINNER Victor added the comment: New patch: - sys.setdefaultcloexec() takes again an argument, so sys.setdefaultcloexec(False) is allowed - add cloexec parameter to select.devpoll(), select.kqueue() and select.epoll() - when a function accepts a file name and a file descriptor: the cloexec parameter is ignored if the argument is a file descriptor (it was already done for open(), but not for socket.socket on Windows) - revert enhancements using cloexec=True to simplify the patch: will be done in another issue - fix various bugs in error handling (close newly created file descriptors on error) - release the GIL when calling the os: os.urandom(), os.pipe(), os.dup(), etc. -- Added file: http://bugs.python.org/file28887/bc88690df059.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17036 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17036] Implementation of the PEP 433: Easier suppression of file descriptor inheritance
STINNER Victor added the comment: My TODO list is almost empty: the implementation is done. I just see possible enhancement on Windows: socket.socket() and os.dup() can use an atomic flag to set close-on-exec if native functions are used (WSASocket, DuplicateHandle) instead of the POSIX API. But it can be done later. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17036 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17070] Use the new cloexec to improve security and avoid bugs
New submission from STINNER Victor: Attached patches use the new cloexec parameter added by the PEP 433 (see issue #17036). cloexec_fs_walk.patch: [security] don't leak a file descriptors of directories to a child processes cloexec_listening_socket.patch: [security] don't leak a listening socket to child processes, see also #12107 cloexec_log_file.patch: [security] don't leak the file descriptor of a log file to child processes cloexec_subprocess.patch: [security/bugs] don't leak file descriptors to child processes cloexec_misc.patch: misc mmodules security is a strong word: if subprocess is called with close_fds=True, there is no such problem at all. It's more a theorical problem if a process is created in another thread without using the subprocess module (but directly low level functions). -- components: Library (Lib) files: cloexec_fs_walk.patch keywords: patch messages: 180905 nosy: haypo, neologix priority: normal severity: normal status: open title: Use the new cloexec to improve security and avoid bugs versions: Python 3.4 Added file: http://bugs.python.org/file2/cloexec_fs_walk.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17070 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17070] Use the new cloexec to improve security and avoid bugs
Changes by STINNER Victor victor.stin...@gmail.com: Added file: http://bugs.python.org/file28892/cloexec_subprocess.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17070 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17071] Signature.bind() fails with a keyword argument named self
New submission from Antoine Pitrou: def f(a, self): pass ... sig = inspect.signature(f) sig.bind(1, 2) inspect.BoundArguments object at 0x7f607ead1e28 sig.bind(a=1, self=2) Traceback (most recent call last): File stdin, line 1, in module TypeError: bind() got multiple values for argument 'self' -- components: Library (Lib) messages: 180906 nosy: larry, pitrou, yselivanov priority: normal severity: normal status: open title: Signature.bind() fails with a keyword argument named self type: behavior versions: Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17071 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17036] Implementation of the PEP 433: Easier suppression of file descriptor inheritance
STINNER Victor added the comment: revert enhancements using cloexec=True to simplify the patch: will be done in another issue I just created the issue #17070 to track this task. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17036 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17070] Use the new cloexec to improve security and avoid bugs
Changes by STINNER Victor victor.stin...@gmail.com: Added file: http://bugs.python.org/file28889/cloexec_listening_socket.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17070 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17070] Use the new cloexec to improve security and avoid bugs
Changes by STINNER Victor victor.stin...@gmail.com: Added file: http://bugs.python.org/file28890/cloexec_log_file.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17070 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17070] Use the new cloexec to improve security and avoid bugs
Changes by STINNER Victor victor.stin...@gmail.com: Added file: http://bugs.python.org/file28891/cloexec_misc.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17070 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17015] mock could be smarter and inspect the spec's signature
Changes by Antoine Pitrou pit...@free.fr: -- dependencies: +Signature.bind() fails with a keyword argument named self ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17015 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17071] Signature.bind() fails with a keyword argument named self
Changes by STINNER Victor victor.stin...@gmail.com: -- nosy: +brett.cannon ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17071 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17036] Implementation of the PEP 433: Easier suppression of file descriptor inheritance
STINNER Victor added the comment: My TODO list is almost empty Oh, I forgot one point: I stil don't know if the close-on-exec flag of file descriptors of pass_fds argument of subprocess.Popen should be set. If close-on-exec flag is set globally, it's not convinient to have to clear the flag manually on each file descriptor. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17036 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17070] PEP 433: Use the new cloexec to improve security and avoid bugs
Changes by STINNER Victor victor.stin...@gmail.com: -- title: Use the new cloexec to improve security and avoid bugs - PEP 433: Use the new cloexec to improve security and avoid bugs ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17070 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17036] Implementation of the PEP 433: Easier suppression of file descriptor inheritance
Changes by STINNER Victor victor.stin...@gmail.com: Removed file: http://bugs.python.org/file28837/9bdfa1a3ea8c.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17036 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17071] Signature.bind() fails with a keyword argument named self
Yury Selivanov added the comment: I'll take a look later today. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17071 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16946] subprocess: _close_open_fd_range_safe() does not set close-on-exec flag on Linux 2.6.23 if O_CLOEXEC is defined
STINNER Victor added the comment: This issue is fixed in my implementation of the PEP 433: see #17036. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16946 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17072] Decimal, quantize, round and negative value
New submission from Hakim Taklanti: from decimal import Decimal from decimal import ROUND_UP, ROUND_DOWN a = Decimal(-3.86) b = Decimal(5.73) a_up = a.quantize(Decimal(.1), ROUND_UP) a.quantize(Decimal(.1), ROUND_UP) # -3.8 expected Decimal('-3.9') a.quantize(Decimal(.1), ROUND_DOWN) # -3.9 expected Decimal('-3.8') b.quantize(Decimal(.1), ROUND_UP) # Ok Decimal('5.8') b.quantize(Decimal(.1), ROUND_DOWN) # Ok Decimal('5.7') -- components: Library (Lib) messages: 180911 nosy: Hakim.Taklanti priority: normal severity: normal status: open title: Decimal, quantize, round and negative value versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17072 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17072] Decimal, quantize, round and negative value
Mark Dickinson added the comment: Indeed, that looks wrong. I'll take a look. -- assignee: - mark.dickinson nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17072 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17072] Decimal, quantize, round and negative value
Mark Dickinson added the comment: Sorry, I take that back. The behaviour is correct: ROUND_UP rounds away from zero; ROUND_DOWN towards zero. For rounding towards +/- infinity, you want ROUND_CEILING and ROUND_FLOOR: Python 2.7.3 |EPD 7.3-1 (32-bit)| (default, Apr 12 2012, 11:28:34) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type credits, demo or enthought for more information. from decimal import * a = Decimal(-3.86) a.quantize(Decimal(.1), ROUND_CEILING) Decimal('-3.8') a.quantize(Decimal(.1), ROUND_FLOOR) Decimal('-3.9') Closing as invalid. -- resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17072 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17072] Decimal, quantize, round and negative value
Hakim Taklanti added the comment: Indeed, perhaps to enhance the documentation. Thanks. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17072 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17073] Integer overflow in sqlite module
New submission from Serhiy Storchaka: The proposed patch fixes an integer overflow in such cases: 1. When an authorizer callback (registered with set_authorizer()) returns an integer which doesn't fit into C int. Now integers out of C int range interpreted as SQLITE_DENY (as any non-integer values). 2. When a callable used in create_collation() returns an integer which doesn't fit into C int. Now all Python integers work. 3. When Python integer doesn't fit into SQLite INTEGER. Now overflow detected and an exception raised. 4. Now sqlite module built even when HAVE_LONG_LONG is not defined. -- components: Extension Modules messages: 180915 nosy: ghaering, serhiy.storchaka priority: normal severity: normal stage: patch review status: open title: Integer overflow in sqlite module type: behavior versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17073 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17073] Integer overflow in sqlite module
Changes by Serhiy Storchaka storch...@gmail.com: -- keywords: +patch Added file: http://bugs.python.org/file28893/sqlite_int_overflow-2.7.patch Added file: http://bugs.python.org/file28894/sqlite_int_overflow-3.2.patch Added file: http://bugs.python.org/file28895/sqlite_int_overflow-3.3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17073 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15989] Possible integer overflow of PyLong_AsLong() results
Serhiy Storchaka added the comment: Sqlite module part extracted to issue17073. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15989 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16968] Fix test discovery for test_concurrent_futures.py
Zachary Ware added the comment: Right you are, Chris. v4 has a comment added to regrtest.runtest_inner pointing back to this issue. Also in v4, ReapedSuite has been moved to test.support. At least one other test module (test_pydoc) uses the same idiom as test_concurrent_futures, and so could use this suite for the same effect. Several others use at least one of reap_threads (or its component pieces) or reap_children in test_main, and I believe those could also use ReapedSuite for simplicity's sake. Used in its current form, it shouldn't cause any issues other than perhaps an extra couple of function calls. -- Added file: http://bugs.python.org/file28896/test_concurrent_futures_discovery.v4.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16968 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17074] (docs) Consistent formatting of constants
New submission from Zearin: When reading the docs, I noticed that the capitalization and formatting of the Python constants ``True``, ``False``, and ``None`` were inconsistent. The attached patch contains a fix for all such occurrences under ``/Doc/library/``. (I **think** I correctly made the patch. I hardly ever make patches, so if I screwed up, let me know and I’ll see if I can get it right. ☺) Parent commit: 9137e2d1c00c6906af206d1c9d217b15613bb1ed -- assignee: docs@python components: Documentation files: python_docs_constants.diff keywords: patch messages: 180918 nosy: docs@python, zearin priority: normal severity: normal status: open title: (docs) Consistent formatting of constants versions: Python 2.7 Added file: http://bugs.python.org/file28897/python_docs_constants.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17074 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17074] (docs) Consistent formatting of constants
Changes by Zearin zea...@users.sourceforge.net: -- type: - enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17074 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com