ANN: Python Tools for Visual Studio 1.5
We're pleased to announce the release of Python Tools for Visual Studio 1.5 RTM - http://pytools.codeplex.com/releases/view/82132. Python Tools for Visual Studio (PTVS) is an open-source plug-in for Visual Studio which supports programming with the Python language. PTVS supports a broad range of features including CPython/IronPython, Edit/Intellisense/Debug/Profile, Cloud, HPC, IPython, etc. support. For a quick overview of the general IDE experience, please see http://www.youtube.com/watch?v=7CoGsSlrxKk There are a number of exciting improvement in this release compared to 1.1, all based on your feedback suggestions. Here's a summary: IDE: * VS2012 support * Django Project, Edit, Intellisense, Template debugging support: - YT: http://www.youtube.com/watch?v=UsLti4KlgAY * A Live Debug REPL - YT: http://www.youtube.com/watch?v=erNx2NLu-t4hd=1 * Parallel Stack View and Parallel Watch windows for threaded code support - YT: http://www.youtube.com/watch?v=WRs4r-cQfjE * Project load time improvements * PyKinect: Kinect SDK 1.5 support * New New Project from Existing Code! * Improved Intellisense (iterator, PyQt, ...) * Python 3.3 language support Cloud: * Python is now a 1st class language on Azure! See: https://www.windowsazure.com/en-us/develop/python/ * Azure Python Client Libraries for Windows, MacOS and Linux (not a typo). See https://github.com/WindowsAzure/azure-sdk-for-python ; o On PyPI: http://pypi.python.org/pypi/azure/ o On GitHub: https://github.com/WindowsAzure/azure-sdk-for-python * New in 1.5 RTM: Azure Python Client Lib support for System Management API's. - YT: http://www.youtube.com/watch?v=nDvqNP_Ja5s * IPython on Azure: A Python IDE in the browser, backed by a Windows or Linux VM. See: https://www.windowsazure.com/en-us/develop/python/tutorials/ipython-notebook/ * Azure: new WFastCGI for Azure/IIS * Azure Web Sites Python Framework support: Django, Flask, Bottle, Web2Py, ... support LINK There were over 100 fixes/improvements in this release compared to 1.1. Here's a link to the list of changes: http://bit.ly/PTVS15RTMBugs We'd like to thank the following people who took the time to report the issues and feedback for this release (in reverse chronological order): RC: Tmaslach, odwalla, jrade, michiya, timeisparallax, tachiorz, sourbox, tramsay, bahrep, lqbest127, hyh, mrpy, boomer_74, BigFreakinGobot, AngeloBast, ajp, mahpour, cecilphillip, dhabersat. Beta: ajp, Anna0311, golubdr, hjyh, hyh, mahpour, tramsay, and zooba. Alpha: Anna0311, golubdr, hjyh, tramsay, zooba. Thank you! -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: sort order for strings of digits
Le mercredi 31 octobre 2012 16:17:19 UTC+1, djc a écrit : I learn lots of useful things from the list, some not always welcome. No sooner had I found a solution to a minor inconvenience in my code, than a recent thread here drew my attention to the fact that it will not work for python 3. So suggestions please: TODO 2012-10-22: sort order numbers first then alphanumeric n ('1', '10', '101', '3', '40', '31', '13', '2', '2000') s ('a', 'ab', 'acd', 'bcd', '1a', 'a1', '222 bb', 'b a 4') sorted(n) ['1', '10', '101', '13', '2', '2000', '3', '31', '40'] sorted(s) ['1a', '222 bb', 'a', 'a1', 'ab', 'acd', 'b a 4', 'bcd'] sorted(n+s) ['1', '10', '101', '13', '1a', '2', '2000', '222 bb', '3', '31', '40', 'a', 'a1', 'ab', 'acd', 'b a 4', 'bcd'] Possibly there is a better way but for Python 2.7 this gives the required result Python 2.7.3 (default, Sep 26 2012, 21:51:14) sorted(int(x) if x.isdigit() else x for x in n+s) [1, 2, 3, 10, 13, 31, 40, 101, 2000, '1a', '222 bb', 'a', 'a1', 'ab', 'acd', 'b a 4', 'bcd'] [str(x) for x in sorted(int(x) if x.isdigit() else x for x in n+s)] ['1', '2', '3', '10', '13', '31', '40', '101', '2000', '1a', '222 bb', 'a', 'a1', 'ab', 'acd', 'b a 4', 'bcd'] But not for Python 3 Python 3.2.3 (default, Oct 19 2012, 19:53:16) sorted(n+s) ['1', '10', '101', '13', '1a', '2', '2000', '222 bb', '3', '31', '40', 'a', 'a1', 'ab', 'acd', 'b a 4', 'bcd'] sorted(int(x) if x.isdigit() else x for x in n+s) Traceback (most recent call last): File stdin, line 1, in module TypeError: unorderable types: str() int() The best I can think of is to split the input sequence into two lists, sort each and then join them. -- djc # Py 3.2.3 z = ['1', '10', '101', '13', '1a', '2', '2000', ... '222 bb', '3', '31', '40', 'a', 'a1', 'ab', ... 'acd', 'b a 4', 'bcd' ... ] n, s = [], [] for e in z: ... if e.isdigit(): ... n.append(int(e)) ... else: ... s.append(e) ... n.sort() s.sort() ns = [str(e) for e in n] ns.extend(s) ns ['1', '2', '3', '10', '13', '31', '40', '101', '2000', '1a', '222 bb', 'a', 'a1', 'ab', 'acd', 'b a 4', 'bcd'] jmf -- http://mail.python.org/mailman/listinfo/python-list
python and Open cv
How to load a yml file in python and work with it ?? I used : import cv data = cv.Load(Z:/data/xyz_0_ 300.yml) But when I print data.. it just gives the detail of the image like number of rows and columns etc I want read what is there in the pixel of the image.. I tried to use the following code .. but it gives me only the pixel values not the information contained in pixel ?? def AccessPixels(img): for y in range(0, img.height): for x in range(0, img.width): cv.Get2D(img, y, x) # Slow get pixel value. cv.Set2D(img, y, x, (0, 0, 0, 0)) # Slow set pixel value. can somebody help.. thanx in advance !!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
/ Robert Miles wrote on Wed 31.Oct'12 at 0:39:02 -0500 / For those of you running Linux: You may want to look into whether NoCeM is compatible with your newsreader and your version of Linux. It checks newsgroups news.lists.filters and alt.nocem.misc for lists of spam posts, and will automatically hide them for you. Not available for other operating systems, though, except possibly Unix. Anybody serious about programming should be using a form of UNIX/Linux if you ask me. It's inconceivable that these systems should be avoided if you're serious about Software Engineering and Computer Science, etc. For UNIX there are loads of decent news reading software and mail user agents to learn and use. slrn is a good one and point it at gmane.org as someone else pointed out. I can't even imagine using a browser or Google Groups, etc. now. -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
/ Steven D'Aprano wrote on Wed 31.Oct'12 at 22:33:16 + / On Wed, 31 Oct 2012 12:32:57 -0700, rurpy wrote: I don't killfile merely for posting from Gmail or Google Groups, but regarding your second point, it has seemed to me for some years now that Gmail is the new Hotmail, which was the new AOL. Whenever there is an inane, lazy, mind-numbingly stupid question or post, chances are extremely high that the sender has a Gmail address. That's a bit harsh but then, sadly there's some truth in it. I subscribe to a number of technical mailing lists, like that of my OS OpenBSD and the problem doesn't exist there whether they use Gmail or Hotmail, etc, or not. This and the tutor python list are the two I have the most problems with formatting. Some people just don't seem to give a shit about sending horrid html and other irritating formatted mail in spite of being asked not to do so. -- http://mail.python.org/mailman/listinfo/python-list
Re: python and Open cv
On 01.11.2012, at 09:55, inshu chauhan wrote: How to load a yml file in python and work with it ?? Try one of these: http://pypi.python.org/pypi?%3Aaction=searchterm=yamlsubmit=search -- Stefan H. Holek ste...@epy.co.at -- http://mail.python.org/mailman/listinfo/python-list
Re: Negative array indicies and slice()
On 10/31/12 8:16 PM, Andrew Robinson wrote: On 10/31/2012 02:20 PM, Ian Kelly wrote: On Wed, Oct 31, 2012 at 7:42 AM, Andrew Robinson wrote: Then; I'd note: The non-goofy purpose of slice is to hold three data values; They are either numbers or None. These *normally* encountered values can't create a memory loop. So, FOR AS LONG, as the object representing slice does not contain an explicit GC pair; I move that we mandate (yes, in the current python implementation, even as a *fix*) that its named members may not be assigned any objects other than None or numbers eg: Lists would be forbidden Since functions, and subclasses, can be test evaluated by int( the_thing_to_try ) and *[] can too, generality need not be lost for generating nothing or numbers. PEP 357 requires that anything implementing the __index__ special method be allowed for slicing sequences (and also that __index__ be used for the conversion). For the most part, that includes ints and numpy integer types, but other code could be doing esoteric things with it. I missed something... (but then that's why we're still talking about it...) Reading the PEP, it notes that *only* integers (or longs) are permitted in slice syntax. (Overlooking None, of course... which is strange...) The PEP gives the only exceptions as objects with method __index__. Automatically, then, an empty list is forbidden (in slice syntax). However, What you did, was circumvent the PEP by passing an empty list directly to slice(), and avoiding running it through slice syntax processing. Why do you think it is forbidden by the syntax? [~] |1 class A(object): .. def __getitem__(self, key): .. return key .. [~] |2 a = A() [~] |3 a[[]:] slice([], None, None) The PEP is a little unclear and refers to a state of the Python interpreter that no longer exists. At the time, I think __getslice__() was still not deprecated, and it did require ints (or after the PEP, __index__able objects). __getslice__() is now deprecated in favor of __getitem__() where you can interpret slice objects with arbitrary objects to your heart's content. Arbitrary objects *are* definitely allowed by the slice syntax (how could the syntax know what is an int and what is another kind of object?). Most objects that interpret slices, especially the builtin sequence types, do require __index__able objects (or None). So, what's the psychology behind allowing slice() to hold objects which are not converted to ints/longs in the first place? In numpy, we (ab)use this freedom for some convenient notation in special objects. We have a couple of grid-making convenience objects: [~] |5 numpy.mgrid[1.5:2.5:0.1] array([ 1.5, 1.6, 1.7, 1.8, 1.9, 2. , 2.1, 2.2, 2.3, 2.4]) This syntax uses the start:stop:step notation to make a float range. If we use an imaginary integer in the step slot, mgrid will interpret it as the number of items requested instead of the step. [~] |6 numpy.mgrid[1.5:2.5:11j] array([ 1.5, 1.6, 1.7, 1.8, 1.9, 2. , 2.1, 2.2, 2.3, 2.4, 2.5]) -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: python and Open cv
On 01/11/2012 08:55, inshu chauhan wrote: How to load a yml file in python and work with it ?? I used : import cv data = cv.Load(Z:/data/xyz_0_ 300.yml) But when I print data.. it just gives the detail of the image like number of rows and columns etc I want read what is there in the pixel of the image.. I tried to use the following code .. but it gives me only the pixel values not the information contained in pixel ?? def AccessPixels(img): for y in range(0, img.height): for x in range(0, img.width): cv.Get2D(img, y, x) # Slow get pixel value. cv.Set2D(img, y, x, (0, 0, 0, 0)) # Slow set pixel value. can somebody help.. thanx in advance !!! I think the subject should be changed to Obnoxious postings from Google Groups, given this is the same question from the same person within 24 hours but a different subject line, and from a gmail address. -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to perform word sense disambiguation?
On 11/1/12 5:14 AM, nachiket wrote: an initial part of my project involves assigning sense to each word in sentence. I came across this tool called wordnet. do share your views You can get access to Wordnet and a wide variety of useful tools in NLTK: http://nltk.org/ http://nltk.org/book/ch06.html http://nltk.org/api/nltk.classify.html -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
RE: Fastest web framework
Per community request turbogears and pysi were added. The following posts have been updated: http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html http://mindref.blogspot.com/2012/10/python-web-pep8-consistency.html Comments or suggestions are welcome. Thanks. Andriy From: andriy.kornats...@live.com To: python-list@python.org Subject: Fastest web framework Date: Sun, 23 Sep 2012 12:19:16 +0300 I have run recently a benchmark of a trivial 'hello world' application for various python web frameworks (bottle, django, flask, pyramid, web.py, wheezy.web) hosted in uWSGI/cpython2.7 and gunicorn/pypy1.9... you might find it interesting: http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html Comments or suggestions are welcome. Thanks. Andriy Kornatskyy -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: datetime issue
On 2012-10-31, ru...@yahoo.com ru...@yahoo.com wrote: On 10/31/2012 09:11 AM, Grant Edwards wrote: On 2012-09-16, ?? nikos.gr...@gmail.com wrote: Iam positng via google groups using chrome, thats all i know. Learn something else. Google Groups is seriously and permanently broken, and all posts from Google Groups are filtered out and ignored by many people (including myself -- I only saw this because somebody else replied to it). Feel free to filter whatever you want but be aware than in doing so you risk missing information that could help you avoid disseminating erroneous info. Of course, carrying out some kind of private war against Google Groups may be more important to you than that... Based on past experience, the chances of useful information being posted via Google Groups is very small. The benefit of avoiding all the spam and garbage the comes from that source is more than worth the small risk of missing something worthwhile. Note that I'm _not_ talking about people posting to the mailing list using Gmail -- only people posting via the Google Groups web UI. -- Grant Edwards grant.b.edwardsYow! Four thousand at different MAGNATES, MOGULS gmail.com NABOBS are romping in my gothic solarium!! -- http://mail.python.org/mailman/listinfo/python-list
Fwd: python and Open cv
-- Forwarded message -- From: inshu chauhan insidesh...@gmail.com Date: Thu, Nov 1, 2012 at 1:26 PM Subject: Re: python and Open cv To: Mark Lawrence breamore...@yahoo.co.uk I am sorry.. but I need to know what are the rules and what about gmail ?? Many people are using gmail to mail to the list. On Thu, Nov 1, 2012 at 12:15 PM, Mark Lawrence breamore...@yahoo.co.ukwrote: On 01/11/2012 08:55, inshu chauhan wrote: How to load a yml file in python and work with it ?? I used : import cv data = cv.Load(Z:/data/xyz_0_ 300.yml) But when I print data.. it just gives the detail of the image like number of rows and columns etc I want read what is there in the pixel of the image.. I tried to use the following code .. but it gives me only the pixel values not the information contained in pixel ?? def AccessPixels(img): for y in range(0, img.height): for x in range(0, img.width): cv.Get2D(img, y, x) # Slow get pixel value. cv.Set2D(img, y, x, (0, 0, 0, 0)) # Slow set pixel value. can somebody help.. thanx in advance !!! I think the subject should be changed to Obnoxious postings from Google Groups, given this is the same question from the same person within 24 hours but a different subject line, and from a gmail address. -- Cheers. Mark Lawrence. -- http://mail.python.org/**mailman/listinfo/python-listhttp://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Negative array indicies and slice()
Andrew Robinson wrote: On 10/31/2012 02:20 PM, Ian Kelly wrote: On Wed, Oct 31, 2012 at 7:42 AM, Andrew Robinson wrote: Then; I'd note: The non-goofy purpose of slice is to hold three data values; They are either numbers or None. These *normally* encountered values can't create a memory loop. So, FOR AS LONG, as the object representing slice does not contain an explicit GC pair; I move that we mandate (yes, in the current python implementation, even as a *fix*) that its named members may not be assigned any objects other than None or numbers eg: Lists would be forbidden Since functions, and subclasses, can be test evaluated by int( the_thing_to_try ) and *[] can too, generality need not be lost for generating nothing or numbers. PEP 357 requires that anything implementing the __index__ special method be allowed for slicing sequences (and also that __index__ be used for the conversion). For the most part, that includes ints and numpy integer types, but other code could be doing esoteric things with it. I missed something... (but then that's why we're still talking about it...) Reading the PEP, it notes that *only* integers (or longs) are permitted in slice syntax. Keep in mind that PEPs represent Python /at that time/ -- as Python moves forward, PEPs are not updated (this has gotten me a couple times). The change would be backward-incompatible in any case, since there is certainly code out there that uses non-numeric slices -- one example has already been given in this thread. Hmmm. Now, I'm thinking -- The purpose of index(), specifically, is to notify when something which is not an integer may be used as an index; You've helpfully noted that index() also *converts* those objects into numbers. Ethan Fullman mentioned that he used the names of fields, instead of having to remember the _offsets_; Which means that his values _do convert_ to offset numbers Furman, actually. :) And my values do *not* convert to indices (at least, not automatically). My __getitem__ code looks like: elif isinstance(item, slice): sequence = [] if isinstance(item.start, (str, unicode)) \ or isinstance(item.stop, (str, unicode)): field_names = dbf.field_names(self) start, stop, step = item.start, item.stop, item.step if start not in field_names or stop not in field_names: raise MissingFieldError( Either %r or %r (or both) are not valid field names % (start, stop)) if step is not None and not isinstance(step, (int, long)): raise DbfError( step value must be an int or long, not %r % type(step)) start = field_names.index(start) stop = field_names.index(stop) + 1 item = slice(start, stop, step) for index in self._meta.fields[item]: sequence.append(self[index]) return sequence In other words, the slice contains the strings, and my code calculates the offsets -- Python doesn't do it for me. His example was actually given in slice syntax notation [::]. Hence, his objects must have an index() method, correct?. Nope. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: Negative array indicies and slice()
On Fri, Nov 2, 2012 at 1:12 AM, Ethan Furman et...@stoneleaf.us wrote: In other words, the slice contains the strings, and my code calculates the offsets -- Python doesn't do it for me. That's correct, but you're still translating those strings into numeric indices. You can slice a database record based on column names (though personally I would recommend against it - creates too much dependence on column order, which I prefer to treat as non-significant), but you can't, for instance, slice a dictionary by keys: foo = {asdf:123,qwer:234,zxcv:345,1234:456} foo[qwer:1234] # What should this return? I suppose conceptually you could slice any iterable by discarding till you match the start, then yielding till you match the stop, then returning (it'd function like itertools.islice but using non-numeric indices - somehow). But it still depends on there being a dependable order. (Incidentally, isinstance(X, (str, unicode)) can become isinstance(X, basestring) - they both inherit from that.) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
pythonic way
what is the most pythonic way to do this : if 0 ix 10 and 0 iy 10 ??? -- http://mail.python.org/mailman/listinfo/python-list
How to remotely Automate GUI using pywinauto
Hi, Here I have a situation: I am trying to automate a GUI application and get some data from it. I tried using 'pywinauto' to launch the application and select the data and save it in -say notepad and later read it. This works fine when the script is locally run on the windows machine. My scenario is to do it remotely. What I have done is, keep the script in a location on windows machine and execute from a linux machine over SSH. The scripts gets Initiated but raises exception as below: File C:\Python27\lib\site-packages\pywinauto\application.py, line 229, in __getattr__ ctrls = _resolve_control(self.criteria) File C:\Python27\lib\site-packages\pywinauto\application.py, line 788, in _resolve_control raise e.original_exception Can anyone please tell me how to remotely Automate Windwos GUI using pywinauto , or there another better method. Thanks, Shambhu -- http://mail.python.org/mailman/listinfo/python-list
Re: pythonic way
On 2012-11-01 15:32, inshu chauhan wrote: what is the most pythonic way to do this : if 0 ix 10 and 0 iy 10 ??? That looks Pythonic to me, except for the missing colon. -- http://mail.python.org/mailman/listinfo/python-list
Re: pythonic way
On 11/01/12 10:32, inshu chauhan wrote: what is the most pythonic way to do this : if 0 ix 10 and 0 iy 10 ??? What's wrong with the syntax you provide? It's perfectly pythonic: ix = 42 yx = 3.14159 if 0 ix 10 and 0 iy 10: do_stuff(ix, iy) else: do_other_stuff(ix, iy) -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: pythonic way
On 11/1/2012 11:32 AM, inshu chauhan wrote: what is the most pythonic way to do this : if 0 ix 10 and 0 iy 10 ??? end with : instead of ??? ix, iy = 3,4 if 0 ix 10 and 0 iy 10: print('This was too easy') This was too easy -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Negative array indicies and slice()
Chris Angelico wrote: On Fri, Nov 2, 2012 at 1:12 AM, Ethan Furman et...@stoneleaf.us wrote: In other words, the slice contains the strings, and my code calculates the offsets -- Python doesn't do it for me. That's correct, but you're still translating those strings into numeric indices. True, but the point is that the /slice/ contains a data type that is neither a number, nor directly translatable into a number (that is, no __index__ method), and my code would cease to function should that change to slices be made. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: pythonic way
On Thu, Nov 1, 2012 at 9:32 AM, inshu chauhan insidesh...@gmail.com wrote: what is the most pythonic way to do this : if 0 ix 10 and 0 iy 10 ??? I suppose you could do if all(0 i 10 for i in (ix, iy)): but I think that the original is more readable unless you have several variables to test. -- http://mail.python.org/mailman/listinfo/python-list
Re: pythonic way
: On 1 November 2012 11:32, inshu chauhan insidesh...@gmail.com wrote: what is the most pythonic way to do this : if 0 ix 10 and 0 iy 10 ??? As everyone else has said, it's perfectly pythonic once you stick the colon on the end. You might find it more instantly readable with some extra parentheses: if (0 ix 10) and (0 iy 10): # do something ... but that's really just down to taste. -[]z. -- http://mail.python.org/mailman/listinfo/python-list
Re: python and Open cv
: On 1 November 2012 08:48, inshu chauhan insidesh...@gmail.com wrote: I am sorry.. but I need to know what are the rules and what about gmail ?? Many people are using gmail to mail to the list. There aren't any rules about gmail (except the unwritten rule that to be a real geek you need to use a mail client that takes a whole weekend to configure, and another three years to properly understand). It's helpful to other people on the list, though, if you post follow-up questions in the same thread - finding the last relevant message and hitting reply to all will do this in gmail. -[]z. -- http://mail.python.org/mailman/listinfo/python-list
Re: python and Open cv
Zero Piraeus sche...@gmail.com writes: There aren't any rules about gmail (except the unwritten rule that to be a real geek you need to use a mail client that takes a whole weekend to configure, and another three years to properly understand). Ha! 3 years? I've been using gnus for nearly 20 years and I still don't understand it! -- http://mail.python.org/mailman/listinfo/python-list
Re: Negative array indicies and slice()
On 11/01/2012 07:12 AM, Ethan Furman wrote: Andrew Robinson wrote: On 10/31/2012 02:20 PM, Ian Kelly wrote: On Wed, Oct 31, 2012 at 7:42 AM, Andrew Robinson wrote: Then; I'd note: The non-goofy purpose of slice is to hold three data values; They are either numbers or None. These *normally* encountered values can't create a memory loop. So, FOR AS LONG, as the object representing slice does not contain an explicit GC pair; snip A little review... The premise of my statement here, is that Tim Peter's closed the Bug report; http://bugs.python.org/issue1501180 With the *reason* being that using GC was *goofy* on account of what slice() was intended to hold, None and a number. So, My first attempt at bug fix was simply to take Tim Peter's at his word... since we all assume he *isn't* a Bloody Idiot. Hey isn't that a swear-word somewhere in the world? Its not where I live, but I seem to recall... oh, well... whatever. I missed something... (but then that's why we're still talking about it...) Reading the PEP, it notes that *only* integers (or longs) are permitted in slice syntax. Keep in mind that PEPs represent Python /at that time/ -- as Python moves forward, PEPs are not updated (this has gotten me a couple times). And, since I am reading them in the order written (but in 3.0) trying to get the whole of Python into my mind on the journey to prep for porting it into a tiny chip -- I'm frustrated by not being finished yet... Furman, actually. :) :-! And my values do *not* convert to indices (at least, not automatically). Ahhh (Rhetorical sarcastic) I was wondering how you added index() method to strings, not access it, and still be following the special PEP we are talking about,when you gave that example using unwrapped strings. -- H was that PEP the active state of Python, when Tim rejected the bug report? eg: have we moved on into a place where the bug report ought to be re-issued since that PEP is now *effectively* passe, and Tim could thus be vindicated from being a b... Idiot? (Or has he been given the 1st place, Python Twit award -- and his *man* the bug list been stripped?) In other words, the slice contains the strings, and my code calculates the offsets -- Python doesn't do it for me. ~Ethan~ I see, so the problem is that PEP wants you to implement the index(), but that is going to cause you to subclass string, and add a wrapper interface every time you need to index something. eg: doing something llke --- mydbclass[ MyString( 'fromColumn' ) : MyString( 'toColum' ) ] and the code becomes a candy machine interface issue (Chapter 5, Writing Solid Code). My favorite line there uses no swearing If they had just taken an extra *30* seconds thinking about their design, they could have saved me, and I'm sure countless others, from getting something they didn't want. I laugh, if they didn't get it already -- an extra *30* seconds is WY to optimistic. Try minutes at least, will a policeman glaring over their shoulder. But anyhow --- The problem lies in *when* the conversion to an integer is to take place, not so much if it is going to happen. Your indexes, no matter how disguised, eventually will become numbers; and you have a way that minimizes coding cruft (The very reason I started the thread, actually... subclassing trivially to fix candy machine interfaces leads to perpetual code increases -- In cPython source-code, realloc wrappers and malloc wrappers are found I've seen these wrappers *re*-invented in nearly every C program I've every looked at! Talk about MAN-hours, wasted space, and cruft.) So; is this a reasonable summary of salient features (status quo) ? * Enforcing strict numerical indexes (in the slice [::] operator) causes much psychological angst when attempting to write clear code without lots of wrapper cruft. * Pep 357 merely added cruft with index(), but really solved nothing. Everything index() does could be implemented in __getitem__ and usually is. * slice().xxxs are merely a container for *whatever* was passed to [::] * slice() is * slice is also a full blown object, which implements a trivial method to dump the contents of itself to a tuple. * presently slice() allows memory leaks through GC loops. * Slice(), even though an object with a constructor, does no error checking to deny construction of memory leaks. If people would take 30 seconds to think about this the more details added -- the more comprehensive can be my understanding -- and perhaps a consensus reached about the problem. These are a list of relevant options, without respect to feasability. * Don't bother to fix the bug; allow Python to crash with a subtle bug that often take weeks to track down by the very small minority doing strange things (Equivalent to the monkey patch syndrome of D'Aprano; BTW: The longer the bug is left unfixed, the
Re: Negative array indicies and slice()
On Thu, Nov 1, 2012 at 10:32 PM, Andrew Robinson andr...@r3dsolutions.com wrote: presently slice() allows memory leaks through GC loops. Forgive me if I've missed something here, but isn't it only possible to make a refloop by decidedly abnormal behaviour? Stuff like: a=[]; a.append(slice(a)) Seriously, who does this? First you have to have a reference to a container in place of an index, and then you have to retain the slice object inside that same container as well. Neither operation is normal use of a slice. Where is the problem? ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Negative array indicies and slice()
On Thu, Nov 1, 2012 at 5:32 AM, Andrew Robinson andr...@r3dsolutions.com wrote: H was that PEP the active state of Python, when Tim rejected the bug report? Yes. The PEP was accepted and committed in March 2006 for release in Python 2.5. The bug report is from June 2006 has a version classification of Python 2.5, although 2.5 was not actually released until September 2006. Pep 357 merely added cruft with index(), but really solved nothing. Everything index() does could be implemented in __getitem__ and usually is. No. There is a significant difference between implementing this on the container versus implementing it on the indexes. Ethan implemented his string-based slicing on the container, because the behavior he wanted was specific to the container type, not the index type. Custom index types like numpy integers on the other hand implement __index__ on the index type, because they apply to all sequences, not specific containers. This must be separate from standard int conversion, because standard int conversion is too general for indexing. slice is also a full blown object, which implements a trivial method to dump the contents of itself to a tuple. slice.indices() does not trivially dump its contents as given. It takes a sequence length and adjusts its indices to that length. The C implementation of this is around 60 lines of code. Don't bother to fix the bug; allow Python to crash with a subtle bug that often take weeks to track down by the very small minority doing strange things (Equivalent to the monkey patch syndrome of D'Aprano; BTW: The longer the bug is left unfixed, the more people will invent uses for it ) It's been 6 years already. AFAIK nobody has invented any uses that are actually at risk of invoking the GC bug. -- http://mail.python.org/mailman/listinfo/python-list
Re: Negative array indicies and slice()
Ian Kelly wrote: On Thu, Nov 1, 2012 at 5:32 AM, Andrew Robinson wrote: Don't bother to fix the bug; allow Python to crash with a subtle bug that often take weeks to track down by the very small minority doing strange things (Equivalent to the monkey patch syndrome of D'Aprano; BTW: The longer the bug is left unfixed, the more people will invent uses for it ) It's been 6 years already. AFAIK nobody has invented any uses that are actually at risk of invoking the GC bug. The bug is not that slice allows non-numbers, but that slice objects aren't tracked by gc; I'm not seeing an issue with not fixing the bug. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
lazy properties?
Seeing the wonderful lazy val in Scala I thought that I should try to get the following also in Python. The problem is that I often have this pattern in my code: class Sample: def __init__(self): self._var = None @property def var(self): if self._var is None: self._var = long_computation() else: return self._var which is quite useful when you have some expensive attribute to compute that is not going to change. I was trying to generalize it in a @lazy_property but my attempts so far failed, any help on how I could do that? What I would like to write is @lazy_property def var_lazy(self): return long_computation() and this should imply that the long_computation is called only once.. -- http://mail.python.org/mailman/listinfo/python-list
Re: python and Open cv
On Thu, Nov 1, 2012 at 7:02 PM, Paul Rudin paul.nos...@rudin.co.uk wrote: Zero Piraeus sche...@gmail.com writes: There aren't any rules about gmail (except the unwritten rule that to be a real geek you need to use a mail client that takes a whole weekend to configure, and another three years to properly understand). :D :D :D Ha! 3 years? I've been using gnus for nearly 20 years and I still don't understand it! -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: pythonic way
OK ..I got it.. On Thu, Nov 1, 2012 at 5:54 PM, Zero Piraeus sche...@gmail.com wrote: : On 1 November 2012 11:32, inshu chauhan insidesh...@gmail.com wrote: what is the most pythonic way to do this : if 0 ix 10 and 0 iy 10 ??? As everyone else has said, it's perfectly pythonic once you stick the colon on the end. You might find it more instantly readable with some extra parentheses: if (0 ix 10) and (0 iy 10): # do something ... but that's really just down to taste. -[]z. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: lazy properties?
On Thu, Nov 1, 2012 at 3:38 PM, Andrea Crotti andrea.crott...@gmail.com wrote: What I would like to write is @lazy_property def var_lazy(self): return long_computation() and this should imply that the long_computation is called only once.. If you're using Python 3.2+, then functools.lru_cache probably suffices for your needs. @property @functools.lru_cache() def var_lazy(self): return long_computation() If you really need to shorten that to a single declaration: def lazy_property(func): return property(functools.lru_cache()(func)) -- http://mail.python.org/mailman/listinfo/python-list
Re: datetime issue
On Wednesday, October 31, 2012 3:38:57 PM UTC-6, Mark Lawrence wrote: On 31/10/2012 19:35, ru...@yahoo.com wrote: Broken? Yes. But so is every piece of software in one way or another. Thunderbird is one of the most perpetually buggy pierces of software I have ever used on a continuing basis Please provide evidence that Thunderbird is buggy. I use it quite happily, don't have problems, and have never seen anybody complaining about it. I hesitate to respond to this because thunderbird bugs are really OT, but since you insist... A few years ago started keeping a list TB problems I encountered. I stopped maintaining it a year or so ago. It is a mixture of bugs, misfeatures, and things I couldn't figure out, etc. Many have been fixed in later versions. Nevertheless, it illustrates *my* experience with TB. Note that despite the problems, I still use TB in some contexts. Different apps have different bugs/(mis)features and every person has their own weighting factors on those bugs. End result is different people prefer different apps for different purposes (and some of us find GG the least worst choice for posting here.) * In Search dialog clicked on the Search in folder dropdown after an earlier search and TB crashed (disappeared along with the new message I was editing.) [3.0.1] * Search for japanese text in body no longer works (never finds text even when it exists). [3.0.1] Used to work. * Each mail message displays useless header info that uses 25% of the available vertical space. * When editing a reply message, typing a return at eol results in two blank lines inserted. * When editing message, siometimes edit cursor disappears tho editing still seems to work normally. * Requires voodoo to create hmtl new message when default is plain text or visa versa. Have to hold shift key while clicking write button. Shift while choosing new, reply, etc in menu doesn't work. * Frequently, clinking on a usenet newsgroup results in TB freeze. Only solution is to remove group and re-add later. (Problem since 2.x days.) * Frequently after an apparently normal shutdown, attempt to restart results in TB is already running error. * Some folders in the folder tree view are greyed out and not selectable even though they have no visible different properties than selectable ones. Don't know how they got that way. * Clicking on a folder in the folder tree pane results in a pop- up dialog this folder is not selectable that has to be dismissed, even though one is trying to get it's properties, or is selecting it to create a subfolder. * Messages change from read to unread in folders at random when folder is accessed, or even when it is not accessed. [gone in 3.0.3?] * Interminttently, when I click a usenet message to view it, the contents pane remains blank. Contents of that message remain blank foreever. [new with 3.0.1]. * When TB main window closed while editing an email, can no longer save the email, even if the TB main window is reopened. * Counts of new messages in usenet groups are often wildly high. * When opening up a usenet server, status bar reports no new messages on server even though TB then updates the groups with the new messages that *are* on the server. [new in 3.0.1] * After upgrade to TB-3.0, opening a usenet server results not only in the group being scanned for new messages in each group (as before) but also the headers for all those new messages being downloaded (slow on a dialup connection and a waste of time if I don't intend to read anything in that group). No obvious way to revert to original behaviour. * Even tho the number of unread messages listed beside a usenet group in the folder pane is less than the download limit, I sometimes get pop-up asking how many messages to download, when I access the group. (side effect of above problem I think.) * Sometimes TB downloads two copies of each header. * When I compress folders, get a series of several dozen pop- up messages (each requiring a click on OK) telling me that foplder xx is not selectable. * Copy-paste from TB to other app fails if TB is closed before the paste -- the paste buffer appears empty [TB-3.0b4] * Copy paste fails by removing text (forgot if it is just the copied text or other text) in the TB message when pasted somewhere else. [TB-2?] * After upgrade to TB-3.0x, i no longer see a way to create a new imap subfolder. Had to create it using MSOE. * After upgrade to TB-3.0x double clicking on attached .jpg image no longer opens it -- only option is to save and open outside of TB. phfft. * HTF do you change the font size for plain text message composition? Prefs has a setting for html but... * search of body for multiple anded text never ends if one of the search boxes is empty. * Search stop button doesn't stop search. * One group frequently, without any action on my part, read thousands of
Re: lazy properties?
On 01Nov2012 21:38, Andrea Crotti andrea.crott...@gmail.com wrote: | Seeing the wonderful lazy val in Scala I thought that I should try to | get the following also in Python. | The problem is that I often have this pattern in my code: | | class Sample: | def __init__(self): | self._var = None | | @property | def var(self): | if self._var is None: | self._var = long_computation() | else: | return self._var | | | which is quite useful when you have some expensive attribute to compute | that is not going to change. | I was trying to generalize it in a @lazy_property but my attempts so far | failed, any help on how I could do that? | | What I would like to write is | @lazy_property | def var_lazy(self): | return long_computation() | | and this should imply that the long_computation is called only once.. I've got one of these which I use exactly as you wish above: def lazy_property(func): ''' A property whose access is controlled by a lock if unset. ''' lock_name = '_lock' prop_name = '_' + func.__name__ unset_object = None def getprop(self): ''' Attempt lockless fetch of property first. Use lock if property is unset. ''' p = getattr(self, prop_name) if p is unset_object: with getattr(self, lock_name): p = getattr(self, prop_name) if p is unset_object: ##debug(compute %s..., prop_name) p = func(self) ##warning(compute %s[%s].%s: %s, self, id(self), prop_name, type(p)) setattr(self, prop_name, p) return p return property(getprop) It computes the cached property name from the function name, but uses a global lock name _lock on the basis that the long_computation() will use shared state with the rest of the object. The microoptimisation of the lockless fetch may be either nonportable or pointless. I need to abstract this with a deeper level of nesting to support chaning lock_name, prop_name and unset_object if the caller desires, but for what you want it will work out of the box. I've got a similar thing that watches files for modification and reloads at need. Cheers, -- Cameron Simpson c...@zip.com.au Cordless hoses have been around for quite some time. They're called buckets. - Dan Prener pre...@watson.ibm.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
On 11/01/2012 03:55 AM, Jamie Paul Griffin wrote: Anybody serious about programming should be using a form of UNIX/Linux if you ask me. It's inconceivable that these systems should be avoided if you're serious about Software Engineering and Computer Science, etc. For UNIX there are loads of decent news reading software and mail user agents to learn and use. slrn is a good one and point it at gmane.org as someone else pointed out. I can't even imagine using a browser or Google Groups, etc. now. Are you saying that this group is only for serious programmers? serious is also a matter of opinion. I have some serious programmer friends who maintain, in complete sincerity, that serious programmers should not waste time on slow, script-kiddie languages like Python, but should be developing their skills with serious professional languages like Java, C#, etc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Negative array indicies and slice()
On 11/01/2012 12:07 PM, Ian Kelly wrote: On Thu, Nov 1, 2012 at 5:32 AM, Andrew Robinson andr...@r3dsolutions.com wrote: H was that PEP the active state of Python, when Tim rejected the bug report? Yes. The PEP was accepted and committed in March 2006 for release in Python 2.5. The bug report is from June 2006 has a version classification of Python 2.5, although 2.5 was not actually released until September 2006. That explain's Peter's remark. Thank you. He looks *much* smarter now. Pep 357 merely added cruft with index(), but really solved nothing. Everything index() does could be implemented in __getitem__ and usually is. No. There is a significant difference between implementing this on the container versus implementing it on the indexes. Ethan implemented his string-based slicing on the container, because the behavior he wanted was specific to the container type, not the index type. Custom index types like numpy integers on the other hand implement __index__ on the index type, because they apply to all sequences, not specific containers. Hmmm... D'Aprano didn't like the monkey patch;and sub-classing was his fix-all. Part of my summary is based on that conversation with him,and you touched on one of the unfinished points; I responded to him that I thought __getitem__ was under-developed. The object slice() has no knowledge of the size of the sequence; nor can it get that size on it's own, but must passively wait for it to be given to it. The bottom line is: __getitem__ must always *PASS* len( seq ) to slice() each *time* the slice() object is-used. Since this is the case, it would have been better to have list, itself, have a default member which takes the raw slice indicies and does the conversion itself. The size would not need to be duplicated or passed -- memory savings, speed savings... I'm just clay pidgeoning an idea out here Let's apply D'Aprano 's logic to numpy; Numpy could just have subclassed *list*; so let's ignore pure python as a reason to do anything on the behalf on Numpy: Then, lets' consider all thrid party classes; These are where subclassing becomes a pain -- BUT: I think those could all have been injected. class ThirdParty( list ): # Pretend this is someone else's... ... def __init__(self): return ... def __getitem__(self,aSlice): return aSlice ... We know it will default work like this: a=ThirdParty() a[1:2] slice(1, 2, None) # So, here's an injection... ThirdParty.superOnlyOfNumpy__getitem__ = MyClass.__getitem__ ThirdParty.__getitem__ = lambda self,aSlice: ( 1, 3, self.superOnlyOfNumpy__getitem__(aSlice ).step ) a[5:6] (1, 3, None) Numpy could have exported a (workable) function that would modify other list functions to affect ONLY numpy data types (eg: a filter). This allows user's creating their own classes to inject them with Numpy's filter only when they desire; Recall Tim Peter's explicit is better than implicit Zen? Most importantly normal programs not using Numpy wouldn't have had to carry around an extra API check for index() *every* single time the heavily used [::] happened. Memory speed both. It's also a monkey patch, in that index() allows *conflicting* assumptions in violation of the unexpected monkey patch interaction worry. eg: Numpy *CAN* release an index() function on their floats -- at which point a basic no touch class (list itself) will now accept float as an index in direct contradiction of PEP 357's comment on floats... see? My point isn't that this particular implementation I have shown is the best (or even really safe, I'd have to think about that for a while). Go ahead and shoot it down... My point is that, the methods found in slice(), and index() now have moved all the code regarding a sequence *out* of the object which has information on that sequence. It smacks of legacy. The Python parser takes values from many other syntactical constructions and passes them directly to their respective objects -- but in the case of list(), we have a complicated relationship; and not for any reason that can't be handled in a simpler way. Don't consider the present API legacy for a moment, I'm asking hypothetical design questions: How many users actually keep slice() around from every instance of [::] they use? If it is rare, why create the slice() object in the first place and constantly be allocating and de-allocating memory, twice over? (once for the original, and once for the repetitive method which computes dynamic values?) Would a single mutable have less overhead, since it is destroyed anyway? -- http://mail.python.org/mailman/listinfo/python-list
Re: datetime issue
On 11/01/2012 06:09 AM, Grant Edwards wrote: On 2012-10-31, ru...@yahoo.com ru...@yahoo.com wrote: On 10/31/2012 09:11 AM, Grant Edwards wrote: On 2012-09-16, ?? nikos.gr...@gmail.com wrote: Iam positng via google groups using chrome, thats all i know. Learn something else. Google Groups is seriously and permanently broken, and all posts from Google Groups are filtered out and ignored by many people (including myself -- I only saw this because somebody else replied to it). Feel free to filter whatever you want but be aware than in doing so you risk missing information that could help you avoid disseminating erroneous info. Of course, carrying out some kind of private war against Google Groups may be more important to you than that... Based on past experience, the chances of useful information being posted via Google Groups is very small. The benefit of avoiding all the spam and garbage the comes from that source is more than worth the small risk of missing something worthwhile. Note that I'm _not_ talking about people posting to the mailing list using Gmail -- only people posting via the Google Groups web UI. Your experience is that most GG posts are junk but not most Gmail posts. And yet someone else posted that Gmail posts are the junk ones. So I wonder how accurate these evaluations are. In either case, while there has been some spam and garbage posts in c.l.p in the past, I haven't seen very many lately. And even in the past, they seemed pretty recognizable to me and easily skipped over. As for stupid questions, undesired formatting etc, I seldom look at the message headers so I never noticed whether they are mostly from GG or Gmail. But then again I never found it hard to glance at a post and move on if I didn't want to read it. YMMV. -- http://mail.python.org/mailman/listinfo/python-list
Re: Private methods
On Tue, Oct 9, 2012 at 5:51 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Tue, 09 Oct 2012 11:08:13 -0600, Ian Kelly wrote: I tend to view name mangling as being more for avoiding internal attribute collisions in complex inheritance structures than for designating names as private. Really? I tend to view name mangling as a waste of time, and complex inheritance structures as something to avoid. Name mangling is also useful for object tagging. Suppose you have object A that is passed object B and needs to track some data concerning object B, but does not need a strong reference to B. One solution is to use a weak-key dictionary, but this relies upon B being hashable, and I find it neater to just store the data on B itself. The problem is that whatever name you use might conflict with an existing attribute belonging to B. class Tagger(object): def tag(self, taggee): taggee.__tag = some_tag_data One of the curious ramifications of Python's name-mangling system is that even though the attribute above is being set on some arbitrary object, the mangling that is applied is in any case that of the class Tagger. Thus the mangled attribute name ends up being _Tagger__tag, which is unlikely to cause a conflict. There are some disadvantages to tagging. One is that you can't tag objects of built-in types. Another is that you can't tag instances of classes with __slots__. I tend to view the latter as another reason to avoid using __slots__. -- http://mail.python.org/mailman/listinfo/python-list
Re: lazy properties?
If you're using Python 3.2+, then functools.lru_cache probably ... And if you're on 2.X, you can grab lru_cache from http://code.activestate.com/recipes/498245-lru-and-lfu-cache-decorators/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
On Fri, Nov 2, 2012 at 9:08 AM, ru...@yahoo.com wrote: On 11/01/2012 03:55 AM, Jamie Paul Griffin wrote: Anybody serious about programming should be using a form of UNIX/Linux if you ask me. It's inconceivable that these systems should be avoided if you're serious about Software Engineering and Computer Science, etc. For UNIX there are loads of decent news reading software and mail user agents to learn and use. slrn is a good one and point it at gmane.org as someone else pointed out. I can't even imagine using a browser or Google Groups, etc. now. Are you saying that this group is only for serious programmers? It's not; also, so long as Python maintains an official Windows build, this list/group will be fielding questions about Windows. But there's still good reason to grab a Linux. http://catb.org/~esr/faqs/smart-questions.html#idp29970256 serious is also a matter of opinion. I have some serious programmer friends who maintain, in complete sincerity, that serious programmers should not waste time on slow, script-kiddie languages like Python, but should be developing their skills with serious professional languages like Java, C#, etc. And there are probably still a few around who maintain that Java, C#, and even C are too modern, and that serious programmers use FORTRAN or COBOL. Or assembly language. Let 'em. Meanwhile I'll have demonstrable code done while they're still fiddling around with details, because my languages (including, though by no means limited to, Python) do most of the work for me. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: sort order for strings of digits
On Thu, 01 Nov 2012 11:53:06 +1100, Chris Angelico wrote: On Thu, Nov 1, 2012 at 10:44 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On the contrary. If you are using cmp with sort, your sorts are slow, and you should upgrade to using a key function as soon as possible. But cmp_to_key doesn't actually improve anything. So I'm not sure how Py3 has achieved anything; Py2 supported key-based sorting already. Yes, but there is a lot of old code pre-dating key-based sorts. There's also some examples of code where it isn't obvious how to write it as a key-based sort, but a comparison function is simple. And people coming from other languages that only support comparison-based sorts (C?) will probably continue with what they know. Even though key-based sorting is better, there's a lot of comparison sorting that falls under if it ain't broke, don't fix it. So even though key-based sorts are better, there are still comparison- based sorts in the wild. Python 2 has to support them. Python 3, which is allowed to break backwards compatibility, does not. So when porting to 3, you have to change the sorts. Most of the time it is simple to convert a comparison-based sort to a key- based sort. For the cases where you either can't come up with a good key function yourself, or were you want to do so mechanically, Python provides cmp_to_key. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Negative array indicies and slice()
On Thu, Nov 1, 2012 at 4:25 PM, Andrew Robinson andr...@r3dsolutions.com wrote: The bottom line is: __getitem__ must always *PASS* len( seq ) to slice() each *time* the slice() object is-used. Since this is the case, it would have been better to have list, itself, have a default member which takes the raw slice indicies and does the conversion itself. The size would not need to be duplicated or passed -- memory savings, speed savings... And then tuple would need to duplicate the same code. As would deque. And str. And numpy.array, and anything else that can be sliced, including custom sequence classes. Let's apply D'Aprano 's logic to numpy; Numpy could just have subclassed *list*; Numpy arrays are very different internally from lists. They are basically fancy wrappers of C arrays, whereas lists are a higher-level abstraction. They allow for multiple dimensions, which lists do not. Slices of numpy arrays produce views, whereas slices of lists produce brand new lists. And they certainly do not obey the Liskov Substitution Principle with respect to lists. class ThirdParty( list ): # Pretend this is someone else's... ... def __init__(self): return ... def __getitem__(self,aSlice): return aSlice ... We know it will default work like this: a=ThirdParty() a[1:2] slice(1, 2, None) # So, here's an injection... ThirdParty.superOnlyOfNumpy__getitem__ = MyClass.__getitem__ ThirdParty.__getitem__ = lambda self,aSlice: ( 1, 3, self.superOnlyOfNumpy__getitem__(aSlice ).step ) a[5:6] (1, 3, None) I'm not understanding what this is meant to demonstrate. Is MyClass a find-replace error of ThirdParty? Why do you have __getitem__ returning slice objects instead of items or subsequences? What does this example have to do with numpy? Numpy could have exported a (workable) function that would modify other list functions to affect ONLY numpy data types (eg: a filter). This allows user's creating their own classes to inject them with Numpy's filter only when they desire; Recall Tim Peter's explicit is better than implicit Zen? We could also require the user to explicitly declare when they're performing arithmetic on variables that might not be floats. Then we can turn off run-time type checking unless the user explicitly requests it, all in the name of micro-optimization and explicitness. Seriously, whether x is usable as a sequence index is a property of x, not a property of the sequence. Users shouldn't need to pick and choose *which* particular sequence index types their custom sequences are willing to accept. They should even be able to accept sequence index types that haven't been written yet. Most importantly normal programs not using Numpy wouldn't have had to carry around an extra API check for index() *every* single time the heavily used [::] happened. Memory speed both. The O(1) __index__ check is probably rather inconsequential compared to the O(n) cost of actually performing the slicing. It's also a monkey patch, in that index() allows *conflicting* assumptions in violation of the unexpected monkey patch interaction worry. eg: Numpy *CAN* release an index() function on their floats -- at which point a basic no touch class (list itself) will now accept float as an index in direct contradiction of PEP 357's comment on floats... see? Such a change would only affect numpy floats, not all floats, so it would not be a monkey-patch. In any case, that would be incorrect usage of __index__. We're all consenting adults here; we don't need supervision to protect us from buggy third-party code. -- http://mail.python.org/mailman/listinfo/python-list
Re: Negative array indicies and slice()
andrew...@gmail.com於 2012年10月29日星期一UTC+8上午11時12分11秒寫道: The slice operator does not give any way (I can find!) to take slices from negative to positive indexes, although the range is not empty, nor the expected indexes out of range that I am supplying. Many programs that I write would require introducing variables and logical statements to correct the problem which is very lengthy and error prone unless there is a simple work around. I *hate* replicating code every time I need to do this! I also don't understand why slice() is not equivalent to an iterator, but can replace an integer in __getitem__() whereas xrange() can't. Here's an example for Linux shell, otherwise remove /bin/env... {{{#!/bin/env python a=[1,2,3,4,5,6,7,8,9,10] print a[-4:3] # I am interested in getting [7,8,9,10,1,2] but I get []. }}} I'll suggest to use the reverse method to get what you want. Of course, the reverse method is not efficient for a list of a huge number of objects in python. -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
On Fri, 02 Nov 2012 10:32:08 +1100, Chris Angelico wrote: And there are probably still a few around who maintain that Java, C#, and even C are too modern, and that serious programmers use FORTRAN or COBOL. Huh. If you're messing about with ancient[1] languages like Java, C# and especially C, you're not a real programmer. Real programmers use modern, advanced languages like D, Erlang, Go or Haskell. [1] Ancient is a frame of mind, not a chronological state. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
In article 50932111$0$29967$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Huh. If you're messing about with ancient[1] languages like Java, C# and especially C, you're not a real programmer. Real programmers use modern, advanced languages like D, Erlang, Go or Haskell. Does anybody actually use D for anything? I looked at the language a while ago. There seemed to be a lot in it that made sense. Does it get any real use, or is it just an interesting research project? -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
On Fri, 02 Nov 2012 01:25:37 -, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Huh. If you're messing about with ancient[1] languages like Java, C# and especially C, you're not a real programmer. Real programmers use modern, advanced languages like D, Erlang, Go or Haskell. Advanced? Huh. I have here a language that does exactly what I want without all that messy syntax nonsense. I call it Research Assistant. -- Rhodri James *-* Wildebeest Herder to the Masses -- http://mail.python.org/mailman/listinfo/python-list
Avoiding defunct processes
Hello, I create child processes with subprocess.Popen(). Then I either wait for them to finish or kill them. Either way these processes end up as defunct until the parent process completes: $ ps e 6851 pts/5Z+ 1:29 [python] defunct This confuses another library as to whether the processes are complete. For now I detect which processes are defunct by parsing the output of ps. What would you recommend? I am hoping there is a cleaner way. Richard -- http://mail.python.org/mailman/listinfo/python-list
Re: Negative array indicies and slice()
On Thu, 01 Nov 2012 15:25:51 -0700, Andrew Robinson wrote: On 11/01/2012 12:07 PM, Ian Kelly wrote: Pep 357 merely added cruft with index(), but really solved nothing. Everything index() does could be implemented in __getitem__ and usually is. No. There is a significant difference between implementing this on the container versus implementing it on the indexes. Ethan implemented his string-based slicing on the container, because the behavior he wanted was specific to the container type, not the index type. Custom index types like numpy integers on the other hand implement __index__ on the index type, because they apply to all sequences, not specific containers. Hmmm... D'Aprano didn't like the monkey patch;and sub-classing was his fix-all. I pointed out that monkey-patching is a bad idea, even if it worked. But it doesn't work -- you simply cannot monkey-patch built-ins in Python. Regardless of whether I like the m-p or not, *you can't use it* because you patch built-in list methods. The best you could do is subclass list, then shadow the built-in name list with your subclass. But that gives all sorts of problems too, in some ways even worse than monkey-patching. You started this thread with a question about slicing. You believe that one particular use-case for slicing, which involves interpreting lists as circular rather than linear, is the use-case that built-in list slicing should have supported. Fine, you're entitled to your option. But that boat has sailed about 20 years ago. Python didn't make that choice, and it won't change now. If you write up a PEP, you could aim to have the built-in behaviour changed for Python 4 in perhaps another 10-15 years or so. But for the time being, that's not what lists, tuples, strings, etc. do. If you want that behaviour, if you want a circular list, then you have to implement it yourself, and the easiest way to do so is with a subclass. That's not a fix-all. I certainly don't believe that subclassing is the *only* way to fix this, nor that it will fix all things. But it might fix *some* things, such as you wanting a data type that is like a circular list rather than a linear list. If you prefer to create a circular-list class from scratch, re- implementing all the list-like behaviour, instead of inheriting from an existing class, then by all means go right ahead. If you have a good reason to spend days or weeks writing, testing, debugging and fine-tuning your new class, instead of about 15 minutes with a subclass, then I'm certainly not going to tell you not to. Part of my summary is based on that conversation with him,and you touched on one of the unfinished points; I responded to him that I thought __getitem__ was under-developed. The object slice() has no knowledge of the size of the sequence; nor can it get that size on it's own, but must passively wait for it to be given to it. That's because the slice object is independent of the sequence. As I demonstrated, you can pass a slice object to multiple sequences. This is a feature, not a bug. The bottom line is: __getitem__ must always *PASS* len( seq ) to slice() each *time* the slice() object is-used. The bottom line is: even if you are right, so what? The slice object doesn't know what the length of the sequence is. What makes you think that __getitem__ passes the length to slice()? Why would it need to recreate a slice object that already exists? It is the *sequence*, not the slice object, that is responsible for extracting the appropriate items when __getitem__ is called. __getitem__ gets a slice object as argument, it doesn't create one. It no more creates the slice object than mylist[5] creates the int 5. Since this is the case, But it isn't. it would have been better to have list, itself, have a default member which takes the raw slice indicies and does the conversion itself. The size would not need to be duplicated or passed -- memory savings, speed savings... We have already demonstrated that slice objects are smaller than (x)range objects and three-item tuples. In Python 3.3: py sys.getsizeof(range(1, 10, 2)) # xrange remained in Python 3 24 py sys.getsizeof((1, 10, 2)) 36 py sys.getsizeof(slice(1, 10, 2)) 20 It might help you to be taken seriously if you base your reasoning on Python as it actually is, rather than counter-factual assumptions. I'm just clay pidgeoning an idea out here Let's apply D'Aprano 's logic to numpy; Numpy could just have subclassed *list*; Sure they could have, if numpy arrays were intended to be a small variation on Python lists. But they weren't, so they didn't. so let's ignore pure python as a reason to do anything on the behalf on Numpy: Then, lets' consider all thrid party classes; These are where subclassing becomes a pain -- BUT: I think those could all have been injected. class ThirdParty( list ): # Pretend this is someone else's... ... def
Re: Avoiding defunct processes
On Fri, Nov 2, 2012 at 1:16 PM, Richard richar...@gmail.com wrote: Hello, I create child processes with subprocess.Popen(). Then I either wait for them to finish or kill them. Either way these processes end up as defunct until the parent process completes: $ ps e 6851 pts/5Z+ 1:29 [python] defunct This confuses another library as to whether the processes are complete. For now I detect which processes are defunct by parsing the output of ps. What would you recommend? I am hoping there is a cleaner way. That's a zombie process, it's finished but the parent hasn't wait()ed for it yet. http://docs.python.org/3.3/library/subprocess.html#subprocess.Popen.wait Once the process has ended, call that to get its return value and clean everything up. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
[issue16378] venv.EnvBuilder docstring inconsistencies
Éric Araujo added the comment: Tagging for the bug day. -- keywords: +easy nosy: +eric.araujo, vinay.sajip ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16378 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15873] datetime cannot parse ISO 8601 dates and times
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15873 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13701] Remove Decimal Python 2.3 Compatibility
Ramchandra Apte added the comment: On 31 October 2012 23:29, Mark Dickinson rep...@bugs.python.org wrote: Mark Dickinson added the comment: Fixed the unuse of decorator syntax. I think the dummy_threading changes should be considered a separate issue. With regards to the patch: I assume you mean import dummy_threading as threading rather than just import dummy_threading. Also, it looks to me as though test_decimal would need updating too to do the correct thing when the threading module isn't present. Closing this issue as fixed; please open a new issue for the dummy_threading if you think it's worth pursuing. -- assignee: rhettinger - mark.dickinson resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13701 ___ In the docs for dummy_threading, Be careful to not use this module where deadlock might occur from a thread being created that blocks waiting for another thread to be created. This often occurs with blocking I/O. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13701 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13701] Remove Decimal Python 2.3 Compatibility
Mark Dickinson added the comment: I'm not quite sure why you're quoting the docs at me. What's the point you want to make? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13701 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16379] SQLite error code not exposed to python
New submission from Torsten Landschoff: The sqlite3 module does not expose the sqlite3 error codes to python. This makes it impossible to detect specific error conditions directly. Case in point: If a user selects some random file as the database in our application, we can not detect that it is not a valid database file: $ /opt/python3/bin/python3 Python 3.4.0a0 (default:2d6eec5d01f7, Nov 1 2012, 10:47:27) [GCC 4.6.3] on linux Type help, copyright, credits or license for more information. import sqlite3 conn = sqlite3.connect(/etc/passwd) from pprint import pprint try: ... conn.execute(select * from random_table) ... except Exception as e: ... pprint({name: getattr(e, name) for name in dir(e)}) ... raise ... {'__cause__': None, '__class__': class 'sqlite3.DatabaseError', '__context__': None, '__delattr__': method-wrapper '__delattr__' of DatabaseError object at 0x7ffc9a13b050, '__dict__': {}, '__dir__': built-in method __dir__ of DatabaseError object at 0x7ffc9a13b050, '__doc__': None, '__eq__': method-wrapper '__eq__' of DatabaseError object at 0x7ffc9a13b050, '__format__': built-in method __format__ of DatabaseError object at 0x7ffc9a13b050, '__ge__': method-wrapper '__ge__' of DatabaseError object at 0x7ffc9a13b050, '__getattribute__': method-wrapper '__getattribute__' of DatabaseError object at 0x7ffc9a13b050, '__gt__': method-wrapper '__gt__' of DatabaseError object at 0x7ffc9a13b050, '__hash__': method-wrapper '__hash__' of DatabaseError object at 0x7ffc9a13b050, '__init__': method-wrapper '__init__' of DatabaseError object at 0x7ffc9a13b050, '__le__': method-wrapper '__le__' of DatabaseError object at 0x7ffc9a13b050, '__lt__': method-wrapper '__lt__' of DatabaseError object at 0x7ffc9a13b050, '__module__': 'sqlite3', '__ne__': method-wrapper '__ne__' of DatabaseError object at 0x7ffc9a13b050, '__new__': built-in method __new__ of type object at 0x8267e0, '__reduce__': built-in method __reduce__ of DatabaseError object at 0x7ffc9a13b050, '__reduce_ex__': built-in method __reduce_ex__ of DatabaseError object at 0x7ffc9a13b050, '__repr__': method-wrapper '__repr__' of DatabaseError object at 0x7ffc9a13b050, '__setattr__': method-wrapper '__setattr__' of DatabaseError object at 0x7ffc9a13b050, '__setstate__': built-in method __setstate__ of DatabaseError object at 0x7ffc9a13b050, '__sizeof__': built-in method __sizeof__ of DatabaseError object at 0x7ffc9a13b050, '__str__': method-wrapper '__str__' of DatabaseError object at 0x7ffc9a13b050, '__subclasshook__': built-in method __subclasshook__ of type object at 0x1238770, '__suppress_context__': False, '__traceback__': traceback object at 0x7ffc9a138cf8, '__weakref__': None, 'args': ('file is encrypted or is not a database',), 'with_traceback': built-in method with_traceback of DatabaseError object at 0x7ffc9a13b050} Traceback (most recent call last): File stdin, line 2, in module sqlite3.DatabaseError: file is encrypted or is not a database Currently, one can only match the error message, with is bad programming style. The error code for this error is SQLITE_NOTADB, as found in the function sqlite3ErrStr when searching for the message in SQLite's main.c at http://www.sqlite.org/src/artifact/02255cf1da50956c5427c469abddb15bccc4ba09 Unfortunately, the sqlite3 module does not expose the error code itself (neither the actual error code nor the defined error codes) in any way. Errors are handled in Modules/_sqlite/util.c: http://hg.python.org/cpython/file/2d6eec5d01f7/Modules/_sqlite/util.c#l99 I would like to have the defined error codes available in some mapping inside the sqlite3 module as well as the actual error code inside every sqlite exception e as e.sqlite_errcode -- components: Library (Lib) messages: 174395 nosy: torsten priority: normal severity: normal status: open title: SQLite error code not exposed to python type: enhancement versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16379 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16248] Security bug in tkinter allows for untrusted, arbitrary code execution.
Mark Dickinson added the comment: Ramchandra: can you give an example of a realistic situation where the existence of this code in tkinter allows users to execute code *that they wouldn't be able to execute otherwise*? -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16248 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11566] hypot define in pyconfig.h clashes with g++'s cmath
Martin v. Löwis added the comment: In general, including standard library headers before including Python.h is not recommended, since it may break binary compatibility across object files. So the proposed work-around may also cause harm. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11566 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13701] Remove Decimal Python 2.3 Compatibility
Ramchandra Apte added the comment: On 1 November 2012 14:09, Mark Dickinson rep...@bugs.python.org wrote: Mark Dickinson added the comment: I'm not quite sure why you're quoting the docs at me. What's the point you want to make? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13701 ___ Does decimal use the dummy_threading module where deadlock might occur from a thread being created that blocks waiting for another thread to be created? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13701 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16373] Recursion error comparing set() and collections.Set instances
Roundup Robot added the comment: New changeset 8e95a078d490 by Andrew Svetlov in branch '3.2': Issue #16373: Prevent infinite recursion for ABC Set class operations. http://hg.python.org/cpython/rev/8e95a078d490 New changeset 11a9297733b8 by Andrew Svetlov in branch '3.3': Merge issue #16373: Prevent infinite recursion for ABC Set class operations. http://hg.python.org/cpython/rev/11a9297733b8 New changeset e67c8803cd82 by Andrew Svetlov in branch 'default': Merge issue #16373: Prevent infinite recursion for ABC Set class operations. http://hg.python.org/cpython/rev/e67c8803cd82 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16373 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16373] Recursion error comparing set() and collections.Set instances
Andrew Svetlov added the comment: Fixed. Thanks, Serhiy. -- nosy: +asvetlov resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16373 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16248] Security bug in tkinter allows for untrusted, arbitrary code execution.
Changes by Andrew Svetlov andrew.svet...@gmail.com: -- nosy: +asvetlov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16248 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13701] Remove Decimal Python 2.3 Compatibility
Mark Dickinson added the comment: No. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13701 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13701] Remove Decimal Python 2.3 Compatibility
Stefan Krah added the comment: Ramchandra Apte rep...@bugs.python.org wrote: I'm not quite sure why you're quoting the docs at me. What's the point you want to make? Does decimal use the dummy_threading module where deadlock might occur from a thread being created that blocks waiting for another thread to be created? The modus operandi on the issue tracker is generally like this: For finished modules like decimal you need to provide a concrete example that triggers an alleged misbehavior. The reason is simple: In general no one has time for open-ended questions like the one you asked. Also, such questions are perfectly on-topic on python-list. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13701 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16261] Fix bare excepts in various places in std lib
Andrew Svetlov added the comment: I'm pretty sure Doc and Lib are already fixed, only Tools left. -- nosy: +asvetlov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16261 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7317] Display full tracebacks when an error occurs asynchronously
Changes by Andrew Svetlov andrew.svet...@gmail.com: -- nosy: +asvetlov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7317 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14965] super() and property inheritance behavior
Andrew Svetlov added the comment: I'm -0 for proposed changes, these changes reduce code readability from my perspective. I think better to use existing approach: explicitly specify what do you want to do with overloaded properties. -- nosy: +asvetlov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14965 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14266] pyunit script as shorthand for python -m unittest
Andrew Svetlov added the comment: +1 for both pyunit script and autodiscovering by default. -- nosy: +asvetlov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14266 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16261] Fix bare excepts in various places in std lib
Ramchandra Apte added the comment: On 1 November 2012 17:21, Andrew Svetlov rep...@bugs.python.org wrote: Andrew Svetlov added the comment: I'm pretty sure Doc and Lib are already fixed, only Tools left. -- nosy: +asvetlov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16261 ___ No. 405 are there in Lib. Try running `grep except: -R Lib --include *.py` to see yourself. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16261 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13701] Remove Decimal Python 2.3 Compatibility
Ramchandra Apte added the comment: On 1 November 2012 17:12, Stefan Krah rep...@bugs.python.org wrote: Stefan Krah added the comment: Ramchandra Apte rep...@bugs.python.org wrote: I'm not quite sure why you're quoting the docs at me. What's the point you want to make? Does decimal use the dummy_threading module where deadlock might occur from a thread being created that blocks waiting for another thread to be created? The modus operandi on the issue tracker is generally like this: For finished modules like decimal you need to provide a concrete example that triggers an alleged misbehavior. The reason is simple: In general no one has time for open-ended questions like the one you asked. Also, such questions are perfectly on-topic on python-list. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13701 ___ I just wanted to ensure that there wouldn't be any bugs by my patch. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13701 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16218] Python launcher does not support non ascii characters
Roundup Robot added the comment: New changeset 02d25098ad57 by Andrew Svetlov in branch '3.3': Issue #16218: Support non ascii characters in python launcher. http://hg.python.org/cpython/rev/02d25098ad57 New changeset 1267d64c14b3 by Andrew Svetlov in branch 'default': Merge issue #16218: Support non ascii characters in python launcher. http://hg.python.org/cpython/rev/1267d64c14b3 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16218 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16218] Python launcher does not support non ascii characters
Andrew Svetlov added the comment: Fixed. Thanks, Serhiy. -- nosy: +asvetlov resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16218 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16380] true/proper subset
New submission from abcdef: The documentation http://docs.python.org/2.7/library/stdtypes.html#set-types-set-frozenset http://docs.python.org/3/library/stdtypes.html#set-types-set-frozenset of for sets uses true subset and true superset. The correct termininology is proper subset and proper superset, as evidenced by Google searches http://google.com/search?q=true subset http://google.com/search?q=proper subset and most set theory books. -- assignee: docs@python components: Documentation messages: 174410 nosy: abcdef, docs@python priority: normal severity: normal status: open title: true/proper subset type: enhancement versions: Python 2.7, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16380 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16380] true/proper subset
Mark Dickinson added the comment: +1 -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16380 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16284] concurrent.futures ThreadPoolExecutor keeps unnecessary references to worker functions.
Andrew Svetlov added the comment: Updated patch to execute tests only for CPython. -- nosy: +asvetlov Added file: http://bugs.python.org/file27820/kill_reference_3.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16284 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16381] Introduce option to force the interpreter to exit upon MemoryErrors
New submission from Christian Theune: I run long-running server processes (web apps, etc) a lot and I keep encountering the situation that many applications will not properly deal with MemoryError exceptions but end up in an unusable state. From an operational perspective I wish the process in this case would just fail and exit. I talked to Guido about this general idea at EuroPython2012 and he encouraged me to look into this. Here's a patch: https://bitbucket.org/ctheune/cpython/changeset/323bb572344d46df669d3dbec4431cf6720fc5b4 I think it does what I want it to do, but a) my C knowledge is really bad and b) I'm not sure whether this is the right approach anyway. I'd appreciate feedback and possibly inclusion in the core. -- components: Interpreter Core hgrepos: 158 messages: 174413 nosy: ctheune, gvanrossum priority: normal severity: normal status: open title: Introduce option to force the interpreter to exit upon MemoryErrors type: enhancement versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16381 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16381] Introduce option to force the interpreter to exit upon MemoryErrors
Changes by Christian Theune c...@gocept.com: -- keywords: +patch Added file: http://bugs.python.org/file27821/9430a5c65114.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16381 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16228] JSON crashes during encoding resized lists
Andrew Svetlov added the comment: The patch LGTM except I cannot reproduce crash on unmodified sources with running applied test. -- nosy: +asvetlov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16228 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16230] select.select crashes on resized lists
Changes by Andrew Svetlov andrew.svet...@gmail.com: -- nosy: +asvetlov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16230 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1207589] IDLE: Right Click Context Menu
Changes by Andrew Svetlov andrew.svet...@gmail.com: -- nosy: +asvetlov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1207589 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16381] Introduce option to force the interpreter to exit upon MemoryErrors
Christian Heimes added the comment: Your proposal sounds like a very good idea. IMHO it should be discussed on the python-ideas or python-dev mailing list before it gets integrated into 3.4. Embrace yourself for some serious bike shedding! :) By the way your patch contains several changes that aren't related to your proposal. Can you clean up your patch, please? It makes code review much easier. -- nosy: +christian.heimes stage: - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16381 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13701] Remove Decimal Python 2.3 Compatibility
Mark Dickinson added the comment: I just wanted to ensure that there wouldn't be any bugs by my patch. Okay, understood. Thanks. Please note that this issue is now closed, though: the 2.3 compatibility workarounds have been dealt with. The use or non-use of dummy_threading has nothing to do with 2.3 compatibility and so is out of scope for the issue. You should feel free to open a new issue if there's a demonstrable problem or demonstrable room for improvement w.r.t. the way dummy threading is handled. (I'm personally not convinced that either of those is true, but others may have different views.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13701 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9742] Python 2.7: math module fails to build on Solaris 9
Matt Selsky added the comment: I tested this patch again python 2.7.3 on Solaris 9 and the math module now builds correctly. Thanks! Let me know if you need any output. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9742 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13701] Remove Decimal Python 2.3 Compatibility
Ramchandra Apte added the comment: But my patch does use dummy_threading. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13701 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16381] Introduce option to force the interpreter to exit upon MemoryErrors
Christian Theune added the comment: Grr. Sorry. The automatic patch extraction went wrong and I didn't notice. Here's a manual try. -- Added file: http://bugs.python.org/file27822/issue16381.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16381 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16381] Introduce option to force the interpreter to exit upon MemoryErrors
Changes by Christian Theune c...@gocept.com: Removed file: http://bugs.python.org/file27821/9430a5c65114.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16381 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16248] Security bug in tkinter allows for untrusted, arbitrary code execution.
Ramchandra Apte added the comment: @Mark Dickinson Run the attached file, exploit.py, with normal priveleges and then run IDLE with sudo (something I did to actually uncover this bug!). Then the file /root/exploited should contain Exploit succeeded! -- Added file: http://bugs.python.org/file27823/exploit.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16248 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16382] Better warnings exception for bad category
New submission from Phil Elson: When passing an invalid Warning subclasses to the warnings.warn function, a bare issubclass exception is raised: import warnings warnings.warn('hello world', 'not a valid warning type') Traceback (most recent call last): File stdin, line 1, in module TypeError: issubclass() arg 1 must be a class This exception is consistent accross both Python/_warnings.c and Lib/warnings.py implementations, but I feel it could be more helpful/explicit about the nature problem. To test both cases I have been using the following code (python3.4): import test.support py_warnings = test.warnings = test.support.import_fresh_module('warnings', blocked=['_warnings']) c_warnings = test.support.import_fresh_module('warnings', fresh=['_warnings']) Now: py_warnings.warn('hello world', '') Traceback (most recent call last): File stdin, line 1, in module File lib/python3.4/warnings.py, line 168, in warn assert issubclass(category, Warning) TypeError: issubclass() arg 1 must be a class c_warnings.warn('hello world', '') Traceback (most recent call last): File stdin, line 1, in module TypeError: issubclass() arg 1 must be a class Additionally, there is a difference in the denotational semantics of None between the c and py warnings implementation: py_warnings.warn('Hello world', None) __main__:1: UserWarning: Hello world c_warnings.warn('Hello world', None) Traceback (most recent call last): File stdin, line 1, in module TypeError: issubclass() arg 1 must be a class I can understand that python does not allow the concept of an optional positional arguments and therefore it is arguable that the signatures of the two functions are inevitably going to be different. I defer to someone more knowledgeable in Python to decide if this is a problem, and whether it should be made consistent. Attached is a patch to address these two issues, with associated tests. Please review (n.b. I am a python developer at heart, and only dabble in C when I have to, so extra scrutiny on the C would be valuable to me) and I'd be happy to get any necessary changed applied to the patch asap. In short, as a result of applying this patch, the following results ensue: py_warnings.warn('hello world', '') Traceback (most recent call last): File stdin, line 1, in module File lib/python3.4/warnings.py, line 175, in warn 'Got {!r}'.format(Warning, category)) from None ValueError: category must be a subclass of class 'Warning'.Got '' c_warnings.warn('hello world', '') Traceback (most recent call last): File stdin, line 1, in module ValueError: category must be a subclass of class 'Warning'. Got ''. c_warnings.warn('hello world', None) __main__:1: UserWarning: hello world Thanks! -- components: Library (Lib) files: pelson_warnings_fix.diff keywords: patch messages: 174421 nosy: pelson priority: normal severity: normal status: open title: Better warnings exception for bad category type: behavior versions: Python 3.4 Added file: http://bugs.python.org/file27824/pelson_warnings_fix.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16382 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16228] JSON crashes during encoding resized lists
Serhiy Storchaka added the comment: Of course, this kind of bugs can cause unpredictable behavior, they do not have to lead to an immediate crash. This depends from the platform, the compiler and its options. On my computers the test always crashed, this is the maximum that I can say. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16228 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16381] Introduce option to force the interpreter to exit upon MemoryErrors
Christian Heimes added the comment: Thanks! Py_FatalError() might be too drastic for the task. It calls abort() which kills the process with SIGABRT. The function closes and flushes all stream but no additional cleanup code is executed. This might be bad for resources like shared memories, named semaphores or database connections. On Windows abort() causes a pop up window with a crash report, too. Would exit(3) or _exit(2) work here? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16381 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16381] Introduce option to force the interpreter to exit upon MemoryErrors
Benjamin Peterson added the comment: I think the fatal erroring should be done in PyErr_NoMemory. -- nosy: +benjamin.peterson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16381 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16165] sched.scheduler.run() blocks scheduler
Changes by Serhiy Storchaka storch...@gmail.com: Removed file: http://bugs.python.org/file27490/sched_unblock.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16165 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16165] sched.scheduler.run() blocks scheduler
Serhiy Storchaka added the comment: Tests added. Please review. -- keywords: +needs review Added file: http://bugs.python.org/file27825/sched_unblock_2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16165 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16215] Possible double memory free in str.replace
Serhiy Storchaka added the comment: Please review. -- keywords: +needs review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16215 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16165] sched.scheduler.run() blocks scheduler
Changes by Serhiy Storchaka storch...@gmail.com: Removed file: http://bugs.python.org/file27825/sched_unblock_2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16165 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16165] sched.scheduler.run() blocks scheduler
Changes by Serhiy Storchaka storch...@gmail.com: Added file: http://bugs.python.org/file27826/sched_unblock_2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16165 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16218] Python launcher does not support non ascii characters
Vinay Sajip added the comment: I'm not especially familiar with this code, but just trying to understand - how come filename_obj isn't decref'd on normal exit? -- nosy: +vinay.sajip ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16218 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10182] match_start truncates large values
Serhiy Storchaka added the comment: Please review. -- keywords: +needs review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10182 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16245] Update html.entities.html5 dictionary and parseentities.py
Changes by Serhiy Storchaka storch...@gmail.com: -- nosy: -serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16245 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16248] Security bug in tkinter allows for untrusted, arbitrary code execution.
Mark Dickinson added the comment: Okay, but if a user can run IDLE with sudo, they presumably *already* have many other ways to use sudo to create files in /root, without using IDLE or tkinter. That's why I said: *that they wouldn't be able to execute otherwise*. I don't see the security issue here. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16248 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16218] Python launcher does not support non ascii characters
Andrew Svetlov added the comment: Vinay, it's processed in PyObject_CallFunction(loader_type, sN, __main__, filename_obj) Please note sN format istead sO. N means PyObject* is passed but unlike sO that object is not increfed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16218 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14900] cProfile does not take its result headers as sort arguments
Arne Babenhauserheide added the comment: …you were faster than me (I only managed to get the repo onto my current computer yesterday and the children kept me occupied). Thank you! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14900 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com