Announce: Windows version of LDTP - GUI test automation tool
Hello, I'm excited to announce Windows version of Linux Desktop Testing Porject (WinLDTP) !!! Special thanks: VMware Inc permitting me to open source my work VMware Desktop Engineering QE team to test it extensively David Connet dcon...@vmware.com for creating the WinLDTP installer Existing LDTP API's are compatible with WinLDTP, if there is any mismatch then we have to fix it ;-) About LDTP: Linux Desktop Testing Project is aimed at producing high quality test automation framework (using GNOME / Python) and cutting-edge tools that can be used to test Linux Desktop and improve it. It uses the Accessibility libraries to poke through the application's user interface. We strive to help in building a quality desktop. Download source: https://github.com/ldtp/winldtp Download binary (Windows XP / Windows 7): http://download.freedesktop.org/ldtp/winldtp-latest/WinLDTP.msi System requirement: .NET 3.5, refer README.txt after installation Documentation references: For detailed information on LDTP framework and latest updates visit http://ldtp.freedesktop.org For information on various APIs in LDTP including those added for this release can be got from http://ldtp.freedesktop.org/user-doc/index.html Report bugs - http://ldtp.freedesktop.org/wiki/Bugs To subscribe to LDTP mailing lists, visit http://ldtp.freedesktop.org/wiki/Mailing_20list IRC Channel - #ldtp on irc.freenode.net Thanks Nagappan -- Linux Desktop (GUI Application) Testing Project - http://ldtp.freedesktop.org http://nagappanal.blogspot.com -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: A case for real multiline comments
On 19Apr2012 15:13, Chris Angelico ros...@gmail.com wrote: | On Thu, Apr 19, 2012 at 2:29 PM, Cameron Simpson c...@zip.com.au wrote: | On 18Apr2012 22:07, Jordan Perr jor...@jperr.com wrote: | | I came across this case while debugging some Python code that contained an | | error stemming from the use of multiline strings as comments. The code | | contained a very long list of objects, and I had commented out some of the | | objects using the multiline string. | | You are aware that a string is not a comment? | | They're often (ab)used as comments, since Python lacks a multiline | comment facility. Even docstrings are really comments in disguise. Bah! To get into a function's docstring they need to be parsed by the Python compiler. Ergo, not comments. Calling them comments in disguise is a bit of a stretch. | I'd just do this: | | list = [ | Object1(arg), | ## Object2(arg), | ## Object3(arg), | Object4(arg) | ] | | Multiple lines of single line comments. Frankly, I find this much easier | to see (all the disabled lines are delineated with nice bright comment | markers, and the beginning and end of the comment (were it a multiline | comment) can't disappear off my screen. | | I would say you've made a case _against_ multiline coments. | | On the contrary, he has definitely made a case for multiline comments. Sorry, he's made a misparsed program (not parsed as he intended) by using a string where he should have used a comment? And because of this he says we need (or should want) multiline comments? A multiline comment can just as easily be misused to similar effect: list = [ Object1(arg) /* bored now Object2(arg), Object3(arg), */ Object4(arg) ] I'd be more included to call implicit string concatenation a syntax flaw, for all that it makes breaking strings us pretty nice. | You just happen to disagree, and you prefer single line comments. :) With cited reasons. A multiline comment can have its top or bottom off the screen, so the reader need not know they're looking at commented out code. And the number of parse errors I've seen where the offending comment opener was WAY WAY back in the code because someone forgot or removed a closing comment marker is huge. | I like multiline comments, but they do have their associated problems, | most notably nesting. It gets quite awkward commenting out code that | searches for comment markers, too. | Perhaps what's needed is not a C-style /* */ comment marker, but | something which must always be on a line of its own, and can therefore | ONLY delimit entire-line comments. Something like what's often done | with a preprocessor #if 0 #endif pair. Which are also something of a pain to match up, leading to (hopefully correctly labelled) #endifs thus: #endif /* !FEATUREMACRO */ I realise I could paint myself into opposing all multiline constructs, especially loops and ifs, but I am generally quite happy with single line comments. For one thing, they pretty much force you to mark all the lines with leading comment syntax; you can't ever be misled. | There's no way you can lose | the #endif at the end of a line, True. Cheers, -- Cameron Simpson c...@zip.com.au DoD#743 http://www.cskk.ezoshosting.com/cs/ It's better, when you're racing with someone you don't know so well, to stick to the inside line - it's easier to avoid the bits. - Barry Sheene, bike GP commentator -- http://mail.python.org/mailman/listinfo/python-list
Regular expressions, help?
Hi, So I am trying to get the number of casualties in a text. After 'death toll' in the text the number I need is presented as you can see from the variable called text. Here is my code I'm pretty sure my regex is correct, I think it's the group part that's the problem. I am using nltk by python. Group grabs the string in parenthesis and stores it in deadnum and I make deadnum into a list. text=accounts put the death toll at 637 and those missing at 653 , but the total number is likely to be much bigger dead=re.match(r.*death toll.*(\d[,\d\.]*), text) deadnum=dead.group(1) deaths.append(deadnum) print deaths Any help would be appreciated, Thank you, Sania -- http://mail.python.org/mailman/listinfo/python-list
Re: how do i merge two sequence
hi, On Wed, Apr 18, 2012 at 10:41:00PM +0200, Peter Otten wrote: Python Email wrote: how do i merge two seqs alernative; (xyz, 7890) output: x7y8z90 import itertools .join(a+b for a, b in itertools.izip_longest(xyz, 7890, fillvalue=)) 'x7y8z90' why is this better than simple .join((xyz, 7890))? thanks: a. -- I � UTF-8 -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular expressions, help?
Sania wrote: Hi, So I am trying to get the number of casualties in a text. After 'death toll' in the text the number I need is presented as you can see from the variable called text. Here is my code I'm pretty sure my regex is correct, I think it's the group part that's the problem. No. A regex like .*(\d+) is greedy, the .* matches as much as possible: re.match(.*(\d+), alpha 123 beta 456 gamma).group(1) '6' You want to find the first number and need the non-greedy form .*? re.match(.*?(\d+), alpha 123 beta 456 gamma).group(1) '123' I am using nltk by python. Group grabs the string in parenthesis and stores it in deadnum and I make deadnum into a list. text=accounts put the death toll at 637 and those missing at 653 , but the total number is likely to be much bigger dead=re.match(r.*death toll.*(\d[,\d\.]*), text) deadnum=dead.group(1) deaths.append(deadnum) print deaths Any help would be appreciated, Thank you, Sania -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular expressions, help?
Sania wrote: So I am trying to get the number of casualties in a text. After 'death toll' in the text the number I need is presented as you can see from the variable called text. Here is my code I'm pretty sure my regex is correct, I think it's the group part that's the problem. No. A regex like .*(\d+) is greedy, the .* matches as much as possible: re.match(.*(\d+), alpha 123 beta 456 gamma).group(1) '6' You want to find the first number and need the non-greedy form .*? re.match(.*?(\d+), alpha 123 beta 456 gamma).group(1) '123' I am using nltk by python. Group grabs the string in parenthesis and stores it in deadnum and I make deadnum into a list. text=accounts put the death toll at 637 and those missing at 653 , but the total number is likely to be much bigger dead=re.match(r.*death toll.*(\d[,\d\.]*), text) deadnum=dead.group(1) deaths.append(deadnum) print deaths -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular expressions, help?
On 18Apr2012 23:11, Sania fantasyblu...@gmail.com wrote: | So I am trying to get the number of casualties in a text. After 'death | toll' in the text the number I need is presented as you can see from | the variable called text. Here is my code | I'm pretty sure my regex is correct, I think it's the group part | that's the problem. | I am using nltk by python. Group grabs the string in parenthesis and | stores it in deadnum and I make deadnum into a list. | | text=accounts put the death toll at 637 and those missing at | 653 , but the total number is likely to be much bigger I presume you want the 637 and not the 653. | dead=re.match(r.*death toll.*(\d[,\d\.]*), text) I always feel a little uncomfortable about double quotes and backslashes (for all that the above is a raw string). Too much shell and C programming perhaps. Anyway... I would break this up like this: re_DEATH_TOLL = r.*death toll.*(\d[,\d\.]*) print sys.stderr, re_DEATH_TOLL =, re_DEATH_TOLL dead=re.match(re_DEATH_TOLL, text) so I can print the raw text of the regexp _after_ python has parsed the string. Secondly, your regexp will match the wrong number, based on my presumption above. Regexps are greedy and so your second .* will match as much as possible while still matching the rest of the regexp. ANd therefore if will match all the text before the 653, and grab the wrong number. Try (raw regexp): death toll\D*(\d+) or death toll\D*(\d[\d,.]*) and also use re.find instead of re.match; re.find will find the first match anywhere in the string, avoiding complicating the regexp with a leading .*. \D is a non-digit. + means one or more like * means zero or more. Cheers -- Cameron Simpson c...@zip.com.au DoD#743 http://www.cskk.ezoshosting.com/cs/ I'm not weird; I'm gifted. -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular expressions, help?
Sania writes: So I am trying to get the number of casualties in a text. After 'death toll' in the text the number I need is presented as you can see from the variable called text. Here is my code I'm pretty sure my regex is correct, I think it's the group part that's the problem. I am using nltk by python. Group grabs the string in parenthesis and stores it in deadnum and I make deadnum into a list. text=accounts put the death toll at 637 and those missing at 653 , but the total number is likely to be much bigger dead=re.match(r.*death toll.*(\d[,\d\.]*), text) deadnum=dead.group(1) deaths.append(deadnum) print deaths It's the regexp. The .* after death toll each the input as far as it can without making the whole match fail. The group matches only the last digit in the text. You could allow only non-digits before the number. Or you could look up the variant of * that only matches as much as it must. -- http://mail.python.org/mailman/listinfo/python-list
Re: how do i merge two sequence
Ervin Hegedüs wrote: On Wed, Apr 18, 2012 at 10:41:00PM +0200, Peter Otten wrote: Python Email wrote: how do i merge two seqs alernative; (xyz, 7890) output: x7y8z90 import itertools .join(a+b for a, b in itertools.izip_longest(xyz, 7890, fillvalue=)) 'x7y8z90' why is this better than simple .join((xyz, 7890))? Have a second look at the desired output. Your suggestion doesn't produce that. -- http://mail.python.org/mailman/listinfo/python-list
Re: A case for real multiline comments
On Thu, Apr 19, 2012 at 4:04 PM, Cameron Simpson c...@zip.com.au wrote: Bah! To get into a function's docstring they need to be parsed by the Python compiler. Ergo, not comments. Calling them comments in disguise is a bit of a stretch. They're fundamentally the same thing as Doxygen/Javadoc/etc comments. The interpreter could easily have been written to take the contents of a comment immediately preceding a function definition and store it as an attribute. It's not fundamentally a literal string, because there's nowhere for it to go. It's a special feature of the parser that takes a pile of text and stores it somewhere for self-documentation purposes. Sorry, he's made a misparsed program (not parsed as he intended) by using a string where he should have used a comment? And because of this he says we need (or should want) multiline comments? Since Python doesn't have multiline comments, triple-quoted strings are sometimes pressed into service. In this particular instance, a triple-quoted string *cannot* be used. Ergo, he is making the case that Python needs multiline comments. It makes perfectly good sense. You can disagree with it, but you can't scoff at his logic. A multiline comment can just as easily be misused to similar effect: list = [ Object1(arg) /* bored now Object2(arg), Object3(arg), */ Object4(arg) ] Heh, you can do far worse with slash-star comments. list = [ Object1(arg), Object2(arg), /* Object3(arg), * Important comment Object4(arg), */ Object5(arg), ] Oops, just how many objects are in that list? I'd be more included to call implicit string concatenation a syntax flaw, for all that it makes breaking strings us pretty nice. | You just happen to disagree, and you prefer single line comments. :) With cited reasons. Yes, so let's have a sane discussion :) I do see your reasons, and there's no perfect solution. A multiline comment can have its top or bottom off the screen, so the reader need not know they're looking at commented out code. And the number of parse errors I've seen where the offending comment opener was WAY WAY back in the code because someone forgot or removed a closing comment marker is huge. Yep. That's a pretty tricky one to find, if your editor doesn't color-code comments. It's also tricky to handle when your editor is buggy. As mentioned, I use SciTE; a while back, there was an odd little bug in it with regard to a combination of #if and /* and #endif and */ in some order, and the parser did get confused. (The author is pretty good at dealing with reported bugs, though. It didn't take long from report to patch.) But in the normal case, where you're using a decent editor that knows what's commented and what's not? It's pretty easy to figure out what's going on. And if someone mucked up comment markers in an edit, source control should help you pin the error down. | ... preprocessor #if 0 #endif pair. Which are also something of a pain to match up, leading to (hopefully correctly labelled) #endifs thus: #endif /* !FEATUREMACRO */ Well, I was thinking of having *only* the #if 0 construct, nothing else, so there's no need to worry about matching them up. I realise I could paint myself into opposing all multiline constructs, especially loops and ifs, but I am generally quite happy with single line comments. For one thing, they pretty much force you to mark all the lines with leading comment syntax; you can't ever be misled. Yes, that is true. It's tedious, though, when you want to quickly remove a dozen lines of code; most editors that allow you to block-comment code have only one way of doing it, and if that way doesn't suit your personal style, it grates. I'd still rather have a proper multiline comment. So, here's a proposal. (Maybe I should take this part to another list or the Python issue tracker.) Introduce a new keyword or reuse existing keywords to form a marker that unambiguously says Ignore these lines and then subsequently Stop ignoring lines. These markers must go on their own lines, optionally with whitespace and/or a one-line comment, but nothing else. This could accidentally terminate or nest if a triple-quoted string contains Python code, but that would always be an issue. Option 1: New keyword. comment def ... parser completely ignores these lines ... comment break Option 2: Reuse keywords. from None import ... ignore these lines ... from True import The exact choice of keywords is open to discussion, I just looked at keyword.kwlist on my Python 3.2 and tried to come up with something. This syntax looks like it wouldn't nest, so it's unideal for the proposal. Does Python need multi-line code removal? And if so, will something like this work? Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: md5 check
import hashlib f=open('c:\gpg4win-2.1.0.exe','rb') print hashlib.md5(f.read()).hexdigest() ad6245f3238922bb7afdc4a6d3402a65 print hashlib.sha1(f.read()).hexdigest() da39a3ee5e6b4b0d3255bfef95601890afd80709 i get it with md5,why the sha1 is wrong? the sha1 right is f619313cb42241d6837d20d24a814b81a1fe7f6d 2012/4/19 Jason Friedman ja...@powerpull.net i have download file (gpg4win-2.1.0.exe from http://www.gpg4win.org/download.html) when i run : Type help, copyright, credits or license for import md5 f=open('c:\gpg4win-2.1.0.exe','r') print md5.new(f.read()).hexdigest() 'd41d8cd98f00b204e9800998ecf8427e' it is not = f619313cb42241d6837d20d24a814b81a1fe7f6d gpg4win-2.1.0.exe please see :gpg4win-2.1.0.exe from http://www.gpg4win.org/download.html Are you wanting md5 or sha1? http://www.bresink.de/osx/sha1.html http://www.gpg4win.org/download.html -- http://mail.python.org/mailman/listinfo/python-list
Re: md5 check
contro opinion wrote: import hashlib f=open('c:\gpg4win-2.1.0.exe','rb') print hashlib.md5(f.read()).hexdigest() ad6245f3238922bb7afdc4a6d3402a65 print hashlib.sha1(f.read()).hexdigest() da39a3ee5e6b4b0d3255bfef95601890afd80709 i get it with md5,why the sha1 is wrong? You get the checksum for the empty string which is what f.read() returns on the second time. Try data = open('c:\gpg4win-2.1.0.exe','rb').read() print hashlib.md5(data).hexdigest() print hashlib.sha1(data).hexdigest() the sha1 right is f619313cb42241d6837d20d24a814b81a1fe7f6d I'm sure you can solve simple problems like the above yourself; please spend a few more minutes on finding the cause before you post here. -- http://mail.python.org/mailman/listinfo/python-list
Re: md5 check
On Thu, Apr 19, 2012 at 5:46 PM, contro opinion contropin...@gmail.com wrote: import hashlib f=open('c:\gpg4win-2.1.0.exe','rb') print hashlib.md5(f.read()).hexdigest() ad6245f3238922bb7afdc4a6d3402a65 print hashlib.sha1(f.read()).hexdigest() da39a3ee5e6b4b0d3255bfef95601890afd80709 i get it with md5,why the sha1 is wrong? the sha1 right is f619313cb42241d6837d20d24a814b81a1fe7f6d After you read from the file, you can't read that content again without rewinding it. What you got there is this: hashlib.sha1(b'').hexdigest() 'da39a3ee5e6b4b0d3255bfef95601890afd80709' Try again, but without getting the md5 first. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: how do i merge two sequence
Hello, On Thu, Apr 19, 2012 at 08:54:28AM +0200, Peter Otten wrote: Have a second look at the desired output. Your suggestion doesn't produce that. oh', I'm really sorry, I was distracted... thanks: a. -- I � UTF-8 -- http://mail.python.org/mailman/listinfo/python-list
Re: Whither paramiko?
On Apr 16, 1:42 am, Bryan bryanjugglercryptograp...@yahoo.com wrote: Paramiko is a Python library for SSH (Secure Shell). Over about the last year, I've grown dependent upon it. Its home page is still easy to search up, but the links to its mailing list and repository don't work. Paramiko depends on PyCrypto, and not so long ago that dependency was the stated reason why paramiko did not yet play with Python 3. Even more recently, PyCrypto has gone green on the Python 3 Wall of Shame. Anyone know recent news on the status of paramiko? You may have already tried this but on the web page ( http://www.lag.net/jaramiko/ )for Jaramiko, the Java port of Paramiko, there's an email address for the author - maybe you could try that ? The email address quoted is : robey at lag.net . What's a bit odd is that, as you mentioned, the repository is mentioned as being at : http://github.com/robey/paramiko/ but comes up 404. However the user robey (robeypointer at gmail.com) is still on GitHub (and has been there since 2008) but there's no mention of anything related to Paramiko on his page. If you do find anything maybe you could update this thread as I'm just about to start using the library and I'd like to know a little more about where it might be going in future. regards Richard. -- http://mail.python.org/mailman/listinfo/python-list
Re: Whither paramiko?
On Apr 19, 8:28 pm, Richard Shea shearich...@gmail.com wrote: On Apr 16, 1:42 am, Bryan bryanjugglercryptograp...@yahoo.com wrote: Paramiko is a Python library for SSH (Secure Shell). Over about the last year, I've grown dependent upon it. Its home page is still easy to search up, but the links to its mailing list and repository don't work. Paramiko depends on PyCrypto, and not so long ago that dependency was the stated reason why paramiko did not yet play with Python 3. Even more recently, PyCrypto has gone green on the Python 3 Wall of Shame. Anyone know recent news on the status of paramiko? You may have already tried this but on the web page (http://www.lag.net/jaramiko/ )for Jaramiko, the Java port of Paramiko, there's an email address for the author - maybe you could try that ? The email address quoted is : robey at lag.net . What's a bit odd is that, as you mentioned, the repository is mentioned as being at :http://github.com/robey/paramiko/but comes up 404. However the user robey (robeypointer at gmail.com) is still on GitHub (and has been there since 2008) but there's no mention of anything related to Paramiko on his page. If you do find anything maybe you could update this thread as I'm just about to start using the library and I'd like to know a little more about where it might be going in future. regards Richard. Just another data point . I've just taken a look at the bundled documention of the 1.7.7.1 release and in there the robeypointer @ gmail.com is cited as being the contact point for the developer . regards Richard. -- http://mail.python.org/mailman/listinfo/python-list
Re: A case for real multiline comments
I think docstrings should look like strings, because they're essentially data: they end up as the __doc__ attribute of whatever class or function they're documenting. Conversely, they shouldn't be used as multi-line comments that aren't data (in the middle of functions) - the parser should disallow strings as stand-alone expressions after the initial docstring. This wouldn't solve Jordan's problem outright, since his string was inside a list, but it may prevent people from making that mistake in the future, since docstrings would have a purpose more specialized than multi-line comment. comment def ... parser completely ignores these lines ... comment break I believe the more Pythonic syntax would be: comment: ...some ...indented ...lines God help us if that ever happens. Alek On Thu, Apr 19, 2012 at 1:56 AM, Chris Angelico ros...@gmail.com wrote: On Thu, Apr 19, 2012 at 4:04 PM, Cameron Simpson c...@zip.com.au wrote: Bah! To get into a function's docstring they need to be parsed by the Python compiler. Ergo, not comments. Calling them comments in disguise is a bit of a stretch. They're fundamentally the same thing as Doxygen/Javadoc/etc comments. The interpreter could easily have been written to take the contents of a comment immediately preceding a function definition and store it as an attribute. It's not fundamentally a literal string, because there's nowhere for it to go. It's a special feature of the parser that takes a pile of text and stores it somewhere for self-documentation purposes. Sorry, he's made a misparsed program (not parsed as he intended) by using a string where he should have used a comment? And because of this he says we need (or should want) multiline comments? Since Python doesn't have multiline comments, triple-quoted strings are sometimes pressed into service. In this particular instance, a triple-quoted string *cannot* be used. Ergo, he is making the case that Python needs multiline comments. It makes perfectly good sense. You can disagree with it, but you can't scoff at his logic. A multiline comment can just as easily be misused to similar effect: list = [ Object1(arg) /* bored now Object2(arg), Object3(arg), */ Object4(arg) ] Heh, you can do far worse with slash-star comments. list = [ Object1(arg), Object2(arg), /* Object3(arg), * Important comment Object4(arg), */ Object5(arg), ] Oops, just how many objects are in that list? I'd be more included to call implicit string concatenation a syntax flaw, for all that it makes breaking strings us pretty nice. | You just happen to disagree, and you prefer single line comments. :) With cited reasons. Yes, so let's have a sane discussion :) I do see your reasons, and there's no perfect solution. A multiline comment can have its top or bottom off the screen, so the reader need not know they're looking at commented out code. And the number of parse errors I've seen where the offending comment opener was WAY WAY back in the code because someone forgot or removed a closing comment marker is huge. Yep. That's a pretty tricky one to find, if your editor doesn't color-code comments. It's also tricky to handle when your editor is buggy. As mentioned, I use SciTE; a while back, there was an odd little bug in it with regard to a combination of #if and /* and #endif and */ in some order, and the parser did get confused. (The author is pretty good at dealing with reported bugs, though. It didn't take long from report to patch.) But in the normal case, where you're using a decent editor that knows what's commented and what's not? It's pretty easy to figure out what's going on. And if someone mucked up comment markers in an edit, source control should help you pin the error down. | ... preprocessor #if 0 #endif pair. Which are also something of a pain to match up, leading to (hopefully correctly labelled) #endifs thus: #endif /* !FEATUREMACRO */ Well, I was thinking of having *only* the #if 0 construct, nothing else, so there's no need to worry about matching them up. I realise I could paint myself into opposing all multiline constructs, especially loops and ifs, but I am generally quite happy with single line comments. For one thing, they pretty much force you to mark all the lines with leading comment syntax; you can't ever be misled. Yes, that is true. It's tedious, though, when you want to quickly remove a dozen lines of code; most editors that allow you to block-comment code have only one way of doing it, and if that way doesn't suit your personal style, it grates. I'd still rather have a proper multiline comment. The exact choice of keywords is open to discussion, I just looked at keyword.kwlist on my Python 3.2 and tried to come up with something. This syntax looks like it wouldn't nest, so it's unideal for the proposal. Does Python need multi-line code removal? And
Re: A case for real multiline comments
Chris Angelico wrote: [snip] Since Python doesn't have multiline comments, triple-quoted strings are sometimes pressed into service. [snip] Chris Angelico Let the triple quotes where they're meant to be. Use your text editor, any decent one will allow you to comment uncomment a block of code. JM -- http://mail.python.org/mailman/listinfo/python-list
Re: A case for real multiline comments
On Thu, Apr 19, 2012 at 8:17 PM, Alek Storm alek.st...@gmail.com wrote: comment def ... parser completely ignores these lines ... comment break I believe the more Pythonic syntax would be: comment: ...some ...indented ...lines God help us if that ever happens. Certainly not. That completely ignores the whole point of this, which is to remove a block of lines without editing them all. Anyway, replace comment: with if 0: and you have it already. No, this is something that's parsed before indentation blocks are processed. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Framework for a beginner
On 4/19/2012 6:21, lkcl wrote: yeah, it does :) python is... the best word i can describe it is: it's beautiful. it has an elegance of expression that is only marred by the rather silly mistake of not taking map, filter and reduce into the list object itself: l.map(str) for example would be intuitive, compact and elegant. instead, i have to look up how to use map each and every damn time! the reason for the mistake is historical: map, filter and reduce were contributed by a lisp programmer. that lisp programmer, presumably, was used to everything being function(args...) and it simply didn't occur to anyone to properly integrate map, filter and reduce properly into the list objects that they work with. I don't think that map, filter and reduce are that useful in Python. List comprehensions are better. *shrugs* :) but that's literally the only thing about python that i could possibly complain about. everything else, it's just... beautiful. i think also that as a general rule, python programmers are just... more intelligent. either it does something to their brains, or... yeah :) There are many things I don't like about Python. The first flaw is the absence of anonymous code blocks, but I've already solved this problem. Unfortunately, the bug I found in Python will delay the release of my solution. I don't like the inability of using assignments inside of expressions. I don't like the fact that regexps are implemented as a library. Perl is much more readable and expressive in this regard. Operator overloading is too limited. I sometimes avoid classes because prefixing hundreds of identifiers with 'self.' makes the code uglier and much less readable. The absence of type inference makes it difficult to find many errors at writing-time. Dynamic typing is useful, but there are times when I know what type a variable is but the IDE won't help me because it doesn't know. I don't like when a community imposes style on a programmer. For instance, many told me that I shouldn't use camelCase and I should adhere to PEP8. Well, that's not me. I write my code the way I like it and if that is frowned upon by some standardizing community, so be it. I want to retain my freedom of expression. I'm also tired of hearing mottos such as TIMTOWTDI... oops, that's Perl. You say that Python programmers are smarter. I think that the greater part of them are too fond of their language. The problem is that they see Python as their language. When you know more than 30 languages you stop thinking that way and you also don't try to defend your language against infidels. Python is a very good language, but so is Ruby, Scala and many other languages. Denying that fact is deluding oneself. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list
Re: Framework for a beginner
On Wed, Apr 18, 2012 at 11:21 PM, lkcl luke.leigh...@gmail.com wrote: On Apr 11, 9:11 pm, biofob...@gmail.com wrote: I am new to python and only have read the Byte of Python ebook, but want to move to the web. I am tired of being a CMS tweaker and after I tried python, ruby and php, the python language makes more sense (if that makes any sense for the real programmers). yeah, it does :) python is... the best word i can describe it is: it's beautiful. it has an elegance of expression that is only marred by the rather silly mistake of not taking map, filter and reduce into the list object itself: l.map(str) for example would be intuitive, compact and elegant. instead, i have to look up how to use map each and every damn time! the reason for the mistake is historical: map, filter and reduce were contributed by a lisp programmer. that lisp programmer, presumably, was used to everything being function(args...) and it simply didn't occur to anyone to properly integrate map, filter and reduce properly into the list objects that they work with. Why not use list comprehension syntax? It gets you map and filter functionality for free, and is more readable than python's clunky version of lambdas. I believe they're faster than the for-loop equivalents, but I'm not sure about the actual map() and filter() functions (reduce() was removed from 3.0 for reasons I will never understand). Map: [val+1 for val in some_list] Filter: [val for val in some_list if val 0] Alek -- http://mail.python.org/mailman/listinfo/python-list
Re: Framework for a beginner
On Thu, Apr 19, 2012 at 9:14 PM, Kiuhnm kiuhnm03.4t.yahoo...@mail.python.org wrote: There are many things I don't like about Python. The first flaw is the absence of anonymous code blocks, but I've already solved this problem. You mean lambdas? Yeah, they're a lot more limited in Python than in some other languages. However, you can always define a local function and just use it. It may as well be anonymous since nobody else can use that name. I don't like the inability of using assignments inside of expressions. Yes, I'm fond of assignment-as-expression too. But it has its downsides, and by forbidding it, Python makes available a variety of syntax elements such as keyword arguments (rather than positional); it's a perfectly tenable design choice. I don't like the fact that regexps are implemented as a library. Perl is much more readable and expressive in this regard. Definitely not. As a library, it can be extended or even totally replaced without tampering with the language itself. Much more flexible. Yes, it may be a little more readable in Perl or Javascript - but ONLY if you consider regexps as the most important part of the language. They're not - they're only one thing that Python does. Why should they merit special syntax when there's none for, say, retrieving the contents of a document based on its URL? Operator overloading is too limited. I sometimes avoid classes because prefixing hundreds of identifiers with 'self.' makes the code uglier and much less readable. Stylistic choice. In the absence of variable declarations, everything has to be more explicit. Again, I would prefer declared variables, but the Python choice is quite viable. The absence of type inference makes it difficult to find many errors at writing-time. Dynamic typing is useful, but there are times when I know what type a variable is but the IDE won't help me because it doesn't know. Valid point. Again, design choice because there's no declaration of variables. I don't like when a community imposes style on a programmer. For instance, many told me that I shouldn't use camelCase and I should adhere to PEP8. Well, that's not me. I write my code the way I like it and if that is frowned upon by some standardizing community, so be it. I want to retain my freedom of expression. PEP 8 is by no means demanded. It's recommendations. I violate it all the time, especially as regards placement of whitespace :) You say that Python programmers are smarter. I think that the greater part of them are too fond of their language. The problem is that they see Python as their language. When you know more than 30 languages you stop thinking that way and you also don't try to defend your language against infidels. I know (many) more than thirty languages, and I still want to defend Python against turning into Perl, or turning into C, or turning into lisp. That's not because those are bad languages, but they are *not Python*. Python is a very good language, but so is Ruby, Scala and many other languages. Denying that fact is deluding oneself. Does anyone honestly deny that? I doubt it. Bye-bye, straw-man. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in Python
On 4/18/2012 3:08, Kiuhnm wrote: I'm using Python 3.2.2, 64 bit on Windows 7. Consider this code: --- print(1) print(2) print(3) with open('test') as f: data = f.read() with open('test') as f: data = f.read() --- If I debug this code with python -m pdb script.py and I issue the command j 7 Python crashes. I read that bug fix releases have a 6-month cycle :( It seems that I'll have to work around the problem... Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list
Re: Framework for a beginner
In article 4f8ff38c$0$1381$4fafb...@reader1.news.tin.it, Kiuhnm kiuhnm03.4t.yahoo.it wrote: I don't like when a community imposes style on a programmer. For instance, many told me that I shouldn't use camelCase and I should adhere to PEP8. Well, that's not me. I write my code the way I like it and if that is frowned upon by some standardizing community, so be it. I want to retain my freedom of expression. Freedom of expression is fine, until you have to work in a big group. The more everybody uses the same style, the easier it is for everybody to understand everybody else's code. There's another nice thing about PEP-8, or at least about the concept of an official global style. I've been in groups where a huge amount of time has been wasted arguing about style. In my current gig, when it came time to decide on a style, the conversation went something like one person suggesting we just use PEP-8 and everybody else nodding in agreement. In 2 minutes, we saved many person-months of arguing. -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular expressions, help?
On Apr 19, 2:48 am, Jussi Piitulainen jpiit...@ling.helsinki.fi wrote: Sania writes: So I am trying to get the number of casualties in a text. After 'death toll' in the text the number I need is presented as you can see from the variable called text. Here is my code I'm pretty sure my regex is correct, I think it's the group part that's the problem. I am using nltk by python. Group grabs the string in parenthesis and stores it in deadnum and I make deadnum into a list. text=accounts put the death toll at 637 and those missing at 653 , but the total number is likely to be much bigger dead=re.match(r.*death toll.*(\d[,\d\.]*), text) deadnum=dead.group(1) deaths.append(deadnum) print deaths It's the regexp. The .* after death toll each the input as far as it can without making the whole match fail. The group matches only the last digit in the text. You could allow only non-digits before the number. Or you could look up the variant of * that only matches as much as it must. Hey Thanks, So now my regex is dead=re.match(r.*death toll.{0,20}(\d[,\d\.]*), text) But I only find 7 not 657. How is it that the group is only matching the last digit? The whole thing is parenthesis not just the last part. ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Framework for a beginner
On Thu, Apr 19, 2012 at 12:20 PM, Alek Storm alek.st...@gmail.com wrote: On Wed, Apr 18, 2012 at 11:21 PM, lkcl luke.leigh...@gmail.com wrote: On Apr 11, 9:11 pm, biofob...@gmail.com wrote: I am new to python and only have read the Byte of Python ebook, but want to move to the web. I am tired of being a CMS tweaker and after I tried python, ruby and php, the python language makes more sense (if that makes any sense for the real programmers). yeah, it does :) python is... the best word i can describe it is: it's beautiful. it has an elegance of expression that is only marred by the rather silly mistake of not taking map, filter and reduce into the list object itself: l.map(str) for example would be intuitive, compact and elegant. instead, i have to look up how to use map each and every damn time! the reason for the mistake is historical: map, filter and reduce were contributed by a lisp programmer. that lisp programmer, presumably, was used to everything being function(args...) and it simply didn't occur to anyone to properly integrate map, filter and reduce properly into the list objects that they work with. Why not use list comprehension syntax? because it's less characters to type, and thus less characters to read. i find that syntax incredibly klunky. left to right you're reading, you declare something to be the case... and then oh whoops actually it's not really the case because it's modified by a list thing - it breaks reading expectations. that's what i meant about beauty and elegance. the bang per buck ratio in python, results obtained for the number of characters used, is higher, and that's something that i personally find to be a priority over speed. you don't *have* to use lambdas with map and reduce, you just have to use a function, where a lambda happens to be a nameless function. another example of the compactness of python is kicking around somewhere, i wish i could remember where it is. it compares scheme with python and java. scheme does this amazing programming thing in a single operator, expressed in 3 characters. python manages the same thing in about 10, and java requires *six* lines! It gets you map and filter functionality for free, and is more readable than python's clunky version of lambdas. I believe they're faster than the for-loop equivalents, but I'm not sure about the actual map() and filter() functions (reduce() was removed from 3.0 for reasons I will never understand). likewise. /salutes -- http://mail.python.org/mailman/listinfo/python-list
Re: A case for real multiline comments
On Thu, Apr 19, 2012 at 2:56 AM, Chris Angelico ros...@gmail.com wrote: So, here's a proposal. (Maybe I should take this part to another list or the Python issue tracker.) Introduce a new keyword or reuse existing keywords to form a marker that unambiguously says Ignore these lines and then subsequently Stop ignoring lines. These markers must go on their own lines, optionally with whitespace and/or a one-line comment, but nothing else. This could accidentally terminate or nest if a triple-quoted string contains Python code, but that would always be an issue. -8- The exact choice of keywords is open to discussion, I just looked at keyword.kwlist on my Python 3.2 and tried to come up with something. This syntax looks like it wouldn't nest, so it's unideal for the proposal. Does Python need multi-line code removal? And if so, will something like this work? Two questions: Why don't you allow nested multiline comments? Many languages (e.g. ML, Scheme, Haskell, etc.) allow you to nest multi-line comments. It's mostly the C family of languages that refuse to do this, AFAIK. Least importantly: Why are multiline comments line-oriented? Why not inline, like with the C-style /* ... */ comments? This doesn't seem like a proper multiline comment. -- Devin -- http://mail.python.org/mailman/listinfo/python-list
Re: Framework for a beginner
On Thu, Apr 19, 2012 at 7:12 AM, lkcl luke luke.leigh...@gmail.com wrote: On Thu, Apr 19, 2012 at 12:20 PM, Alek Storm alek.st...@gmail.com wrote: Why not use list comprehension syntax? because it's less characters to type, and thus less characters to read. i find that syntax incredibly klunky. left to right you're reading, you declare something to be the case... and then oh whoops actually it's not really the case because it's modified by a list thing - it breaks reading expectations. that's what i meant about beauty and elegance. the bang per buck ratio in python, results obtained for the number of characters used, is higher, and that's something that i personally find to be a priority over speed. Did I miss something? `[a+1 for a in some_list]` is shorter than both `map(lambda a: a+1, some_list)` and `some_list.map(lambda a: a+1)`. Alek -- http://mail.python.org/mailman/listinfo/python-list
Re: python kinterbasdb - check default charset of db or table
On Wednesday, April 18, 2012 9:08:59 PM UTC+8, miamia wrote: Hello, I am using python 2.7 and kinterbasdb. How could I find out default charset used by database? I need to check it and then according to used charset decode returned strings. thank you You could use a tool like flamerobin and look at the meta data to see which charset was used for the firebird database in question. You also want to look there: http://kinterbasdb.sourceforge.net/dist_docs/usage.html#adv_prog_maint_database_info Kinterbasdb will not be further developed and you might want to use the fdb driver for further python development. http://pypi.python.org/pypi/fdb/0.7.2 -- http://mail.python.org/mailman/listinfo/python-list
How do you refer to an iterator in docs?
Let's say I have a function which takes a list of words. I might write the docstring for it something like: def foo(words): Foo-ify words (which must be a list) What if I want words to be the more general case of something you can iterate over? How do people talk about that in docstrings? Do you say something which can be iterated over to yield words, an iterable over words, or what? I can think of lots of ways to describe the concept, but most of them seem rather verbose and awkward compared to a list of words, a dictionary whose keys are words, etc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Framework for a beginner
On 2012-04-19, Kiuhnm kiuhnm03.4t.yahoo.it wrote: I don't like when a community imposes style on a programmer. For instance, many told me that I shouldn't use camelCase and I should adhere to PEP8. Well, that's not me. I write my code the way I like it and if that is frowned upon by some standardizing community, so be it. I want to retain my freedom of expression. Choose a reasonable style, preferably ours, and stick with it. --Brian Kernighan and Bob Pike, The Practice of Programming On the other hand, if you're writing Python code that will comprise the standard library, then, Stick with it, means, Follow PEP8. Adopting PEP8 for all Python code (something PEP8 does not call for) supports the Python community by making your code more digestible to the general Python user. So when you receive that advice, it is not meant to make your code better, but to increase your code's fidelity within the Python community. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: A case for real multiline comments
On Thu, Apr 19, 2012 at 10:15 PM, Devin Jeanpierre jeanpierr...@gmail.com wrote: Why don't you allow nested multiline comments? Many languages (e.g. ML, Scheme, Haskell, etc.) allow you to nest multi-line comments. It's mostly the C family of languages that refuse to do this, AFAIK. Allowing nesting or not allowing nesting is a design choice. If you write code that looks for the string /* or */ in a REXX program, you need to be careful in case it mis-nests (the usual recommendation is to use /||* instead of /* as a single literal). It makes no difference which way you choose, there's always issues to deal with. Least importantly: Why are multiline comments line-oriented? Why not inline, like with the C-style /* ... */ comments? This doesn't seem like a proper multiline comment. That thought was to avoid the complaint that you can easily lose the comment markers somewhere other than clearly at the beginning of the line. By demanding that they delimit entire lines, we avoid this. Of course, Python could choose to support /* */ comments instead/as well. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in Python
On Thu, Apr 19, 2012 at 10:01 PM, Kiuhnm kiuhnm03.4t.yahoo...@mail.python.org wrote: I read that bug fix releases have a 6-month cycle :( It seems that I'll have to work around the problem... If a fix has been committed, the easiest thing to do is clone the Mercurial repository and build Python from source. Takes a little bit of work to set up, but gives you all the flexibility you need. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Gotcha's?
In article 4f7de152$0$29983$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Thu, 05 Apr 2012 08:32:10 -0400, Roy Smith wrote: In article 4f7d896f$0$29983$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: You mean JSON expects a string with valid JSON? Quelle surprise. No. The surprise is that there exists a tool invented in the 21st century that makes a distinction between strings quoted with and those quoted with '. Being used to a sensible language like Python, it boggled my brain the first time I tried to write some JSON and naturally treated the choice of quote mark as arbitrary. Your brain has a low boggle threshold. There's absolutely no reason why JSON should follow Python syntax rules. Except for the most important reason of all: Python's use of alternate string delimiters is an excellent design, one which Javascript itself follows. http://www.javascripter.net/faq/quotesin.htm I'm not the only one who has had trouble with JSON's poor design choice: http://stackoverflow.com/a/4612914 For a 21st century programming language or data format to accept only one type of quotation mark as string delimiter is rather like having a 21st century automobile with a hand crank to start the engine instead of an ignition. Even if there's a good reason for it (which I doubt), it's still surprising. Making it support either kind of quotes would have complicated every JSON library in the world, for no added value. Ooooh, such complication. I wish my software was that complicated. The added value includes: * semantic simplicity -- a string is a string, regardless of which quotes are used for delimiters; * reducing the number of escaped quotes needed; * compatibility with Javascript; * robustness. As it stands, JSON fails to live up to the Robustness principle and Postel's law: Be liberal in what you accept, and conservative in what you send. http://en.wikipedia.org/wiki/Robustness_principle Nobody should ever be hand-writing JSON So you say, but it is a fact that people do. And even if they don't hand- write it, people do *read* it, and allowing both quotation marks aids readability: \Help me Obiwan,\ she said, \You're my only hope!\ Blah. You can cut the number of escapes needed to one: 'Help me Obiwan, she said, You\'re my only hope!' I still think the doubling convention of Algol68 is superior: Help me Obiwan, she said, You're my only hope! No special treatment of any other symbol than the quote itself. A quoting symbol is such a devious syntactic element that I rather not have two ( ' ) or even three ( ' \ ) -- Steven Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert@spearc.xs4all.nl =n http://home.hccnet.nl/a.w.m.van.der.horst -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular expressions, help?
On Thu, Apr 19, 2012 at 10:02 PM, Sania fantasyblu...@gmail.com wrote: So now my regex is dead=re.match(r.*death toll.{0,20}(\d[,\d\.]*), text) But I only find 7 not 657. How is it that the group is only matching the last digit? The whole thing is parenthesis not just the last part. ? Your problem is still that the early part is greedy. Either switch to the non-greedy version or use something other than . such that it can't match what you don't want it to match - \D will serve here. (Both suggestions have been made already.) You don't need {0,20} that way. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you refer to an iterator in docs?
On Thu, Apr 19, 2012 at 10:21 PM, Roy Smith r...@panix.com wrote: def foo(words): Foo-ify words (which must be a list) What if I want words to be the more general case of something you can iterate over? How do people talk about that in docstrings? Do you say something which can be iterated over to yield words, an iterable over words, or what? Foo-ify an iterable yielding words or an iterable of words is what I'd use, others may have other preferences. Possibly even Foo-ify a series of words and have a few examples that make it clear that you mean a list/tuple/iterable. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Gotcha's?
On Thu, Apr 19, 2012 at 11:11 PM, Albert van der Horst alb...@spenarnc.xs4all.nl wrote: I still think the doubling convention of Algol68 is superior: Help me Obiwan, she said, You're my only hope! No special treatment of any other symbol than the quote itself. A quoting symbol is such a devious syntactic element that I rather not have two ( ' ) or even three ( ' \ ) Trouble with that is the forest of backslashes that you get with non-raw strings containing regular expressions that look for Windows paths. One backslash in the path becomes two in the regexp and four in the string. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Framework for a beginner
On Thu, Apr 19, 2012 at 1:21 PM, Alek Storm alek.st...@gmail.com wrote: On Thu, Apr 19, 2012 at 7:12 AM, lkcl luke luke.leigh...@gmail.com wrote: On Thu, Apr 19, 2012 at 12:20 PM, Alek Storm alek.st...@gmail.com wrote: Why not use list comprehension syntax? because it's less characters to type, and thus less characters to read. i find that syntax incredibly klunky. left to right you're reading, you declare something to be the case... and then oh whoops actually it's not really the case because it's modified by a list thing - it breaks reading expectations. that's what i meant about beauty and elegance. the bang per buck ratio in python, results obtained for the number of characters used, is higher, and that's something that i personally find to be a priority over speed. Did I miss something? `[a+1 for a in some_list]` is shorter than both `map(lambda a: a+1, some_list)` and `some_list.map(lambda a: a+1)`. :) yes you missed something. :) a) if you use that lambda a:a+1 a lot, you make it an actual function, don't you? even for clarity you'd still probably use a function not a lambda. i use map quite a lot, filter and reduce not so much. a more real-world example was one that i actually gave initially: map(str, l). or, the syntax i really prefer which doesn't exist: l.map(str). or, one that i also use in web applications or their back-ends: map(int, l). if you have a comma-separated set of variables in a single string, like this: 5, 20, 3, i tend to use this: from string import strip l = map(int, map(strip, l.split(,))) ok to make it clearer i sometimes do that on 3 separate lines. i'd _love_ it to be this: l = l.split(,).map(strip).map(int) or even better would be this: l = l.split(,).map(strip, int) b) read the text from left to right, in plain english: * map(str, l): you're going to map i.e. apply a string function to a list's members. (now you see why i keep getting confused with map, because the natural language version of this is map a list's members to a string - the other way round) * a+1 for a in l: take an expression which is a mathematical operation and therefore has the expectation that its arguments are mathematical in nature. then oh damn it wait a minute, actually there's more going on here: for every variable in a list, use the variables in the expression to make a new list... i'm belabouring the point (not entirely intentionally) but you see how clumsy that is? it's probably just as complex in the actual lexer/grammar file in the http://python.org source code itself, as it is to think about in real life and to psychologically parse in english. you actually have to think *backwards*! is that clearer, or have i added mud? :) l. -- http://mail.python.org/mailman/listinfo/python-list
Re: Framework for a beginner
On Thu, Apr 19, 2012 at 10:12 PM, lkcl luke luke.leigh...@gmail.com wrote: that's what i meant about beauty and elegance. the bang per buck ratio in python, results obtained for the number of characters used, is higher, and that's something that i personally find to be a priority over speed. Number of characters isn't the sole metric; number of thought units is closer - well-known keywords are usually one thought unit each, and sometimes larger tokens than that. But yes, concise syntax is of value. another example of the compactness of python is kicking around somewhere, i wish i could remember where it is. it compares scheme with python and java. scheme does this amazing programming thing in a single operator, expressed in 3 characters. python manages the same thing in about 10, and java requires *six* lines! Big deal. I could doubtless show you something in REXX that does in one line what will take quite a few lines in Python, and it'd probably involve the PARSE statement or possibly SysSetObjectData. Doesn't prove a thing. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular expressions, help?
Le 19/04/2012 14:02, Sania a écrit : On Apr 19, 2:48 am, Jussi Piitulainenjpiit...@ling.helsinki.fi [...] text=accounts put the death toll at 637 and those missing at 653 , but the total number is likely to be much bigger dead=re.match(r.*death toll.*(\d[,\d\.]*), text) deadnum=dead.group(1) deaths.append(deadnum) print deaths It's the regexp. The .* after death toll each the input as far as it can without making the whole match fail. The group matches only the last digit in the text. You could allow only non-digits before the number. Or you could look up the variant of * that only matches as much as it must. Hey Thanks, So now my regex is dead=re.match(r.*death toll.{0,20}(\d[,\d\.]*), text) Hi, But there, your regex matches : somethingdeath tollanything which length is =20 followed by what you capture (which is made up of a digit, at least) there are at least two issues here : - the number of characters between death toll and the figure may be 20 - your {0,20} is greedy = .{0,20} matches as many as . as it can AND one digit is matched by (\d[,\d\.]*), since your group captures a digit followed(OR NOT) by a digit, a comma, a dot = so at 63 is sucked by .{0,20} and (\d[,\d\.]*) matches the remaining digit 7 a solution would be to follow what Jussi suggested... = dead=re.match(r.*death toll\D*(\d*), text) But I only find 7 not 657. How is it that the group is only matching the last digit? = .{,20} greed The whole thing is parenthesis not just the last part. ? yeah but only one digit remains when your group matches... Good luck understanding regexes, it's a powerful tool ! :) best, azra. -- http://mail.python.org/mailman/listinfo/python-list
Re: Framework for a beginner
On Thu, Apr 19, 2012 at 10:56 PM, lkcl luke luke.leigh...@gmail.com wrote: i'm belabouring the point (not entirely intentionally) but you see how clumsy that is? it's probably just as complex in the actual lexer/grammar file in the http://python.org source code itself, as it is to think about in real life and to psychologically parse in english. you actually have to think *backwards*! is that clearer, or have i added mud? :) No, that's clear, and it is a very good point. There are several language constructs that feel backwards to me, and have a somewhat clunky feel as a consequence. Perl has the unless keyword, putting the code before the condition: die(Must use either foo or bar) unless $foo or $bar; Python has the ternary operator, putting the if-true value before the condition: foo = 5 if bar else 7 REXX has all variables global, unless you use PROCEDURE, in which case all variables are local except ones that you explicitly EXPOSE. functionname: procedure expose foo bar They're all design decisions that would now be roughly impossible to change. You simply accept that they exist, and code accordingly. *shrug* ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular expressions, help?
Sania writes: On Apr 19, 2:48 am, Jussi Piitulainen jpiit...@ling.helsinki.fi wrote: Sania writes: So I am trying to get the number of casualties in a text. After 'death toll' in the text the number I need is presented as you can see from the variable called text. Here is my code I'm pretty sure my regex is correct, I think it's the group part that's the problem. I am using nltk by python. Group grabs the string in parenthesis and stores it in deadnum and I make deadnum into a list. text=accounts put the death toll at 637 and those missing at 653 , but the total number is likely to be much bigger dead=re.match(r.*death toll.*(\d[,\d\.]*), text) deadnum=dead.group(1) deaths.append(deadnum) print deaths It's the regexp. The .* after death toll each the input as far as it can without making the whole match fail. The group matches only the last digit in the text. You could allow only non-digits before the number. Or you could look up the variant of * that only matches as much as it must. Hey Thanks, So now my regex is dead=re.match(r.*death toll.{0,20}(\d[,\d\.]*), text) But I only find 7 not 657. How is it that the group is only matching the last digit? The whole thing is parenthesis not just the last part. ? It's still consuming the digits among the text that comes _before_ the parenthesised group: the .{0,20} matches as _much_ as it _can_ without making the whole regex fail, and the . in it matches also digits. Try \D{0,20} to limit its matching ability to non-digits. Try \.{0,20}? to limit to it to matching as _little_ as it can. (The variant of * I referred to is *?; {} and {}? are similar.) The simplicity of regexen is deceptive. Be careful. Be surprised. http://docs.python.org/library/re.html. Keep them simple. Consider also other means instead or in addition. -- http://mail.python.org/mailman/listinfo/python-list
Request META Help
I have a system that uses request.META ['HTTP_HOST'] to identify which will run APPLICATION. The domains testes1.xyz.com.br, tes.xyzk.com.br, xx.xyzk.com.br through a DNS redirect TYPE A link to the server IP. In most cases I get the request.META ['HTTP_HOST'] with the URL in the request header, but today I had a problem that a customer made an appointment for me, and I get the IP of the server that information. Actually I need to get tes.xyzk.com.br Does anyone know better how it works? How can I overcome this? -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular expressions, help?
On Thursday, 19 April 2012 07:11:54 UTC+1, Sania wrote: Hi, So I am trying to get the number of casualties in a text. After 'death toll' in the text the number I need is presented as you can see from the variable called text. Here is my code I'm pretty sure my regex is correct, I think it's the group part that's the problem. I am using nltk by python. Group grabs the string in parenthesis and stores it in deadnum and I make deadnum into a list. text=accounts put the death toll at 637 and those missing at 653 , but the total number is likely to be much bigger dead=re.match(r.*death toll.*(\d[,\d\.]*), text) deadnum=dead.group(1) deaths.append(deadnum) print deaths Any help would be appreciated, Thank you, Sania Or just don't fully rely on a regex. I would, for time, and the little sanity I believe I have left, would just do something like: death_toll = re.search(r'death toll.*\d+', text).group().rsplit(' ', 1)[1] hth, Jon. -- http://mail.python.org/mailman/listinfo/python-list
Re: Framework for a beginner
On 4/19/2012 14:02, Roy Smith wrote: In article4f8ff38c$0$1381$4fafb...@reader1.news.tin.it, Kiuhnmkiuhnm03.4t.yahoo.it wrote: I don't like when a community imposes style on a programmer. For instance, many told me that I shouldn't use camelCase and I should adhere to PEP8. Well, that's not me. I write my code the way I like it and if that is frowned upon by some standardizing community, so be it. I want to retain my freedom of expression. Freedom of expression is fine, until you have to work in a big group. The more everybody uses the same style, the easier it is for everybody to understand everybody else's code. There's another nice thing about PEP-8, or at least about the concept of an official global style. I've been in groups where a huge amount of time has been wasted arguing about style. In my current gig, when it came time to decide on a style, the conversation went something like one person suggesting we just use PEP-8 and everybody else nodding in agreement. In 2 minutes, we saved many person-months of arguing. Nothing wrong with that. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular expressions, help?
On Apr 19, 9:52 am, Jon Clements jon...@googlemail.com wrote: On Thursday, 19 April 2012 07:11:54 UTC+1, Sania wrote: Hi, So I am trying to get the number of casualties in a text. After 'death toll' in the text the number I need is presented as you can see from the variable called text. Here is my code I'm pretty sure my regex is correct, I think it's the group part that's the problem. I am using nltk by python. Group grabs the string in parenthesis and stores it in deadnum and I make deadnum into a list. text=accounts put the death toll at 637 and those missing at 653 , but the total number is likely to be much bigger dead=re.match(r.*death toll.*(\d[,\d\.]*), text) deadnum=dead.group(1) deaths.append(deadnum) print deaths Any help would be appreciated, Thank you, Sania Or just don't fully rely on a regex. I would, for time, and the little sanity I believe I have left, would just do something like: death_toll = re.search(r'death toll.*\d+', text).group().rsplit(' ', 1)[1] hth, Jon. Thank you all so much! I ended up using Jussi's advice. \D{0,20} Azrazer what you suggested works but I need to make sure that it catches numbers like 6,370 as well as 637. And I tried tweaking the regex around from the one you said in your reply but It didn't work (probably would have if I was more adept). But thanks! Jon- I kind of see what you are doing. In the regex you say that after death toll there can be 0 or more characters followed by 1 or more digits (although I would need to add a comma within digit so it catches 6,370). I can also see that you are splitting each string but I don't understand the 1 in rsplit(' ', 1)[1]. I am not really familiar with the syntax I guess. Thanks again! -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular expressions, help?
On Fri, Apr 20, 2012 at 1:07 AM, Sania fantasyblu...@gmail.com wrote: Azrazer what you suggested works but I need to make sure that it catches numbers like 6,370 as well as 637. And I tried tweaking the regex around from the one you said in your reply but It didn't work (probably would have if I was more adept). But thanks! Okay. Here's a general principle when working with regular expressions: First look for a negated set, then look for a positive set. For instance: death toll[^0-9,]*([0-9,]+) Note the parallel between what's inside the grouping parentheses and what's before them. You're telling the regex parser to ignore everything that's not digit or comma, then consume everything that's digit or comma. (I'm simplifying this by working with ASCII-only. YMMV if you need to handle other definitions of digit; the same principle applies.) The other option is to use dot, but non-greedily. This accomplishes the same thing: death toll.*?([0-9,]+) I strongly recommend you pick up a hefty document on regular expressions and get to know them thoroughly. It's an investment of time, but you'll be working with less magic and more tools. In fact, I'd recommend that for anyone who's doing more than the most trivial work with regexps. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Request META Help
On Thu, Apr 19, 2012 at 11:32 PM, Gabriel Novaes semprobl...@gmail.com wrote: The domains testes1.xyz.com.br, tes.xyzk.com.br, xx.xyzk.com.br through a DNS redirect TYPE A link to the server IP. In most cases I get the request.META ['HTTP_HOST'] with the URL in the request header, but today I had a problem that a customer made an appointment for me, and I get the IP of the server that information. Actually I need to get tes.xyzk.com.br Does anyone know better how it works? How can I overcome this? As I understand it, your customer accessed your web site via direct IP address. The easiest way to deal with that is to have a single default name, and if the Host: header (which is what comes through as HTTP_HOST) doesn't match any of the names you're expecting, you treat it as though it had been sent as your default. This is how Apache works when using name-based virtual hosting, and you seem to be doing pretty much the same thing, so following convention will keep things convenient. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you refer to an iterator in docs?
On Thursday, April 19, 2012 5:21:20 AM UTC-7, Roy Smith wrote: Let's say I have a function which takes a list of words. I might write the docstring for it something like: def foo(words): Foo-ify words (which must be a list) What if I want words to be the more general case of something you can iterate over? How do people talk about that in docstrings? Do you say something which can be iterated over to yield words, an iterable over words, or what? I can think of lots of ways to describe the concept, but most of them seem rather verbose and awkward compared to a list of words, a dictionary whose keys are words, etc. When I talk about an iterable, I say iterable. Based on my recent readings of the style guide PEPs I would write something like: Foo-ify some words. Arguments: words -- an iterable of words Just remember that types don't matter (until you get down to the C, really), just the methods associated with an object. Have fun and happy coding! -- http://mail.python.org/mailman/listinfo/python-list
Re: Framework for a beginner
On 4/19/2012 7:14 AM, Kiuhnm wrote: On 4/19/2012 6:21, lkcl wrote: yeah, it does :) python is... the best word i can describe it is: it's beautiful. it has an elegance of expression that is only marred by the rather silly mistake of not taking map, filter and reduce into the list object itself: l.map(str) for example would be intuitive, compact and elegant. It would be WRONG! Those functions are NOT list methods. They are functions that apply to ANY serialized collection, which is to say, ANY iterable (which includes iterators). This deep orthogonality is, in my opinion, part of the deep elegance of Python. instead, i have to look up how to use map each and every damn time! the reason for the mistake is historical: map, filter and reduce were contributed by a lisp programmer. that lisp programmer, presumably, was used to everything being function(args...) and it simply didn't occur to anyone to properly integrate map, filter and reduce properly into the list objects that they work with. Because, again, map, filter, and reduce do not work with list objects. They work with iterables. People make the same mistake when they say that join should be a list method, even though lists are not one of join's parameter types. I sometimes avoid classes because prefixing hundreds of identifiers with 'self.' makes the code uglier and much less readable. You can shorten the prefix to, for instance, 's.' if you wish. I don't like when a community imposes style on a programmer. For instance, many told me that I shouldn't use camelCase and I should adhere to PEP8. PEP8 is a style guide for *new* stdlib code. Guido has asked that core developers not revise non-comforming but working library code only because of its non-conformance. The risk of getting conforming but buggy code is too great. (Revising style while editing and testing otherwise is a different matter.) The PEP itself disclaims being a straightjacket. Anyone who clubs you with it is violating it. I want to retain my freedom of expression. You do, just as others are free to opinionate when reading your code ;-). PEP 8 surprise! It has a line about always surrounding binary operators with spaces. Many developers disagree. When this came up on pydev list, Guido said I did not write that and do not agree. Change it. I'm also tired of hearing mottos such as TIMTOWTDI... oops, that's Perl. I think Tim meant for the Zen to be a summary and stimulus of thought, not a substitute for thought. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Framework for a beginner
On 4/19/2012 7:20 AM, Alek Storm wrote: Why not use list comprehension syntax? For 3.x, that should be shortened to Why not use comprehension syntax?, where comprehensions by default become generator expressions. These: Map: [val+1 for val in some_list] Filter: [val for val in some_list if val 0] become Map: (val+1 for val in some_list) Filter: (val for val in some_list if val 0) as map and filter produce iterators, just like comprehensions interpreted as generator expressions. functions (reduce() was removed from 3.0 for reasons I will never understand). The signature of Python's reduce is defective* because it combines two versions of reduce (2 and 3 arg forms) into one function in a way that makes it confusing and hard to use and therefore less used than it might be otherwise. So it was moved (not removed) to the functools module. * One consistent signature that people could remember would be reduce3(update(current,next), initial_current, source_of_nexts) -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Framework for a beginner
On 19.04.2012, Kiuhnm kiuhnm03.4t.yahoo.it wroted: When you know more than 30 languages you stop thinking that way and you also don't try to defend your language against infidels. Then again, even when you know more than 100 languages, you may find some that fit your brain and some that just don't work well with your neurons. And you may still call the former my languages. GS -- Grzegorz Staniak gstaniak _at_ gmail [dot] com -- http://mail.python.org/mailman/listinfo/python-list
Re: Framework for a beginner
On 4/19/2012 8:12 AM, lkcl luke wrote: you don't *have* to use lambdas with map and reduce, you just have touse a function, where a lambda happens to be a nameless function. Abbreviated statements like the above sometimes lead people to think that there is more difference between def functions and lambda functions than there is, at least in Python. The word 'lambda' is used ambiguously by various people for either the expression or the resulting object -- or perhaps even for both. You clearly mean the function object above, but other are not so clear. The word 'nameless' is also ambiguous in that it could refer to the syntax construct, a name attribute, or a namespace binding. Lambda expressions are nameless, but the resulting function objects are not. Lambda expressions and def statements both produce function objects with a .__name__ attribute. For lambda functions, .__name__ is always 'lambda'. So to be exact, a lambda function, resulting from a lambda expression, is a function with the default name 'lambda'. As for name binding: a lambda function can be explicitly bound to a name in any namespace, just like any other object. The automatic local namespace binding of a def function can be explicitly undone, just like any other binding. So any function, regardless of creation syntax, can be named or not in any namespace, just like any other object. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: with statement
On 4/19/2012 20:02, Jacob MacDonald wrote: On Thursday, April 19, 2012 10:15:23 AM UTC-7, Kiuhnm wrote: A with statement is not at the module level only if it appears inside a function definition or a class definition. Am I forgetting something? Kiuhnm That sounds about right to me. However, I haven't really used with's very much. So why would it matter where the statement is? (The only possibility that occurs to me is if your __enter__ or __exit__ methods reference a variable at some arbitrary level.) You'll see. It's related to my post 'Bug in Python'. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system()
On 19/04/2012 19:09, Yigit Turgut wrote: When I use os.system() function, script waits for termination of the windows that is opened by os.system() to continue thus throwing errors and etc. How can i tell Python to let it go and keep on with the next execution after os.system() ? Try using the subprocess module instead. -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you refer to an iterator in docs?
On 4/19/2012 11:51 AM, Jacob MacDonald wrote: When I talk about an iterable, I say iterable. Ditto. Examples from manual: filter(function, iterable) Construct an iterator from those elements of iterable for which function returns true. (I would work this differently.) map(function, iterable, ...) Return an iterator that applies function to every item of iterable, yielding the results. Foo-ify some words. Arguments: words -- an iterable of words And if I mean an iterable of x, where x is a subset of Python objects, I say that. For example, the argument to str.join is an iterable of strings. Not everyone says exactly that. The manual happens to say str.join(iterable) Return a string which is the concatenation of the strings in the iterable [in blue parameter font] iterable. A TypeError will be raised if there are any non-string values in iterable, including bytes objects. But I find that slightly awkward. Sometimes the restricted category is harder to describe. Min and max requires an iterable of mutually comparable objects. The first item determines the specific class or category. Sum requires an iterable of mutually addable objects, with the specific class or category (such as 'number') again determined by the initial value. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
pyjamas-desktop running under python 2.6... on wine (!)
i think this is so hilarious and just such a stunning achievement by the wine team that i had to share it with people. the writeup's here: http://appdb.winehq.org/objectManager.php?sClass=versioniId=25765 but, to summarise: * python2.6 runs under wine (the win32 emulator) * so does python-comtypes (0.6.1) * you can also install IE6, 7 or 8 under wine * then you can also install pyjamas * and at the C:\ DOS prompt you can run python.exe Hello.py ... and it will work! you'll actually get a desktop application as a win32 GDI program running on your X-Windows GNU/Linux desktop :) i just fell off my chair when that happened. underneath, what's happening is that pyjd's mshtml.py is firing up a COM interface to MSHTML.DLL (which is part of IE), it's embedding an IWebBrowser2 OCX control into a w32 GDI window (using a ctypes wrapper to do that, if you're interested in those kinds of details), and then handing that over to pyjamas. and this is all emulated! it's just an absolutely staggering testament to how far wine has come that it can run python.exe in the first place, but being able to run COM interfaces around something as sophisticated as MSHTML.DLL is just mind-blowing. all right, rant over :) l. -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system()
On Thursday, April 19, 2012 11:09:22 AM UTC-7, Yigit Turgut wrote: When I use os.system() function, script waits for termination of the windows that is opened by os.system() to continue thus throwing errors and etc. How can i tell Python to let it go and keep on with the next execution after os.system() ? You have to use threads. As in most programming languages (I believe), the program waits for a line to finish before moving on. So you'll have to create a new thread to deal with the windows, then move on to other stuff. Read the docs on the threading modules. -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you refer to an iterator in docs?
On Thursday, 19 April 2012 13:21:20 UTC+1, Roy Smith wrote: Let's say I have a function which takes a list of words. I might write the docstring for it something like: def foo(words): Foo-ify words (which must be a list) What if I want words to be the more general case of something you can iterate over? How do people talk about that in docstrings? Do you say something which can be iterated over to yield words, an iterable over words, or what? I can think of lots of ways to describe the concept, but most of them seem rather verbose and awkward compared to a list of words, a dictionary whose keys are words, etc. I would just write the function signature as (very similar to how itertools does it): def func(iterable, ..): pass IMHO that documents itself. If you need explicit, look at the itertools documentation. hth Jon. -- http://mail.python.org/mailman/listinfo/python-list
can I overload operators like =, - or something like that?
hi all, can I somehow overload operators like =, - or something like that? (I'm searching for appropriate overload for logical implication if a then b) Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
Passing a object to my test case from mainthread using unittest
i am new to python and just now started developing an linux application automation. scenario i am trying is thread.py --- will invoke all primary device threads and load test from testcase admincase.py --- hold my tests for the case.. what i am unable to do is i want to pass certain objects from thread.py to admincase.py when loading the test. how do i do that.. object which i am tryin to pass is (*EppQueue*) thread.py code |import threading import sys import time import logging import os import Queue from EPPimport EPP import ldtp import ldtputils from functionsimport functions from admincasesimport admincases import unittest #logging.basicConfig(level=logging.DEBUG, #format='(%(threadName)-10s) %(message)s', #) class inittest(unittest.TestCase): global fun global EppQueue global window_name def cleanup(epp_port): if os.path.exists(epp_port): os.unlink(epp_port) def start_threads(EppQueue,server_ip,epp_port): epp= EPP EPP1= threading.Thread(name='EPP', target=epp, args=(server_ip,54321,epp_port,EppQueue,)) EPP1.setDaemon(True) EPP1.start() return epp fun= functions() EppQueue = Queue.Queue(1) server_ip='192.168.10.125' epp_port='/dev/ttyS17' print Starting cleanup(epp_port) print Clean up Over epp= start_threads(EppQueue,server_ip,epp_port) raw_input(## Please Start the main appilcation in the ATM and hit a KEY to continue ) check= 0 while check== 0: window_name= fun.start_up_verify('atm_main_app') if any(window_name): check= 1 else: check= 0 if not any(window_name): print Please start the application and run the test sys.exit(0) else: print window_name print SYSTEM IS READY TO PERFORM TEST raw_input(## HIT ANY KEY TO START UNIT TEST ) raw_input(kkk) test= unittest.defaultTestLoader.loadTestsFromName(admincases) unittest.TextTestRunner(verbosity=2).run(test) raw_input(keyy) print final | admincase.py code |import unittest from functionsimport functions import time import Queue class admincases(unittest.TestCase): global fun global EppQueue global window_name def test_case_1(self): print test case 1 window_name= 'frmatm_main_app' fun.send_queue(self.EppQueue,send_keys,) fun.verify_screen(window_name,ico0) fun.send_queue(self.EppQueue,send_keys,C) fun.verify_screen(window_name,ManagementFunctions) fun.send_queue(self.EppQueue,send_keys,001234) fun.verify_screen(window_name,MainMenu) fun.send_queue(self.EppQueue,send_keys,1) fun.verify_screen(window_name,Diagnostics) fun.send_queue(self.EppQueue,send_keys,1) fun.verify_screen(window_name,TerminalStatus) fun.send_queue(self.EppQueue,send_keys,2) time.sleep(10) fun.send_queue(self.EppQueue,send_keys,) fun= functions() #EppQueue = Queue.Queue(1) | Need some assistance on this... -- Regards Venkat.S -- http://mail.python.org/mailman/listinfo/python-list
Re: can I overload operators like =, - or something like that?
On Thursday, April 19, 2012 12:28:50 PM UTC-7, dmitrey wrote: hi all, can I somehow overload operators like =, - or something like that? (I'm searching for appropriate overload for logical implication if a then b) Thank you in advance, D. I don't believe that you could overload those particular operators, since to my knowledge they do not exist in Python to begin with. -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system()
Yigit Turgut wrote in message news:b9a8bb28-3003-4a36-86fb-339ef697b...@i2g2000vbd.googlegroups.com... When I use os.system() function, script waits for termination of the windows that is opened by os.system() to continue thus throwing errors and etc. How can i tell Python to let it go and keep on with the next execution after os.system() ? Can you make use of subprocess.Popen() ? -- http://mail.python.org/mailman/listinfo/python-list
*.sdf database access
Hi, I am trying to connect and access data in a *.sdf file on Win7 system using Python 2.7. I have three questions: 1. What python module should I use? I have looked at sqlite3 and pyodbc. However, I can seem to get the connection to the database file setup properly. 2. How can I determine the appropriate connection string? I have opened database file in Visual Studio and can see the tables. I don't understand where to find the connection string in Visual Studio. 3. Assuming a module from (1) above, does anyone have a code snippet for connecting to the database and then accessing a varbinary (image) in one of the tables of the databese? Thanks in advance. Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you refer to an iterator in docs?
On 19Apr2012 14:32, Terry Reedy tjre...@udel.edu wrote: | On 4/19/2012 11:51 AM, Jacob MacDonald wrote: | When I talk about an iterable, I say iterable. | | Ditto. I used to, but find myself saying sequence these days. It reads better, but is it the same thing? Cheers, -- Cameron Simpson c...@zip.com.au DoD#743 http://www.cskk.ezoshosting.com/cs/ all coders are created equal; that they are endowed with certain unalienable rights, of these are beer, net connectivity, and the pursuit of bugfixes... - Gregory R Block -- http://mail.python.org/mailman/listinfo/python-list
Re: with statement
On 4/19/2012 1:15 PM, Kiuhnm wrote: A with statement is not at the module level only if it appears inside a function definition or a class definition. This is true, I believe, of all statements. Am I forgetting something? Comprehensions (in Py3) and lambda expressions also introduce new local scopes -- because they are abbreviated def statements. But they cannot contain statements, only expressions, in that new scope. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular expressions, help?
If you plan on doing more work with regular expressions in the future and you have access to a Windows machine you may want to consider picking up a copy of RegxBuddy. I don't have any affiliation with the makers but I have been using the software for a few years and it has saved me a lot of frustration. Thanks, -Andy- -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you refer to an iterator in docs?
On 4/19/2012 5:32 PM, Cameron Simpson wrote: On 19Apr2012 14:32, Terry Reedytjre...@udel.edu wrote: | On 4/19/2012 11:51 AM, Jacob MacDonald wrote: | When I talk about an iterable, I say iterable. | | Ditto. I used to, but find myself saying sequence these days. It reads better, but is it the same thing? A Python 'sequence' is a collection that has a length and can be indexed by counts 0, 1, ... . In other words, len(s) and s[n] work. This definition is in the library manual somewhere. With those two, 'in', 'count', and 'index' and iteration are theoretically trivial. See 4.6.3. Range Type but note that ranges were sequences before the 3.2 additions. 'Sequence' excludes all other iterables that do not have length and count indexing: sets, dicts, iterators, files, and others, such as user defined or extension tree structures. The point of the new iter/next iterator protocol added in 2.2 was to expand the notion of iterable from 'sequence' or 'pseudo-sequence' to 'collection whose items can be accessed one at a time' (whether or not the collection is linearly ordered). The point of documenting an arg as 'iterable', when that is what the function expects, is that is does not have to specifically be a sequence or worse, a list. It is a wonderful freedom when the restriction is not needed. --- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you refer to an iterator in docs?
On 19Apr2012 18:07, Terry Reedy tjre...@udel.edu wrote: | On 4/19/2012 5:32 PM, Cameron Simpson wrote: | On 19Apr2012 14:32, Terry Reedytjre...@udel.edu wrote: | | On 4/19/2012 11:51 AM, Jacob MacDonald wrote: | | When I talk about an iterable, I say iterable. | | | | Ditto. | | I used to, but find myself saying sequence these days. It reads | better, but is it the same thing? | | A Python 'sequence' is a collection that has a length and can be indexed | by counts 0, 1, ... . In other words, len(s) and s[n] work. This | definition is in the library manual somewhere. I think I've failed to find this definition in the past, hence my misuse. I'll go back to saying iterable, as that is usually what I intend. On the same topic, when I write a generator my docstring tends to come in one of two forms: foo() yields values ... or foo() returns an iterable ... I find the first clumsy, but tend not to think of generators as returning an iterable as a single action. But of course they do, don't they: the generator instance itself, since I can say x = foo() and then iterate over x. So is the second docstring style better/preferred/more common? Cheers, -- Cameron Simpson c...@zip.com.au DoD#743 http://www.cskk.ezoshosting.com/cs/ The trouble with the rat-race is, even if you win, you're still a rat. - James Youngman jyoung...@vggas.com -- http://mail.python.org/mailman/listinfo/python-list
Re: with statement
On Thu, Apr 19, 2012 at 3:33 PM, Terry Reedy tjre...@udel.edu wrote: On 4/19/2012 1:15 PM, Kiuhnm wrote: A with statement is not at the module level only if it appears inside a function definition or a class definition. This is true, I believe, of all statements. Am I forgetting something? Comprehensions (in Py3) and lambda expressions also introduce new local scopes -- because they are abbreviated def statements. But they cannot contain statements, only expressions, in that new scope. Syntactically, that's true. However, lambdas and comprehensions are just functions and generator functions under the hood, so in principle there is nothing preventing with blocks from being injected into their byte code. -- http://mail.python.org/mailman/listinfo/python-list
Re: Suggest design to accomodate non-unix platforms ?
On Wed, Apr 18, 2012 at 5:16 PM, Miki Tebeka miki.teb...@gmail.com wrote: So I'm interested in suggestions/examples where a user can update a config file to specify by which means they want (in this case) the ssh functionality to be supplied. You can do something like that (it's called a factory): COMMANDS = { 'win32': 'win32 command goes here', 'linux2': 'linux command goes here', 'darwin': 'OSX command goes here', } def get_command(): return COMMANDS.get(sys.platform) I'd actually suggest that you not do this. It's too analogous to the old way of making things portable: #ifdef and #define all over, EG: #ifdef win32 #define thinga #define thingb #define thingc #endif #ifdef linux32 #define otherthinga #define otherthingb #define otherthingc #endif It's not nearly as adaptive as scaning $PATH for ssh, falling back on putty if necessary - this is analogous to GNU autoconf. You'd probably have a small class you genericize this with - with one instance for each such executable that might be different from one OS to another. You could probably just pass __init__ a list of possible commands to try, and then have a __call__ method. That way when Haiku takes the world by storm, your porting effort should be smaller. ^_^ (Or something. I really, really hope that Windows, OS/X and Linux won't be the only major OS's for all time) -- http://mail.python.org/mailman/listinfo/python-list
Re: with statement
Ian Kelly wrote: On Thu, Apr 19, 2012 at 3:33 PM, Terry Reedy tjre...@udel.edu wrote: On 4/19/2012 1:15 PM, Kiuhnm wrote: A with statement is not at the module level only if it appears inside a function definition or a class definition. This is true, I believe, of all statements. Am I forgetting something? Comprehensions (in Py3) and lambda expressions also introduce new local scopes -- because they are abbreviated def statements. But they cannot contain statements, only expressions, in that new scope. Syntactically, that's true. However, lambdas and comprehensions are just functions and generator functions under the hood, so in principle there is nothing preventing with blocks from being injected into their byte code. Which would still not be at the module level. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: Suggest design to accomodate non-unix platforms ?
On Fri, Apr 20, 2012 at 8:35 AM, Dan Stromberg drsali...@gmail.com wrote: It's not nearly as adaptive as scaning $PATH for ssh, falling back on putty if necessary - this is analogous to GNU autoconf. You'd probably have a small class you genericize this with - with one instance for each such executable that might be different from one OS to another. You could probably just pass __init__ a list of possible commands to try, and then have a __call__ method. The question then is whether to choose or auto-detect. Attempting to auto-detect could be quite inefficient; imagine if you have to call on ssh every couple of seconds, and something in $PATH is on a slow network share (or on a floppy drive, if you still have one of those). Yes, it's a poor choice of executable path, but it's perfectly legal, and the detection could get pathologically expensive. At very least, consider caching the result. That way when Haiku takes the world by storm, your porting effort should be smaller. ^_^ (Or something. I really, really hope that Windows, OS/X and Linux won't be the only major OS's for all time) Heh. Point. But the detection technique does depend on 'ssh' being the secure shell client and accepting parameters exactly like you're looking for - imagine if the Haiku (or whatever) ssh client takes slightly different params. How do you handle that with autodetection? ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you refer to an iterator in docs?
On 4/19/2012 6:16 PM, Cameron Simpson wrote: On 19Apr2012 18:07, Terry Reedytjre...@udel.edu wrote: | On 4/19/2012 5:32 PM, Cameron Simpson wrote: | On 19Apr2012 14:32, Terry Reedytjre...@udel.edu wrote: | | On 4/19/2012 11:51 AM, Jacob MacDonald wrote: | | When I talk about an iterable, I say iterable. | | | | Ditto. | | I used to, but find myself saying sequence these days. It reads | better, but is it the same thing? | | A Python 'sequence' is a collection that has a length and can be indexed | by counts 0, 1, ... . In other words, len(s) and s[n] work. This | definition is in the library manual somewhere. 7.4.1. Collections Abstract Base Classes defines a Sequence as a Sized, Iterable, Container. The glossary entry for 'sequence' leaves out the container part: An iterable which supports efficient element access using integer indices via the __getitem__() special method and defines a len() method that returns the length of the sequence. ... Note that dict also supports __getitem__() and __len__(), but is considered a mapping rather than a sequence because the lookups use arbitrary immutable keys rather than integers. Then there is this: iter(object[, sentinel]) ... object must be ... or it must support the sequence protocol (the __getitem__() method with integer arguments starting at 0). On the same topic, when I write a generator my docstring tends to come in one of two forms: foo() yields values ... or foo() returns an iterable ... 'Generator' is another area of confusion. Here is what the implementation says def gf(): yield 1 type(gf) class 'function' g = gf() type(g) class 'generator' I and as far as I know, most people, call gf a generator function (function that returns a generator) and g a generator, as in instance of class 'generator', just as 'a list' is an instance of class 'list'. Unfortunately, whoever wrote the glossary contradicted the language and called gf a 'generator' and g merely an 'iterator'. It is, but generators are an important subcategory of iterator with extra api and currently unique suspend-resume behavior. Actually, the entry contradicts itself and later uses 'generator' as I have, to refer to the class 'generator' instance whose .__next__ method suspends and resumes. I will have to propose a patch. I find the first clumsy, but tend not to think of generators as returning an iterable as a single action. But of course they do, don't they: A generator function returns a generator, which is a sub-category of iterator, which is a sub-category of iterable. A generator function is not an iterable itself, because it does not have a .__iter__ method. Since there are minor api differences between generators and other iterators, I think the docstring should be specific. For gf above, I would say Return a generator that yields 1. Note that the Python docs are intended to consistently say 'return' rather than 'returns'. If the return is the default None, they use some other imperative verb such as 'convert' or 'invoke'. I try to do the same so I will have that habit when I work on them. As far as I know, generators are only constructed from Python-coded generator functions and expressions, so that there are no built-in generators. Still, generators are the easiest to write Python equivalents of the various built-in iterator types, such as those in itertools. So there are no trivially found generator doc examples that I know of, though there must be some in some Python-coded module. --- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Twisted: UDP socket not closed.
Did anyone in the group ever have an answer to Kevac's question, I'm having a similar issue? Thanks in advance, Luther [Python] Twisted: UDP socket not closed. [cid:image001.png@01CD1E6B.15DF6BB0]http://grokbase.com/user/Kevac-Marko/tTjuHcXzmQtuttsnhLfi5e Kevac Markohttp://grokbase.com/user/Kevac-Marko/tTjuHcXzmQtuttsnhLfi5e Dec 22, 2007 at 9:02 amhttp://grokbase.com/g/python/python-list/2007/12 Hi. I have to send UDP packets very often. Approx twice in a second. But socket is not closed after sending packet. So soon i bump into open sockets\files limit. How to close socket after sending data? Python 2.5, Twisted class DataClient(DatagramProtocol): def __init__(self, address, datagram = PONG): self.address, self.datagram = address, datagram def startProtocol(self): self.transport.socket.setsockopt(socket.SOL_SOCKET, \ socket.SO_BROADCAST, True) self.transport.connect(self.address[0], self.address[1]) self.sendDatagram() def sendDatagram(self): self.transport.write(self.datagram) debug(Data client: Sending to %s % repr(self.address)) while True: clientprotocol = DataClient((255.255.255.255, 5999), data) reactor.listenUDP(0, clientprotocol).stopListening() knight at rknb:~$ ls -la /proc/15429/fd/ | wc -l 43 knight at rknb:~$ ls -la /proc/15429/fd/ | wc -l 44 knight at rknb:~$ ls -la /proc/15429/fd/ | wc -l 44 knight at rknb:~$ ls -la /proc/15429/fd/ | wc -l 44 knight at rknb:~$ ls -la /proc/15429/fd/ | wc -l 45 knight at rknb:~$ ls -la /proc/15429/fd/ | wc -l 45 knight at rknb:~$ ls -la /proc/15429/fd/ | wc -l 46 inline: image001.png-- http://mail.python.org/mailman/listinfo/python-list
Re: can I overload operators like =, - or something like that?
On Apr 20, 5:54 am, Jacob MacDonald jaccar...@gmail.com wrote: On Thursday, April 19, 2012 12:28:50 PM UTC-7, dmitrey wrote: can I somehow overload operators like =, - or something like that? I don't believe that you could overload those particular operators, since to my knowledge they do not exist in Python to begin with. It all depends on if the operators use special methods on objects: http://docs.python.org/reference/datamodel.html#special-method-names You can overload = via object.__le__, for example. -- http://mail.python.org/mailman/listinfo/python-list
Re: can I overload operators like =, - or something like that?
On Fri, Apr 20, 2012 at 2:38 PM, alex23 wuwe...@gmail.com wrote: On Apr 20, 5:54 am, Jacob MacDonald jaccar...@gmail.com wrote: On Thursday, April 19, 2012 12:28:50 PM UTC-7, dmitrey wrote: can I somehow overload operators like =, - or something like that? I don't believe that you could overload those particular operators, since to my knowledge they do not exist in Python to begin with. It all depends on if the operators use special methods on objects: http://docs.python.org/reference/datamodel.html#special-method-names You can overload = via object.__le__, for example. Yes, but it will be a comparison operator, and to an extent, will be assumed to function as one. I don't recommend abusing comparisons for other operations - you'll confuse people no end. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: can I overload operators like =, - or something like that?
On Thu, Apr 19, 2012 at 3:28 PM, dmitrey dmitre...@gmail.com wrote: hi all, can I somehow overload operators like =, - or something like that? (I'm searching for appropriate overload for logical implication if a then b) Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list There is no logical implication operator in Python, and indeed Python doesn't really work that way; you can use a condition to trigger an action, and you can have a conditionally-valued expression, but you don't tell Python a bunch of facts and then expect it to reason from those - that's Prolog. You cannot invent your own operators for Python, either. Again, this isn't something that programming languages commonly support. Could you please tell us more about what you're **really** trying to do? -- ~Zahlman {: -- http://mail.python.org/mailman/listinfo/python-list
Re: can I overload operators like =, - or something like that?
On Fri, Apr 20, 2012 at 12:43 AM, Chris Angelico ros...@gmail.com wrote: On Fri, Apr 20, 2012 at 2:38 PM, alex23 wuwe...@gmail.com wrote: On Apr 20, 5:54 am, Jacob MacDonald jaccar...@gmail.com wrote: On Thursday, April 19, 2012 12:28:50 PM UTC-7, dmitrey wrote: can I somehow overload operators like =, - or something like that? I don't believe that you could overload those particular operators, since to my knowledge they do not exist in Python to begin with. It all depends on if the operators use special methods on objects: http://docs.python.org/reference/datamodel.html#special-method-names You can overload = via object.__le__, for example. Yes, but it will be a comparison operator, and to an extent, will be assumed to function as one. I don't recommend abusing comparisons for other operations - you'll confuse people no end. ChrisA -- http://mail.python.org/mailman/listinfo/python-list Actually, the = operator can't be spelled = anyway: 3=4 File stdin, line 1 3=4 ^ SyntaxError: invalid syntax -- ~Zahlman {: -- http://mail.python.org/mailman/listinfo/python-list
[issue14591] Value returned by random.random() out of valid range
Mark Dickinson dicki...@gmail.com added the comment: Here's a modification of Serhiy's patch that assures that the new state is nonzero. (Just to clarify the nonzero requirement: the MT state is formed from bit 31 of mt[0] together with all the bits of mt[i], 1 = i 624. At least one of these 19937 bits must be nonzero.) -- Added file: http://bugs.python.org/file25267/random_jumpahead_2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14591 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14591] Value returned by random.random() out of valid range
Mark Dickinson dicki...@gmail.com added the comment: The latest patch has the disadvantage that it'll often change the behaviour of jumpahead for people on 32-bit platforms, which may lead to unnecessary breakage. Here's a better version that only fixes mt[0] in the unlikely (but possible) event that mt[1] through mt[623] are all zero. That should mean that users on 32-bit machines who are depending on jumpahead being reproducible won't notice (unless they're very unlucky indeed). -- Added file: http://bugs.python.org/file25268/random_jumpahead_3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14591 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14590] ConfigParser doesn't strip inline comment when delimiter occurs earlier without preceding space.
Łukasz Langa luk...@langa.pl added the comment: INI files won't go away and there will come a time where 3.3 is old. Since 3.2 inline comments are turned off by default which mitigates the problem. Fixing this parser bug for the 3.3 release seems safe enough for me as long as you clearly state in NEWS and the docs that it changed. I'll leave 2.7 and 3.2 behind as to my doubts stated in the previous comment. -- versions: -Python 2.7, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14590 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14619] Enhanced variable substitution for databases
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: I agree this would be very handy, but the database engines I know which accept bind variables (Oracle, MySQL, JDBC) only accept simple types. So to handle ?? it would be necessary to modify the SQL statement passed to the database server: name in (?, ?, ?). This has some drawbacks IMO: - One advantage of bind variables is that the SQL server sees the same statement for different invocations of execute() and thus can reuse computed data (parsed query, execution plan, etc) . The ?? placeholder would silently kill this optimization. - cursor.executemany() would have to format and pass a different statement for each row, which would break the implementations that prepare the statement once and pass all the rows in a single call. - cx_Oracle has a cursor.prepare(stmt) function which explicitly exposes the above mechanism; it could not work with ??. Yes, the IN operator in SQL is difficult to address. I've tried several approaches to this, one of them was to create a temporary table and joint it in the main query... -- nosy: +amaury.forgeotdarc ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14619 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13959] Re-implement parts of imp in pure Python
Eric Snow ericsnowcurren...@gmail.com added the comment: Looking it over, I'm confident that tokenizer.detect_encoding() does not raise a SyntaxError where PyTokenizer_FindEncodingFilename() does. I've run out of time tonight, but I'll look at it more tomorrow. Once find_module() is done, I'd like to move on to reload(), which I expect will be pretty straightforward at this point. Then the feasibility of issue14618 should be clear. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13959 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14601] PEP sources not available as documented
Martin v. Löwis mar...@v.loewis.de added the comment: Not sure how it was supposed to be fixed in the past, as the docutils formatter would happily use whatever URL the docutils release had in place. I now fixed it for real (I hope) in 34076bfed420 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14601 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14620] Fatal Python error: Cannot recover from stack overflow.
New submission from Florian Bruhin python@the-compiler.org: Hey, I just got the error message in the title when trying to run a script with python. You can find the coredump, stacktrace, and the scripts I ran at http://the-compiler.org/tmp/pythoncrash/ The command line I ran: python -u pythonomegle.py Running Python 3.2.2 on Archlinux. -- components: None messages: 158706 nosy: The-Compiler priority: normal severity: normal status: open title: Fatal Python error: Cannot recover from stack overflow. type: crash versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14620 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14619] Enhanced variable substitution for databases
Marc-Andre Lemburg m...@egenix.com added the comment: Raymond, the variable substitution is normally done by the database and not the Python database modules, so you'd have to ask the database maintainers for assistance. The qmark ('?') parameter style is part of the ODBC standard, so it's unlikely that this will get changed any time soon unless you have good contacts with Microsoft :-) The ODBC standard also doesn't support multi-value substitutions in the API, so there's no way to pass the array to the database driver. BTW: Such things are better discussed on the DB-SIG mailing list than the Python tracker. -- nosy: +lemburg ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14619 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7980] time.strptime not thread safe
Changes by Cédric Krier cedric.kr...@b2ck.com: -- nosy: +ced ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7980 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14611] inspect.getargs fails on some anonymous tuples
Stefano Taschini tasch...@ieee.org added the comment: I think this should do. inspect.getargs is now looking for STORE_DEREF besides STORE_FAST, and is making sure that the appropriate namespace (locals vs cell + free vars) is selected depending on the opcode. The only changes to the test suite are three additional tests, based on the two examples above. -- keywords: +patch Added file: http://bugs.python.org/file25269/issue_14611.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14611 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14381] Intern certain integral floats for memory savings and performance
Mark Dickinson dicki...@gmail.com added the comment: Why do you think it isn't safe, Antoine? It violates C's strict aliasing rules; Google for 'C strict aliasing' or 'C type punning' for more information. This isn't just a theoretical concern: gcc is known to make optimizations based on the assumption that strict aliasing isn't violated. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14381 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14423] Getting the starting date of iso week from a week number and a year.
Esben Agerbæk Black esbe...@gmail.com added the comment: 2) I get errors for all my test when I build my python and run ./python.exe -m test.datetimetester -j3 I asume this is because I have yet to implement the c version in Modules/_datetimemodule.c is this the correct assumption? You should probably run ./python.exe -m test -v test_datetime instead. Not sure that will fix your test failures, though :) Ok so now i only get errors for _Fast tests am I correct in assuming that this is because i lack a C implementation? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14423 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4892] Sending Connection-objects over multiprocessing connections fails
sbt shibt...@gmail.com added the comment: Up to date patch. -- Added file: http://bugs.python.org/file25270/mp_pickle_conn.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4892 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14381] Intern certain integral floats for memory savings and performance
Mark Dickinson dicki...@gmail.com added the comment: We only support IEEE platforms. I don't think that's true, BTW. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14381 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11618] Locks broken wrt timeouts on Windows
Kristján Valur Jónsson krist...@ccpgames.com added the comment: Here is a new patch. This uses critical sections and condition variables to avoid kernel mode switches for locks. Windows mutexes are expensive and for uncontented locks, this offers a big win. It also adds an internal set of critical section/condition variable structures, that can be used on windows to do other such things without resorting to explicit kernel objects. This code works on XP and newer, since it relies on the semaphore kernel object being present. In addition, if compiled to target Vista or greater, it will use the built-in critical section primitives and the FRWLock objects (which are faster still than CriticalSection objects and more robust) -- status: pending - open Added file: http://bugs.python.org/file25271/ntlocks.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11618 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4892] Sending Connection-objects over multiprocessing connections fails
sbt shibt...@gmail.com added the comment: A couple of minor changes based on Antoine's earlier review (which I did not notice till now). -- Added file: http://bugs.python.org/file25272/mp_pickle_conn.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4892 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14428] Implementation of the PEP 418
Marc-Andre Lemburg m...@egenix.com added the comment: STINNER Victor wrote: STINNER Victor victor.stin...@gmail.com added the comment: Please leave the pybench default timers unchanged in case the new APIs are not available. Ok, done in the new patch: perf_counter_process_time-2.patch. Thanks. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14428 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5118] '%.2f' % 2.545 doesn't round correctly
Zeev Rotshtein zee...@gmail.com added the comment: Well this IS a bug. There is a certain globally accepted manner in which rounding work and python does something else. P.S.: A bug is when something doesn't do what it's supposed to do the way it's supposed to do it. This definition does not depend on internal representation or any such things. -- nosy: +Zeev.Rotshtein ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5118 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5118] '%.2f' % 2.545 doesn't round correctly
Mark Dickinson dicki...@gmail.com added the comment: Well this IS a bug. I assume that you're referring to behaviour like this: Python 2.7.2 (default, Jan 13 2012, 17:11:09) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type help, copyright, credits or license for more information. x = 2.545 round(x, 2) 2.54 To explain again, what happens here is: (1) After the assignment 'x = 2.545', what's stored for x is not the precise decimal value 2.545, but a binary approximation to it. That binary approximation just happens to be very slightly less than 2.545. (2) Now when rounding, the usual rules are applies (values less than half get rounded down), to give 2.54. Which part(s) of the above do you think should be changed? Should the 'round' function incorrectly round some numbers up even though they fall below the halfway case? -- assignee: - mark.dickinson versions: +Python 2.7 -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5118 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14538] HTMLParser: parsing error
Michel Leunen michel.leu...@gmail.com added the comment: Thanks guys for your comments and for solving this issue. Great work! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14538 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14032] test_cmd_line_script prints undefined 'data' variable
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset c4c67c2d8ffc by Nick Coghlan in branch '3.2': Close #14032: fix incorrect variable reference in test_cmd_line_script http://hg.python.org/cpython/rev/c4c67c2d8ffc -- nosy: +python-dev resolution: - fixed stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14032 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com