Re: Array of Functions
I realized that I mentioned earlier that I found a solution to my original question, but that I never posted an example of the solution. So, here is a simplified example for anyone who is interested. def fArray(fselect, fparm = 1): def A1(p = fparm): if p == 1: print(printing A1[1]) else: print(printing A1[other]) def A2(p = fparm): if p == 1: print(printing A2[1]) else: print(printing A2[other]) A = [A1, A2] A[fselect]() In this example, I enclosed two functions within another function, and then put those two functions in a list. Then, with appropriate parameters, I called one of the functions in the list, associated the formal parameter with the function in a call to the array, and presto, it performs the function. The more advanced problem I wanted to solve, a two dimensional array of functions, once this example is understood, becomes trivial to implement. In fact, the more interesting problem I wanted to solve involved a dictionary of functions in a two-dimensional array, and that too was easy to do in Python. When I compare what this would require in C, C++, Java, or most other languages, I find Python to be really easy for solving this kind of problem. Next, I plan to develop the solution using decorators and assertions to empower it with a greater level of portability and to make the functions more generic. I hope someone finds this interesting. Richard Riehle, PhD -- https://mail.python.org/mailman/listinfo/python-list
Re: Array of Functions
In a message of Tue, 26 May 2015 19:43:31 -0500, richard_riehle writes: I realized that I mentioned earlier that I found a solution to my original question, but that I never posted an example of the solution. So, here is a simplified example for anyone who is interested. def fArray(fselect, fparm = 1): def A1(p = fparm): if p == 1: print(printing A1[1]) else: print(printing A1[other]) def A2(p = fparm): if p == 1: print(printing A2[1]) else: print(printing A2[other]) A = [A1, A2] A[fselect]() In this example, I enclosed two functions within another function, and then put those two functions in a list. Then, with appropriate parameters, I called one of the functions in the list, associated the formal parameter with the function in a call to the array, and presto, it performs the function. The more advanced problem I wanted to solve, a two dimensional array of functions, once this example is understood, becomes trivial to implement. In fact, the more interesting problem I wanted to solve involved a dictionary of functions in a two-dimensional array, and that too was easy to do in Python. When I compare what this would require in C, C++, Java, or most other languages, I find Python to be really easy for solving this kind of problem. Next, I plan to develop the solution using decorators and assertions to empower it with a greater level of portability and to make the functions more generic. I hope someone finds this interesting. Richard Riehle, PhD I am happy you found a solution, but I fear that adding decorators and assertions will not do what you are asking for. I missed the original question, but it looks to me as if what you were looking for is a nice python dictionary with a tuple as an index. Since tuples are immutable, they can be used as indices, while arrays cannot. Or, despite finding it interesting, have I misunderstood what you are doing altogether? Laura -- https://mail.python.org/mailman/listinfo/python-list
Re: should self be changed?
On Tuesday, May 26, 2015 at 12:28:31 PM UTC-5, Mark Lawrence wrote: On 26/05/2015 17:37, zipher wrote: Would it be prudent to rid the long-standing argument (pun unintended) about self and the ulterior spellings of it, by changing it into a symbol rather than a name? Yes, how about you taking a permanent holiday rather than bother this list with more of your nonsense? Mark Lawrence Mr. Lawrence, could you calm down with your sadism on the list. Our session last time ended with a lot of semen on your floor instead of in your mouth. Your bosom buddy, Mark Janssen -- https://mail.python.org/mailman/listinfo/python-list
[issue24293] Windows installer unreadable with std/custom themes
New submission from Mike Miller: The new Windows installer displays itself with an HTML (or perhaps skinned) interface with hard-coded white background which does not adhere to the desktop GUI color scheme chosen by the user. Many times this is only an aesthetic problem, but it may cause the window to be unreadable if the user is using a darker, custom color scheme, or one of the standard Accessible themes such as High Contrast. Invariably the developer/framework sets only one out of two of the background/foreground pair, which I believe happened here. See attached, the white text is lost on a white background. Please set both the background/foreground to system colors to avoid this issue. These are available in CSS as well, though not commonly known. -- components: Installation, Windows files: pywin_setup.png messages: 244140 nosy: mixmastamyk, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: Windows installer unreadable with std/custom themes type: behavior versions: Python 3.5 Added file: http://bugs.python.org/file39511/pywin_setup.png ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24293 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22758] Regression in Python 3.2 cookie parsing
Changes by Tim Graham timogra...@gmail.com: Added file: http://bugs.python.org/file39512/secure-httponly-3.2-backport.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22758 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Array of Functions
On 05/26/2015 05:43 PM, richard_riehle wrote: I realized that I mentioned earlier that I found a solution to my original question, but that I never posted an example of the solution. So, here is a simplified example for anyone who is interested. def fArray(fselect, fparm = 1): def A1(p = fparm): if p == 1: print(printing A1[1]) else: print(printing A1[other]) def A2(p = fparm): if p == 1: print(printing A2[1]) else: print(printing A2[other]) A = [A1, A2] A[fselect]() Nested functions are often confusing and unclear, and there is really no need for them here. This does the same thing: def A1(p): print(printing, A1[1] if p==1 else A1[other])) def A2(p): print(printing, A2[1] if p==1 else A2[other])) def fArray(fselect, fparm=1): A = [A1,A2] A[fselect](fparm) In this example, I enclosed two functions within another function, and then put those two functions in a list. Then, with appropriate parameters, I called one of the functions in the list, associated the formal parameter with the function in a call to the array, and presto, it performs the function. The more advanced problem I wanted to solve, a two dimensional array of functions, once this example is understood, becomes trivial to implement. In fact, the more interesting problem I wanted to solve involved a dictionary of functions in a two-dimensional array, and that too was easy to do in Python. When I compare what this would require in C, C++, Java, or most other languages, I find Python to be really easy for solving this kind of problem. Next, I plan to develop the solution using decorators and assertions to empower it with a greater level of portability and to make the functions more generic. I hope someone finds this interesting. Richard Riehle, PhD -- https://mail.python.org/mailman/listinfo/python-list
[issue22758] Regression in Python 3.2 cookie parsing
Tim Graham added the comment: Patch rebased again after cookie fix from #22931. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22758 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
PyDev 4.1.0 Released
What is PyDev? --- PyDev is an open-source Python IDE on top of Eclipse for Python, Jython and IronPython development. It comes with goodies such as code completion, syntax highlighting, syntax analysis, code analysis, refactor, debug, interactive console, etc. Details on PyDev: http://pydev.org Details on its development: http://pydev.blogspot.com What is LiClipse? --- LiClipse is a PyDev standalone with goodies such as support for Multiple cursors, theming, TextMate bundles and a number of other languages such as Django Templates, Jinja2, Kivy Language, Mako Templates, Html, Javascript, etc. It's also a commercial counterpart which helps supporting the development of PyDev. Details on LiClipse: http://www.liclipse.com/ Release Highlights: --- * **Code Completion** * Improved unpacking of compound types on more situations (PyDev-573). * **Debugger** * PyDev remote debugging no longer blocks running program to completion (PyDev-574). * When there are too many referrers to some object, results are trimmed. * **Python 3 grammar** * Accepting **@** as matrix multiplication operator. * **async** and **await** are properly parsed. * Fixed issue parsing 'list remainder' construct (PyDev-568). * **Others** * Fixed issue showing editor title name when more than one dot was present in the filename. * Support automatic folding elements when opening a file -- must be enabled in PyDev Editor Code Folding (patch by Andreas Pakulat). * Fixed issue on search page. * Included css to set default editor colors for PyDev for in Eclipse dark theme. * Tab-stops on comments added and enabled by default (patch by jheiv). * Fixed StackOverflowError on code-completion (PyDev-570) Cheers, -- Fabio Zadrozny -- Software Developer LiClipse http://www.liclipse.com PyDev - Python Development Environment for Eclipse http://pydev.org http://pydev.blogspot.com PyVmMonitor - Python Profiler http://www.pyvmmonitor.com/ -- https://mail.python.org/mailman/listinfo/python-list
[issue23560] Group the docs of similar methods in stdtypes.rst
Changes by Berker Peksag berker.pek...@gmail.com: -- nosy: +berker.peksag ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23560 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24292] wsgiref.simple_server.WSGIRequestHandler doesn't log request timeouts
Changes by Berker Peksag berker.pek...@gmail.com: -- nosy: +berker.peksag ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: should self be changed?
On Tuesday, May 26, 2015 at 11:57:44 AM UTC-5, Laura Creighton wrote: In a message of Tue, 26 May 2015 09:37:29 -0700, zipher writes: Would it be prudent to rid the long-standing argument (pun unintended) about self and the ulterior spellings of it, by changing it into a symbol rather than a name? class MyClass(object): def __init__(@): @.dummy = None OR, even better, getting *rid of it* in the parameter list, so it stops confusing people about how many parameters a method needs, and transform it into a true *operator*. class MyClass(object): def __init__(): #takes no arguments! @.dummy = None #the @ invokes the class object's dictionary That would seem to be a nice solution to the problem, really. It doesn't become PERLish because you've made it into a genuine operator -- self was always a non-variable that looked like a variable and hence created an itch that couldn't be scratched. Guido did. :) http://neopythonic.blogspot.se/2008/10/why-explicit-self-has-to-stay.html Sweet link. I see now that my confusion surrounds the mistaken notion that Python is lexing python source into *abstract syntax trees* (wikipedia describes nicely), so that code inside a method knows what class it's in. But GvR hasn't defined his language to the extent where the notion of object even exists. He's only set aside a keyword called class. So of course he has to treat the method code, practically, like a [C] function. But that limits the language, not to define what an object is inside the lexical structure: object ::= class identifier ( inheritence_list ) : inheritence_list ::= [[et cetera]] If he did this, then code inside the class could already know what class they're in and all the objections in Laura's link would be moot. Mark J -- https://mail.python.org/mailman/listinfo/python-list
[issue24293] Windows installer unreadable with std/custom themes
Steve Dower added the comment: Thanks, good catch. I'm not entirely sure how we ended up in this state, since the background is actually the system colour and the text is currently hardcoded, but I'll go through and make sure that the system colour indexes are used throughout. FWIW, it's just plain Win32 UI, nothing special, but it does use some controls that were added in Windows XP and don't get used very often. -- assignee: - steve.dower ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24293 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24293] Windows installer unreadable with std/custom themes
Roundup Robot added the comment: New changeset a77214dbf1f3 by Steve Dower in branch '3.5': Issue #24293: Fixes installer colors to use system settings throughout. https://hg.python.org/cpython/rev/a77214dbf1f3 New changeset 37ed61b1234a by Steve Dower in branch 'default': Issue #24293: Fixes installer colors to use system settings throughout. https://hg.python.org/cpython/rev/37ed61b1234a -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24293 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: should self be changed?
On Wednesday 27 May 2015 05:46, Marko Rauhamaa wrote: Python's practice works. However, a small problem is presented by nested classes: class Connection: def __init__(self): class Idle: def signal_start(self): # how to refer to the outer self : : The best solution is not to use nested classes, but if you really must: class Connection: def __init__(self): class Idle: def signal_start(this): # this is the Idle instance; # self is the Connection instance -- Steve -- https://mail.python.org/mailman/listinfo/python-list
[issue21970] Broken code for handling file://host in urllib.request.FileHandler.file_open
Martin Panter added the comment: I do not believe the change fixes anything on its own. It essentially just changed the error message to something even worse, and the added test case already passes without the change. I am posting a patch which cleans up the code and related tests. It also fixes three minor theoretical bugs: urlopen(file://127.0.0.1//dev/null) # Should succeed urllib.error.URLError: urlopen error unknown url type: file urlopen(file://127.1//dev/null) # 127.1 is localhost; should succeed urllib.error.URLError: urlopen error file:// scheme is supported only on localhost urlopen(file://remote/missing) # Should not try to access local file urllib.error.URLError: urlopen error [Errno 2] No such file or directory: '/missing' The localhost check in file_open() was added by revision 982c8ec73ae3 for Issue 10063. But notice how all the test cases involve strange URLs like file://ftp.example.com//foo.txt, with second extra double slash. I removed the check, because it is redundant with the more thorough and correct check that has existed since 1994 (revision 020d8c2d9d3c) in open_local_file(). For cases like file://remote/nonlocal-file, I think it is better to raise the correct error, even if that requires a DNS check, rather than raising a faster error with a misleading message. So I moved the check before the stat() call inside open_local_file(). -- keywords: +patch stage: - patch review type: - behavior versions: +Python 3.5, Python 3.6 Added file: http://bugs.python.org/file39513/file-handler.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21970 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: should self be changed?
On Tuesday, May 26, 2015 at 11:57:44 AM UTC-5, Laura Creighton wrote: In a message of Tue, 26 May 2015 09:37:29 -0700, zipher writes: Would it be prudent to rid the long-standing argument (pun unintended) about self and the ulterior spellings of it, by changing it into a symbol rather than a name? Something like: class MyClass(object): def __init__(@): @.dummy = None OR, even better, getting *rid of it* in the parameter list, so it stops confusing people about how many parameters a method needs, and transform it into a true *operator*. class MyClass(object): def __init__(): #takes no arguments! @.dummy = None #the @ invokes the class object's dictionary That would seem to be a nice solution to the problem, really. It doesn't become PERLish because you've made it into a genuine operator -- self was always a non-variable that looked like a variable and hence created an itch that couldn't be scratched. Anyone else have any thoughts? Guido did. :) http://neopythonic.blogspot.se/2008/10/why-explicit-self-has-to-stay.html Nice link, thanks. I see the problem. I was under the false impression that Python's lexer built an *abstract syntax tree* (see wikipedia for a nice description) like C does so that lexical items like functions and objects are defined. As it stands now, Python doesn't even seem to know what an *expression* is. Guido hasn't defined his language so that an object is defined lexically, so he's cheating a little by requiring self to be passed in. If Python were to be defined more completely, all his points in reference to Bruce Eckel's suggestion would be moot. A method would automatically (not auto*magically*) know what class they are in. Mark -- https://mail.python.org/mailman/listinfo/python-list
Re: should self be changed?
On Tuesday, May 26, 2015 at 9:48:25 PM UTC-5, zipher wrote: On Tuesday, May 26, 2015 at 12:28:31 PM UTC-5, Mark Lawrence wrote: On 26/05/2015 17:37, zipher wrote: Would it be prudent to rid the long-standing argument (pun unintended) about self and the ulterior spellings of it, by changing it into a symbol rather than a name? Yes, how about you taking a permanent holiday rather than bother this list with more of your nonsense? Mark Lawrence Mr. Lawrence, could you calm down with your sadism on the list. Our session last time ended with a lot of semen on your floor instead of in your mouth. Your bosom buddy, Mark Janssen Arrgh. Sorry, that was meant privately... -m -- https://mail.python.org/mailman/listinfo/python-list
Re: should self be changed?
zipher dreamingforw...@gmail.com writes: Arrgh. Sorry, that was meant privately... I'm glad we saw it publicly, so that we get more of an idea how you treat people. That kind of homophobic slur is inappropriate from anyone in this community. Kindly cut it out altogether. -- \ “Always do right. This will gratify some people, and astonish | `\the rest.” —Mark Twain | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: OpenCV with Python (cv or cv2)
On Tuesday, May 26, 2015 at 6:52:00 AM UTC-7, Markos wrote: Hi, I want to use OpenCV with Python. I installed version 2.4.9 (http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.9/opencv-2.4.9.zip/) in debian Squeeze running Python 2.6.6. Using the tutorial: http://indranilsinharoy.com/2012/11/01/installing-opencv-on-linux/ (I tried to install versions 2.4.11 and 2.4.10 (in Squeeze with python 2.2.6) but I couldn't.) I lost some time trying to load the module cv2: Import cv2.cv the cv Traceback (most recent call last): File stdin, line 1, in module ImportError: No module named cv2.cv After a while I realized I could use the cv module. (import cv) But still I do not understand the differences between the modules cv and cv2. Do you suggest any good tutorial about the differences between cv and cv2? I will have to make many changes in python programs using cv to reuse the code later with cv2? Thanks, Markos To actually answer your questions, cv2 is the newest and best opencv binding. It uses numpy arrays, instead of what cv uses. This means it is much easier to deal with. I will also point you to https://stackoverflow.com/questions/10417108/what-is-different-between-all-these-opencv-python-interfaces -- https://mail.python.org/mailman/listinfo/python-list
Re: should self be changed?
On Wednesday 27 May 2015 02:37, zipher wrote: Would it be prudent to rid the long-standing argument (pun unintended) about self and the ulterior spellings of it, by changing it into a symbol rather than a name? No. Something like: class MyClass(object): def __init__(@): @.dummy = None OR, even better, getting *rid of it* in the parameter list, so it stops confusing people about how many parameters a method needs, and transform it into a true *operator*. I think you misspelled a word. There's no be, tt or er in worse :-) All joking aside, I cannot imagine why you think that the first argument to a method should be considered an operator. It's an argument, a named variable, not an operator. class MyClass(object): def __init__(): #takes no arguments! But that is completely wrong. __init__ DOES take a single argument -- the instance. Methods, it can be either bound to the instance or unbound: py str.upper(hello world) # unbound method, self provided explicitly 'HELLO WORLD' py hello world.upper() # bound method, self provided automatically 'HELLO WORLD' I suggest you study these two examples carefully. @.dummy = None #the @ invokes the class object's dictionary It certainly shouldn't do that. It should invoke the full attribute lookup machinery, which does far more than invoke the class __dict__. In fact, if it invoked the class __dict__, that would *completely* break the object oriented paradigm. Writing to the class __dict__ means that all instances share the same value. That would seem to be a nice solution to the problem, really. It doesn't become PERLish because you've made it into a genuine operator -- self was always a non-variable that looked like a variable and hence created an itch that couldn't be scratched. That is completely wrong. self is, and always has been, a real variable. That's why you can call it anything you like -- self is just the convention, nothing more. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: should self be changed?
On Wednesday 27 May 2015 06:45, Mark Lawrence wrote: Apart from breaking all the tools that rely on self being spelt self this looks like an excellent idea. Tools which rely on self being spelled self are already broken. It's a convention, nothing more, and there are various good reasons for breaking the convention: - metaclasses - classmethods - custom descriptors - nested classes -- Steve -- https://mail.python.org/mailman/listinfo/python-list
[issue24293] Windows installer unreadable with std/custom themes
Changes by Steve Dower steve.do...@microsoft.com: -- resolution: - fixed stage: - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24293 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: should self be changed?
On Wednesday 27 May 2015 14:39, Ben Finney wrote: zipher dreamingforw...@gmail.com writes: Arrgh. Sorry, that was meant privately... I'm glad we saw it publicly, so that we get more of an idea how you treat people. That kind of homophobic slur is inappropriate from anyone in this community. Kindly cut it out altogether. I look forward to the day when people would read the earlier insult and be perplexed as to why it is a slur at all. In the same way as your mother wears army boots has become a joke slur, not taken seriously. So long as it does nobody any harm, and all participants have consented, what one adult chooses to take into their mouth is nobody else's business and certainly no reason to look down on them. -- Steve -- https://mail.python.org/mailman/listinfo/python-list
[issue24009] Get rid of rare format units in PyArg_Parse*
Martin Panter added the comment: “u#” should not be deprecated without first deprecating “u”, which is less useful due to not returning a buffer length. Also, I have always been mystified about how “s#”, “z#”, “y” and “y#” can properly to return a pointer into a buffer for arbitrary immutable bytes-like objects, without requiring PyBuffer_Release() to be called. Perhaps this is bad design to be discouraged. Or maybe a documentation oversight somewhere. -- nosy: +vadmium ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24009 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Creating a reliable sandboxed Python environment
davidf...@gmail.com writes: Has anyone on this list attempted to sandbox Python programs in a serious fashion? I'd be interested to hear your approach. There is something like that for C++ and it is quite complicated: https://github.com/Eelis/geordi I expect that for Python you'd have to do most of the same stuff. -- https://mail.python.org/mailman/listinfo/python-list
[issue24287] Let ElementTree prolog include comments and processing instructions
Stefan Behnel added the comment: FTR, lxml's Element class has addnext() and addprevious() methods which are commonly used for this purpose. But ET can't adopt those due to its different tree model. I second Martin's comment that ET.append() is a misleading name. It suggests adding stuff to the end, whereas things are actually being inserted before the root element here. I do agree, however, that this is a helpful feature and that the ElementTree class is a good place to expose it. I propose to provide a prolog (that's the spec's spelling) property holding a list that users can fill and modify any way they wish. The serialiser would then validate that all content is proper XML prologue content, and would serialise it in order. My guess is that lxml would eventually use a MutableSequence here that maps changes directly to the underlying tree (and would thus validate them during modification), but ET can be more lenient, just like it allows arbitrary objects in the text and tail properties which only the serialiser rejects. Note that newlines can easily be generated on user side by setting the tail of a PI/Comment to \n. (The serialiser must also validate that the tail text is only allowed whitespace.) For reference: http://www.w3.org/TR/REC-xml/#sec-prolog-dtd -- components: +XML ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24287 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Creating a reliable sandboxed Python environment
On Tuesday 26 May 2015 12:24, davidf...@gmail.com wrote: I am writing a web service that accepts Python programs as input, runs the provided program with some profiling hooks, and returns various information about the program's runtime behavior. To do this in a safe manner, I need to be able to create a sandbox that restricts what the submitted Python program can do on the web server. Almost all discussion about Python sandboxes I have seen on the internet involves selectively blacklisting functionality that gives access to system resources, such as trying to hide the open builtin to restrict access to file I/O. All such approaches are doomed to fail because you can always find a way around a blacklist. It's not so much that you can find your way around a blacklist, but that a blacklist only bans things which you have thought of. Perhaps the attacker has thought of something else. Ideally, a sandbox will whitelist functions which you know are safe, with a default deny policy. That requires building your own parser which only allows code that passes your whitelist. Even then, the problem is that perhaps there is an attack vector you didn't think of: something you thought was safe, actually is not. Have you read Tav's admirable but failed attempt to sandbox file IO? http://tav.espians.com/a-challenge-to-break-python-security.html http://tav.espians.com/paving-the-way-to-securing-the-python- interpreter.html http://tav.espians.com/update-on-securing-the-python-interpreter.html Also google for Capabilities Python or CapPython. My sense is that the only way to safely sandbox Python is to create your own Python implementation designed with security in mind. You can't get there starting from CPython. Maybe Jython? For my particular sandbox, I wish to allow *only* the following kinds of actions (in a whitelist): * reading from stdin writing to stdout; * reading from files, within a set of whitelisted directories; * pure Python computation. Pure Python computation can be used to DOS your machine, e.g. (100**100)**100 will, I think, do it. (I'm not about to try it.) -- Steve -- https://mail.python.org/mailman/listinfo/python-list
[issue10685] trace does not ignore --ignore-module
Tom Hines added the comment: Test attached. Paste into test/test_trace.py. I tested in 2.7 and 3.4. Feel free to modify it. -- Added file: http://bugs.python.org/file39503/test_ignoredir.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10685 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24288] Include/opcode.h is modified during building
New submission from Serhiy Storchaka: Changeset eeeb666a5365 in issue24017 unintentionally changed formatting of generated file Include/opcode.h. Now clean building CPython modifies Include/opcode.h. One solution is to restore formatting of Include/opcode.h (regenerate it and commit). Other solution is to change Tools/scripts/generate_opcode_h.py to generate a file without trailing spaces. -- components: Build messages: 244089 nosy: asvetlov, gvanrossum, haypo, ncoghlan, python-dev, scoder, serhiy.storchaka, yselivanov priority: normal severity: normal stage: needs patch status: open title: Include/opcode.h is modified during building type: compile error versions: Python 3.5, Python 3.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24288 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24009] Get rid of rare format units in PyArg_Parse*
Martin Panter added the comment: Yes I just figured out that myself. Specifically, PyBufferProcs.bf_releasebuffer has to be NULL, and the buffer stays alive as long as the object stays alive. Also it looks like I was wrong about “u” being useless. I was tricked by a contradiction in the documentation, but I will try to fix this in a patch to Issue 24278. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24009 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24278] Docs on Parsing arguments should say something about mem mgmt for formatters returning C strings
Martin Panter added the comment: Here is a patch. Looking at the code, s#, z#, y and y# are the conversions that call convertbuffer(). These require that the object does not have a PyBufferProcs.bf_releasebuffer() method, which guarantees that the buffer’s lifetime is the same as the underlying object. In the patch I also removed a contradictory notice about nulls with the “u” conversion. -- keywords: +patch stage: needs patch - patch review versions: +Python 3.4, Python 3.5, Python 3.6 Added file: http://bugs.python.org/file39504/buffer-convert.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24278 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24286] Should OrderedDict.viewitems compare equal to dict.viewitems when the items are equal?
Serhiy Storchaka added the comment: I don't know if it is worth to backport this feature (dict views were registered in 1f024a95e9d9), but the patch itself LGTM. I think tests should be foreported to 3.x (if they don't exist in 3.x). Are there generic set tests similar to mapping_tests and seq_tests? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24286 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Documentaion of dunder methods
On Tuesday 26 May 2015 14:34, Ian Kelly wrote: Apart from PEP 8, is this documented anywhere in the official documentation? If so, I have been unable to find it. https://docs.python.org/3/reference/lexical_analysis.html#reserved- classes-of-identifiers That's the bunny! Thanks for that. -- Steve -- https://mail.python.org/mailman/listinfo/python-list
[issue24009] Get rid of rare format units in PyArg_Parse*
Serhiy Storchaka added the comment: “s#”, “z#”, “y” and “y#” work only with read-only buffers, for which PyBuffer_Release() is no-op operation. Initially they was designed for work with old buffer protocol that doesn't support releasing a buffer. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24009 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23359] Speed-up set_lookkey()
Changes by Raymond Hettinger raymond.hettin...@gmail.com: -- versions: +Python 3.6 -Python 3.5 Added file: http://bugs.python.org/file39505/nd_lookkey_insertkey3.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23359 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24286] Should OrderedDict.viewitems compare equal to dict.viewitems when the items are equal?
Roundup Robot added the comment: New changeset ff8b603ee51e by Raymond Hettinger in branch 'default': Issue #24286: Forward port dict view abstract base class tests. https://hg.python.org/cpython/rev/ff8b603ee51e -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24286 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24286] Should OrderedDict.viewitems compare equal to dict.viewitems when the items are equal?
Raymond Hettinger added the comment: I don't know if it is worth to backport this feature I don't think so either. The Iterator registry is a bit of a waste. Are there generic set tests similar to mapping_tests and seq_tests? Not that I know of. Also, I don't see the need. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24286 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24286] Should OrderedDict.viewitems compare equal to dict.viewitems when the items are equal?
Changes by Raymond Hettinger raymond.hettin...@gmail.com: -- stage: - resolved ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24286 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Documentaion of dunder methods
On 26/05/2015 04:30, Rustom Mody wrote: On Tuesday, May 26, 2015 at 8:48:11 AM UTC+5:30, Steven D'Aprano wrote: On Tue, 26 May 2015 12:17 pm, Steven D'Aprano wrote: In other words, dunder methods are reserved for use by the core developers for the use of the Python interpreter. Er, that's easy to misinterpret. Let me try rewording: You should not invent new dunder methods. And if possible, you should not call such dunder methods directly. Instead, use the official protocol (e.g. next(x), not x.__next__()) whenever possible. The operator module contains many helpers for that. But of course you may *write* dunder methods. I guess you and I know what we want to convey and to proscribe. However the above doesn't pass muster as documentation The most glaring lack in the docs is some reification of the acceptable 'protocols'. Yeah people like to wax about duck-typing but that translates into semi-formal protocols and they are just not documented All you need do is raise an issue on the bug tracker with an attached patch. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Creating a reliable sandboxed Python environment
In a message of Tue, 26 May 2015 17:10:30 +1000, Steven D'Aprano writes: My sense is that the only way to safely sandbox Python is to create your own Python implementation designed with security in mind. You can't get there starting from CPython. Maybe Jython? You get there starting with PyPy. see: http://pypy.readthedocs.org/en/latest/sandbox.html Note: this is not very heavily used. You may find bugs we don't know about yet. Laura -- https://mail.python.org/mailman/listinfo/python-list
[issue24286] Should OrderedDict.viewitems compare equal to dict.viewitems when the items are equal?
Roundup Robot added the comment: New changeset 9213c70c67d2 by Raymond Hettinger in branch '2.7': Issue #24286: Register dict views with the MappingView ABCs. https://hg.python.org/cpython/rev/9213c70c67d2 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24286 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Creating a reliable sandboxed Python environment
In a message of Tue, 26 May 2015 09:53:56 +0200, Laura Creighton writes: In a message of Tue, 26 May 2015 17:10:30 +1000, Steven D'Aprano writes: My sense is that the only way to safely sandbox Python is to create your own Python implementation designed with security in mind. You can't get there starting from CPython. Maybe Jython? You get there starting with PyPy. see: http://pypy.readthedocs.org/en/latest/sandbox.html Note: this is not very heavily used. You may find bugs we don't know about yet. Laura Also, the place to discuss this is pypy-...@python.org or the #pypy channel on freenode. Laura -- https://mail.python.org/mailman/listinfo/python-list
Re: Creating a reliable sandboxed Python environment
On Monday, May 25, 2015 at 10:24:32 PM UTC-4, davi...@gmail.com wrote: I am writing a web service that accepts Python programs as input, runs the provided program with some profiling hooks, and returns various information about the program's runtime behavior. To do this in a safe manner, I need to be able to create a sandbox that restricts what the submitted Python program can do on the web server. Almost all discussion about Python sandboxes I have seen on the internet involves selectively blacklisting functionality that gives access to system resources, such as trying to hide the open builtin to restrict access to file I/O. All such approaches are doomed to fail because you can always find a way around a blacklist. For my particular sandbox, I wish to allow *only* the following kinds of actions (in a whitelist): * reading from stdin writing to stdout; * reading from files, within a set of whitelisted directories; * pure Python computation. In particular all other operations available through system calls are banned. This includes, but is not limited to: * writing to files; * manipulating network sockets; * communicating with other processes. I believe it is not possible to limit such operations at the Python level. The best you could do is try replacing all the standard library modules, but that is again just a blacklist - it won't prevent a determined attacker from doing things like constructing their own 'code' object and executing it. It might be necessary to isolate the Python process at the operating system level. * A chroot jail on Linux OS X can limit access to the filesystem. Again this is just a blacklist. * No obvious way to block socket creation. Again this would be just a blacklist. * No obvious way to detect unapproved system calls and block them. In the limit, I could dynamically spin up a virtual machine and execute the Python program in the machine. However that's extremely expensive in computational time. Has anyone on this list attempted to sandbox Python programs in a serious fashion? I'd be interested to hear your approach. - David When we needed this at edX, we wrote CodeJail (https://github.com/edx/codejail). It's a wrapper around AppArmor to provide OS-level protection of code execution in subprocesses. It has Python-specific features, but because it is based on AppArmor, can sandbox any process, so long as it's configured properly. --Ned. -- https://mail.python.org/mailman/listinfo/python-list
[issue16927] Separate built-in types from functions and group similar functions in functions.rst
Changes by Martin Panter vadmium...@gmail.com: -- nosy: +vadmium ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16927 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24258] BZ2File objects do not have name attribute
Cliff Dyer added the comment: I'd be happy to take a look at this one, if no one else is working on it. -- nosy: +jcd ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24258 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24281] String formatting: incorrect number of decimal places
Eric V. Smith added the comment: And I just double checked: the entirety of the sentence you quoted is: The precision is a decimal number indicating how many digits should be displayed after the decimal point for a floating point value formatted with 'f' and 'F', or before and after the decimal point for a floating point value formatted with 'g' or 'G'. I think that's reasonably clear for 'g' and 'G', but if you think it could be improved, I'm open to suggestions. Maybe the disconnect is that 'g' is the default? The only reason I'm following up on this is that I'm familiar with all of this, yet it still took me some experimenting to remember what the issue is. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24281 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24285] regression for importing extensions in packages
Roundup Robot added the comment: New changeset 55e6f3f94b99 by Nick Coghlan in branch '3.5': Issue #24285: fix importing extensions from packages https://hg.python.org/cpython/rev/55e6f3f94b99 New changeset 32ee7b9d58c9 by Nick Coghlan in branch 'default': Merge fix for issue #24285 from 3.5 https://hg.python.org/cpython/rev/32ee7b9d58c9 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24285 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24268] PEP 489 -- Multi-phase extension module initialization
Nick Coghlan added the comment: I registered the fix for importing extension modules from packages against issue 24285 in the commit and NEWS file rather than against this original implementation RFE. Commit references in http://bugs.python.org/issue24285#msg244098 -- resolution: - fixed stage: - resolved status: open - closed type: - enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24268 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Creating a reliable sandboxed Python environment
On Tuesday, May 26, 2015 at 4:24:32 AM UTC+2, davi...@gmail.com wrote: I am writing a web service that accepts Python programs as input, runs the provided program with some profiling hooks, and returns various information about the program's runtime behavior. To do this in a safe manner, I need to be able to create a sandbox that restricts what the submitted Python program can do on the web server. Almost all discussion about Python sandboxes I have seen on the internet involves selectively blacklisting functionality that gives access to system resources, such as trying to hide the open builtin to restrict access to file I/O. All such approaches are doomed to fail because you can always find a way around a blacklist. For my particular sandbox, I wish to allow *only* the following kinds of actions (in a whitelist): * reading from stdin writing to stdout; * reading from files, within a set of whitelisted directories; * pure Python computation. In particular all other operations available through system calls are banned. This includes, but is not limited to: * writing to files; * manipulating network sockets; * communicating with other processes. I believe it is not possible to limit such operations at the Python level. The best you could do is try replacing all the standard library modules, but that is again just a blacklist - it won't prevent a determined attacker from doing things like constructing their own 'code' object and executing it. It might be necessary to isolate the Python process at the operating system level. * A chroot jail on Linux OS X can limit access to the filesystem. Again this is just a blacklist. * No obvious way to block socket creation. Again this would be just a blacklist. * No obvious way to detect unapproved system calls and block them. In the limit, I could dynamically spin up a virtual machine and execute the Python program in the machine. However that's extremely expensive in computational time. Has anyone on this list attempted to sandbox Python programs in a serious fashion? I'd be interested to hear your approach. - David What about launching the Python process in a Docker container? Spinning up a new container is pretty quick and it might provide you with enough isolation. Probably not a perfect solution, but I do believe that it would be easier than trying to sandbox Python itself. Marco -- https://mail.python.org/mailman/listinfo/python-list
Re: Json Comaprision
Hey all thanks for the answers, I am done wiht the same . Sorry fore delayed replied On Wed, May 6, 2015 at 9:27 AM, John Gordon gor...@panix.com wrote: In mailman.164.1430902487.12865.python-l...@python.org pra devOPS siv.dev...@gmail.com writes: I wanted to compare two json files ignoring few of the keys in the json files. Can anybody suggest me few things? Load each json file into a python object, delete the keys you don't care about, and compare the two objects. -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'. -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
[issue23560] Group the docs of similar methods in stdtypes.rst
Martin Panter added the comment: Here is a patch that groups similar methods of the str() class together at various levels. I added an alphabetical index of the methods, currently as a big paragraph of hyperlinks in the existing String Methods section. Then I added the following seven new sections. Ideally they would be ordered from important to obscure. * String Formatting * Searching and Replacing * Splitting and Joining * String Classification * Case Manipulation * Padding and Stripping * Translation and Encoding Within each section, most methods remain separate with no change to their descriptions. Some are grouped under a single description, where a there is an obvious pattern. I have tried put closely related methods nearby, while putting important and simple methods higher up, and moving their obscure and complex counterparts lower down. Depending on outcome of these changes to the string methods, I may also be interested in doing a similar job to the bytes() and bytearray() methods. -- keywords: +patch stage: needs patch - patch review versions: +Python 3.6 Added file: http://bugs.python.org/file39506/str-groups.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23560 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24260] TabError behavior doesn't match documentation
Stefan Krah added the comment: Prohibiting tabs after spaces is not enough. No, I really meant that once a new block is started with tabs, all following nested blocks must use tabs for indentation. The only place where spaces would be allowed is for aligment in logical lines that extend over multiple physical lines. Basically, just tab-oblivious formatting (which is generally nice for other languages). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24260 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24285] regression for importing extensions in packages
Nick Coghlan added the comment: Since this error was in the beta release, I used this issue reference in the NEWS file, rather than the original implementation issue. -- resolution: duplicate - fixed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24285 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24281] String formatting: incorrect number of decimal places
James Luscher added the comment: Eric, I am not familiar with the 'g' format and did not know it was the default, but the documentation, read fully, is correct. It just took the response of Christopher Welborn to wake me up (it was a LONG day and I was struggling to understand the problem - I would hate to tell you how long I worked on this problem ! {embarrassment!!}). My programming usually involves text manipulation, data structures and GUIs. The am familiar with the use of 'precision' as length of the decimal fraction but was thrown by (the equally valid) use of 'precision' as the mathematical idea referring to 'significant digits'. Counting BOTH sides of decimal point was a difficult switch of word meaning to get my head around. Just because I have never(!) used the 'g' format doesn't mean it isn't the proper choice for 'default'. Language is often a challenge and 'precision' with two meanings (# of digits to right of decimal AND total # of digits {right and left of decimal)) does present a linguistic challenge to one's ability to comprehend what the word means ;-) I wish I could give you the solution but at least I (finally !) understand the mental issue involved. Thanks to both of you for your help getting me past my 'mental fugue' ;-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24281 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21998] asyncio: support fork
Yury Selivanov added the comment: I was thinking only in the child. The parent should be able to continue to use the loop as if the fork didn't happen, right? Yes, everything should be fine. I'll rephrase my question: do you think there is a way (and need) to at least throw a warning in the master process that the fork has failed (without monkey patching os.fork() which is not an option)? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21998 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21998] asyncio: support fork
Martin Richard added the comment: Hi, My patch was a variation of haypo's patch. The goal was to duplicate the loop and its internal objects (loop and self pipes) without changing much to its state from the outside (keeping callbacks and active tasks). I wanted to be conservative with this patch, but it is not the option I prefer. I think that raising a RuntimeError in the child is fine, but may not be enough: Imho, saying the loop can't be used anymore in the child is fine, but a process in which lives an asyncio loop must not be forked is too restrictive (I'm not thinking of the fork+exec case, which is probably fine anyway) because a library may rely on child processes, for instance. Hence, we should allow a program to fork and eventually dispose the resources of the loop by calling loop.close() - or any other mechanism that you see fit (clearing all references to the loop is tedious because of the global default event loop and the cycles between futures/tasks and the loop). However, the normal loop.close() sequence will unregister all the fds registered to the selector, which will impact the parent. Under Linux with epoll, it's fine if we only close the selector. I would therefore, in the child after a fork, close the loop without breaking the selector state (closing without unregister()'ing fds), unset the default loop so get_event_loop() would create a new loop, then raise RuntimeError. I can elaborate on the use case I care about, but in a nutshell, doing so would allow to spawn worker processes able to create their own loop without requiring an idle blank child process that would be used as a base for the workers. It adds the benefit, for instance, of allowing to share data between the parent and the child leveraging OS copy-on-write. 2015-05-26 18:20 GMT+02:00 Yury Selivanov rep...@bugs.python.org: Yury Selivanov added the comment: How do other event loops handle fork? Twisted, Tornado, libuv, libev, libevent, etc. It looks like using fork() while an event loop is running isn't recommended in any of the above. If I understand the code correctly, libev gevent reinitialize loops in the forked process (essentially, you have a new loop). I think we have the following options: 1. Document that using fork() is not recommended. 2. Detect fork() and re-initialize event loop in the child process (cleaning-up callback queues, re-initializing selectors, creating new self-pipe). 3. Detect fork() and raise a RuntimeError. Document that asyncio event loop does not support forking at all. 4. The most recent patch by Martin detects the fork() and reinitializes self-pipe and selector (although all FDs are kept in the new selector). I'm not sure I understand this option. I'm torn between 2 3. Guido, Victor, Martin, what do you think? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21998 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21998 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21998] asyncio: support fork
Yury Selivanov added the comment: That's really the problem of the code that calls fork(), not directly of the event loop. There are some very solid patterns around that (I've written several in the distant past, and Unix hasn't changed that much :-). Alright ;) I'll draft a patch sometime soon. -- assignee: - yselivanov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21998 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: should self be changed?
On Tue, May 26, 2015, at 12:57, Laura Creighton wrote: Guido did. :) http://neopythonic.blogspot.se/2008/10/why-explicit-self-has-to-stay.html It's worth noting that the dynamically modify a class argument (and to some extent the decorator argument) misses Javascript's solution - _any_ function may refer to this (which is not in the argument list), which will be the global scope object (the browser window for browser-hosted javascript - presumably the current module for a hypothetical equivalent python feature, though it might be more prudent to simply make it None.) if the function is called without an object reference. Of course, Javascript also lacks bound methods, which makes it much more likely to happen by accident. I can't really think of anything that you can do with decorators, either, in the current model, that you _couldn't_ do in a JS-alike function call model... but I doubt it would be possible to implement backwards-compatibly. In principle, if you added a class keyword (hey, technically, isn't there one already?) you wouldn't need decorators at all for the staticmethod/classmethod/instance method case. -- https://mail.python.org/mailman/listinfo/python-list
[issue21998] asyncio: support fork
Guido van Rossum added the comment: I don't understand. If the fork fails nothing changes right? I guess I'm missing some context or use case. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21998 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21998] asyncio: support fork
Yury Selivanov added the comment: I don't understand. If the fork fails nothing changes right? I guess I'm missing some context or use case. Maybe I'm wrong about this. My line of thoughts is: a failed fork() call is a bug in the program. Now, the master process will continue operating as it was, no warnings, no errors. The child process will crash with a RuntimeError exception. Will it be properly reported/logged? I guess the forked child will share the stderr, so the exception won't pass completely unnoticed, right? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21998 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21998] asyncio: support fork
Yury Selivanov added the comment: I would therefore, in the child after a fork, close the loop without breaking the selector state (closing without unregister()'ing fds), unset the default loop so get_event_loop() would create a new loop, then raise RuntimeError. I can elaborate on the use case I care about, but in a nutshell, doing so would allow to spawn worker processes able to create their own loop without requiring an idle blank child process that would be used as a base for the workers. It adds the benefit, for instance, of allowing to share data between the parent and the child leveraging OS copy-on-write. The only solution to safely fork a process is to fix loop.close() to check if it's called from a forked process and to close the loop in a safe way (to avoid breaking the master process). In this case we don't even need to throw a RuntimeError. But we won't have a chance to guarantee that all resources will be freed correctly (right?) So the idea is (I guess it's the 5th option): 1. If the forked child doesn't call loop.close() immediately after forking we raise RuntimeError on first loop operation. 2. If the forked child calls (explicitly) loop.close() -- it's fine, we just close it, the error won't be raised. When we close we only close the selector (without unregistering or re-regestering any FDs), we cleanup callback queues without trying to close anything). Guido, do you still think that raising a RuntimeError in a child process in an unavoidable way is a better option? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21998 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16991] Add OrderedDict written in C
Eric Snow added the comment: Eric I realize that O (1) deletion is hard, and don't see a good way around it without changing the implementation ... I just think that the preserving the current C layout may be forcing an even more complicated solution than neccessary. I am nervous about pushing this to 3.5 because of the complexity. I agree that a simpler solution should (also?) wait for 3.6. Noted (and thanks for the feedback). I'm still comfortable with moving ahead for 3.5 with what we have. The code is documented and structured in such a way that it should be clear what's going on and relatively straightforward to adjust. There's a decent chance we will find a bug or two in corner cases, but nothing at a scale that would give me pause for a 3.5 release. Furthermore, the test suite for OrderedDict is pretty thorough so strict compatibility with the pure Python OrderedDict allows us to derive a lot of confidence about the C implementation. The question about dictheaher.h boils down to: if someone asks whether something is a dictview (not even using exact, though that isn't an option), an odictview will say false ... is that really what you want? Ah. I misunderstood your question to imply what should be added. Instead, you were just indicating what is already there. I don't think anything needs to be changed though. Those checks don't pass for the pure Python OrderedDict so I would not expect them to do so for the C implementation. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16991 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: OpenCV with Python (cv or cv2)
Markos wrote: ^^ Please append your last name. I want to use OpenCV with Python. I installed version 2.4.9 (http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.9/opencv-2.4.9.zip/) in debian Squeeze running Python 2.6.6. Using the tutorial: http://indranilsinharoy.com/2012/11/01/installing-opencv-on-linux/ Do not do that. Install the distribution packages instead. (I tried to install versions 2.4.11 and 2.4.10 (in Squeeze with python 2.2.6) but I couldn't.) I have stretch/sid with python-opencv=2.4.9+dsfg-1.1 installed. squeeze has python-opencv=2.1.0-3+squeeze1. squeeze is *oldoldstable* now. You want to upgrade NOW. https://packages.debian.org/search?suite=squeezesearchon=nameskeywords=python-opencv -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail. -- https://mail.python.org/mailman/listinfo/python-list
[issue24289] can't start Python3 due to ImportError of copy_reg
Changes by Zachary Ware zachary.w...@gmail.com: -- components: -2to3 (2.x to 3.x conversion tool) ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24289 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: SyntaxError on progress module
On Wed, May 27, 2015 at 1:59 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: On 26/05/2015 16:48, alb wrote: Hi everyone, I've installed the 'progress' module (ver 1.2) and I have the following error when used: File /home/debian/repos/2418_IASI-NG/Documents/Tools/tex_tool/venv/local/lib/python3.2/site-packages/progress/bar.py, line 48 empty_fill = u'∙' ^ SyntaxError: invalid syntax I'm running in a virtual environment with python3.2 Python 3.0 removed the 'u' for unicode in front of strings but due to popular demand to ease porting it was reinstated in 3.3. Strip it away and you should be fine to go. Or upgrade to 3.3 or better; is there anything holding you on 3.2? Building CPython from source is pretty easy on Debian, and of course upgrading to Jessie will correspondingly upgrade you to a more recent Python (3.4, to be precise). ChrisA -- https://mail.python.org/mailman/listinfo/python-list
should self be changed?
Would it be prudent to rid the long-standing argument (pun unintended) about self and the ulterior spellings of it, by changing it into a symbol rather than a name? Something like: class MyClass(object): def __init__(@): @.dummy = None OR, even better, getting *rid of it* in the parameter list, so it stops confusing people about how many parameters a method needs, and transform it into a true *operator*. class MyClass(object): def __init__(): #takes no arguments! @.dummy = None #the @ invokes the class object's dictionary That would seem to be a nice solution to the problem, really. It doesn't become PERLish because you've made it into a genuine operator -- self was always a non-variable that looked like a variable and hence created an itch that couldn't be scratched. Anyone else have any thoughts? --mark -- https://mail.python.org/mailman/listinfo/python-list
[issue21998] asyncio: support fork
Guido van Rossum added the comment: I think only (3) is reasonable -- raise RuntimeError. There are too many use cases to consider and the behavior of the selectors seems to vary as well. Apps should ideally not fork with an event loop open; the only reasonable thing to do after a fork with an event loop open is to exec another binary (hopefully closing FDs using close-on-exec). *Perhaps* it's possible to safely release some resources used by a loop after a fork but I'm skeptical even of that. Opportunistically closing the FDs used for the self-pipe and the selector seems fine (whatever is safe could be done the first time the loop is touched after the fork, just before raising RuntimeError). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21998 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
SyntaxError on progress module
Hi everyone, I've installed the 'progress' module (ver 1.2) and I have the following error when used: File /home/debian/repos/2418_IASI-NG/Documents/Tools/tex_tool/venv/local/lib/python3.2/site-packages/progress/bar.py, line 48 empty_fill = u'∙' ^ SyntaxError: invalid syntax I believe I have some problems with unicode handling but it's just a rough guess. I'm running in a virtual environment with python3.2 with the following configuration: (venv)debian@debian:tex_tool$ pip list pip (7.0.1) progress (1.2) pypandoc (0.9.7) setuptools (15.0) Any suggestions/comments/pointer is appreciated. Al -- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail? -- https://mail.python.org/mailman/listinfo/python-list
Re: should self be changed?
On Tuesday, May 26, 2015 at 3:47:20 PM UTC-4, Marko Rauhamaa wrote: zipher dreamingforw...@gmail.com: Would it be prudent to rid the long-standing argument (pun unintended) about self and the ulterior spellings of it, by changing it into a symbol rather than a name? Something like: class MyClass(object): def __init__(@): @.dummy = None OR, even better, getting *rid of it* in the parameter list, so it stops confusing people about how many parameters a method needs, and transform it into a true *operator*. Python's practice works. However, a small problem is presented by nested classes: class Connection: def __init__(self): class Idle: def signal_start(self): # how to refer to the outer self : : Solutions include: ... class Connection: def __init__(self): conn = self class Idle: def signal_start(self): conn.set_state(Ready) : I have used the latter method recently. I would find it much clearer to not use a nested class at all, and instead to pass the object into the constructor: class Idle: def __init__(self, conn): self.conn = conn def signal_start(self): self.conn.set_state(Ready) class Connection: def __init__(self): something(Idle(self)) --Ned. -- https://mail.python.org/mailman/listinfo/python-list
[issue24270] PEP 485 (math.isclose) implementation
Tal Einat added the comment: Attached is a revised patch including changed due to the reviews by Berker and Yuri. The significant changes from the previous patch are: 1. The rel_tol and abs_tol parameters have been made keyword-only. 2. The tests have been extracted into a separate TestCase sub-class. They are now better organized and will be easy to re-use for testing cmath.isclose when it is added (hopefully soon). -- Added file: http://bugs.python.org/file39509/math_isclose_v3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24270 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24292] wsgiref.simple_server.WSGIRequestHandler doesn't log request timeouts
New submission from Jonathan Kamens: http.BaseHTTPRequestHandler logs request timeouts. In handle_one_request(): except socket.timeout as e: #a read or a write timed out. Discard this connection self.log_error(Request timed out: %r, e) self.close_connection = 1 return Unfortunately, wsgiref.simple_server.WSGIRequestHandler, which overrides BaseHTTPRequestHandler's handle() method, does _not_ catch and log request timeouts. Fixing this is a simple matter of wrapping the entire body of its handle() function in a try with this except clause: except socket.timeout as e: self.log_error(Request timed out: %r, e) raise -- components: Library (Lib) messages: 244134 nosy: Jonathan Kamens priority: normal severity: normal status: open title: wsgiref.simple_server.WSGIRequestHandler doesn't log request timeouts type: behavior versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: should self be changed?
zipher dreamingforw...@gmail.com wrote: Would it be prudent to rid the long-standing argument (pun unintended) about self and the ulterior spellings of it, by changing it into a symbol rather than a name? Something like: class MyClass(object): def __init__(@): @.dummy = None Believe or not, python3 (via Guido's time machine) already anticipated this suggestion and you can indeed use a symbol instead of 'self': class MyClass(object): def __init__(ስ): ስ.dummy = None -- --- | Radovan Garabík http://kassiopeia.juls.savba.sk/~garabik/ | | __..--^^^--..__garabik @ kassiopeia.juls.savba.sk | --- Antivirus alert: file .signature infected by signature virus. Hi! I'm a signature virus! Copy me into your signature file to help me spread! -- https://mail.python.org/mailman/listinfo/python-list
[issue24291] wsgiref.handlers.SimpleHandler truncates large output blobs
New submission from Jonathan Kamens: The _write method of wsgiref.handlers.SimpleHandler reads as follows: def _write(self,data): self.stdout.write(data) The problem here is that calling write() on a socket is not actually guaranteed to write all of the data in the buffer. If the length of data is large enough, then the kernel will take only part of it. In that case, the rest of the response data will be silently discarded by wsgiref. _write needs to check the return value of self.stdout.write(data), and if it is less than the length of data, repeat the write from the middle of the data buffer, etc., until all the data has been written. -- components: Library (Lib) messages: 244131 nosy: Jonathan Kamens priority: normal severity: normal status: open title: wsgiref.handlers.SimpleHandler truncates large output blobs type: behavior versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24291 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21998] asyncio: support fork
Guido van Rossum added the comment: I don't actually know if the 5th option is possible. My strong requirement is that no matter what the child process does, the parent should still be able to continue using the loop. IMO it's better to leak a FD in the child than to close a resource owned by the parent. Within those constraints I'm okay with various solutions. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21998 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24290] c_uint32 bitfields break structures
Ned Deily added the comment: Without diving into the details of your test program, I get the same results on a 64-bit Debian Python 2.7.9 as with a 64-bit OS X 2.7.10: c_uint32 TESTS: Class Name exponentnumber Signfloat binary repr IEEE754Float_u ('-0x7b', '0xbeb2aL', 0L, 69.95930480957031, ['0x42', '0x8b', '0xeb', '0x2a']) IEEE754Float_u ('-0x7b', '0xbeb2aL', 0L, 69.95930480957031, ['0x42', '0x8b', '0xeb', '0x2a']) AN575Float_uint ('0x0', '0xbeb2a', 0L, 1.094551427887186e-39, ['0x0', '0xb', '0xeb', '0x2a']) AN575Float_uint ('0x0', '0xbeb2a', 0L, 1.094551427887186e-39, ['0x0', '0xb', '0xeb', '0x2a']) AN575Float_uint ('-0x7b', '0xbeb2a', 0L, 1.094551427887186e-39, ['0x85', '0xb', '0xeb', '0x2a']) IEEE754Float_u ('-0x7b', '0xbeb2aL', 1L, -69.95930480957031, ['0xc2', '0x8b', '0xeb', '0x2a']) AN575Float_uint ('-0x7b', '0xbeb2a', 1L, 1.094551427887186e-39, ['0x85', '0x8b', '0xeb', '0x2a']) But using the same OS X 2.7.10 in 32-bit mode, I get: c_uint32 TESTS: Class Name exponentnumber Signfloat binary repr IEEE754Float_u ('-0x7b', '0xbeb2aL', 0L, 69.95930480957031, ['0x42', '0x8b', '0xeb', '0x2a']) IEEE754Float_u ('-0x7b', '0xbeb2aL', 0L, 69.95930480957031, ['0x42', '0x8b', '0xeb', '0x2a']) AN575Float_uint ('-0x7b', '0xbeb2a', 0L, 69.95930480957031, ['0x85', '0xb', '0xeb', '0x2a']) AN575Float_uint ('-0x7b', '0xbeb2a', 0L, 69.95930480957031, ['0x85', '0xb', '0xeb', '0x2a']) AN575Float_uint ('-0x7b', '0xbeb2a', 0L, 69.95930480957031, ['0x85', '0xb', '0xeb', '0x2a']) IEEE754Float_u ('-0x7b', '0xbeb2aL', 1L, -69.95930480957031, ['0xc2', '0x8b', '0xeb', '0x2a']) AN575Float_uint ('-0x7b', '0xbeb2a', 1L, -69.95930480957031, ['0x85', '0x8b', '0xeb', '0x2a']) -- nosy: +ned.deily ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24290 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: different types of inheritence...
Apart from object composition or mix-in style, I want to illustrate something regarding the arrow of inheritance. class super_dict(dict): def __init__(self, init={}, default_value=0, collision_function=None): *expands what dict can do* def get_default(self): #stupid method to illustrate a point return self._default_value class specialized_dict(dict): def update(self, other): *change the behavior of how updates work* def setdefault(self, key, value): if key=sentinel: self[key]=0 else: self[key]=value Okay, perhaps I wasn't being clear THESE OBJECTS HAVE THE SAME CLASS *SYNTAX*, BUT COMPLETELY DIFFERENT *SEMANTICS*. Comprende? I'm not trying to be cryptic here. This is a bit of OOP theory to be discussed. Mark -- https://mail.python.org/mailman/listinfo/python-list
Re: should self be changed?
Ned Batchelder n...@nedbatchelder.com: I would find it much clearer to not use a nested class at all, and instead to pass the object into the constructor: Nested classes are excellent and expressing the state pattern URL: http://en.wikipedia.org/wiki/State_pattern. Marko -- https://mail.python.org/mailman/listinfo/python-list
[issue24290] c_uint32 bitfields break structures
New submission from Rony Batista: ctypes Structures with c_uint32 bitfields have strange behaviour on OS X. In the attached code when the field number is set, it changes the whole 32 bits, even thou its meant to be 23 bits. The behavior is unexpected in: OS X: Python 2.7.9 The behavior is as expected in the following environments: Windows: python 2.7.9 Ubuntu: python 2.7.6 -- components: ctypes messages: 244125 nosy: Rony Batista priority: normal severity: normal status: open title: c_uint32 bitfields break structures type: behavior versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24290 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16500] Add an 'atfork' module
Changes by Yury Selivanov yseliva...@gmail.com: -- nosy: +yselivanov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16500 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24284] Inconsistency in startswith/endswith
Serhiy Storchaka added the comment: Could you please help me with wording? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24284 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24290] c_uint32 bitfields break structures
Ronald Oussoren added the comment: You forgot to actually attach the code. -- nosy: +ronaldoussoren ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24290 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23509] Speed up Counter operators
Serhiy Storchaka added the comment: Perhaps correct __pos__ docstring? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23509 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23509] Speed up Counter operators
Changes by Serhiy Storchaka storch...@gmail.com: -- Removed message: http://bugs.python.org/msg244128 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23509 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23509] Speed up Counter operators
Serhiy Storchaka added the comment: Perhaps update __pos__ docstring? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23509 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21998] asyncio: support fork
Martin Richard added the comment: 015-05-26 20:40 GMT+02:00 Yury Selivanov rep...@bugs.python.org: Yury Selivanov added the comment: The only solution to safely fork a process is to fix loop.close() to check if it's called from a forked process and to close the loop in a safe way (to avoid breaking the master process). In this case we don't even need to throw a RuntimeError. But we won't have a chance to guarantee that all resources will be freed correctly (right?) If all the tasks are cancelled and loop's internal structures (callback lists, tasks sets, etc) are cleared, I believe that the garbage collector will eventually be able to dispose everything. However, it's indeed not enough: resources created by other parts of asyncio may leak (transports, subprocess). For instance, I proposed to add a detach() method for SubprocessTransport here: http://bugs.python.org/issue23540 : in this case, I need to close stdin, stdout, stderr pipes without killing the subprocess. So the idea is (I guess it's the 5th option): 1. If the forked child doesn't call loop.close() immediately after forking we raise RuntimeError on first loop operation. 2. If the forked child calls (explicitly) loop.close() -- it's fine, we just close it, the error won't be raised. When we close we only close the selector (without unregistering or re-regestering any FDs), we cleanup callback queues without trying to close anything). Guido, do you still think that raising a RuntimeError in a child process in an unavoidable way is a better option? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21998 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21998 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: should self be changed?
zipher dreamingforw...@gmail.com: Would it be prudent to rid the long-standing argument (pun unintended) about self and the ulterior spellings of it, by changing it into a symbol rather than a name? Something like: class MyClass(object): def __init__(@): @.dummy = None OR, even better, getting *rid of it* in the parameter list, so it stops confusing people about how many parameters a method needs, and transform it into a true *operator*. Python's practice works. However, a small problem is presented by nested classes: class Connection: def __init__(self): class Idle: def signal_start(self): # how to refer to the outer self : : Solutions include: class Connection: def __init__(self): class Idle: def signal_start(_): self.set_state(Ready) : class Connection: def __init__(self): conn = self class Idle: def signal_start(self): conn.set_state(Ready) : I have used the latter method recently. Marko -- https://mail.python.org/mailman/listinfo/python-list
[issue24290] c_uint32 bitfields break structures
Rony Batista added the comment: Silly me, Heres the code. -- Added file: http://bugs.python.org/file39508/ctypesBug.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24290 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24291] wsgiref.handlers.SimpleHandler truncates large output blobs
Changes by Ned Deily n...@acm.org: -- nosy: +pje versions: +Python 3.6 -Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24291 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23359] Speed-up set_lookkey()
Changes by Raymond Hettinger raymond.hettin...@gmail.com: Added file: http://bugs.python.org/file39510/new_set_timings.txt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23359 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: should self be changed?
On 26/05/2015 21:26, garabik-news-2005...@kassiopeia.juls.savba.sk wrote: zipher dreamingforw...@gmail.com wrote: Would it be prudent to rid the long-standing argument (pun unintended) about self and the ulterior spellings of it, by changing it into a symbol rather than a name? Something like: class MyClass(object): def __init__(@): @.dummy = None Believe or not, python3 (via Guido's time machine) already anticipated this suggestion and you can indeed use a symbol instead of 'self': class MyClass(object): def __init__(ስ): ስ.dummy = None Apart from breaking all the tools that rely on self being spelt self this looks like an excellent idea. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
[issue24292] wsgiref.simple_server.WSGIRequestHandler doesn't log request timeouts
Changes by Ned Deily n...@acm.org: -- nosy: +pje versions: +Python 3.6 -Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: different types of inheritence...
On 05/26/2015 08:57 AM, zipher wrote: Comprende? I'm not trying to be cryptic here. This is a bit of OOP theory to be discussed. No, sorry. Maybe an actual example (with use case) would spur discussion. -- https://mail.python.org/mailman/listinfo/python-list
Re: different types of inheritence...
On Tue, May 26, 2015 at 2:52 PM, Michael Torrie torr...@gmail.com wrote: On 05/26/2015 08:57 AM, zipher wrote: Comprende? I'm not trying to be cryptic here. This is a bit of OOP theory to be discussed. No, sorry. Maybe an actual example (with use case) would spur discussion. Better yet, ignore the troll. -- https://mail.python.org/mailman/listinfo/python-list
Re: should self be changed?
Mark Lawrence wrote: def __init__(ስ): ስ.dummy = None Apart from breaking all the tools that rely on self being spelt self this looks like an excellent idea. too bad for the tools: using the name self is just a convention, not a rule. -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Re: should self be changed?
On 2015-05-26 21:45, Mark Lawrence wrote: class MyClass(object): def __init__(ስ): ስ.dummy = None Apart from breaking all the tools that rely on self being spelt self this looks like an excellent idea. Though to be fair, they *are* broken tools if they rely on self since there's nothing in the Python specs that require that. It's just a convention[1]. -tkc [1] https://docs.python.org/2/tutorial/classes.html#random-remarks Often, the first argument of a method is called self. This is nothing more than a convention: the name self has absolutely no special meaning to Python. Note, however, that by not following the convention your code may be less readable to other Python programmers, and it is also conceivable that a class browser program might be written that relies upon such a convention. It does give fair warning, but I'd consider that a warning to authors of class browser program[s] as much as to developers. -- https://mail.python.org/mailman/listinfo/python-list
[issue24270] PEP 485 (math.isclose) implementation
Tal Einat added the comment: Significant questions brought up by Berker Peksağ in his review of the latest patch (thanks for the review!): 1. Should the tolerance parameters be keyword-only? Berker suggests that they should be. I agree. 2. Should the math.isclose() tests be split into a separate TestCase class with many separate methods? It is currently a single method which does all of the testing for math.isclose(). (Chris's original code has it separated into several TestCase classes; I consolidated it into a single method to keep in line with the current structure of the math module's tests.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24270 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: OpenCV with Python (cv or cv2)
In a message of Tue, 26 May 2015 10:24:30 -0300, Markos writes: Hi, I want to use OpenCV with Python. I installed version 2.4.9 (http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.9/opencv-2.4.9.zip/) in debian Squeeze running Python 2.6.6. Using the tutorial: http://indranilsinharoy.com/2012/11/01/installing-opencv-on-linux/ (I tried to install versions 2.4.11 and 2.4.10 (in Squeeze with python 2.2.6) but I couldn't.) You mean python 2.6.6, right? and this package: https://packages.debian.org/source/squeeze/opencv which is 2.1.0-3 is too old for you? What do you mean that you tried to install versions 2.4.11 and 2.4.10 but couldn't? What error messages did you get? I lost some time trying to load the module cv2: Import cv2.cv the cv s/the/as/ ? Traceback (most recent call last): File stdin, line 1, in module ImportError: No module named cv2.cv After a while I realized I could use the cv module. (import cv) But still I do not understand the differences between the modules cv and cv2. Do you suggest any good tutorial about the differences between cv and cv2? I will have to make many changes in python programs using cv to reuse the code later with cv2? Thanks, Markos -- https://mail.python.org/mailman/listinfo/python-list post the output you got from cmake It will probably complain that it is missing some headers, so couldn't make libcv2.so If you haven't installed python-dev (not just python) and numpy I guarantee it will not find needed headers; if you have but it is still not being made we will have to look harder at what is going wrong. If it made a libcv.so for you, did it put it in a place you can see with your PYTHONPATH? Laura -- https://mail.python.org/mailman/listinfo/python-list
[issue24284] Inconsistency in startswith/endswith
R. David Murray added the comment: Just in the what's new porting section, I think. The fact that there should be very little to no code that relies on this is why I'd like to see it fixed. The fact that the report was a theoretical one, and not one that broke code, is why I think we should fix it only in 3.5. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24284 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24289] can't start Python3 due to ImportError of copy_reg
R. David Murray added the comment: copyreg.py is part of the standard library, but you obviously have a file shadowing it in your site-packages. If this is a result of the pip upgrade, you should report this to the pip tracker. -- nosy: +r.david.murray resolution: - third party stage: - resolved status: open - closed type: compile error - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24289 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: a more precise distance algorithm
On Mon, May 25, 2015, at 15:21, ravas wrote: Is this valid? Does it apply to python? Any other thoughts? :D The math.hypot function uses the C library's function which should deal with such concerns internally. There is a fallback version in case the C library does not have this function, in Python/pymath.c - which, incidentally, does use your algorithm. -- https://mail.python.org/mailman/listinfo/python-list