ANN: PyDTLS
I would like to announce Datagram Transport Layer Security for Python. From the top of the project README: PyDTLS brings Datagram Transport Layer Security (DTLS - RFC 6347: http://tools.ietf.org/html/rfc6347) to the Python environment. In a nutshell, DTLS brings security (encryption, server authentication, user authentication, and message authentication) to UDP datagram payloads in a manner equivalent to what SSL/TLS does for TCP stream content. DTLS is now very easy to use in Python. If you're familiar with the ssl module in Python's standard library, you already know how. All it takes is passing a datagram/UDP socket to the *wrap_socket* function instead of a stream/TCP socket. Here's how one sets up the client side of a connection: import ssl from socket import socket, AF_INET, SOCK_DGRAM from dtls import do_patch do_patch() sock = ssl.wrap_socket(socket(AF_INET, SOCK_DGRAM)) sock.connect(('foo.bar.com', 1234)) sock.send('Hi there') The project is hosted at https://github.com/rbit/pydtls, and licensed under the Apache license 2.0. PyPI has packages. I can be reached at code AT liquibits DOT com for questions, feedback, etc. PA HREF=http://pypi.python.org/pypi/Dtls/0.1.0;Dtls 0.1.0/A - Datagram Transport Layer Security for Python. (07-Jan-13) -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
FYI - wiki.python.org compromised
On December 28th, an unknown attacker used a previously unknown remote code exploit on http://wiki.python.org/. The attacker was able to get shell access as the moin user, but no other services were affected. Some time later, the attacker deleted all files owned by the moin user, including all instance data for both the Python and Jython wikis. The attack also had full access to all MoinMoin user data on all wikis. In light of this, the Python Software Foundation encourages all wiki users to change their password on other sites if the same one is in use elsewhere. We apologize for the inconvenience and will post further news as we bring the new and improved wiki.python.org online. If you have any questions about this incident please contact jnol...@python.org. Thank you for your patience. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: Vigil, the eternal morally vigilant programming language
On 1/7/2013 11:01 AM, Alain Ketterlin wrote: I just came across Vigil, an extension to python for serious software engineers, I hope that last part comes from a sense of humor. at https://github.com/munificent/vigil and thought everybody in this group would be interested (sorry if it has been announced before). From README: | Vigil is a very safe programming language, and an entry in the January | 2013 PLT Games competition. | | Many programming languages claim to take testing, contracts and safety | seriously, but only Vigil is truly vigilant about not allowing code | that fails to pass programmatic specifications. While the language is a joke (Procrustes would be a somewhat better name), the example illustrates the near uselessness of contract checking, at least for functions. The example fib(n) function 'swears' that the answer is a count (not negative). Ha, ha, very funny. A simple 'return 0' would satisfy that useless contract*. A correct fib(n) function must actually calculate fib(n), and in practice, that is not possible to check. Even checking that sorted(iterable) is correct (outside a test situation) is harder than it might first seem#. * In any of the many languages that use biased residue classes as a substitute for real integers, positive + positive = positive is not so trivial. So the function must return a negative to signal bad input or raise an exception either directly or by an input condition. The advantage of the directly exception is that the exception message can be tailored to the audience and situation. [Vigil would simply excise the calling function.] # Given sorted(iterable) where iterable gets some number of comparable items from stdin, how is the contract checker to determine that the output is indeed a permutation of the unmutated input items, before checking that they are are actually sorted. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with Unicode char in Python 3.3.0
On 1/7/2013 8:12 AM, Terry Reedy wrote: On 1/7/2013 7:57 AM, Franck Ditter wrote: print('\U0001d11e') Traceback (most recent call last): File pyshell#1, line 1, in module print('\U0001d11e') UnicodeEncodeError: 'UCS-2' codec can't encode character '\U0001d11e' in position 0: Non-BMP character not supported in Tk The message comes from printing to a tk text widget (the IDLE shell), not from creating the 1 char string. c = '\U0001d11e' works fine. When you have problems with creating and printing unicode, *separate* creating from printing to see where the problem is. (I do not know if the brand new tcl/tk 8.6 is any better.) The windows console also chokes, but with a different message. c='\U0001d11e' print(c) Traceback (most recent call last): File stdin, line 1, in module File C:\Programs\Python33\lib\encodings\cp437.py, line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\U0001d11e' in posit ion 0: character maps to undefined Yes, this is very annoying, especially in Win 7. The above is in 3.3, in which '\U0001d11e' is actually translated to a length 1 string. In 3.2-, that literal is translated (on 3.2- narrow builds, as on Windows) to a length 2 string surrogate pair (in the BMP). On printing, the pair of surrogates got translated to a square box used for all characters for which the font does not have a glyph. 턞When cut and pasted, it shows in this mail composer as a weird music sign with peculiar behavior. 3 -s, 3 spaces, paste, 3 spaces, 3 -s, but it may disappear. --- 턞 --- So 3.3 is the first Windows version to get the UnicodeEncodeError on printing. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: test failed: test_urlwithfrag
On 1/7/2013 1:26 PM, Elli Lola wrote: $ ./python -m test -v test_urlwithfrag == CPython 3.3.0 (default, Jan 4 2013, 23:08:00) [GCC 4.6.3] == Linux-3.2.0-35-generic-pae-i686-with-debian-wheezy-sid little-endian == /home/me/Programme/Python/Python-3.3.0/build/test_python_30744 Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1) [1/1] test_urlwithfrag test test_urlwithfrag crashed -- Traceback (most recent call last): File /home/me/Programme/Python/Python-3.3.0/Lib/test/regrtest.py, line 1213, in runtest_inner the_package = __import__(abstest, globals(), locals(), []) ImportError: No module named 'test.test_urlwithfrag' 1 test failed: test_urlwithfrag Read the message I sent you before. (To everyone else, I already explained that the error message means exactly what it says and listed the test_url files that do exist. No need to repeat a third time.) -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: [Offtopic] Line fitting [was Re: Numpy outlier removal]
On 1/7/2013 8:23 PM, Steven D'Aprano wrote: On Mon, 07 Jan 2013 22:32:54 +, Oscar Benjamin wrote: An example: Earlier today I was looking at some experimental data. A simple model of the process underlying the experiment suggests that two variables x and y will vary in direct proportion to one another and the data broadly reflects this. However, at this stage there is some non-normal variability in the data, caused by experimental difficulties. A subset of the data appears to closely follow a well defined linear pattern but there are outliers and the pattern breaks down in an asymmetric way at larger x and y values. At some later time either the sources of experimental variation will be reduced, or they will be better understood but for now it is still useful to estimate the constant of proportionality in order to check whether it seems consistent with the observed values of z. With this particular dataset I would have wasted a lot of time if I had tried to find a computational method to match the line that to me was very visible so I chose the line visually. If you mean: I looked at the data, identified that the range a x b looks linear and the range x b does not, then used least squares (or some other recognised, objective technique for fitting a line) to the data in that linear range then I'm completely cool with that. If both x and y are measured values, then regressing x on y and y on x with give different answers and both will be wrong in that *neither* will be the best answer for the relationship between them. Oscar did not specify whether either was an experimentally set input variable. But that is not fitting a line by eye, which is what I am talking about. With the line constrained to go through 0,0, a line eyeballed with a clear ruler could easily be better than either regression line, as a human will tend to minimize the deviations *perpendicular to the line*, which is the proper thing to do (assuming both variables are measured in the same units). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Calculate Big Number
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: py from timeit import Timer py t1 = Timer((a**b)*(c**d), setup=a,b,c,d = 10, 25, 2, 50) py min(t1.repeat(repeat=5, number=10)) 0.5256571769714355 So that's about 5 microseconds on my (slow) computer. That's pretty fast. So is there still a need for a GMP python-binding like gmpy? http://code.google.com/p/gmpy/wiki/IntroductionToGmpy GMP can include optimized assembler for the CPU you're using. But I guess it needs more memory. Hence disk-swapping could be an issue on performance. --gv -- http://mail.python.org/mailman/listinfo/python-list
How to call ltm function using rpy package in python
I am trying the following code-- from rpy import * r.library(ltm) dat= #some data frame or matrix r.ltm(r('dat~z1')) error coming is--- RPy_RException: Error in eval(expr, envir, enclos) : object 'dat' not found Please tell me the right way to call ltm function using rpy library -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the selected text of the webpage in chrome through python ?
在 2013年1月8日星期二UTC+8下午12时20分28秒,iMath写道: How to get the selected text of the webpage in chrome through python ? I need the code ,cuz I am only familiar with Python ,so it would be better to give me the code written in Python . You can also give me the code in other programming language ,thanks in advance :) -- http://mail.python.org/mailman/listinfo/python-list
Newbe accessing MySQL, need something like perl's prepare_cached
'Aloha Friends! Still quite new to python I'm trying to access a MySQL database. Being a former perl programmer I recognize much of the semantics going on. Create a database handle, compile a piece of SQL and put it into a cursor, run the query and use the result. exactly the same flow as I am used to. And it works just fine. But as programs grow larger, it is sometimes becomes a burden to compile those SQL's over and over again when they should be perfectly reusable. And implementing a query cache by myself seems not to be the right thing in this batteries included environment. Donno exactly what I'm looking for, but the perl equivalent is called prepare_cached. Oh, by the way, I'm using import MySQLdb, hope that's not the most outdated, inefficient and stupid choice for a MySQL library... -- /Morten %-) -- http://mail.python.org/mailman/listinfo/python-list
Re: what’s the difference between socket.send() and socket.sendall() ?
socket.socket.send is a low-level method and basically just the C/syscall method send(3) / send(2). It can send less bytes than you requested. socket.socket.sendall is a high-level Python-only method that sends the entire buffer you pass or throws an exception. It does that by calling send until everything has been sent or an error occurs. If you're using TCP with blocking sockets and don't want to be bothered by internals (this is the case for most simple network applications), use sendall. Otherwise, use send and make sure to read and process its return value. - Philipp On 01/07/2013 11:35 AM, iMath wrote: what’s the difference between socket.send() and socket.sendall() ? It is so hard for me to tell the difference between them from the python doc so what is the difference between them ? and each one is suitable for which case ? signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the selected text of the webpage in chrome through python ?
On 01/08/2013 07:38 AM, Dennis Lee Bieber wrote: On Mon, 7 Jan 2013 20:20:28 -0800 (PST), iMath redstone-c...@163.com declaimed the following in gmane.comp.python.general: How to get the selected text of the webpage in chrome through python ? Chrome is a browser, is it not... If you want to get the text in Python, you have to write the equivalent of a browser -- something that parses the returned HTML message, extracting the parts you want. To get a selection, you can either wait till it's copied to the clipboard, and get it from there, or you can write a addon for the application. Since Chrome accepts addons, I suggest you research that angle. Probably mozilla.org is the place to start, and function nsISelectionController::GetSelection() might be some place to examine. You might find some hints in http://stackoverflow.com/questions/2671474/range-selection-and-mozilla if you are going to work with the clipboard, realize that it works quite differently from one OS to another, and even from one desktop manager to another. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the selected text of the webpage in chrome through python ?
On Mon, Jan 07, 2013 at 08:20:28PM -0800, iMath wrote: How to get the selected text of the webpage in chrome through python ? What you need is a way to get selected text from wherever it comes. The way to do this depends on your graphical environment. If you use X, i'd make a a quick and dirty call to xclip -o, although there must be a pure python implementation which in turn depends on the python framework you play with (gtk/qt/wx/tk/...). Short answer is : it depends on your system, and it may be easier and more portable if you use a graphical toolkit. cheers. -- Bruno Dupuis -- http://mail.python.org/mailman/listinfo/python-list
Re: [Offtopic] Line fitting [was Re: Numpy outlier removal]
On 8 January 2013 01:23, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Mon, 07 Jan 2013 22:32:54 +, Oscar Benjamin wrote: [...] I also think it would be highly foolish to go so far with refusing to eyeball data that you would accept the output of some regression algorithm even when it clearly looks wrong. I never said anything of the sort. I said, don't fit lines to data by eye. I didn't say not to sanity check your straight line fit is reasonable by eyeballing it. I should have been a little clearer. That was the situation when I decided to just use a (digital) ruler - although really it was more of a visual bisection (1, 2, 1.5, 1.25...). The regression result was clearly wrong (and also invalid for the reasons Terry has described). Some of the problems were easily fixable and others were not. I could have spent an hour getting the code to make the line go where I wanted it to, or I could just fit the line visually in about 2 minutes. Oscar -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the selected text of the webpage in chrome through python ?
On Monday, January 7, 2013 8:20:28 PM UTC-8, iMath wrote: How to get the selected text of the webpage in chrome through python ? You can probably use selenium to do that. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to modify this script?
Am 06.01.2013 15:30 schrieb Kurt Hansen: Den 06/01/13 15.20, Chris Angelico wrote: On Mon, Jan 7, 2013 at 1:03 AM, Kurt Hansen kurt@ugyldig.invalid wrote: I'm sorry to bother you, Chris, but applying the snippet with your code in Gedit still just deletes the marked, tab-separated text in the editor. Ah, whoops. That would be because I had a bug in the code (that's why I commented that it was untested). Sorry about that! Here's a fixed version: [cut] Note that it's a single line: output += 'td colspan=' + str(4-len(columns)) + '\' + item + '/td\ ' If your newsreader (or my poster) wraps it, you'll need to unwrap that line, otherwise you'll get an IndentError. Ahhh, I did'nt realize that. Now it works :-) That version should work. It certainly does. I'll keep it and use it until at better solution is found. That would be simple: Replace output += 'td colspan=' + str(4-len(columns)) + '\' + item + '/td\ ' with if len(columns) = 3: output += 'td\' else: output += 'td colspan=' + str(4-len(columns)) + '\' output += item + '/td\ ' (untested as well; keep the indentation in mind!) Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: How to modify this script?
Am 07.01.2013 18:56 schrieb Gertjan Klein: (Watch out for line wraps! I don't know how to stop Thunderbird from inserting them.) Do insert as quotation (in German Thunderbird: Als Zitat einfügen), or Strg-Shift-O. Then it gets inserted with a before and in blue. Just remove the and the space after it; the non-breaking property is kept. Example: columns = line.split(\t); if len(columns) == 1: output += ('td colspan=%s\' % max_columns) + line + '/td\/tr\\n' continue without and columns = line.split(\t); if len(columns) == 1: output += ('td colspan=%s\' % max_columns) + line + '/td\/tr\\n' continue with this feature. HTH, Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: PyDTLS
This sounds exciting. Are you considering a Python 3 port? It might make a nice demo of PEP 3156. On Monday, January 7, 2013, rbit wrote: I would like to announce Datagram Transport Layer Security for Python. From the top of the project README: PyDTLS brings Datagram Transport Layer Security (DTLS - RFC 6347: http://tools.ietf.org/html/rfc6347) to the Python environment. In a nutshell, DTLS brings security (encryption, server authentication, user authentication, and message authentication) to UDP datagram payloads in a manner equivalent to what SSL/TLS does for TCP stream content. DTLS is now very easy to use in Python. If you're familiar with the ssl module in Python's standard library, you already know how. All it takes is passing a datagram/UDP socket to the *wrap_socket* function instead of a stream/TCP socket. Here's how one sets up the client side of a connection: import ssl from socket import socket, AF_INET, SOCK_DGRAM from dtls import do_patch do_patch() sock = ssl.wrap_socket(socket(AF_INET, SOCK_DGRAM)) sock.connect(('foo.bar.com', 1234)) sock.send('Hi there') The project is hosted at https://github.com/rbit/pydtls, and licensed under the Apache license 2.0. PyPI has packages. I can be reached at code AT liquibits DOT com for questions, feedback, etc. PA HREF=http://pypi.python.org/pypi/Dtls/0.1.0;Dtls 0.1.0/A - Datagram Transport Layer Security for Python. (07-Jan-13) -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/ -- --Guido van Rossum (python.org/~guido) -- http://mail.python.org/mailman/listinfo/python-list
Re: how to download internet files by python ?
On 2013-01-08 05:00, Rodrick Brown wrote: On Mon, Jan 7, 2013 at 11:19 PM, iMath redstone-c...@163.com mailto:redstone-c...@163.com wrote: for example ,if I want to download this file ,how to implement the download functionality by python ? http://down.51voa.com/201208/se-ed-foreign-students-friends-16aug12.mp3 as for download speed ,of course ,the fast ,the better ,so how to implement it ? It would be better to show me an example :) thanks !!! -- http://mail.python.org/mailman/listinfo/python-list #!/usr/bin/python import urllib2 if __name__ == '__main__': fileurl='http://down.51voa.com/201208/se-ed-foreign-students-friends-16aug12.mp3' mp3file = urllib2.urlopen(fileurl) with open('outfile.mp3','wb') as output: output.write(mp3file.read()) Why not just use urlretrieve? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to modify this script?
Well tell me how do you use this script in gedit, are you using it as a plugin ? are you putting this code somewhere ? I'll try to do the same on my side and try to understand how it works. From: Kurt Hansen kurt@ugyldig.invalid To: python-list@python.org Sent: Monday, January 7, 2013 5:42 PM Subject: Re: How to modify this script? Den 06/01/13 16.12, chaouche yacine skrev: I'm not confident this would run on gedit. It works on a python interpreter if you have a file named data.txt in the same directory containing your sample data. It surely has to do with how gedit works then, because the $ sign isn't used in python, this business should be a gedit convention. And sorry, I can't help on that, I'm not a user of gedit myself. Fortunately others have answered and I beleive one of the solutions worked for you. It does not seem to be the case :-( Thank you for trying to help. *From:* Kurt Hansen kurt@ugyldig.invalid *To:* python-list@python.org *Sent:* Sunday, January 6, 2013 3:21 PM *Subject:* Re: How to modify this script? Den 06/01/13 15.01, chaouche yacine wrote: Well, I'm not answering your question since I am rewriting the script, because I prefer it this way :) def addline(line): return tr%s/tr\n % line [cut] I surpose I shall put your code between $ and ? printed table trtd colspan='3'Price table/td/tr trtd1 /tdtd Green apple /tdtd $1/td/tr trtd5 /tdtd Green apples /tdtd $4/td/tr trtd10 /tdtd Green apples /tdtd $7/td/tr /table Aha, so you tested it yourself? When running this in Gedit on four lines of tab-separated text the output is: %s/tr\n % line def addcolumn(item,nb_columns): if nb_columns != 3: return td colspan='%s'%s/td % (3 - nb_columns + 1, item) return td%s/td % item output = table\n for line in file(data.txt): items = line.strip().split(\t) columns = for item in items : columns += addcolumn(item,len(items)) output += addline(columns) output += /table print output -- Venlig hilsen Kurt Hansen -- http://mail.python.org/mailman/listinfo/python-list -- Venlig hilsen Kurt Hansen -- http://mail.python.org/mailman/listinfo/python-list-- http://mail.python.org/mailman/listinfo/python-list
Re: [Offtopic] Line fitting [was Re: Numpy outlier removal]
On 08/01/2013 06:35, Chris Angelico wrote: On Tue, Jan 8, 2013 at 1:06 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: given that weather patterns have been known to follow cycles at least that long. That is not a given. Weather patterns don't last for thirty years. Perhaps you are talking about climate patterns? Yes, that's what I meant. In any case, debate about global warming is quite tangential to the point about statistical validity; it looks quite significant to show a line going from the bottom of the graph to the top, but sounds a lot less noteworthy when you see it as a half-degree increase on about (I think?) 30 degrees, and even less when you measure temperatures in absolute scale (Kelvin) and it's half a degree in three hundred. Why on Earth do you think that the distance from nominal surface temperatures to freezing much less absolute 0 is the right scale to compare global warming changes against? You need to compare against the size of global mean temperature changes that would cause large amounts of human suffering, and that scale is on the order of a *few* degrees, not hundreds. A change of half a degree over a few decades with no signs of slowing down *should* be alarming. -- 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: How to modify this script?
Thomas Rachel wrote: Am 07.01.2013 18:56 schrieb Gertjan Klein: (Watch out for line wraps! I don't know how to stop Thunderbird from inserting them.) Do insert as quotation (in German Thunderbird: Als Zitat einfügen), or Strg-Shift-O. Then it gets inserted with a before and in blue. Just remove the and the space after it; the non-breaking property is kept. Ah, I didn't think of that, thanks. Laborious but manageable. But: Example: Both your examples are wrapped, in the same way. (I checked the message source, it's not some setting on my end.) It appears that, although Thunderbirds editor remembers the don't wrap setting, wrapping still occurs before sending. (The wrapping-before-sending code uses a slightly different algorithm than the editor too, so messages often look different after sending. Thunderbirds editor is really bad.) A last attempt: two (equal) quotes, the second one with the leading removed: output += ('td colspan=%s\' % max_columns) + line + '/td\/tr\\n' output += ('td colspan=%s\' % max_columns) + line + '/td\/tr\\n' I'm curious how this will come out. Regards, Gertjan. -- http://mail.python.org/mailman/listinfo/python-list
Re: Calculate Big Number
On Tuesday, January 8, 2013 2:06:09 AM UTC-8, Gisle Vanem wrote: Steven D'Aprano email deleted wrote: py from timeit import Timer py t1 = Timer((a**b)*(c**d), setup=a,b,c,d = 10, 25, 2, 50) py min(t1.repeat(repeat=5, number=10)) 0.5256571769714355 So that's about 5 microseconds on my (slow) computer. That's pretty fast. So is there still a need for a GMP python-binding like gmpy? http://code.google.com/p/gmpy/wiki/IntroductionToGmpy GMP can include optimized assembler for the CPU you're using. But I guess it needs more memory. Hence disk-swapping could be an issue on performance. gmpy will be faster than Python as the numbers get larger. The cutover varies depending on the platform, but usually occurs between 50 and 100 digits. casevh --gv -- http://mail.python.org/mailman/listinfo/python-list
Re: [Offtopic] Line fitting [was Re: Numpy outlier removal]
On Tuesday, January 8, 2013 10:07:08 AM UTC+1, Terry Reedy wrote: With the line constrained to go through 0,0, a line eyeballed with a clear ruler could easily be better than either regression line, as a human will tend to minimize the deviations *perpendicular to the line*, which is the proper thing to do (assuming both variables are measured in the same units). In that case use an appropriate algorithm to perform the fit. ODR comes to mind. http://docs.scipy.org/doc/scipy/reference/odr.html Maarten -- http://mail.python.org/mailman/listinfo/python-list
ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes
Thesaurus: A different way to call a dictionary. Thesaurus is a new a dictionary subclass which allows calling keys as if they are class attributes and will search through nested objects recursively when __getitem__ is called. You will notice that the code is disgusting simple. However I have found that this has completely changed the way I program in python. I've re-written some exiting programs using Thesaurus, and often realized 15-30% code reduction. Additionally I find the new code much easier to read. If you find yourself programing with nested dictionaries often, fighting to generate output or command lines for external programs, or wish you had a dictionary that could act (sort of) like a class, Thesaurus may be for you. #!/usr/bin/env python thesaurus.py 2012-09-13 Copyright (c) 2012 Dave Cinege Licence: python, Copyright notice may not be altered. Thesaurus: A different way to call a dictionary. Thesaurus is a new a dictionary subclass which allows calling keys as if they are class attributes and will search through nested objects recursivly when __getitem__ is called. You will notice that the code is disgusting simple. However I have found that this has completely changed the way I program in python. I've re-written some exiting programs using Thesaurus, and often relized 15-30% code reduction. Additionally I find the new code much easier to read. If you find yourself programing with nested dictionaries often, fighting to generate output or command lines for external programs, or wish you had a dictionary that could act (sort of) like a class, Thesaurus may be for you. By example: --- #!/usr/bin/env python import thesaurus thes = thesaurus.Thesaurus # I like to create a master global object called 'g'. # No more 'global' statements for me. g = thes() g.prog = thes() g['prog']['VERSION'] = '1.0' # I can do this like a normal nested dictionary g.prog.VERSION = '1.0' # But isn't this so much cleaner? g.prog.NAME = 'Thesaurus' class TestClass: no = 'Class' way = 'this' def main (): L = thes() # Some local varibles L.tc = TestClass() # We can also recurse to class attributes L.l = list() # And recurse to indices too! L.l.append('Some') L.l.append('objects') g.L = L # Easily make these locals global # Here's the real magic. Creating output without a fight. print ''' When programing python using %(prog.NAME)s, it is very easy to access your %(L.l.1)s. %(L.l.0)s people might say %(prog.NAME)s has no %(L.tc.no)s. '''.replace('\t','')[1:-1] % g del g.L # Clean locals up out of global space # If I was using a storage class, I must use hasattr() or an ugly eval. # But we can still use a str for the key name and 'in' like on any # regular dictionary. if 'VERSION' in g.prog: print 'But I challenge them to write code %(tc.way)s clean without it!' % L if __name__ == '__main__': main() --- __VERSION__ = 20120913 class Thesaurus (dict): def __getattr__(self, name): return self.__getitem__(name) def __setattr__(self, name, value): return dict.__setitem__(self, name, value) def __delattr__(self, name): return dict.__delitem__(self, name) def __getitem__(self, key): if '.' not in key: return dict.__getitem__(self, key) l = key.split('.') if isinstance(l[0], (dict, Thesaurus)): a = self.data else: a = self for i in range(len(l)): # Walk keys recursivly try: a = a[l[i]] # Attempt key except: try: a = getattr(a, l[i]) # Attempt attr except: try: a = a[int(l[i])] # Attempt indice except: raise KeyError(key + ' [%s]' % i) return a -- http://mail.python.org/mailman/listinfo/python-list
Re: License status of pycollada?
Hi Gene, I'm the maintainer of pycollada. No such paywall exists, and a login is not required. I'm not sure how you came across that. As Chris said, it's a standard BSD license. I'd be happy to help with packaging, so feel free to contact me. Jeff -- http://mail.python.org/mailman/listinfo/python-list
Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes
Did you intend to give anyone permission to use the code? I see only a copyright notice, but no permissions. -- http://mail.python.org/mailman/listinfo/python-list
Re: Searching through two logfiles in parallel?
i don't think in iterators (yet), so this is a bit wordy. same basic idea, though: for each message (set of parameters), build a list of transactions consisting of matching send/receive times. mildly tested: from datetime import datetime, timedelta sendData = '''\ 05:00:06 Message sent - Value A: 5.6, Value B: 6.2, Value C: 9.9 05:00:08 Message sent - Value A: 3.3, Value B: 4.3, Value C: 2.3 05:00:10 Message sent - Value A: 3.0, Value B: 0.4, Value C: 5.4 #orphan 05:00:14 Message sent - Value A: 1.0, Value B: 0.4, Value C: 5.4 07:00:14 Message sent - Value A: 1.0, Value B: 0.4, Value C: 5.4 ''' receiveData = '''\ 05:00:09 Message received - Value A: 5.6, Value B: 6.2, Value C: 9.9 05:00:12 Message received - Value A: 3.3, Value B: 4.3, Value C: 2.3 05:00:15 Message received - Value A: 1.0, Value B: 0.4, Value C: 5.4 07:00:18 Message received - Value A: 1.0, Value B: 0.4, Value C: 5.4 07:00:30 Message received - Value A: 1.0, Value B: 0.4, Value C: 5.4 #orphan 07:00:30 Message received - Value A: 17.0, Value B: 0.4, Value C: 5.4 #orphan ''' def parse(line): timestamp, rest = line.split(' Message ') action, params = rest.split(' - ' ) params = params.split('#')[0] return timestamp.strip(), params.strip() def isMatch(sendTime,receiveTime,maxDelta): if sendTime is None: return False sendDT = datetime.strptime(sendTime,'%H:%M:%S') receiveDT = datetime.strptime(receiveTime,'%H:%M:%S') return receiveDT - sendDT = maxDelta results = {} for line in sendData.split('\n'): if not line.strip(): continue timestamp, params = parse(line) if params not in results: results[params] = [{'sendTime': timestamp, 'receiveTime': None}] else: results[params].append({'sendTime': timestamp, 'receiveTime': None}) for line in receiveData.split('\n'): if not line.strip(): continue timestamp, params = parse(line) if params not in results: results[params] = [{'sendTime': None, 'receiveTime': timestamp}] else: for tranNum, transaction in enumerate(results[params]): if isMatch(transaction['sendTime'],timestamp,timedelta(seconds=5)): results[params][tranNum]['receiveTime'] = timestamp break else: results[params].append({'sendTime': None, 'receiveTime': timestamp}) for params in sorted(results): print params for transaction in results[params]: print '\t%s' % transaction RESTART Value A: 1.0, Value B: 0.4, Value C: 5.4 {'sendTime': '05:00:14', 'receiveTime': '05:00:15'} {'sendTime': '07:00:14', 'receiveTime': '07:00:18'} {'sendTime': None, 'receiveTime': '07:00:30'} Value A: 17.0, Value B: 0.4, Value C: 5.4 {'sendTime': None, 'receiveTime': '07:00:30'} Value A: 3.0, Value B: 0.4, Value C: 5.4 {'sendTime': '05:00:10', 'receiveTime': None} Value A: 3.3, Value B: 4.3, Value C: 2.3 {'sendTime': '05:00:08', 'receiveTime': '05:00:12'} Value A: 5.6, Value B: 6.2, Value C: 9.9 {'sendTime': '05:00:06', 'receiveTime': '05:00:09'} HTH, Don -- http://mail.python.org/mailman/listinfo/python-list
Re: License status of pycollada?
On Tuesday 08 January 2013 14:09:55 Jeff Terrace did opine: Message additions Copyright Tuesday 08 January 2013 by Gene Heskett Hi Gene, I'm the maintainer of pycollada. No such paywall exists, and a login is not required. I'm not sure how you came across that. Google search. As Chris said, it's a standard BSD license. I'd be happy to help with packaging, so feel free to contact me. It doesn't seem to be that important at the moment. I did find the src tarball later on another site, but it bails out because something is missing, gene@coyote:~/src/pycollada-0.4$ python setup.py Traceback (most recent call last): File setup.py, line 2, in module from setuptools import find_packages, setup ImportError: No module named setuptools I should go look for setuptools. matplotlib also fails to configure, numpy is a version too old on 10.04.4 Ubuntu, with no update for it available for that old a Ubuntu. 10.04.4 LTS only has 1.3, so I am blocked there too. ATM, no biggie. Thanks for the email. I'm going to go make some swarf freehand. Jeff Cheers, Gene -- There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order. -Ed Howdershelt (Author) My web page: http://coyoteden.dyndns-free.com:85/gene is up! My views http://www.armchairpatriot.com/What%20Has%20America%20Become.shtml The possession of a book becomes a substitute for reading it. -- Anthony Burgess I was taught to respect my elders, but its getting harder and harder to find any... -- http://mail.python.org/mailman/listinfo/python-list
Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes
On Tue, Jan 8, 2013 at 12:16 PM, Neal Becker ndbeck...@gmail.com wrote: Did you intend to give anyone permission to use the code? I see only a copyright notice, but no permissions. It also says Licence: python, Copyright notice may not be altered. Which suggests to me that the intent is that it be licensed under the PSF License, although I wouldn't want to be the one testing that inference in a courtroom. Dave, this announcement looks identical to the one you posted a couple months ago, and it also seems to include the earlier version of the source. -- http://mail.python.org/mailman/listinfo/python-list
Re: [Offtopic] Line fitting [was Re: Numpy outlier removal]
On Wed, Jan 9, 2013 at 2:55 AM, Robert Kern robert.k...@gmail.com wrote: On 08/01/2013 06:35, Chris Angelico wrote: ... it looks quite significant to show a line going from the bottom of the graph to the top, but sounds a lot less noteworthy when you see it as a half-degree increase on about (I think?) 30 degrees, and even less when you measure temperatures in absolute scale (Kelvin) and it's half a degree in three hundred. Why on Earth do you think that the distance from nominal surface temperatures to freezing much less absolute 0 is the right scale to compare global warming changes against? You need to compare against the size of global mean temperature changes that would cause large amounts of human suffering, and that scale is on the order of a *few* degrees, not hundreds. A change of half a degree over a few decades with no signs of slowing down *should* be alarming. I didn't say what it should be; I gave three examples. And as I said, this is not the forum to debate climate change; I was just using it as an example of statistical reporting. Three types of lies. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
New version of PyGreSQL 4.1.1 - bug fixes
- Release of PyGreSQL version 4.1.1 - A few problems showed up with the 4.1 release so we are releasing a quick bugfix version. It is available at: http://pygresql.org/files/PyGreSQL-4.1.1.tgz. If you are running NetBSD, look in the packages directory under databases. There is also a package in the FreeBSD ports collection. Please refer to `changelog.txt changelog.html`_ for things that have changed in this version. Please refer to `readme.txt readme.html`_ for general information. This version has been built and unit tested on: - NetBSD - FreeBSD - openSUSE 12.2 - Windows 7 with both MinGW and Visual Studio - PostgreSQL 8.4, 9.0 and 9.2 32 and 64bit - Python 2.5, 2.6 and 2.7 32 and 64bit | D'Arcy J.M. Cain | da...@pygresql.org -- D'Arcy J.M. Cain PyGreSQL Development Group http://www.PyGreSQL.org IM:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
How to tell how many weeks apart two datetimes are?
How do you tell how many weeks apart two datetimes (t1 and t2) are? The obvious solution would be: weeks = (t2 - t1) / timedelta(days=7) but that doesn't appear to be allowed. Is there some fundamental reason why timedelta division not supported? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to tell how many weeks apart two datetimes are?
On Tue, Jan 8, 2013, at 04:22 PM, Roy Smith wrote: How do you tell how many weeks apart two datetimes (t1 and t2) are? The obvious solution would be: weeks = (t2 - t1) / timedelta(days=7) but that doesn't appear to be allowed. Is there some fundamental reason why timedelta division not supported? -- http://mail.python.org/mailman/listinfo/python-list It works for python 3(.2): x = datetime.timedelta(days=666) week = datetime.timedelta(days=7) x / week 95.14285714285714 halfday = datetime.timedelta(hours=12) x / halfday 1332.0 -- http://mail.python.org/mailman/listinfo/python-list
Re: How to tell how many weeks apart two datetimes are?
On Tue, Jan 8, 2013 at 2:22 PM, Roy Smith r...@panix.com wrote: How do you tell how many weeks apart two datetimes (t1 and t2) are? The obvious solution would be: weeks = (t2 - t1) / timedelta(days=7) but that doesn't appear to be allowed. Is there some fundamental reason why timedelta division not supported? Seems to be supported in Python 3.3, but not in 2.7. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to tell how many weeks apart two datetimes are?
On Tue, Jan 8, 2013 at 2:33 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On Tue, Jan 8, 2013 at 2:22 PM, Roy Smith r...@panix.com wrote: How do you tell how many weeks apart two datetimes (t1 and t2) are? The obvious solution would be: weeks = (t2 - t1) / timedelta(days=7) but that doesn't appear to be allowed. Is there some fundamental reason why timedelta division not supported? Seems to be supported in Python 3.3, but not in 2.7. From the docs: Changed in version 3.2: Floor division and true division of a timedelta object by another timedelta object are now supported, as are remainder operations and the divmod() function. True division and multiplication of a timedelta object by a float object are now supported. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to tell how many weeks apart two datetimes are?
On 2013-01-08 21:22, Roy Smith wrote: How do you tell how many weeks apart two datetimes (t1 and t2) are? The obvious solution would be: weeks = (t2 - t1) / timedelta(days=7) but that doesn't appear to be allowed. Is there some fundamental reason why timedelta division not supported? Try this: weeks = (t2 - t1).days / 7 -- http://mail.python.org/mailman/listinfo/python-list
Re: How to tell how many weeks apart two datetimes are?
On 8 January 2013 22:50, MRAB pyt...@mrabarnett.plus.com wrote: On 2013-01-08 21:22, Roy Smith wrote: How do you tell how many weeks apart two datetimes (t1 and t2) are? The obvious solution would be: weeks = (t2 - t1) / timedelta(days=7) but that doesn't appear to be allowed. Is there some fundamental reason why timedelta division not supported? Try this: weeks = (t2 - t1).days / 7 You beat me to it... $ python Python 2.7.3 (default, Sep 26 2012, 21:51:14) [GCC 4.7.2] on linux2 Type help, copyright, credits or license for more information. import datetime dt1 = datetime.datetime.now() dt2 = dt1 - datetime.timedelta(days=8) (dt2 - dt1) / 7 datetime.timedelta(days=14) False Oscar -- http://mail.python.org/mailman/listinfo/python-list
Re: [Offtopic] Line fitting [was Re: Numpy outlier removal]
On 08/01/2013 20:14, Chris Angelico wrote: On Wed, Jan 9, 2013 at 2:55 AM, Robert Kern robert.k...@gmail.com wrote: On 08/01/2013 06:35, Chris Angelico wrote: ... it looks quite significant to show a line going from the bottom of the graph to the top, but sounds a lot less noteworthy when you see it as a half-degree increase on about (I think?) 30 degrees, and even less when you measure temperatures in absolute scale (Kelvin) and it's half a degree in three hundred. Why on Earth do you think that the distance from nominal surface temperatures to freezing much less absolute 0 is the right scale to compare global warming changes against? You need to compare against the size of global mean temperature changes that would cause large amounts of human suffering, and that scale is on the order of a *few* degrees, not hundreds. A change of half a degree over a few decades with no signs of slowing down *should* be alarming. I didn't say what it should be; Actually, you did. You stated that a ~0.6 deg increase across ~30 years [is h]ardly statistically significant. Ignoring the confusion between statistical significance and practical significance (as external criteria like the difference between the nominal temp and absolute 0 or the right criteria that I mentioned has nothing to do with statistical significance), you made a positive claim that it wasn't significant. I gave three examples. You gave negligently incorrect ones. Whether your comments were on topic or not, you deserve to be called on them when they are wrong. And as I said, this is not the forum to debate climate change; I was just using it as an example of statistical reporting. Three types of lies. FUD is a fourth. -- 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: Searching through two logfiles in parallel?
On 8 January 2013 19:16, darnold darnold992...@yahoo.com wrote: i don't think in iterators (yet), so this is a bit wordy. same basic idea, though: for each message (set of parameters), build a list of transactions consisting of matching send/receive times. The advantage of an iterator based solution is that we can avoid loading all of both log files into memory. [SNIP] results = {} for line in sendData.split('\n'): if not line.strip(): continue timestamp, params = parse(line) if params not in results: results[params] = [{'sendTime': timestamp, 'receiveTime': None}] else: results[params].append({'sendTime': timestamp, 'receiveTime': None}) [SNIP] This kind of logic is made a little easier (and more efficient) if you use a collections.defaultdict instead of a dict since it saves needing to check if the key is in the dict yet. Example: import collections results = collections.defaultdict(list) results defaultdict(type 'list', {}) results['asd'].append(1) results defaultdict(type 'list', {'asd': [1]}) results['asd'].append(2) results defaultdict(type 'list', {'asd': [1, 2]}) results['qwe'].append(3) results defaultdict(type 'list', {'qwe': [3], 'asd': [1, 2]}) Oscar -- http://mail.python.org/mailman/listinfo/python-list
Best way to do this? List loop (matrix?) iteration
Hi! I might be missing the obvious, or I may have found something more complicated than the VBA I am used to. Could it be I need to use a maths library? For a given list of k items I'd like to turn it into an k*k matrix of item pairs. List_sample = ['a', 'b', 'c'] Output: aa ab ac ba bb bc ca cb cc I'd like to have 2 hooks into this process 1. I want the opportunity to use a value pair each time they are generated (because I need to send these to an api and get a number back to put into a temporary list or dictionary - still tbd). 2. I'd also like to know each time a row is completed so I can bank that temporary list to a database table. Else build one big list and do it at the end, I'm still figuring this out. #Code I've tried: stn_count = len(stn_list_short) for rowcount in range (0, stn_count): for colcount in range (0, stn_count): print stn_list_long[rowcount] stn_list_long[colcount] I've found itertools, tee, and product and felt I was getting warmer. I'm still looking, but any pointers would be appreciated! Thanks, Andy -- http://mail.python.org/mailman/listinfo/python-list
Re: [Offtopic] Line fitting [was Re: Numpy outlier removal]
On Tue, 08 Jan 2013 04:07:08 -0500, Terry Reedy wrote: But that is not fitting a line by eye, which is what I am talking about. With the line constrained to go through 0,0 a line eyeballed with a clear ruler could easily be better than either regression line, as a human will tend to minimize the deviations *perpendicular to the line*, which is the proper thing to do (assuming both variables are measured in the same units). It is conventional to talk about residuals rather than deviations. And it could even more easily be worse than a regression line. And since eyeballing is entirely subjective and impossible to objectively verify, the line that you claim minimizes the residuals might be very different from the line that I claim minimizes the residuals, and no way to decide between the two claims. In any case, there is a technique for working out ordinary least squares (OLS) linear regression using perpendicular offsets rather than vertical offsets: http://mathworld.wolfram.com/LeastSquaresFittingPerpendicularOffsets.html but in general, if you have to care about errors in the dependent variable, you're better off using a more powerful technique than just OLS. The point I keep making, that everybody seems to be ignoring, is that eyeballing a line of best fit is subjective, unreliable and impossible to verify. How could I check that the line you say is the best fit actually *is* the *best fit* for the given data, given that you picked that line by eye? Chances are good that if you came back to the data a month later, you'd pick a different line! As I have said, eyeballing a line is fine for rough back of the envelope type calculations, where you only care that you have a line pointing more or less in the right direction. But for anything where accuracy is required, line fitting by eye is down in the pits of things not to do, right next to making up the answers you prefer. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to do this? List loop (matrix?) iteration
On Tue 08 Jan 2013 07:19:59 PM EST, andydtay...@gmail.com wrote: Hi! I might be missing the obvious, or I may have found something more complicated than the VBA I am used to. Could it be I need to use a maths library? For a given list of k items I'd like to turn it into an k*k matrix of item pairs. List_sample = ['a', 'b', 'c'] Output: aa ab ac ba bb bc ca cb cc I'd like to have 2 hooks into this process 1. I want the opportunity to use a value pair each time they are generated (because I need to send these to an api and get a number back to put into a temporary list or dictionary - still tbd). 2. I'd also like to know each time a row is completed so I can bank that temporary list to a database table. Else build one big list and do it at the end, I'm still figuring this out. #Code I've tried: stn_count = len(stn_list_short) for rowcount in range (0, stn_count): for colcount in range (0, stn_count): print stn_list_long[rowcount] stn_list_long[colcount] I've found itertools, tee, and product and felt I was getting warmer. I'm still looking, but any pointers would be appreciated! Thanks, Andy You can use itertools.product(abc, repeat=2) together with itertools recipe grouper() from the same page: http://docs.python.org/3.3/library/itertools.html?highlight=itertools#itertools HTH, -m -- Lark's Tongue Guide to Python: http://lightbird.net/larks/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Specifying two log files with one configuration file
Peter Steele pwsteele at gmail.com writes: I have been unable to get this to work. My current conf file looks like this: Try with the following changes: [logger_test] level: DEBUG handlers: test propagate: 0 qualname: test The qualname: test is what identifies the logger as the logger named 'test', and propagate: 0 prevents the test message from being passed up to the root logger. Regards, Vinay Sajip -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to do this? List loop (matrix?) iteration
On Wed, Jan 9, 2013 at 11:19 AM, andydtay...@gmail.com wrote: stn_count = len(stn_list_short) for rowcount in range (0, stn_count): for colcount in range (0, stn_count): print stn_list_long[rowcount] stn_list_long[colcount] First off, you can iterate over the list directly: for row in stn_list_short: for col in stn_list_short: print row + col (I'm not sure what your code was doing with the print line, because it ought to have failed. Explicit concatenation will work.) Secondly, you can make a list of all of those pairs with a compact notation called a comprehension: pairs = [row + col for row in stn_list_short for col in stn_list_short] That covers your requirement #2, giving you a full list of all of them. How big is k going to be? Storing the whole list in memory will get a little awkward if you have very large k; on this system, I started seeing performance issues with a thousand elements in the list, but you could probably go to ten thousand (ie a hundred million pairs) if you have a decent bit of RAM. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: [Offtopic] Line fitting [was Re: Numpy outlier removal]
Statistical analysis is a huge science. So is lying. And I'm not sure most people can pick one from the other. Chris, your sentence causes me to think of Mr. Twain's sentence, or at least the one he popularized: http://www.twainquotes.com/Statistics.html. -- http://mail.python.org/mailman/listinfo/python-list
Re: [Offtopic] Line fitting [was Re: Numpy outlier removal]
Statistical analysis is a huge science. So is lying. And I'm not sure most people can pick one from the other. Chris, your sentence causes me to think of Mr. Twain's sentence, or at least the one he popularized: http://www.twainquotes.com/Statistics.html. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the selected text of the webpage in chrome through python ?
在 2013年1月8日星期二UTC+8下午9时19分51秒,Bruno Dupuis写道: On Mon, Jan 07, 2013 at 08:20:28PM -0800, iMath wrote: How to get the selected text of the webpage in chrome through python ? What you need is a way to get selected text from wherever it comes. The way to do this depends on your graphical environment. If you use X, i'd make a a quick and dirty call to xclip -o, although there must be a pure python implementation which in turn depends on the python framework you play with (gtk/qt/wx/tk/...). Short answer is : it depends on your system, and it may be easier and more portable if you use a graphical toolkit. cheers. -- Bruno Dupuis I use it on WinXP , I also learned PyQt4 . can u help ? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the selected text of the webpage in chrome through python ?
在 2013年1月8日星期二UTC+8下午9时11分30秒,Dave Angel写道: On 01/08/2013 07:38 AM, Dennis Lee Bieber wrote: On Mon, 7 Jan 2013 20:20:28 -0800 (PST), iMath redstone-c...@163.com declaimed the following in gmane.comp.python.general: How to get the selected text of the webpage in chrome through python ? Chrome is a browser, is it not... If you want to get the text in Python, you have to write the equivalent of a browser -- something that parses the returned HTML message, extracting the parts you want. To get a selection, you can either wait till it's copied to the clipboard, and get it from there, or you can write a addon for the application. Since Chrome accepts addons, I suggest you research that angle. Probably mozilla.org is the place to start, and function nsISelectionController::GetSelection() might be some place to examine. You might find some hints in http://stackoverflow.com/questions/2671474/range-selection-and-mozilla if you are going to work with the clipboard, realize that it works quite differently from one OS to another, and even from one desktop manager to another. -- DaveA It seems need Javascript to work it on . Unfortunately ,I am only familiar with python . -- http://mail.python.org/mailman/listinfo/python-list
Re: How to implement mouse gesture by python or pyqt ?
在 2013年1月8日星期二UTC+8上午8时44分20秒,iMath写道: It would be better to give me some examples .thanks in advance ! P.S. which module or lib are needed ? what I wanna perhaps like this: when a right mouse button is pressed and we go down and right with a cursor. As in letter 'L'. Our mouse gesture will close the window. I googled such gesture examples on PyQt4 ,but hard to find one ,so your help will be greatly appreciated ! thanks inadvance ! -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: PyDTLS
Thank you. I will gladly port to Python 3 if there is interest from the community. Regarding PEP 3156: asynchronous use of unreliable network protocols makes for an interesting use case. In particular, it forces applications to deal with packet loss under some circumstances. One such situation occurs during DTLS's handshaking phase: if no response is received from the peer after some period of time, we must assume that our most recent datagram has been lost, and so we need to retransmit. The event loop interface as outlined in the PEP makes this a bit difficult (as did the asyncore module). One possible way to make things easier would be by adding two parameters to add_reader: a callable to retrieve the current timeout, and a callable that is invoked if that timeout expires before the descriptor becomes readable. Each loop iteration would then collect all given timeouts, and pass the minimum of that set to whatever polling facility it invokes. If that timeout expires, the corresponding timeout handler would be invoked prior to the next loop iteration. The PEP also considers only stream transports when referring to transport. Datagram transports do not, for example, have the property that calling t.write(b'abc'); t.write(b'def') is equivalent to calling t.write(b'abcdef'). I'm not sure what sort of impact this omission of datagram transports has for an implementation. Though I would certainly like to see datagram transports be treated as first-class citizens, despite not being nearly used as often as stream transports. I would hope that an implementer of, say, RTP over UDP, can tie into the same event loop as someone implementing a single-process, single-threaded Web server. Implementing DTLS as a tulip transport sounds interesting. Is the tulip package available somewhere so that I can try it out? Ray On Tue, Jan 8, 2013 at 6:53 AM, Guido van Rossum gu...@python.org wrote: This sounds exciting. Are you considering a Python 3 port? It might make a nice demo of PEP 3156. On Monday, January 7, 2013, rbit wrote: I would like to announce Datagram Transport Layer Security for Python. From the top of the project README: PyDTLS brings Datagram Transport Layer Security (DTLS - RFC 6347: http://tools.ietf.org/html/rfc6347) to the Python environment. In a nutshell, DTLS brings security (encryption, server authentication, user authentication, and message authentication) to UDP datagram payloads in a manner equivalent to what SSL/TLS does for TCP stream content. DTLS is now very easy to use in Python. If you're familiar with the ssl module in Python's standard library, you already know how. All it takes is passing a datagram/UDP socket to the *wrap_socket* function instead of a stream/TCP socket. Here's how one sets up the client side of a connection: import ssl from socket import socket, AF_INET, SOCK_DGRAM from dtls import do_patch do_patch() sock = ssl.wrap_socket(socket(AF_INET, SOCK_DGRAM)) sock.connect(('foo.bar.com', 1234)) sock.send('Hi there') The project is hosted at https://github.com/rbit/pydtls, and licensed under the Apache license 2.0. PyPI has packages. I can be reached at code AT liquibits DOT com for questions, feedback, etc. PA HREF=http://pypi.python.org/pypi/Dtls/0.1.0;Dtls 0.1.0/A - Datagram Transport Layer Security for Python. (07-Jan-13) -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/ -- --Guido van Rossum (python.org/~guido) -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: PyDTLS
On Tue, Jan 8, 2013 at 8:39 PM, rbit p...@liquibits.com wrote: Thank you. I will gladly port to Python 3 if there is interest from the community. Python 3 is where it's at! :-) Regarding PEP 3156: asynchronous use of unreliable network protocols makes for an interesting use case. In particular, it forces applications to deal with packet loss under some circumstances. But don't you have to deal with that when doing synchronous I/O as well? It's a datagram protocol after all. One such situation occurs during DTLS's handshaking phase: if no response is received from the peer after some period of time, we must assume that our most recent datagram has been lost, and so we need to retransmit. Is this something the transport can handle, or does the protocol (and hence the application) need to be involved here? The event loop interface as outlined in the PEP makes this a bit difficult (as did the asyncore module). One possible way to make things easier would be by adding two parameters to add_reader: a callable to retrieve the current timeout, and a callable that is invoked if that timeout expires before the descriptor becomes readable. Each loop iteration would then collect all given timeouts, and pass the minimum of that set to whatever polling facility it invokes. If that timeout expires, the corresponding timeout handler would be invoked prior to the next loop iteration. Hm, this would add a fair amount of complexity to the event loop. It's true that I don't have the complete story for timeouts yet, but I am hopeful that things like this can be implemented by using call_later() with some callback that does the retransmit (and resets some internal state), and cancelling that callback whenever a packet is received (i.e. in the protocol's datagram_received() method). The PEP also considers only stream transports when referring to transport. Datagram transports do not, for example, have the property that calling t.write(b'abc'); t.write(b'def') is equivalent to calling t.write(b'abcdef'). Yeah, obviously this invariant only applies to stream protocols. The PEP currently doesn't really specify datagram support (it's just in the Open Issues section). I'm not sure what sort of impact this omission of datagram transports has for an implementation. Though I would certainly like to see datagram transports be treated as first-class citizens, despite not being nearly used as often as stream transports. I would hope that an implementer of, say, RTP over UDP, can tie into the same event loop as someone implementing a single-process, single-threaded Web server. Yeah, at the level of the eventloop proper (the APIs that deal with callbacks, not futures, transports and protocols) datagrams won't be a problem. There will have to be separate specifications for the transport and protocol interfaces used with datagrams. Implementing DTLS as a tulip transport sounds interesting. Is the tulip package available somewhere so that I can try it out? Absolutely -- it is very much in flux, but you can check out the latest source from http://code.google.com/p/tulip/source/checkout using Mercurial. --Guido Ray On Tue, Jan 8, 2013 at 6:53 AM, Guido van Rossum gu...@python.org wrote: This sounds exciting. Are you considering a Python 3 port? It might make a nice demo of PEP 3156. On Monday, January 7, 2013, rbit wrote: I would like to announce Datagram Transport Layer Security for Python. From the top of the project README: PyDTLS brings Datagram Transport Layer Security (DTLS - RFC 6347: http://tools.ietf.org/html/rfc6347) to the Python environment. In a nutshell, DTLS brings security (encryption, server authentication, user authentication, and message authentication) to UDP datagram payloads in a manner equivalent to what SSL/TLS does for TCP stream content. DTLS is now very easy to use in Python. If you're familiar with the ssl module in Python's standard library, you already know how. All it takes is passing a datagram/UDP socket to the *wrap_socket* function instead of a stream/TCP socket. Here's how one sets up the client side of a connection: import ssl from socket import socket, AF_INET, SOCK_DGRAM from dtls import do_patch do_patch() sock = ssl.wrap_socket(socket(AF_INET, SOCK_DGRAM)) sock.connect(('foo.bar.com', 1234)) sock.send('Hi there') The project is hosted at https://github.com/rbit/pydtls, and licensed under the Apache license 2.0. PyPI has packages. I can be reached at code AT liquibits DOT com for questions, feedback, etc. PA HREF=http://pypi.python.org/pypi/Dtls/0.1.0;Dtls 0.1.0/A - Datagram Transport Layer Security for Python. (07-Jan-13) -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/ -- --Guido van Rossum (python.org/~guido) -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: PyDTLS
On Tue, Jan 8, 2013 at 9:09 PM, Guido van Rossum gu...@python.org wrote: But don't you have to deal with that when doing synchronous I/O as well? It's a datagram protocol after all. No: when dealing with blocking sockets, the OpenSSL library activates its own retransmission timers, and the application never becomes aware of whether timeouts occurred. Since OpenSSL can't do this in the the case of non-blocking sockets, it becomes the application's problem to call back into OpenSSL at some point in the future (the very same time for which OpenSSL would have set its own timeout had the socket been blocking). OpenSSL exports functions DTLSv1_get_timeout and DTLSv1_handle_timeout to applications to address this case. The timeouts start at one second, and double for each encountered timeout, until the timeout ceiling of one minutes is reached. I'm using the term application here for any code that uses the OpenSSL library, but is not part of it. One such situation occurs during DTLS's handshaking phase: if no response is received from the peer after some period of time, we must assume that our most recent datagram has been lost, and so we need to retransmit. Is this something the transport can handle, or does the protocol (and hence the application) need to be involved here? Given my current understanding of the PEP, I think this can be handled in the transport. Maybe there's some pitfall here that I can't quite see yet - even more reason for me to try to implement it. The event loop interface as outlined in the PEP makes this a bit difficult (as did the asyncore module). One possible way to make things easier would be by adding two parameters to add_reader: a callable to retrieve the current timeout, and a callable that is invoked if that timeout expires before the descriptor becomes readable. Each loop iteration would then collect all given timeouts, and pass the minimum of that set to whatever polling facility it invokes. If that timeout expires, the corresponding timeout handler would be invoked prior to the next loop iteration. Hm, this would add a fair amount of complexity to the event loop. It's true that I don't have the complete story for timeouts yet, but I am hopeful that things like this can be implemented by using call_later() with some callback that does the retransmit (and resets some internal state), and cancelling that callback whenever a packet is received (i.e. in the protocol's datagram_received() method). Yes, ok, I can see how that could work, too. I thought that it might make sense to centralize handling timeouts in the event loop in order to prevent proliferation in the transports (since there are multiple event loop implementations, perhaps a mix-in would be good?). I think one will want to contain handshake (vs. application data) timeout handling at least to the transport, though, and not let it spill over into various protocols. I'm not sure yet where the right place is for cancelling a timeout callback. Implementing DTLS as a tulip transport sounds interesting. Is the tulip package available somewhere so that I can try it out? Absolutely -- it is very much in flux, but you can check out the latest source from http://code.google.com/p/tulip/source/checkout using Mercurial. All right, thanks, I'll check it out. Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: [Offtopic] Line fitting [was Re: Numpy outlier removal]
On Wed, 09 Jan 2013 07:14:51 +1100, Chris Angelico wrote: Three types of lies. Oh, surely more than that. White lies. Regular or garden variety lies. Malicious lies. Accidental or innocent lies. FUD -- fear, uncertainty, doubt. Half-truths. Lying by omission. Exaggeration and understatement. Propaganda. Misinformation. Disinformation. Deceit by emphasis. And manufactured doubt. E.g. the decades long campaign by the tobacco companies to deny that tobacco products caused cancer, when their own scientists were telling them that they did. Having learnt how valuable falsehoods are, those same manufacturers of doubt went on to sell their services to those who wanted to deny that CFCs destroyed ozone, and that CO2 causes warming. The old saw about lies, damned lies and statistics reminds me very much of a quote from Homer Simpson: Pfff, facts, you can prove anything that's even remotely true with facts! -- Steven -- http://mail.python.org/mailman/listinfo/python-list
[issue16748] Make CPython test package discoverable
Serhiy Storchaka added the comment: There are tests outside of Lib/test/ hierarchy. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16748 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16871] Cleanup a few minor things
Serhiy Storchaka added the comment: Agreed. Maintainers of asynchat, tkinter.tix, optparse and difflib must pay attention to this. -- nosy: +aronacher, giampaolo.rodola, gpolo, josiahcarlson, stutzbach resolution: - rejected stage: patch review - committed/rejected status: pending - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16871 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16891] Fix docs about module search order
New submission from Dmitry Mugtasimov: http://docs.python.org/2/tutorial/modules.html should be rewritten. AS IS 6.1.2. The Module Search Path When a module named spam is imported, the interpreter first searches for a built-in module with that name. If not found, it then searches for a file named spam.py in a list of directories given by the variable sys.path. sys.path is initialized from these locations: TO BE 6.1.2. The Module Search Path When a module named spam is imported, the interpreter first searches for a built-in module with that name. If not found, it looks in the containing package (the package of which the current module is a submodule). If not found, it then searches for a file named spam.py in a list of directories given by the variable sys.path. sys.path is initialized from these locations: -- Note that now 6.1.2. The Module Search Path and 6.4.2. Intra-package References are contradictary since in 6.4.2 it is said: In fact, such references are so common that the import statement first looks in the containing package before looking in the standard module search path., but this is not reflected in 6.1.2. -- EXAMPLE (for more information see http://stackoverflow.com/questions/14183541/why-python-finds-module-instead-of-package-if-they-have-the-same-name#comment19687166_14183541 ): /home/dmugtasimov/tmp/name-res3/xyz __init__.py a.py b.py t.py xyz.py Files init.py, b.py and xyz.py are empty File a.py: import os, sys ROOT_DIRECTORY = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) if not sys.path or ROOT_DIRECTORY not in sys.path: print 'sys.path is modified in a.py' sys.path.insert(0, ROOT_DIRECTORY) else: print 'sys.path is NOT modified in a.py' print 'sys.path:', sys.path print 'BEFORE import xyz.b' import xyz.b print 'AFTER import xyz.b' File t.py: import os, sys ROOT_DIRECTORY = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) if not sys.path or ROOT_DIRECTORY not in sys.path: print 'sys.path is modified in t.py' sys.path.insert(0, ROOT_DIRECTORY) else: print 'sys.path is NOT modified in t.py' import xyz.a Run: python a.py Output: sys.path is modified in a.py sys.path: ['/home/dmugtasimov/tmp/name-res3', '/home/dmugtasimov/tmp/name-res3/xyz', '/usr/local/lib/python2.7/dist-packages/tornado-2.3-py2.7.egg', '/home/dmugtasimov/tmp/name-res3/xyz', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg-info', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client'] BEFORE import xyz.b AFTER import xyz.b Run: python -vv a.py Output: import xyz # directory /home/dmugtasimov/tmp/name-res3/xyz # trying /home/dmugtasimov/tmp/name-res3/xyz/__init__.so # trying /home/dmugtasimov/tmp/name-res3/xyz/__init__module.so # trying /home/dmugtasimov/tmp/name-res3/xyz/__init__.py # /home/dmugtasimov/tmp/name-res3/xyz/__init__.pyc matches /home/dmugtasimov/tmp/name-res3/xyz/__init__.py import xyz # precompiled from /home/dmugtasimov/tmp/name-res3/xyz/__init__.pyc # trying /home/dmugtasimov/tmp/name-res3/xyz/b.so # trying /home/dmugtasimov/tmp/name-res3/xyz/bmodule.so # trying /home/dmugtasimov/tmp/name-res3/xyz/b.py # /home/dmugtasimov/tmp/name-res3/xyz/b.pyc matches /home/dmugtasimov/tmp/name-res3/xyz/b.py import xyz.b # precompiled from /home/dmugtasimov/tmp/name-res3/xyz/b.pyc Run: python t.py Output: sys.path is modified in t.py sys.path is NOT modified in a.py sys.path: ['/home/dmugtasimov/tmp/name-res3', '/home/dmugtasimov/tmp/name-res3/xyz', '/usr/local/lib/python2.7/dist-packages/tornado-2.3-py2.7.egg', '/home/dmugtasimov/tmp/name-res3/xyz', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg-info', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client'] BEFORE import xyz.b Traceback (most recent call last): File t.py, line 9, in module import xyz.a File /home/dmugtasimov/tmp/name-res3/xyz/a.py, line 11, in module import xyz.b ImportError: No module named b Run: python -vv t.py Output: import xyz # directory
[issue16891] Fix docs about module search order
Dmitry Mugtasimov added the comment: UPDATE: CHANGE http://stackoverflow.com/questions/14183541/why-python-finds-module-instead-of-package-if-they-have-the-same-name#comment19687166_14183541 TO http://stackoverflow.com/questions/14183541/why-python-finds-module-instead-of-package-if-they-have-the-same-name Because the whole question and replies are important. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16891 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14323] Normalize math precision in RGB/YIQ conversion
Serhiy Storchaka added the comment: According to Wikipedia FCC conversion is defined as: y = 0.30*r + 0.59*g + 0.11*b i = 0.5990*r - 0.2773*g - 0.3217*b q = 0.2130*r - 0.5251*g + 0.3121*b and non-FCC conversion is defined as: y = 0.299*r + 0.587*g + 0.114*b i = 0.595716*r - 0.274453*g - 0.321263*b q = 0.211456*r - 0.522591*g + 0.311135*b Our current code y = 0.30*r + 0.59*g + 0.11*b i = 0.60*r - 0.28*g - 0.32*b q = 0.21*r - 0.52*g + 0.31*b looks like FCC conversion with the precision of two decimal places. Actually with this precision the difference between the different conversions are almost absent. -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14323 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8489] Support UTF8SMTP as part of RFC 5336 in smptlib
Changes by David Lam d...@dlam.me: -- nosy: +dlam ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8489 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14468] Update cloning guidelines in devguide
Ezio Melotti added the comment: Here is another iteration of the patch. I removed some of the old material, added half of the FAQs and the title and outline for the other FAQs. If the structure looks good I'll proceed. -- assignee: sandro.tosi - ezio.melotti Added file: http://bugs.python.org/file28628/issue14468-2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14468 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14468] Update cloning guidelines in devguide
Changes by Ezio Melotti ezio.melo...@gmail.com: Added file: http://bugs.python.org/file28629/committing.rst ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14468 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15845] Fixing some byte-to-string conversion warnings
Roundup Robot added the comment: New changeset 9458a516f769 by Serhiy Storchaka in branch '3.2': Issue #15845: Fix comparison between bytes and string. http://hg.python.org/cpython/rev/9458a516f769 New changeset f6cf2985348a by Serhiy Storchaka in branch '3.3': Issue #15845: Fix comparison between bytes and string. http://hg.python.org/cpython/rev/f6cf2985348a New changeset 51e60d9ee389 by Serhiy Storchaka in branch 'default': Issue #15845: Fix comparison between bytes and string. http://hg.python.org/cpython/rev/51e60d9ee389 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15845 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15845] Fixing some byte-to-string conversion warnings
Serhiy Storchaka added the comment: Fixed. Thank your for report and patch, Alessandro. -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15845 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16851] ismethod and isfunction methods error
Changes by Federico Reghenzani federico@reghe.net: -- keywords: +patch Added file: http://bugs.python.org/file28630/inspect.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16851 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16890] minidom error
Javier Domingo added the comment: I know that is the problem, but that shouldn't happen! if you remove a item from a list, that doesn't happen. That is why I tagged the error as minidom's El 08/01/2013 04:24, Ezio Melotti rep...@bugs.python.org escribió: Ezio Melotti added the comment: The problem is that you are mutating parent.childNodes while you are iterating on it. Iterating over a copy seems to solve the problem. -- nosy: +ezio.melotti resolution: - invalid stage: - committed/rejected status: open - closed type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16890 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16890 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16853] add a Selector to the select module
Charles-François Natali added the comment: So I assume that the second failure is fixed, which means that OS-X returns a funny event (and not POLLIN/POLLHUP/POLLERR) in case of ECONNREFUSED :-( 2 - In EventLoopTestsMixin::test_writer_callback if the writer socket isn't non-blocking, the test hangs forever.. This test is buggy: def test_writer_callback(self): el = events.get_event_loop() r, w = unix_events.socketpair() el.add_writer(w.fileno(), w.send, b'x'*100) el.call_later(0.1, el.remove_writer, w.fileno()) el.run() w.close() Because the writer socket isn't non-blocking, if the output socket buffer fills up in less than 0.1 seconds, the call to w.send(b'x'*100) will block. select()/poll()/kqueue() use a watermark to decide whether the FD is readable/writable: for a Unix domain socket, I guess OS-X returns that the socket is writable is there's at least one byte free in the output socket buffer: since send() tries to write 100 bytes at once, it blocks. I can reproduce the hang on Linux with vanilla (unpatched) tulip by increasing the number of bytes sent() in one syscall: --- tulip-bf4cb136c121/tulip/events_test.py 2092-08-05 00:00:00.0 +0200 +++ tulip/tulip/events_test.py 2013-01-08 11:35:27.400198000 +0100 @@ -149,7 +149,7 @@ def test_writer_callback(self): el = events.get_event_loop() r, w = unix_events.socketpair() -el.add_writer(w.fileno(), w.send, b'x'*100) +el.add_writer(w.fileno(), w.send, b'x'*(118)) el.call_later(0.1, el.remove_writer, w.fileno()) el.run() w.close() (I have to do that because Linux uses an adaptive watermark, see http://lxr.free-electrons.com/source/net/unix/af_unix.c#L2156 and http://lxr.free-electrons.com/source/net/unix/af_unix.c#L319 ). That's why all FDs monitored with select()/poll()/epoll() must be non-blocking (and there's also the risk of spurious wakeups...). 3 - Errors: ERROR: testCreateSslTransport (tulip.events_test.PollEventLoopTests) File /Users/felipecruz/Projects/tulip3/tulip/selectors.py, line 180, in _key_from_fd raise RuntimeError(No key found for fd {}.format(fd)) RuntimeError: No key found for fd -2 ERROR: test_sock_client_ops (tulip.events_test.KqueueEventLoopTests) File /Users/felipecruz/Projects/tulip3/tulip/selectors.py, line 180, in _key_from_fd raise RuntimeError(No key found for fd {}.format(fd)) RuntimeError: No key found for fd 77 Yes, it's the same problem: poll()/kqueue() returning garbage. I guess I'll have to patch Selector to ignore unknown FDs, but that really looks like an OS-X bug. Could you dump the content of the returned kevent when the fd is not found? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16853 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16890] minidom error
Ezio Melotti added the comment: It happens with lists too: l = list(range(10)) for x in l: ... l.remove(x) ... l [1, 3, 5, 7, 9] -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16890 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16889] facilitate log output starting at beginning of line
Vinay Sajip added the comment: I agree this is a reasonable expectation, but I've not encountered this problem before. Can you provide a short script demonstrating the problem? Which platform did you encounter these problems on, and what was the logging configuration? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16889 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16890] minidom error
Javier Domingo added the comment: Ok, sorry then. Javier Domingo 2013/1/8 Ezio Melotti rep...@bugs.python.org Ezio Melotti added the comment: It happens with lists too: l = list(range(10)) for x in l: ... l.remove(x) ... l [1, 3, 5, 7, 9] -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16890 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16890 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16884] logging handler automatically added starting in 3.2+
Roundup Robot added the comment: New changeset 51138680b968 by Vinay Sajip in branch '2.7': Issue #16884: Updated docs to use 'note' directives. http://hg.python.org/cpython/rev/51138680b968 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16884 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16884] logging handler automatically added starting in 3.2+
Roundup Robot added the comment: New changeset 50af862d0625 by Vinay Sajip in branch '3.2': Issue #16884: Updated docs to use 'note' directives in a couple of places missed earlier. http://hg.python.org/cpython/rev/50af862d0625 New changeset b00c4a095b00 by Vinay Sajip in branch '3.3': Issue #16884: Merged doc fix from 3.2. http://hg.python.org/cpython/rev/b00c4a095b00 New changeset 4617b7ac302a by Vinay Sajip in branch 'default': Issue #16884: Merged doc fix from 3.3. http://hg.python.org/cpython/rev/4617b7ac302a -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16884 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16889] facilitate log output starting at beginning of line
Chris Jerdonek added the comment: This can happen with any standard logging configuration when there are writes to sys.stderr that don't end with \n. I'm using Mac OS X 10.7. A minimal script: import logging, unittest log = logging.getLogger() class Test(unittest.TestCase): def setUp(self): log.info(setting up) def test1(self): pass def test2(self): pass logging.basicConfig(level=logging.INFO) unittest.main() Output: INFO:root:setting up .INFO:root:setting up . -- Ran 2 tests in 0.001s -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16889 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16884] logging handler automatically added starting in 3.2+
Chris Jerdonek added the comment: Thanks! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16884 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16871] Cleanup a few minor things
Giampaolo Rodola' added the comment: Ok for asyncore/asynchat in 3.4 branch. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16871 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16889] facilitate log output starting at beginning of line
Ezio Melotti added the comment: Note that for this specific problem you could call unittest.main(verbosity=0). -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16889 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15442] Expand the list of default dirs filecmp.dircmp ignores
Éric Araujo added the comment: Should __pycache__ be ignored too? Sounds good. I don't know how to compile python without having to install it See the devguide http://docs.python.org/devguide -- stage: needs patch - test needed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15442 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16889] facilitate log output starting at beginning of line
Vinay Sajip added the comment: Oh, I see what you mean now. I guess the approach you used is straightforward, and perhaps something could be added to test.support. It's only an aesthetic thing, though, IIUC. I normally don't run into this because I log to file when running unit tests, or run with -v so that the runner prints complete lines rather than just dots. And if you need to test that logging is happening, you can use the TestHandler and Matcher classes in test.support. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16889 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16889] facilitate log output starting at beginning of line
Chris Jerdonek added the comment: Ezio, the use case is to add to the existing test output additional diagnostic logging. In particular, you might want to run tests even with verbosity=2 in addition to the log messages. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16889 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16889] facilitate log output starting at beginning of line
Chris Jerdonek added the comment: Yes, it's primarily for easier scanning/reading as well as aesthetic. With -v I get the following output though: test1 (test_logging.Test) ... INFO:root:setting up ok test2 (test_logging.Test) ... INFO:root:setting up ok -- Ran 2 tests in 0.000s At least it's good to know that I wasn't missing anything obvious. And yes, I did read about TestHandler/Matcher (for making assertions about logging) from the following informative thread a couple years ago (which I came across when filing issue 16884): http://mail.python.org/pipermail/python-dev/2010-December/106526.html -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16889 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13198] Remove duplicate definition of write_record_file
Éric Araujo added the comment: Please don’t; distutils2 still exists and is mutating into one or more projects where these bug reports will be useful. If it bothers Python core devs to have the bugs in this tracker, they will be migrated, but for the moment please leave them open so they can be found. -- resolution: out of date - stage: - patch review status: closed - open versions: -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13198 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12944] Accept arbitrary files for packaging's upload command
Éric Araujo added the comment: distutils2, while not actively developed any more for inclusion in the stdlib in 3.4, will mutate into one or more projects where these bug reports will be useful. Bugs will certainly be migrated (and closed in this tracker), but please keep them open for easy query. -- resolution: out of date - status: closed - open versions: -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12944 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16889] facilitate log output starting at beginning of line
Chris Jerdonek added the comment: and perhaps something could be added to test.support. Also, just to clarify, I had in mind outside projects and the larger community for this request rather than CPython development, so I'm not sure test.support would be the right location. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16889 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16842] Allow to override a function signature for pydoc with a docstring
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16842 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16805] when building docs on Debian 7 -- ERROR: Error in note directive
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16805 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14470] Remove using of w9xopen in subprocess module
Éric Araujo added the comment: FTR, was the deprecation for 3.3 committed? -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14470 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16814] use --directory option of make in describing how to build the docs
Éric Araujo added the comment: FWIW I use make -C Doc all the time but agree with Georg’s point about conciseness. Ezio, I suggest you bookmark some make doc page if you can’t remember it :) -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16814 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16851] ismethod and isfunction methods error
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16851 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16851] Hint about correct ismethod and isfunction usage
Changes by Éric Araujo mer...@netwok.org: -- title: ismethod and isfunction methods error - Hint about correct ismethod and isfunction usage ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16851 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16891] Fix docs about module search order
Changes by Éric Araujo mer...@netwok.org: -- nosy: +brett.cannon, ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16891 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16748] Make CPython test package discoverable
R. David Murray added the comment: Yes, but not many, and not as many as there used to be. I'd like to see them all moved, but met resistance on that front. It may be that those just can't be run using unittest discovery, and perhaps that will eventually convince the maintainers to move them. But probably not until a number of years from now :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16748 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5066] IDLE documentation for Unix obsolete/incorrect
Éric Araujo added the comment: Idle needs to find its text help files at runtime, so they are installed as data alongside with the code. The rst doc files however can be installed anywhere or not installed at all, so we can’t change Idle to look for them. An alternate idea to avoid duplication could be to copy the rst file to the code directory at build time. -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5066 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16748] Make CPython test package discoverable
R. David Murray added the comment: Also, it may be possible to add unittest discovery hooks to the stubs that *are* in Lib/test. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16748 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16851] Hint about correct ismethod and isfunction usage
Changes by Federico Reghenzani federico@reghe.net: -- nosy: +federico.reghenzani ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16851 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16886] Doctests in test_dictcomp depend on dict order
Éric Araujo added the comment: Yes, we definitely want to eat our dogfood and stop relying on dict order, especially now that hashing is randomized. I would argue for backporting this to stable branches. Patch looks good. A semi-related improvement for this bug would be to switch these doctests to proper unit tests. -- keywords: +easy nosy: +eric.araujo stage: - patch review versions: +Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16886 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16836] configure script disables support for IPv6 on a system where IPv6 is disabled
Martin v. Löwis added the comment: LGTM. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16836 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16892] Windows bug picking up stdin from a pipe
New submission from Robert Oeffner: Hi, This is a bug that seems to exist on python 2.7, python 3.3 on Windows versions XP, Vista, 7 and 8 and has been around for some years, presumably also in other python versions. It is only recently I have managed to better isolate it although not completely. My Windows PC is set up with some doskey macros that are loaded at each instance of the commandline interpreter cmd.exe with the registry key HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun\mymacros.cmd Unfortunately this seems to delete stdin when stdin is piped to python scripts that runs another executable invoked with subprocess. In this case the command: python32 testsubproc.py mytextfile.txt will not work. The textfile mytextfile.txt will be ignored. If subprocess is invoked with shell=False the textfile does get piped into stdin. This is however not an option as our porgrams are distributed on other platforms. It would also give an inconsistent experience on the same OS (Windows). If mymacros.cmd is called interactively from the command prompt the problem does not exist and stdin can be piped into the python script with no problem. I have attached a working script below which includes a comment section with a small C++ program and the registry key in question to demonstrate the problem. I would be grateful if there are people who know how to get to the bottom of this bug or even fix it. Many thanks, Robert -- components: Build, Windows files: testsubproc.py messages: 179352 nosy: oeffner priority: normal severity: normal status: open title: Windows bug picking up stdin from a pipe type: behavior versions: Python 2.6, Python 2.7, Python 3.3 Added file: http://bugs.python.org/file28631/testsubproc.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16892 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16891] Fix docs about module search order
Dmitry Mugtasimov added the comment: As I investigate it a little closer it seems to me that it is not a documentation issue, but an implementation issue. http://docs.python.org/2/reference/simple_stmts.html#import A package can contain other packages and modules while modules cannot contain other modules or packages. The only why to import name from module is from xyz import b where b is name defined inside xyz module. Issuing import xyz.b means that b is module or package. Therefore xyz cannot be a module, since ...modules cannot contain other modules or packages. This means that xyz is package. The problem is that it is considered as module for case: python t.py -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16891 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16076] xml.etree.ElementTree.Element and xml.etree.ElementTree.TreeBuilder are no longer pickleable
Eli Bendersky added the comment: Daniel, thanks for this patch, it looks very good. I had some comments in the code review. As for TreeBuilder, let's split it into a separate issue - I think it's much less critical. We can discuss it later once we're done with Element. If anything, it's more important to handle ElementTree itself first - it should be very easy (much simpler than Element). With the factory method I'm not sure how the Py pickling happens. I need to dig a bit in pickling for that, because I don't know how method reference pickling works. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16076 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16891] Fix docs about module search order
R. David Murray added the comment: So it looks like if import xyz.b bahaves different depending on how a.py was initially loaded as a script or imported from another module. There are several differences between importing a module and running a script, one of which is what is on sys.path. You constructed your example to mask the path difference. You are getting hit by the difference between absolute and relative imports. How implicit relative imports behave are one of the other things that are different between running a file as a script and importing it. This kind of confusion is one of the reasons implicit relative imports were dropped in Python3. If you add from __future__ import absolute_import to the top of your a and t files, t will no longer produce an import error. It could be that the documentation could be improved, but I'm not sure it is worth the effort for 2.7. If there are statements in the 3.x docs that are incorrect now that implicit relative imports are gone, those would definitely be worth fixing. -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16891 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com