Re: Hello Everyone! A simple questions!
Thanks I just surprised by three dot 2013/7/26 Florian Baumgartner bflori...@gmail.com As alex23 already indicated you created a recursive data-structure (by inserting a reference to the list into the second place of the list) and the interpreter handles this gracefully by showing [...]. In case you really want to insert the lists members into the second place you can assign a copy of the list. values = [0,1,2] values[1] = values[:] 2013/7/26 Thanatos xiao yanxiaopei...@gmail.com values = [0, 1, 2] values[1] = values values[0, [...], 2] why?? -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
embedded python and threading
in my app i initialize python on the main thread, then immediately call PyEval_SaveThread() because i do no further python stuff on the main thread. then, for each script i want to run, i use boost::threads to create a new thread, then on that thread i ensure the GIL, do my stuff, then release it. so, to test concurrency, on my first background thread, i do an infinite loop that just logs i'm alive, then calls sleep(0.25) so that thread continues to run forever (with it's GIL ensured) according to the doc: In order to emulate concurrency of execution, the interpreter regularly tries to switch threads so i figure i can run another thread that does a single print statement: ensure gil print my thing release gil and this DOES run. however, after releasing it's gil, i guess the interpeter gets back to the first back thread, but then has this error immediately: 9: Traceback (most recent call last): 9: File string, line 70, in ? 9: File string, line 55, in main 9: AttributeError: 'builtin_function_or_method' object has no attribute 'sleep' suddenly the sleep module has been unloaded?? huh? i thought the thread state had been preserved? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to tick checkboxes with the same name?
malay...@gmail.com wrote: вторник, 23 июля 2013 г., 11:25:00 UTC+4 пользователь Peter Otten написал: malay...@gmail.com wrote: For all but the most popular projects a url works wonders. I'm assuming http://grablib.org Well, I have read the documentation, I guess the problem lies in somewhat different field. As long as I understand it refers to Checkboxgroup classes. As checkboxes of interest belong to some common group with the common name a, they do have values different from True or False (probably a sequence?) and I should guess somehow what are the real ones. How to do this? I took a quick look into the source, and it seems that grab has no notion of multiple inputs with the same name. My suggested workaround set_input_by_id(_a1, True) doesn't work because (among other things) the id is immediately translated into the name. I fear you have to construct the request manually or choose another library -- maybe mechanize (Python 2 only)? -- http://mail.python.org/mailman/listinfo/python-list
Newbie: Python 3 and web applications?
I'm currently learning Python, and I've been focusing on Python3. To try to kill two birds with one stone, I would also like to learn the basics of writing small web applications. These web applications don't need to do much more than provide an interface to a small database, and they may not even be required to be accessible outside of a LAN. Does anyone have any tips on what's the best way to start off this adventure? Thanks in advance, Rui Maciel -- http://mail.python.org/mailman/listinfo/python-list
Re: Hello Everyone! A simple questions!
As alex23 already indicated you created a recursive data-structure (by inserting a reference to the list into the second place of the list) and the interpreter handles this gracefully by showing [...]. In case you really want to insert the lists members into the second place you can assign a copy of the list. values = [0,1,2] values[1] = values[:] 2013/7/26 Thanatos xiao yanxiaopei...@gmail.com values = [0, 1, 2] values[1] = values values[0, [...], 2] why?? -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: embedded python and threading
David M. Cotter, 26.07.2013 08:15: in my app i initialize python on the main thread, then immediately call PyEval_SaveThread() because i do no further python stuff on the main thread. then, for each script i want to run, i use boost::threads to create a new thread, then on that thread i ensure the GIL, do my stuff, then release it. so, to test concurrency, on my first background thread, i do an infinite loop that just logs i'm alive, then calls sleep(0.25) so that thread continues to run forever (with it's GIL ensured) according to the doc: In order to emulate concurrency of execution, the interpreter regularly tries to switch threads so i figure i can run another thread that does a single print statement: ensure gil print my thing release gil and this DOES run. however, after releasing it's gil, i guess the interpeter gets back to the first back thread, but then has this error immediately: 9: Traceback (most recent call last): 9: File string, line 70, in ? 9: File string, line 55, in main 9: AttributeError: 'builtin_function_or_method' object has no attribute 'sleep' suddenly the sleep module has been unloaded?? huh? i thought the thread state had been preserved? You didn't show your code, but as a wild guess, maybe you did from time import time instead of import time somewhere? If not, please provide the exact example code that you are running. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Script Hashplings
On 07/25/2013 09:54 AM, MRAB wrote: On 25/07/2013 14:42, Devyn Collier Johnson wrote: If I execute a Python3 script with this haspling (#!/usr/bin/python3.3) and Python3.3 is not installed, but Python3.2 is installed, would the script still work? Would it fall back to Python3.2? Why don't you try it? I hope Dihedral is listening. I would like to see another response from HIM. Good point, but if it falls back to Python3.2, how would I know? Plus, I have Python3.3, 3.2, and 2.7 installed. I cannot uninstall them due to dependencies. DCJ -- http://mail.python.org/mailman/listinfo/python-list
Re: Critic my module
On 07/25/2013 09:58 AM, Schneider wrote: Hi, nice idea. mybe - for security reasons - you should ensure, that the right tool is called and not some tool put the path with the same name. bg, Johannes On Thu 25 Jul 2013 03:24:30 PM CEST, Devyn Collier Johnson wrote: Aloha Python Users! I made a Python3 module that allows users to use certain Linux shell commands from Python3 more easily than using os.system(), subprocess.Popen(), or subprocess.getoutput(). This module (once placed with the other modules) can be used like this import boash; boash.ls() I attached the module. I plan to release it on the Internet soon, but feel free to use it now. It is licensed under LGPLv3. The name comes from combining Boa with SHell. Notice that the module's name almost looks like BASH, a common Linux shell. The Boa is a constrictor snake. This module makes Unix shells easier to use via Python3. This brings the system shell closer to the Python shell. Mahalo, Devyn Collier Johnson devyncjohn...@gmail.com -- GLOBE Development GmbH Königsberger Strasse 260 48157 MünsterGLOBE Development GmbH Königsberger Strasse 260 48157 Münster 0251/5205 390 What do you mean by that Schneider? Mahalo, Devyn Collier Johnson devyncjohn...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Script Hashplings
On 07/25/2013 10:01 AM, Matthew Lefavor wrote: The answer is probably not. If you just want to use the latest version of Python 3 you have installed on your system, use: #!/usr/bin/python3. When you use the specific minor version numbers, they point to that specific minor version. Actually, the preferred shebang line is of the form: #!/usr/bin/env python3. This way the end users can override the interpreter with, say, a virtualenv, rather than being stuck with the system default. On Thu, Jul 25, 2013 at 9:54 AM, MRAB pyt...@mrabarnett.plus.com mailto:pyt...@mrabarnett.plus.com wrote: On 25/07/2013 14:42, Devyn Collier Johnson wrote: If I execute a Python3 script with this haspling (#!/usr/bin/python3.3) and Python3.3 is not installed, but Python3.2 is installed, would the script still work? Would it fall back to Python3.2? Why don't you try it? I hope Dihedral is listening. I would like to see another response from HIM. -- http://mail.python.org/mailman/listinfo/python-list Thanks Matthew Lefavor! But specifically, why use #!/usr/bin/env python3 instead of #!/usr/bin/python3? Mahalo, DCJ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Script Hashplings
On Fri, Jul 26, 2013 at 11:37 AM, Devyn Collier Johnson devyncjohn...@gmail.com wrote: On 07/25/2013 09:54 AM, MRAB wrote: On 25/07/2013 14:42, Devyn Collier Johnson wrote: If I execute a Python3 script with this haspling (#!/usr/bin/python3.3) and Python3.3 is not installed, but Python3.2 is installed, would the script still work? Would it fall back to Python3.2? Why don't you try it? I hope Dihedral is listening. I would like to see another response from HIM. Good point, but if it falls back to Python3.2, how would I know? Plus, I have Python3.3, 3.2, and 2.7 installed. I cannot uninstall them due to dependencies. Easy: #!/usr/bin/python3.3 import sys print(sys.version) Now run that on lots of different computers (virtual computers work well for this). ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Script Hashplings
On 26/07/2013 11:37, Devyn Collier Johnson wrote: On 07/25/2013 09:54 AM, MRAB wrote: On 25/07/2013 14:42, Devyn Collier Johnson wrote: If I execute a Python3 script with this haspling (#!/usr/bin/python3.3) and Python3.3 is not installed, but Python3.2 is installed, would the script still work? Would it fall back to Python3.2? Why don't you try it? I hope Dihedral is listening. I would like to see another response from HIM. Good point, but if it falls back to Python3.2, how would I know? Plus, I have Python3.3, 3.2, and 2.7 installed. I cannot uninstall them due to dependencies. Devyn, I'm not a *nix person so someone can point out if I'm wrong, but my understanding is that the shebang line (or whatever you want to call it) just tells the shell: run this command to run this file. So you can put #!/usr/bin/fish-and-chips as the first line and it will try to run the file using /usr/bin/fish-and-chips. If you put #!/usr/bin/python3.3 the shell will use the executable /usr/bin/python3.3. It doesn't know or care about Python or its versions: it won't go looking for some alternative binary. If /usr/bin/python3.3 isn't there, the shell will fail to run the code with some kind of error message. If you or your package manager symlink /usr/bin/python3 to whatever the latest Python 3.x is on your system then you can safely use /usr/bin/python3 throughout and let the symlink do the work! TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: Critic my module
On 07/25/2013 10:09 AM, Alain Ketterlin wrote: Devyn Collier Johnson devyncjohn...@gmail.com writes: I made a Python3 module that allows users to use certain Linux shell commands from Python3 more easily than using os.system(), subprocess.Popen(), or subprocess.getoutput(). This module (once placed with the other modules) can be used like this Good, but I doubt it's really useful: I think nobody is going to add a dependency on your module for, basically, one-line wrappers... Here are a few comments: def ls(): version = '0.3' print(subprocess.getoutput('ls')) version is local here, so basically your first statement is useless (search for global in python's language ref). def uname(): version = '0.3' print(platform.uname()) I once learned: never print anything in a library function. This is a bad thing to do, for a variety of reasons. For instance, stdout may be redirected during this call... def man(x): version = '0.3' print(subprocess.getoutput('man' + x)) getoutput is (essentially) Popen(...,shell=True), and the doc says: the use of shell=True is strongly discouraged in cases where the command string is constructed from external input (for very good reasons) def clear_bash_history(): version = '0.3' print(subprocess.getoutput('history -c')) Who told you subprocess will use bash? Again, the doc: On Unix with shell=True, the shell defaults to /bin/sh. All your uses of bash-isms may break (esp. !!) def firefox(): version = '0.3' print(subprocess.Popen('(firefox )')) See section Replacing the os.spawn family in... the doc. def go_back(): version = '0.3' print(subprocess.Popen('cd !!:1')) Hopeless. Have you tried this? def reboot(): version = '0.3' print(subprocess.Popen('shutdown -r now')) What do you expect this to print? I mean, after shutdown/reboot. version = '0.6b' So, what's the version? 0.3 or 0.6b (btw, are you sure this version is the same as the one you use in all functions?). -- Alain. The version in each function is the version of that function if users want to know what version they are using. The last version is for the whole module. The module overall is version 0.6b. The module started with a few functions and as I increased the number of functions, I increased the module version number. It is a coincidence that all of the modules happen to have the same version number. I increase the version number after I work on a function. I cannot remember the command to print a module's/function's version number, but with that command, you could see the version of a particular function or module. No, I have not tried go_back(), thank you for catching that. The main point of this is for shell users that are using Python and do not know some of the Python commands. This module would make Python more like a Linux shell. For instance, a shell user would type boash.uname() because they may not know they can type import platform; platform.uname(). I know that printing is not really the best of ideas, but how else can I make the output be displayed without quotes or newline marks? Thank you very much Alain Ketterlin for your feedback! Mahalo, DCJ -- http://mail.python.org/mailman/listinfo/python-list
Re: virtualenv problem
Yeah trying to run virtualenv under IDLE was a desperate move as i couldnt make anything work under cmd. Apparently my problem was that i did not have correctly setup the new path.. Solution for me was the following from http://forums.udacity.com/questions/100064678/pip-installation-instructions; -- ..We want to add that directory to your Path environment variable. Path is a list of directories where your OS looks for executable files. You will need to change the directory if you installed Python in a non-default location. a. go to Control Panel » System » Advanced » Environment Variables, make sure Path is selected under user variables for user, and click edit. b. Add ;C:\Python33\Scripts\ and ;C:\Python33\ (no spaces after the previous entry, ';' is the delimiter) to the end of variable value, then click ok. You should not be erasing anything, just adding to what's already there. This just makes it so we don't have to type the full path name whenever we want to run pip or other programs in those directories. C:\Python33\Scripts\ is the one we want now, but C:\Python33\ might be useful for you in the future. Restart your computer. -- I realised that even if i didn't do the above, i could still have got things rolling just by cd-ing from the cmd, to the script folder of my Python installation. But hey - learning is a good thing -- http://mail.python.org/mailman/listinfo/python-list
Re: RE Module Performance
Le jeudi 25 juillet 2013 22:45:38 UTC+2, Ian a écrit : On Thu, Jul 25, 2013 at 12:18 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Fri, 26 Jul 2013 01:36:07 +1000, Chris Angelico wrote: On Fri, Jul 26, 2013 at 1:26 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Thu, 25 Jul 2013 14:36:25 +0100, Jeremy Sanders wrote: To conserve memory, Emacs does not hold fixed-length 22-bit numbers that are codepoints of text characters within buffers and strings. Rather, Emacs uses a variable-length internal representation of characters, that stores each character as a sequence of 1 to 5 8-bit bytes, depending on the magnitude of its codepoint[1]. For example, any ASCII character takes up only 1 byte, a Latin-1 character takes up 2 bytes, etc. We call this representation of text multibyte. Well, you've just proven what Vim users have always suspected: Emacs doesn't really exist. ... lolwut? JMF has explained that it is impossible, impossible I say!, to write an editor using a flexible string representation. Since Emacs uses such a flexible string representation, Emacs is impossible, and therefore Emacs doesn't exist. QED. Except that the described representation used by Emacs is a variant of UTF-8, not an FSR. It doesn't have three different possible encodings for the letter 'a' depending on what other characters happen to be in the string. As I understand it, jfm would be perfectly happy if Python used UTF-8 (or presumably the Emacs variant) as its internal string representation. -- And emacs it probably working smoothly. Your comment summarized all this stuff very correctly and very shortly. utf8/16/32? I do not care. There are all working correctly, smoothly and efficiently. In fact, these utf's are already doing correctly, what this FSR is doing in a wrong way. My preference? utf32. Why? It is the most simple and consequently performing choice. I'm not a narrow minded ascii user. (I do not pretend to belong to those who are solving the quadrature of the circle, I pretend to belong to those who know, the quadrature of the circle is not solvable). Note: text processing tools or tools that have to process characters — and the tools to build these tools — are all moving to utf32, if not already done. There are technical reasons behind this, which are going beyond the pure raw unicode. There are however still 100% Unicode compliant. jmf -- http://mail.python.org/mailman/listinfo/python-list
Re: RE Module Performance
Le vendredi 26 juillet 2013 05:09:34 UTC+2, Michael Torrie a écrit : On 07/25/2013 11:18 AM, Steven D'Aprano wrote: JMF has explained that it is impossible, impossible I say!, to write an editor using a flexible string representation. Since Emacs uses such a flexible string representation, Emacs is impossible, and therefore Emacs doesn't exist. Now I'm even more confused. He once pointed to Go as an example of how unicode should be done in a language. yet Go uses UTF-8 I think. But I don't think UTF-8 is what JMF refers to as flexible string representation. FSR does use 1,2 or 4 bytes per character, but each character in the string uses the same width. That's different from UTF-8 or UTF-16, which is variable width per character. - sys.getsizeof('––') - sys.getsizeof('–') I have already explained / commented this. Hint: To understand Unicode (and every coding scheme), you should understand utf. The how and the *why*. jmf -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGLet, 2to3...?
On Thu, Jul 25, 2013 at 7:49 PM, John Ladasky john_lada...@sbcglobal.net wrote: === john@john:~/Desktop/pyglet-1.2alpha1$ sudo python3 setup.py install [sudo] password for john: running install running build running build_py running install_lib running install_egg_info Removing /usr/local/lib/python3.3/dist-packages/pyglet-1.2alpha1.egg-info Writing /usr/local/lib/python3.3/dist-packages/pyglet-1.2alpha1.egg-info Pyglet was installed to /usr/local/lib/python3.3/dist-packages ... john@john:~/Desktop/pyglet-1.2alpha1$ python3 Python 3.3.1 (default, Apr 17 2013, 22:30:32) [GCC 4.7.3] on linux Type help, copyright, credits or license for more information. import pyglet Traceback (most recent call last): File stdin, line 1, in module File ./pyglet/__init__.py, line 276 print '[%d] %s%s %s' % (thread, indent, name, location) ^ SyntaxError: invalid syntax ... But here, the error message is talking about ./pyglet/__init__.py. I think you're accidentally importing the pyglet package from the local directory instead of from the proper location in dist-packages. Try changing back to your home directory and trying this again. I think you're picking up the code from ~/Desktop/pyglet-1.2alpha1/pyglet instead of from /usr/local/lib/python3.3/dist-packages. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list
Re: RE Module Performance
Le vendredi 26 juillet 2013 05:20:45 UTC+2, Ian a écrit : On Thu, Jul 25, 2013 at 8:48 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: UTF-8 uses a flexible representation on a character-by-character basis. When parsing UTF-8, one needs to look at EVERY character to decide how many bytes you need to read. In Python 3, the flexible representation is on a string-by-string basis: once Python has looked at the string header, it can tell whether the *entire* string takes 1, 2 or 4 bytes per character, and the string is then fixed-width. You can't do that with UTF-8. UTF-8 does not use a flexible representation. A codec that is encoding a string in UTF-8 and examining a particular character does not have any choice of how to encode that character; there is exactly one sequence of bits that is the UTF-8 encoding for the character. Further, for any given sequence of code points there is exactly one sequence of bytes that is the UTF-8 encoding of those code points. In contrast, with the FSR there are as many as three different sequences of bytes that encode a sequence of code points, with one of them (the shortest) being canonical. That's what makes it flexible. Anyway, my point was just that Emacs is not a counter-example to jmf's claim about implementing text editors, because UTF-8 is not what he (or anybody else) is referring to when speaking of the FSR or something like the FSR. BTW, it is not necessary to use an endorsed Unicode coding scheme (utf*), a string literal would have been possible, but then one falls on memory issures. All these utf are following the basic coding scheme. I repeat again. A coding scheme works with a unique set of characters and its implementation works with a unique set of encoded code points (the utf's, in case of Unicode). And again, that why we live today with all these coding schemes, or, to take the problem from the other side, that's because one has to work with a unique set of encoded code points, that all these coding schemes had to be created. utf's have not been created by newbies ;-) jmf -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Script Hashplings
On 26/07/2013 11:43, Chris Angelico wrote: On Fri, Jul 26, 2013 at 11:37 AM, Devyn Collier Johnson devyncjohn...@gmail.com wrote: On 07/25/2013 09:54 AM, MRAB wrote: On 25/07/2013 14:42, Devyn Collier Johnson wrote: If I execute a Python3 script with this haspling (#!/usr/bin/python3.3) and Python3.3 is not installed, but Python3.2 is installed, would the script still work? Would it fall back to Python3.2? Why don't you try it? I hope Dihedral is listening. I would like to see another response from HIM. Good point, but if it falls back to Python3.2, how would I know? Plus, I have Python3.3, 3.2, and 2.7 installed. I cannot uninstall them due to dependencies. Easy: #!/usr/bin/python3.3 import sys print(sys.version) Now run that on lots of different computers (virtual computers work well for this). There's also sys.version_info: import sys sys.version_info sys.version_info(major=3, minor=3, micro=2, releaselevel='final', serial=0) If you want to test what would happen if that version wasn't installed, set the shebang line to a future version, such as Python 3.4. I doubt you have that installed! :-) -- http://mail.python.org/mailman/listinfo/python-list
RE: Creating a Simple User Interface for a Function
CTSB01 wrote: On Thursday, July 25, 2013 3:19:27 PM UTC-4, Dave Angel wrote: On 07/25/2013 12:03 PM, CTSB01 wrote: I have the following code that runs perfectly: def psi_j(x, j): rtn = [] for n2 in range(0, len(x) * j - 2): n = n2 / j r = n2 - n * j rtn.append(j * x[n] + r * (x[n + 1] - x[n])) print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn return rtn No it doesn't run perfectly. It'll get a syntax error on the print function call. That's assuming you're still using Python 3.3. You really need to start by specifying your environment, without making us look back through previous threads from you. This code takes a string x = [0,1,1,1,2] for example That's not a string. A string would be like xx = psi_j(0abcd1234) Perhaps you mean list? And is it a list of integers, or of arbitrary numbers? Are there any constraints on the sizes or signs of those numbers? (it must always begin with 0) and a parameter j, say 2, and outputs a string (x = [0, 1, 2, 2, 2, 2, 2, 3] in this example). It does this in two steps: First it decomposes some number m into a multiple of j and a remainder. Only if you replace the / with //. Or just use the function divmod(): n, r = divmod(n2, m) Then it runs this decomposition through a function on the rtn.append line. Notice that this has cj - 1 terms where c is the number of terms in the input string and j is the parameter. Normally, we would like it to be able to calculate cj terms. This is an issue with the function that I am more than happy to put aside for the moment. My key interest is to be able to make this program So far you have a function, not a program. If you put it in a text file and run it from python, it'll do nothing but display a syntax error message. And when you fix that, it'll just run without doing anything. usable for someone who has no knowledge of programming. In particular, I need some kind of user interface that prompts the user to input a string (ideally just by putting in numbers in the form 011123334 for example) and a parameter, and then displays the output sequence. This is essentially what the program already does but the idea is to make it usable for even the most technologically disinclined. Ideally it would do this without needing to run Python at all. Then why are you asking on the Python forum? Or perhaps you mean without him knowing he's running Python? In that case, use a shebang line at the beginning, which will tell Linux to automatically invoke the specified program (or programming language in this case). If anyone is able to make this happen in Python I would be eternally grateful. If we assume you're running Python 3.3 on Linux, and the user is willing to us the terminal, then how about parsing the string from the command line he types? You can access it as011123334 a string from sys.argv, and convert it to separate numbers. Of course as it stands now, you cannot tell whether the user wanted 0,1,1,1,2,3,3,3,4 or 0, 111, 23, 3, 3, 4 or something else. DaveA Sorry Dave, to answer each part of your response: 1) I decided to use Python 2.7, and I will be sure to specify this in all future threads. 2) It is a list of positive integers. In fact, it is always going to be a list of positive increasing integers. 3) You're right. What I meant was that if after running that bit of code I enter x = [0,1,2,3,4,5] psi_j(x,2) I will get output that matches my requirements. 4) Yes, sorry that's what I meant (if I understood correctly). I was told elsewhere that I might want to try using tkinter. Essentially I'm trying to create a user interface that allows the user to just type in a string 01112345 for example, and choose a parameter (say j=2) and then click a button to run the function. I'd like to be able to run send a .exe file that the user can just open up and use with no further setup. Any UI will work whether graphical or command line. TK is a good choice if you assume that the user has Python installed. If you are planning to create an exe (Windows) then you can probably bundle any GUI library (wx/gtk/qt) but you might be limited by the support of the exe creating tool. I have never created an executable like this, so I am not sure. So on top of the user interface I would also it looks like need to determine how to make Python change a string 01112345 into a list so that it does that automatically when the user clicks 'run'. This really does not make sense to me. Does that mean 0, 1, 11, 23, 45 or 0, 111, 2345 or 0,11, 2345 or something else entirely? If you are doing this on the shell I would have the
Re: Python Script Hashplings
On Fri, Jul 26, 2013 at 2:53 PM, MRAB pyt...@mrabarnett.plus.com wrote: If you want to test what would happen if that version wasn't installed, set the shebang line to a future version, such as Python 3.4. I doubt you have that installed! :-) Be careful, some people DO have a python3.4 binary :) Go for 3.5 for a bit more reliability. rosuav@sikorsky:~$ python3.4 3.4.0a0 (default:da7d97ca1ef6, Jul 13 2013, 14:05:08) [GCC 4.7.2] ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie: Python 3 and web applications?
In kstdma$pir$1...@dont-email.me Rui Maciel rui.mac...@gmail.com writes: I'm currently learning Python, and I've been focusing on Python3. To try to kill two birds with one stone, I would also like to learn the basics of writing small web applications. These web applications don't need to do much more than provide an interface to a small database, and they may not even be required to be accessible outside of a LAN. Does anyone have any tips on what's the best way to start off this adventure? I recommend using a web framework such as Django or Pylons. It's more to learn, but frameworks handle a ton of low-level details for you and make web development overall much easier. -- 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: PyGLet, 2to3...?
John Ladasky john_lada...@sbcglobal.net writes: On Thursday, July 25, 2013 3:26:01 PM UTC-7, John Ladasky wrote: I'll try again from scratch, and see whether that clears up my problems. Nope, that didn't work. === john@john:~/Desktop/pyglet-1.2alpha1$ sudo python3 setup.py install [sudo] password for john: running install running build running build_py running install_lib running install_egg_info Removing /usr/local/lib/python3.3/dist-packages/pyglet-1.2alpha1.egg-info Writing /usr/local/lib/python3.3/dist-packages/pyglet-1.2alpha1.egg-info john@john:~/Desktop/pyglet-1.2alpha1$ python3 Python 3.3.1 (default, Apr 17 2013, 22:30:32) [GCC 4.7.3] on linux Type help, copyright, credits or license for more information. import pyglet Traceback (most recent call last): File stdin, line 1, in module File ./pyglet/__init__.py, line 276 --^ Your import is attempting to import from your current directory, which has the pre-2to3 version of the files packaged in the original distribution. Switch away and try again. print '[%d] %s%s %s' % (thread, indent, name, location) ^ SyntaxError: invalid syntax === The source code link that Kushal posted is dated December 19, 2012. Since that was several months ago, I double-checked the source code of setup.py in the 1.2alpha1 package that I downloaded. It would appear to perform the same check of sys.version_info that was shown on the Google Code page. To see how that check actually runs, I saved a copy of setup.py as setup2.py, adding diagnostic calls to print() as shown in the code block below: === if sys.version_info = (3,): # Automatically run 2to3 when using Python 3 print(Python version is 3.0 or later.) # I added this if _have_setuptools: print(Have setuptools.) # I added this setup_info[use_2to3] = True else: print(Do not have setuptools.) # I added this from distutils.command.build_py import build_py_2to3 setup_info[cmdclass] = {build_py : build_py_2to3} === Here's the output: === john@john:~/Desktop/pyglet-1.2alpha1$ sudo python3 setup2.py install Python version is 3.0 or later. Do not have setuptools. running install running build running build_py running install_lib running install_egg_info Removing /usr/local/lib/python3.3/dist-packages/pyglet-1.2alpha1.egg-info Writing /usr/local/lib/python3.3/dist-packages/pyglet-1.2alpha1.egg-info === So, I don't know much yet about this _have_setuptools flag. I don't know whether it has to be True, instead of False, in order for 2to3 to work properly. I get the impression from the code that 2to3 should run regardless of the _have_setuptools flag, it is just that the task is accomplished in two different ways? That seems correct. My familiarity with the python packaging tools is limited, though. -- regards, kushal -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Script Hashplings
Thanks Matthew Lefavor! But specifically, why use #!/usr/bin/env python3 instead of #!/usr/bin/python3? The env program looks up its argument in the current $PATH environment variable, and then executes that. This means you aren't necessarily tied to /usr/bin/python3. It makes things more portable. For example, old Linux distributions don't have Python 3 installed with them, and the user might not have permissions to install Python 3 system-wide. Instead they have it in some sort of ~/HOME/bin directory, and then that is placed on the path by their .bashrc file. If your shebang line was #!/usr/bin/python3, the program wouldn't work without them changing that line. If the shebang ling was #!/usr/bin/env python3, it would find the Python3 binary no problem. -- http://mail.python.org/mailman/listinfo/python-list
Re: Critic my module
The main point of this is for shell users that are using Python and do not know some of the Python commands. This module would make Python more like a Linux shell. For instance, a shell user would type boash.uname() because they may not know they can type import platform; platform.uname(). But they will know how to import your module? to be honest I think this module is a solution looking for a problem you have re-invented the wheel (Square). don't let that put you off, there are many command line tools that could do with a good wrapper to make them easier to use,perhaps you are tryingto be too general. I know that printing is not really the best of ideas, but how else can I make the output be displayed without quotes or newline marks? as this is a module intended for others to use in their programs (rather than a tool in its own right) the correct approach is to return the result lave it for the user to print the result, or process it however they require. -- I also never expected Intel to dispose of themselves in such a cute way. - Rik van Riel on linux-kernel -- http://mail.python.org/mailman/listinfo/python-list
RE: Python Script Hashplings
Devyn Collier Johnson wrote: Thanks Matthew Lefavor! But specifically, why use #!/usr/bin/env python3 instead of #!/usr/bin/python3? Mahalo, DCJ I believe this will work on Windows for Python 3.3+ and also with virtualenv. https://pypi.python.org/pypi/virtualenv Virtualenv is highly recommended as it lets you create isolated Python environments on a per project basis. ~Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
Re: RE Module Performance
Le vendredi 26 juillet 2013 05:20:45 UTC+2, Ian a écrit : On Thu, Jul 25, 2013 at 8:48 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: UTF-8 uses a flexible representation on a character-by-character basis. When parsing UTF-8, one needs to look at EVERY character to decide how many bytes you need to read. In Python 3, the flexible representation is on a string-by-string basis: once Python has looked at the string header, it can tell whether the *entire* string takes 1, 2 or 4 bytes per character, and the string is then fixed-width. You can't do that with UTF-8. UTF-8 does not use a flexible representation. A codec that is encoding a string in UTF-8 and examining a particular character does not have any choice of how to encode that character; there is exactly one sequence of bits that is the UTF-8 encoding for the character. Further, for any given sequence of code points there is exactly one sequence of bytes that is the UTF-8 encoding of those code points. In contrast, with the FSR there are as many as three different sequences of bytes that encode a sequence of code points, with one of them (the shortest) being canonical. That's what makes it flexible. Anyway, my point was just that Emacs is not a counter-example to jmf's claim about implementing text editors, because UTF-8 is not what he (or anybody else) is referring to when speaking of the FSR or something like the FSR. - Let's be clear. I'm perfectly understanding what is utf-8 and that's for that precise reason, I put the editor as an exemple on the table. This FSR is not *a* coding scheme. It is more a composite coding scheme. (And form there, all the problems). BTW, I'm pleased to read sequence of bits and not bytes. Again, utf transformers are producing sequence of bits, call Unicode Transformation Units, with lengths of 8/16/32 *bits*, from there the names utf8/16/32. UCS transformers are (were) producing bytes, from there the names ucs-2/4. jmf -- http://mail.python.org/mailman/listinfo/python-list
Re: how to package embedded python?
does nobody know how to do this? does nobody know where proper documentation on this is? -- http://mail.python.org/mailman/listinfo/python-list
Re: embedded python and threading
okay, i have simplified it: here is the code == import time def main(): while True: print i'm alive time.sleep(0.25) #- if __name__ == __main__: main() == the new error is: == 9: Traceback (most recent call last): 9: File string, line 10, in ? 9: File string, line 6, in main 9: AttributeError: 'builtin_function_or_method' object has no attribute 'sleep' == -- http://mail.python.org/mailman/listinfo/python-list
Re: embedded python and threading
Works for me. Except that if I then do: touch time.py I get the same error as you do. Can you figure out the problem now? On Fri, Jul 26, 2013 at 11:57 AM, David M. Cotter m...@davecotter.com wrote: okay, i have simplified it: here is the code == import time def main(): while True: print i'm alive time.sleep(0.25) #- if __name__ == __main__: main() == the new error is: == 9: Traceback (most recent call last): 9: File string, line 10, in ? 9: File string, line 6, in main 9: AttributeError: 'builtin_function_or_method' object has no attribute 'sleep' == -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: embedded python and threading
In 965b463e-e5bf-4ccd-9a3c-b0cb964b3...@googlegroups.com David M. Cotter m...@davecotter.com writes: == 9: Traceback (most recent call last): 9: File string, line 10, in ? 9: File string, line 6, in main 9: AttributeError: 'builtin_function_or_method' object has no attribute 'sleep' == You must have a file named 'time.py' in the current directory, and the import statement is getting that module instead of the system time module. -- 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: Critic my module
On 26 July 2013 16:08, Alister alister.w...@ntlworld.com wrote: The main point of this is for shell users that are using Python and do not know some of the Python commands. This module would make Python more like a Linux shell. For instance, a shell user would type boash.uname() because they may not know they can type import platform; platform.uname(). But they will know how to import your module? to be honest I think this module is a solution looking for a problem you have re-invented the wheel (Square). don't let that put you off, there are many command line tools that could do with a good wrapper to make them easier to use,perhaps you are tryingto be too general. I actually think http://plumbum.readthedocs.orghttp://plumbum.readthedocs.org/en/latest/ , http://sarge.readthedocs.org and http://amoffat.github.io/sh/ do a really good job at this. I might one day even try them ;). -- http://mail.python.org/mailman/listinfo/python-list
Re: embedded python and threading
no, there is no time.py anywhere (except perhaps as the actual python library originally imported) did you understand that the function works perfectly, looping as it should, up until the time i run a second script on a separate thread? -- http://mail.python.org/mailman/listinfo/python-list
Re: embedded python and threading
DOH! as my second thread, i had been using a sample script that i had copy-pasted without much looking at it. guess what? it prints the time. and yes, it did from time import time, which explains it all. thanks for the hints here, that helped me figure it out! -- http://mail.python.org/mailman/listinfo/python-list
Re: embedded python and threading
David M. Cotter, 26.07.2013 19:28: DOH! as my second thread, i had been using a sample script that i had copy-pasted without much looking at it. guess what? it prints the time. and yes, it did from time import time, which explains it all. Ah, and you were using the same globals dict for both scripts, I guess? That explains it then. Stefan -- http://mail.python.org/mailman/listinfo/python-list
dump a multi dimensional dictionary
Hi, Can I somehow use pickle.dump() to store a dictionary of lists to a file? I tried this: import pickle mylist = [] mydict = {} mylist = '1','2' mydict['3'] = mylist fhg = open (test, 'w') pickle.dump(fhg,mydict) Traceback (most recent call last): File stdin, line 1, in module File /usr/lib/python2.7/pickle.py, line 1370, in dump Pickler(file, protocol).dump(obj) File /usr/lib/python2.7/pickle.py, line 203, in __init__ self.write = file.write AttributeError: 'dict' object has no attribute 'write' print mydict {'3': ('1', '2')} or should I just write my own dump function that can hanle thiS? Please advise! Thanks, Ron -- http://mail.python.org/mailman/listinfo/python-list
Re: dump a multi dimensional dictionary
In efdc6f6b-c061-4d3d-9d02-c397f8953...@googlegroups.com cerr ron.egg...@gmail.com writes: Can I somehow use pickle.dump() to store a dictionary of lists to a file? I tried this: import pickle mylist = [] mydict = {} mylist = '1','2' mydict['3'] = mylist fhg = open (test, 'w') pickle.dump(fhg,mydict) Traceback (most recent call last): File stdin, line 1, in module File /usr/lib/python2.7/pickle.py, line 1370, in dump Pickler(file, protocol).dump(obj) File /usr/lib/python2.7/pickle.py, line 203, in __init__ self.write = file.write AttributeError: 'dict' object has no attribute 'write' print mydict {'3': ('1', '2')} or should I just write my own dump function that can hanle thiS? I think you have the arguments to pickle.dump() in the wrong order. The data to be dumped should come first, then the file object. -- 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: dump a multi dimensional dictionary
cerr wrote: Hi, Can I somehow use pickle.dump() to store a dictionary of lists to a file? I tried this: import pickle mylist = [] mydict = {} mylist = '1','2' mydict['3'] = mylist fhg = open (test, 'w') pickle.dump(fhg,mydict) Traceback (most recent call last): File stdin, line 1, in module File /usr/lib/python2.7/pickle.py, line 1370, in dump Pickler(file, protocol).dump(obj) File /usr/lib/python2.7/pickle.py, line 203, in __init__ self.write = file.write AttributeError: 'dict' object has no attribute 'write' print mydict {'3': ('1', '2')} or should I just write my own dump function that can hanle thiS? Please advise! Thanks, Ron I think you have the parameters for dump backwards. According to API http://docs.python.org/2/library/pickle.html#pickle.dump the format is: pickle.dump(obj, file, protocol=None) Which means you need to use: pickle.dump(mydict, fhg) Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Script Hashplings
Tim Golden m...@timgolden.me.uk writes: Devyn, I'm not a *nix person so someone can point out if I'm wrong, but my understanding is that the shebang line (or whatever you want to call it) just tells the shell: run this command to run this file. So you can put #!/usr/bin/fish-and-chips as the first line and it will try to run the file using /usr/bin/fish-and-chips. Close: it's an instruction not to the shell, but to the kernel. The shell defers any “run the program in this file” to the kernel, and it's the kernel that pays attention to the file's shebang line. -- \ “When cryptography is outlawed, bayl bhgynjf jvyy unir | `\ cevinpl.” —Anonymous | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Script Hashplings
On 07/26/2013 10:14 AM, Chris Angelico wrote: On Fri, Jul 26, 2013 at 2:53 PM, MRAB pyt...@mrabarnett.plus.com wrote: If you want to test what would happen if that version wasn't installed, set the shebang line to a future version, such as Python 3.4. I doubt you have that installed! :-) Be careful, some people DO have a python3.4 binary :) Go for 3.5 for a bit more reliability. rosuav@sikorsky:~$ python3.4 3.4.0a0 (default:da7d97ca1ef6, Jul 13 2013, 14:05:08) [GCC 4.7.2] ChrisA Thank you everyone for your comments and suggestions. I made a script to test the question. see for yourself: SCRIPT: #!/usr/bin/env python3.5 import sys; print(sys.version) OUTPUT IN TERMINAL: collier@Nacho-Laptop:~$ ./test.py /usr/bin/env: python3.5: No such file or directory Mahalo, DCJ -- http://mail.python.org/mailman/listinfo/python-list
Re: dump a multi dimensional dictionary
On Fri, Jul 26, 2013 at 9:21 PM, cerr ron.egg...@gmail.com wrote: mylist = [] mydict = {} mylist = '1','2' Side point: mylist is no longer a list, it's a tuple. I don't think pickle has problems with tuples, but it's worth noting that difference. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGLet, 2to3...?
On Thursday, July 25, 2013 4:49:16 PM UTC-7, John Ladasky wrote: On Thursday, July 25, 2013 3:26:01 PM UTC-7, John Ladasky wrote: I'll try again from scratch, and see whether that clears up my problems. Nope, that didn't work. Thanks to both Jerry and Kushal. You were right, I was doing a local import of Py2.x code, instead of importing the 2to3-converted code from site-packages. -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGLet, 2to3...?
I'm making progress, but I'm not out of the woods yet. I'm trying to run some of the programs from the tutorial web pages, and from the pyglet1.2alpha1/examples directory. I've realized that I will probably need to run 2to3 on the many of the latter. The Hello, World example runs. http://www.pyglet.org/doc/programming_guide/hello_world.html The Image Viewer example... http://www.pyglet.org/doc/programming_guide/image_viewer.html ...runs if I provide a local image file, and load it using pyglet.image.load(). As written, the example fails on the line: image = pyglet.resource.image('kitten.jpg') It's possible that the alpha1.2 version of PyGLet is missing some resources. It looks like the code for the bouncing ball example ought to work, but it doesn't. That code can be found on the web at: http://www.pyglet.org/doc/programming_guide/noisy.py and also in the PyGLet package, in the folder pyglet1.2alpha1/examples/noisy. Here's my traceback which, I am sorry to report, I find less than fully informative: === Traceback (most recent call last): File /usr/local/lib/python3.3/dist-packages/pyglet/__init__.py, line 332, in __getattr__ return getattr(self._module, name) AttributeError: 'NoneType' object has no attribute 'load' During handling of the above exception, another exception occurred: Traceback (most recent call last): File /usr/local/lib/python3.3/dist-packages/pyglet/lib.py, line 111, in load_library lib = ctypes.cdll.LoadLibrary(name) File /usr/lib/python3.3/ctypes/__init__.py, line 431, in LoadLibrary return self._dlltype(name) File /usr/lib/python3.3/ctypes/__init__.py, line 353, in __init__ self._handle = _dlopen(self._name, mode) OSError: libavbin.so: cannot open shared object file: No such file or directory During handling of the above exception, another exception occurred: Traceback (most recent call last): File noisy.py, line 56, in module sound = pyglet.resource.media(BALL_SOUND, streaming=False) File /usr/local/lib/python3.3/dist-packages/pyglet/resource.py, line 610, in media return media.load(path, streaming=streaming) File /usr/local/lib/python3.3/dist-packages/pyglet/__init__.py, line 338, in __getattr__ __import__(import_name) File /usr/local/lib/python3.3/dist-packages/pyglet/media/__init__.py, line 1469, in module from . import avbin File /usr/local/lib/python3.3/dist-packages/pyglet/media/avbin.py, line 64, in module darwin='/usr/local/lib/libavbin.dylib') File /usr/local/lib/python3.3/dist-packages/pyglet/lib.py, line 118, in load_library if ((self.linux_not_found_error not in o.message) and AttributeError: 'OSError' object has no attribute 'message' === I think that only the top few lines of this traceback are relevant. Somehow a None is being passed into some function in pyglet/__init__.py, when that function expects an object with an attribute named load. Looking at the source, the function being called is _ModuleProxy.__getattr__(). I often find that Python's tracebacks stop one level short of what I really want to know. The top level calling function is frequently not named. What part of noisy.py called the code that crashed? Is there any way to get traceback to tell you more? Anyway, I wondered whether this might be a Python compatibility wart in noisy.py. Thus I tried running 2to3 on noisy.py, even though my eyes told me that the code was OK. 2to3 agreed with me, reporting: RefactoringTool: No changes to noisy.py. I'm not sure where to go next with this. One thing is for certain, all of this is way over the heads of my students... -- http://mail.python.org/mailman/listinfo/python-list
Re: RE Module Performance
On 07/26/2013 07:21 AM, wxjmfa...@gmail.com wrote: sys.getsizeof('––') - sys.getsizeof('–') I have already explained / commented this. Maybe it got lost in translation, but I don't understand your point with that. Hint: To understand Unicode (and every coding scheme), you should understand utf. The how and the *why*. Hmm, so if python used utf-8 internally to represent unicode strings would not that punish *all* users (not just non-ascii users) since searching a string for a certain character position requires an O(n) operation? UTF-32 I could see (and indeed that's essentially what FSR uses when necessary does it not?), but not utf-8 or utf-16. -- http://mail.python.org/mailman/listinfo/python-list
Re: Critic my module
As requested, some constructive criticism of your module. On Thu, 25 Jul 2013 09:24:30 -0400, Devyn Collier Johnson wrote: #!/usr/bin/python3 #Made by Devyn Collier Johnson, NCLA, Linux+, LPIC-1, DCTS What's NCLA, Linux+, LPIC-1, DCTS? Do these mean anything? Are we supposed to know what they mean? Made by has no legal significance. You probably want: Copyright © 2013 Devyn Collier Johnson. #Made using the Geany IDE Nobody gives a monkey's toss what editor you used to type up the module. You might as well mention the brand of monitor you used, or whether the keyboard is Dvorak or Qwerty. #LGPLv3 You can't just drop in a mention of LGPLv3 and expect it to mean anything. You actually have to obey the licence yourself, and that includes *actually including the licence in your work*. (You're technically in violation of the licence at the moment, however since the only person whose copyright you are infringing is yourself, it doesn't matter. However anyone else using your code is at risk.) http://www.gnu.org/licenses/gpl-howto.html In the case of the LGPL, you have to include the text of *both* the GPL and the LGPL, not just one. import re, sys, subprocess, platform def grep(regex,textf): #Sample Command: grep.grep(^x,dir()) #Syntax: boash.grep(regexp_string,list_of_strings_to_search) Comments using # are only of use to people reading the source code. If you want comments to be available at the interactive prompt, you should write them as doc strings: def grep(regex, textf): This string is a docstring. Sample command: ... Blah blah blah Then, at the interactive prompt, the user can say: help(boash.grep) to read the docstring. version = '0.2a' That's quite useless, since it is a local variable invisible outside of the function. Also, why would you bother giving every individual function a version number? That's rather pointless. The user cannot pick and choose function A with version number 0.6 and function B with version number 0.7 if the module provides versions 0.7 of both. expr = re.compile(regex) match = re.findall(expr, textf) if match != None: print(match) When comparing with None, it is preferred to use is and is not rather than equality tests. def ls(): version = '0.3' print(subprocess.getoutput('ls')) def dir(): version = '0.3' print(subprocess.getoutput('dir')) A blank line or two between functions does wonders for readability. There is no prize for conserving newlines. You might like to read PEP 8, the Python style guide. It is optional, but still makes a very good guide. http://www.python.org/dev/peps/pep-0008/ def bash(*arg): version = '0.3' print(subprocess.getoutput(arg)) def shell(*arg): version = '0.3' print(subprocess.getoutput(arg)) bash is not a synonym for shell. The shell might be sh, csh, bash, or any one of many other shells, all of which are slightly (or not so slightly) different. def clear_bash_history(): version = '0.3' print(subprocess.getoutput('history -c')) [...] Do you really need ten aliases for 'history -c'? If you want to define aliases for a function, don't recreate the entire function ten times. Start with defining the function once, then: clear_bash_hist = clear_hist = clear_history = clear_bash_history etc. But really, having ten names for the one function just confuses people, who then wonder what subtle difference there is between delete_history and clear_history. def firefox(): version = '0.3' print(subprocess.Popen('(firefox )')) Is Firefox really so important that it needs a dedicated command? What about Debian users? Doesn't Iceweasel get a command? def xterm(): version = '0.3' print(subprocess.Popen('(xterm )')) Surely the user already has an xterm open, if they are running this interactively? Why not just use your xterm's new window or new tab command? [...delete more trivial calls to subprocess...] def repeat_cmd(): version = '0.3' print(subprocess.Popen('!!')) [... delete two exact copies of this function...] def ejcd(): version = '0.3' print(subprocess.Popen('eject cdrom1')) [... delete FOURTEEN exact copies of this function...] Really? Is anyone going to type eject_disc_tray instead of eject? I think that will do. This doesn't really do anything except define a large number of trivial wrappers to commands already available in the shell. Emphasis on the *trivial* -- with the exception of the grep wrapper, which is all of four lines (ignoring the useless internal version number), every single one of these wrapper functions is a one-liner.[1] In other words, you're not adding any value to the shell commands by wrapping them in Python. There are plenty of big, complex shell commands that take a plethora of options and could do with some useful Python wrappers, like wget. But
Re: dump a multi dimensional dictionary
On Fri, 26 Jul 2013 13:21:47 -0700, cerr wrote: or should I just write my own dump function that can hanle thiS? Please advise! Given the choice between reading the documentation to pickle.dump: help(pickle.dump) or spending the next month writing a replacement for pickle, testing it, debugging it, going through revision after revision to try to bring it to the same level of maturity as pickle, which would you prefer? :-) -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: RE Module Performance
On Thu, 25 Jul 2013 21:20:45 -0600, Ian Kelly wrote: On Thu, Jul 25, 2013 at 8:48 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: UTF-8 uses a flexible representation on a character-by-character basis. When parsing UTF-8, one needs to look at EVERY character to decide how many bytes you need to read. In Python 3, the flexible representation is on a string-by-string basis: once Python has looked at the string header, it can tell whether the *entire* string takes 1, 2 or 4 bytes per character, and the string is then fixed-width. You can't do that with UTF-8. UTF-8 does not use a flexible representation. I disagree, and so does Jeremy Sanders who first pointed out the similarity between Emacs' UTF-8 and Python's FSR. I'll quote from the Emacs documentation again: To conserve memory, Emacs does not hold fixed-length 22-bit numbers that are codepoints of text characters within buffers and strings. Rather, Emacs uses a variable-length internal representation of characters, that stores each character as a sequence of 1 to 5 8-bit bytes, depending on the magnitude of its codepoint. For example, any ASCII character takes up only 1 byte, a Latin-1 character takes up 2 bytes, etc. And the Python FSR: To conserve memory, Python does not hold fixed-length 21-bit numbers that are codepoints of text characters within buffers and strings. Rather, Python uses a variable-length internal representation of characters, that stores each character as a sequence of 1 to 4 8-bit bytes, depending on the magnitude of the largest codepoint in the string. For example, any all-ASCII or all-Latin1 string takes up only 1 byte per character, an all- BMP string takes up 2 bytes per character, etc. See the similarity now? Both flexibly change the width used by code- points, UTF-8 based on the code-point itself regardless of the rest of the string, Python based on the largest code-point in the string. [...] Anyway, my point was just that Emacs is not a counter-example to jmf's claim about implementing text editors, because UTF-8 is not what he (or anybody else) is referring to when speaking of the FSR or something like the FSR. Whether JMF can see the similarities between different implementations of strings or not is beside the point, those similarities do exist. As do the differences, of course, but in this case the differences are in favour of Python's FSR. Even if your string is entirely Latin1, a UTF-8 implementation *cannot know that*, and still has to walk the string byte- by-byte checking whether the current code point requires 1, 2, 3, or 4 bytes, while a FSR implementation can simply record the fact that the string is pure Latin1 at creation time, and then treat it as fixed-width from then on. JMF claims that FSR is impossible to use efficiently, and yet he supports encoding schemes which are *less* efficient. Go figure. He tells us he has no problem with any of the established UTF encodings, and yet the FSR internally uses UTF-16 and UTF-32. (Technically, it's UCS-2, not UTF-16, since there are no surrogate pairs. But the difference is insignificant.) Having watched this issue from Day One when JMF first complained about it, I believe this is entirely about denying any benefit to ASCII users. Had Python implemented a system identical to the current FSR except that it added a fourth category, all ASCII, which used an eight-byte encoding scheme (thus making ASCII strings twice as expensive as strings including code points from the Supplementary Multilingual Planes), JMF would be the scheme's number one champion. I cannot see any other rational explanation for why JMF prefers broken, buggy Unicode implementations, or implementations which are equally expensive for all strings, over one which is demonstrably correct, demonstrably saves memory, and for realistic, non-contrived benchmarks, demonstrably faster, except that he wants to punish ASCII users more than he wants to support Unicode users. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Help
Thank you everybody who replied. The problem is fixed now and the program is running correctly. I will also try to use your suggestions in the future to make sure I don't make the same mistake. Thanks again :). -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGLet, 2to3...?
On Friday, July 26, 2013 6:19:48 PM UTC-7, John Ladasky wrote: I'm making progress, but I'm not out of the woods yet. And while I appreciate any comments that may appear here, I've just found the pyglet-users group... https://groups.google.com/forum/#!forum/pyglet-users ...so that's probably the best place for me to ask further questions. -- http://mail.python.org/mailman/listinfo/python-list
Re: RE Module Performance
On Fri, Jul 26, 2013 at 9:37 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: See the similarity now? Both flexibly change the width used by code- points, UTF-8 based on the code-point itself regardless of the rest of the string, Python based on the largest code-point in the string. No, I think we're just using the word flexible differently. In my view, simply being variable-width does not make an encoding flexible in the sense of the FSR. But I'm not going to keep repeating myself in order to argue about it. Having watched this issue from Day One when JMF first complained about it, I believe this is entirely about denying any benefit to ASCII users. Had Python implemented a system identical to the current FSR except that it added a fourth category, all ASCII, which used an eight-byte encoding scheme (thus making ASCII strings twice as expensive as strings including code points from the Supplementary Multilingual Planes), JMF would be the scheme's number one champion. I agree. In fact I made a similar observation back in December: http://mail.python.org/pipermail/python-list/2012-December/636942.html -- http://mail.python.org/mailman/listinfo/python-list
Re: RE Module Performance
On Fri, 26 Jul 2013 22:12:36 -0600, Ian Kelly wrote: On Fri, Jul 26, 2013 at 9:37 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: See the similarity now? Both flexibly change the width used by code- points, UTF-8 based on the code-point itself regardless of the rest of the string, Python based on the largest code-point in the string. No, I think we're just using the word flexible differently. In my view, simply being variable-width does not make an encoding flexible in the sense of the FSR. But I'm not going to keep repeating myself in order to argue about it. But I paid for the full half hour! http://en.wikipedia.org/wiki/The_Argument_Sketch -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Best python web framework to build university/academic website
Hi, I got a chance to build an university website, within very short period of time. I know web2py, little bit of Django, so please suggest me the best to build rapidly. Thanks in advance Raghu -- http://mail.python.org/mailman/listinfo/python-list
[issue18555] type_set_bases() doesn't check return value of PyArg_UnpackTuple()
Ronald Oussoren added the comment: This appears to be harmless. The contents of the temp list are added by mro_subclasses, and that function only adds tuples of 2 elements. That means that the call to PyArg_UnpackTuple cannot fail. It might be better to explicitly document this, either using an assert() or by calling Py_FatalError. -- nosy: +ronaldoussoren ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18555 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18555] type_set_bases() doesn't check return value of PyArg_UnpackTuple()
Christian Heimes added the comment: Ah, you are right! Good catch :) I have marked CID 486265 as intentional / ignore. -- priority: normal - low stage: needs patch - ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18555 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8079] make install fails with -j8 with python2.6/config on FreeBSD
Christian Heimes added the comment: I have never seen that kind of error with Python 2.7 or 3.3+. It's probably fixed. -- nosy: +christian.heimes resolution: - out of date stage: - committed/rejected status: open - closed type: - compile error ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8079 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18559] _pickle: NULL ptr dereference when PyLong_FromSsize_t() fails
New submission from Christian Heimes: Two functions in _pickle Py_DECREF() a variable although it may be NULL. The patch corrects the error handling paths. CID 1058277 CID 1058278 -- components: Extension Modules files: pickle_pylong_null.patch keywords: patch messages: 193729 nosy: christian.heimes priority: normal severity: normal stage: patch review status: open title: _pickle: NULL ptr dereference when PyLong_FromSsize_t() fails type: crash versions: Python 3.3, Python 3.4 Added file: http://bugs.python.org/file31037/pickle_pylong_null.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18559 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12978] Figure out extended attributes on BSDs
Changes by Ronald Oussoren ronaldousso...@mac.com: -- nosy: +ronaldoussoren ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12978 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18560] builtin_sum() doesn't check return value of PyLong_FromLong()
New submission from Christian Heimes: 2032result = PyLong_FromLong(i_result); CID 1058287 (#1 of 1): Dereference null return value (NULL_RETURNS) 34. dereference: Dereferencing a pointer that might be null result when calling PyNumber_Add(PyObject *, PyObject *). [show details] 2033temp = PyNumber_Add(result, item); -- components: Interpreter Core files: builtin_sum.patch keywords: patch messages: 193730 nosy: christian.heimes priority: normal severity: normal stage: patch review status: open title: builtin_sum() doesn't check return value of PyLong_FromLong() type: crash versions: Python 3.3, Python 3.4 Added file: http://bugs.python.org/file31038/builtin_sum.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18560 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18561] ctypes _build_callargs() doesn't check name for NULL
New submission from Christian Heimes: http://hg.python.org/cpython/file/40bec72df2a1/Modules/_ctypes/_ctypes.c#l3565 3565case PARAMFLAG_FIN: 3566/* 'in' parameter. Copy it from inargs. */ CID 486199 (#1 of 1): Explicit null dereferenced (FORWARD_NULL) 31. var_deref_model: Passing null pointer name to function _get_arg(int *, PyObject *, PyObject *, PyObject *, PyObject *), which dereferences it. [show details] 3567ob =_get_arg(inargs_index, name, defval, inargs, kwds); -- components: Extension Modules messages: 193731 nosy: christian.heimes priority: normal severity: normal stage: needs patch status: open title: ctypes _build_callargs() doesn't check name for NULL type: behavior versions: Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18561 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12978] Figure out extended attributes on BSDs
Ronald Oussoren added the comment: The OSX API also has a position argument for both getting and setting extended attributes. The position should be 0 for normal attributes, and can have other values when accessing the resource fork of a file. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12978 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18562] Regex howto: revision pass
New submission from A.M. Kuchling: I read through the 3.3 regex howto and have made various edits in the attached patch. * describe how \w is different when used in bytes and Unicode patterns. * describe re.ASCII flag to change that behaviour. * remove a personal reference ('I generally prefer...') * some small edits and re-wording. -- assignee: docs@python components: Documentation files: regex.diff keywords: patch messages: 193733 nosy: akuchling, docs@python priority: normal severity: normal stage: patch review status: open title: Regex howto: revision pass versions: Python 3.3 Added file: http://bugs.python.org/file31039/regex.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18562 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18562] Regex howto: revision pass
Changes by Berker Peksag berker.pek...@gmail.com: -- nosy: +ezio.melotti versions: +Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18562 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18563] No unit test for yiq to rgb and rgb to yiq converting functions
New submission from Vajrasky Kok: Module colorsys has hsv_to_rgb, rgb_to_hsv, hls_to_rgb, rgb_to_hls, yiq_to_rgb, rgb_to_yig public API functions. But only hsv_to_rgb, rgb_to_hsv, hls_to_rgb, rgb_to_hls functions are being unit tested. Attached the patch for adding unit test to cover the yiq_to_rgb, rgb_to_yig functions as well. -- components: Tests files: unit_test_for_yiq.txt messages: 193734 nosy: vajrasky priority: normal severity: normal status: open title: No unit test for yiq to rgb and rgb to yiq converting functions versions: Python 3.4 Added file: http://bugs.python.org/file31040/unit_test_for_yiq.txt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18563 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14074] argparse allows nargs1 for positional arguments but doesn't allow metavar to be a tuple
Changes by paul j3 ajipa...@gmail.com: -- nosy: +paul.j3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14074 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16360] argparse: comma in metavar causes assertion failure when formatting long usage message
paul j3 added the comment: My rewrite of _format_actions_usage in http://bugs.python.org/issue11874 should take care of this issue. It keeps the groups and actions separate until the final formatting step, bypassing the regular expression parsing. -- nosy: +paul.j3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16360 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18538] `python -m dis ` relying on argparse
Changes by Tshepang Lekhonkhobe tshep...@gmail.com: -- nosy: +tshepang ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18538 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18564] Integer overflow in socketmodule
New submission from Michele Orrù: In Modules/socketmodule.c , the bluetooth address supplied is vulnerable to integer overflow. Attaching patch and a couple of tests, which should be considered as a step forward in #7687. -- components: Extension Modules files: btoverflow.patch keywords: patch messages: 193736 nosy: maker priority: normal severity: normal status: open title: Integer overflow in socketmodule type: behavior Added file: http://bugs.python.org/file31041/btoverflow.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18564 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18538] `python -m dis ` should use argparse
Changes by Terry J. Reedy tjre...@udel.edu: -- title: `python -m dis ` relying on argparse - `python -m dis ` should use argparse versions: +Python 3.4 -Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18538 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14074] argparse allows nargs1 for positional arguments but doesn't allow metavar to be a tuple
paul j3 added the comment: This patch fixes the problem by joining the metavar terms with '|'. So the help for the test case (adapted from an existing tuple test) looks like: usage: PROG [-h] W1 [W2 ...] [X1 [X2 ...]] Y1 Y2 Y3 [Z1] positional arguments: W1|W2 w X1|X2 x Y1|Y2|Y3y Z1 z Alternatives include: - use ',',' ',or '/' instead of '|' - use just the 1st item of the tuple - use the default (non-tuple) metavar in the help line These all pass existing tests. The last alternative would use: #metavar = '|'.join(metavar) if len(metavar)1: metavar = default else: metavar = metavar[0] -- keywords: +patch Added file: http://bugs.python.org/file31042/issue14074.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14074 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18519] test_sqlite crashes on OS X tiger 3.x buildbot
Roundup Robot added the comment: New changeset f7a0a4e0ada4 by Victor Stinner in branch 'default': Issue #18519: the Python authorizer callback of sqlite3 must not raise Python exceptions http://hg.python.org/cpython/rev/f7a0a4e0ada4 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18519 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18519] test_sqlite crashes on OS X tiger 3.x buildbot
STINNER Victor added the comment: I take it the overflow error is the only one the C code could ever raise? If so, the patch looks good to me. Yes, _PyLong_AsInt() was the last function raising Python exception (without clearing it). Thanks for your help on fixing this function -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18519 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18504] IDLE:Improvements- Improving Mock_Text
R. Jayakrishnan added the comment: Yes,correcting myself. I should aim indexes which actual idlelib uses. Thank you Terry for the grammar. Fighting with the index parsing last week, and finally came up with a level to break the index into base and modifier and decode it along with using regular expressions. Now the mock_tk attached at this patch passes all the existing test cases, and failing the new test I have written on text_test The problem now I am dealing with is, there are four exceeding conditions I have to handle which make errors. 1.returning line 0 2.returning line last line 3.returning char 0 4.returning char its line length For example, in parsing base the return line may exceed last line but the modifier will say '-2lines' doing that, now the return line is not exceeding last line. -- keywords: +patch Added file: http://bugs.python.org/file31043/mocktk_decodeByRE1.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18504 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18559] _pickle: NULL ptr dereference when PyLong_FromSsize_t() fails
STINNER Victor added the comment: The patch looks good to me. -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18559 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18559] _pickle: NULL ptr dereference when PyLong_FromSsize_t() fails
Christian Heimes added the comment: Thanks Victor -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18559 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18559] _pickle: NULL ptr dereference when PyLong_FromSsize_t() fails
Roundup Robot added the comment: New changeset dbdd07657e23 by Christian Heimes in branch '3.3': Issue #18559: Fix NULL pointer dereference error in _pickle module http://hg.python.org/cpython/rev/dbdd07657e23 New changeset b33f81974516 by Christian Heimes in branch 'default': Issue #18559: Fix NULL pointer dereference error in _pickle module http://hg.python.org/cpython/rev/b33f81974516 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18559 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue791968] Arguments tooltip wrong if def contains tuple
Terry J. Reedy added the comment: If someone pushes a patch and closes the issue and the buildbots break, reopening the issue is the appropriate response. Too much later and the pool of potentially interested people will have changed. Anyway, the new issue is #18539. -- nosy: +terry.reedy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue791968 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18560] builtin_sum() doesn't check return value of PyLong_FromLong()
STINNER Victor added the comment: The patch looks good to me. -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18560 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15892] _PyImport_GetDynLoadFunc() doesn't check return value of fstat()
Christian Heimes added the comment: Already fixed -- resolution: - out of date stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15892 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15892] _PyImport_GetDynLoadFunc() doesn't check return value of fstat()
STINNER Victor added the comment: changeset: 84741:654268ff29b5 branch: 3.3 parent: 84736:ce771c2d0220 user:Christian Heimes christ...@cheimes.de date:Sat Jul 20 22:17:55 2013 +0200 files: Python/dynload_shlib.c description: Check return value of fstat() in _PyImport_GetDynLoadFunc() CID 486250 -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15892 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18560] builtin_sum() doesn't check return value of PyLong_FromLong()
Roundup Robot added the comment: New changeset de7e4fd634fb by Christian Heimes in branch '3.3': Issue #18560: Fix potential NULL pointer dereference in sum() http://hg.python.org/cpython/rev/de7e4fd634fb New changeset a5d9e2f3f6c7 by Christian Heimes in branch 'default': Issue #18560: Fix potential NULL pointer dereference in sum() http://hg.python.org/cpython/rev/a5d9e2f3f6c7 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18560 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15892] _PyImport_GetDynLoadFunc() doesn't check return value of fstat()
Christian Heimes added the comment: I wonder why I did not mention the issue # in the checkin message... Thanks :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15892 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18560] builtin_sum() doesn't check return value of PyLong_FromLong()
Christian Heimes added the comment: Thanks again! -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18560 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18561] ctypes _build_callargs() doesn't check name for NULL
STINNER Victor added the comment: _get_arg() should skip not check keywords if name is NULL (which looks to be a valid case, since name is check at the end of the function). -- keywords: +patch nosy: +haypo Added file: http://bugs.python.org/file31044/issue18561.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18561 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18561] ctypes _build_callargs() doesn't check name for NULL
Roundup Robot added the comment: New changeset 57457028dd7a by Christian Heimes in branch '3.3': Issue #18561: Skip name in ctypes' _build_callargs() if name is NULL. http://hg.python.org/cpython/rev/57457028dd7a New changeset d543829eda7d by Christian Heimes in branch 'default': Issue #18561: Skip name in ctypes' _build_callargs() if name is NULL. http://hg.python.org/cpython/rev/d543829eda7d -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18561 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18528] Possible fd leak in socketmodule
STINNER Victor added the comment: http://bugs.python.org/file31016/closesock3.patch looks overkill. For example, BEGIN_SELECT_LOOP already sets errno to 0. Here is a simpler patch. -- nosy: +haypo Added file: http://bugs.python.org/file31045/accept.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18528 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18528] Possible fd leak in socketmodule
STINNER Victor added the comment: @pitrou: Does accept.patch look correct? I don't understand why we would call accept() more than once. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18528 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18529] Use long dash
Éric Araujo added the comment: This looks like the kind of high-churn, low-benefit patches that we typically encourage new contributors not to do. It’s fine to update dashes when modifying the surrounding text for another fix, and it may be useful to encourage using them in the markup docs, but not to do one big change. -- nosy: +eric.araujo, r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18529 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18555] type_set_bases() doesn't check return value of PyArg_UnpackTuple()
Changes by Christian Heimes li...@cheimes.de: -- resolution: - wont fix stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18555 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18539] Idle 2.7: Calltip wrong if def contains float default value
Terry J. Reedy added the comment: If you are the same 'ariel' as on SO, thank you for the detective work and the informative report here. Without it this 2.7-only bug would be low priority and might have sat open until we stopped patching 2.7. The underlying issue is that a) 2.x had the 'feature' of allowing tuples of parameter names to signal automatic unpacking of tuples of arguments, and b) the unnamed tuple got a pseudoname of the form '.n' in the list of argument names, which calltips uses. def f((a,b), (c,d)): pass f.func_code.co_varnames ('.0', '.1', 'a', 'b', 'c', 'd') Issue #791968 added the following line to change '.n' to 'tuple'. arg_text = (%s) % re.sub(\.\d+, tuple, arg_text) But this also changes float strings of form 'm.n' to 'mtuple'. The solution is to recognize the difference between the absence and presence of a preceding digit and not do the substitution in the latter case. Adding the negative lookbehind assertion (?![0-9]) makes def f((a,b), c=0.0): produce (tuple, c=0.0). I am preparing a patch, including the test. -- assignee: - terry.reedy nosy: +terry.reedy stage: - test needed title: Arguments tooltip wrong if def contains fractional default value - Idle 2.7: Calltip wrong if def contains float default value ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18539 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4079] new urllib2.Request 'timeout' attribute needs to have a default
Indra Talip added the comment: Ah sorry you are right the tests didn't test the specific case of someone overriding the OpenerDirector. The intent was to demonstrate that adding a default timeout to Request didn't break things. I think you are right about how much of an issue this is. I agree that if you are overriding open you probably should be replicating it's functionality and doing something sane about the timeout parameter. Reading the code and the online docs I think that the more pertinent issue here is that it isn't documented how the timeout is passed to the handlers. That is if someone implements a new handler that could timeout just from reading the documentation it isn't clear how the timeout is passed to the handler. Given that open adds the timeout to the Request object perhaps the issue should be that the timeout attribute should be added to the public api of the Request and the docs modified to suit, thus making it explicit how handlers get the expected timeout. That does uglify the api though as you would have two places where you could set the timeout (on the Request and via open) and currently calling open with a Request, with a non-default timeout, means that open would override the timeout on the Request with whatever was set on the call to open. So overall I'm fairly ambivalent about how much of an issue the original report was. I think the larger issue is that how timeouts are handled/passed to handlers/processors should probably be documented. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4079 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18539] Idle 2.7: Calltip wrong if def contains float default value
Roundup Robot added the comment: New changeset 3236709650b0 by Terry Jan Reedy in branch '2.7': Issue #18539: Calltips now work for float default arguments. http://hg.python.org/cpython/rev/3236709650b0 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18539 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18539] Idle 2.7: Calltip wrong if def contains float default value
Changes by Terry J. Reedy tjre...@udel.edu: -- resolution: - fixed stage: test needed - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18539 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18552] obj2ast_object() doesn't check return value of PyArena_AddPyObject()
STINNER Victor added the comment: -Py_XINCREF(obj); +Py_INCREF(obj); This change is not correct. Here is an updated patch. -- nosy: +haypo Added file: http://bugs.python.org/file31046/obj2ast_object.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18552 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18561] ctypes _build_callargs() doesn't check name for NULL
Christian Heimes added the comment: Thanks! -- resolution: - fixed stage: needs patch - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18561 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18552] obj2ast_object() doesn't check return value of PyArena_AddPyObject()
Roundup Robot added the comment: New changeset 65121aa79ab3 by Christian Heimes in branch '3.3': Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object(). http://hg.python.org/cpython/rev/65121aa79ab3 New changeset ad90fc28769a by Christian Heimes in branch 'default': Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object(). http://hg.python.org/cpython/rev/ad90fc28769a -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18552 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18552] obj2ast_object() doesn't check return value of PyArena_AddPyObject()
Changes by Christian Heimes li...@cheimes.de: -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18552 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18369] X509 cert class for ssl module
Derek Wilson added the comment: For ssl.match_hostname to work with this, you need to get the info dict first. I've attached at patch for it. -- nosy: +underrun Added file: http://bugs.python.org/file31047/ssl_pyx509cert_match_hostname_fix.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18369 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15893] Py_FrozenMain() resource leak and missing malloc checks
Roundup Robot added the comment: New changeset ab8121466785 by Victor Stinner in branch '3.3': Issue #15893: frozenmain.c now handles PyMem_Malloc() failure http://hg.python.org/cpython/rev/ab8121466785 New changeset 386ab2c12301 by Victor Stinner in branch 'default': (Merge 3.3) Issue #15893: frozenmain.c now handles PyMem_Malloc() failure http://hg.python.org/cpython/rev/386ab2c12301 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15893 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18548] In unittest doc change WidgetTestCase to SimpleWidgetTestCase in suite()
Changes by Terry J. Reedy tjre...@udel.edu: -- nosy: +ezio.melotti, michael.foord stage: - patch review versions: +Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18548 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11152] pb in zipfile module
Changes by Damien M Calloway dama...@gmail.com: -- nosy: +dmcalloway ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11152 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18558] Iterable glossary entry needs clarification
Terry J. Reedy added the comment: Stephen, your class, or rather instances thereof when initialized with a sequence, follow the old iteration protocol. You might call them iterators in the generic sense, though I cannot remember whether we used 'iterator' much before the introduction of the new and now dominant iteration protocol. I am sure 'iterable' was introduced with the new protocol for objects with .__iter__ methods that return iterators, which in this context means an object with a .__next__ method and excludes .__getitem__ objects. It would have been less confusing is we had disabled the old protocol in 3.0, but aside from the predictable confusion, it seemed better to keep it. -- nosy: +terry.reedy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18558 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com