Re: pls help me with this prog
On Friday, October 19, 2012 4:40:42 PM UTC+8, inshu chauhan wrote: in this prog I have written a code to calculate teh centre of a given 3D data.. but i want to calculate it for every 3 points not the whole data, but instead of giving me centre for every 3 data the prog is printing the centre 3 times... import cv from math import floor, sqrt, ceil from numpy import array, dot, subtract, add, linalg as lin def CalcCentre(data): centre = array([0,0,0]) count = 0 n = 0 for p in data[n:n+3]: centre = add(centre, array(p[:3])) count += 1 centre = dot(1./count, centre) return centre n += 1 def ReadPointCloud(filename): f = open(filename) result = [] for l in f: sp = l.split() t = tuple(map(float, sp[1:4])) result.append(t) return result def main (data): j = 0 for i in data[:3]: while j != 3: centre = CalcCentre(data) j += 1 print centre if __name__ == '__main__': data = ReadPointCloud(r'Z:\data\NEHreflectance_Scanner 1_part.txt') main(data) PLS HELP # assume data is a list of 3 n numbers, n!=0 n3=data.length() n=n/3 x=sum(data[0:n3:3])/n y=sum(data[1:n3:3])/n z=sum(data[2:n3:3])/n #(x,y,z) -- http://mail.python.org/mailman/listinfo/python-list
Re: A desperate lunge for on-topic-ness
On Sat, 20 Oct 2012 14:18:47 +, Grant Edwards wrote: On 2012-10-20, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: Strangely, we've gone from 80-character fixed width displays to who-knows-what (if I drop my font size I can probably get nearly 200 characters across in full-screen mode)... But at the same time we've gone from 132-character line-printers using fan-fold 11x17 pages, to office inkjet/laser printers using 8.5x11 paper, defaulting to portrait orientation -- with a 10 character/inch font, and 1/4 left/right margins, we're back to 80 character limitation G True, but nobody prints source code out on paper do they? I do. There's nothing better than spreading out a dozen sheets of source code over a table to get a good, high-level overview of what does what in preparation to refactoring it. Seriously -- I can't remember the last time I printed souce code... I've never printed souce code either *wink* -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: change the first letter into uppercase (ask)
: On 20 October 2012 20:22, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: Based on the documentation, most of that pattern is fluff: (?#...) is considered a comment. The comment isn't entirely fluff ... it provides a Google target for whoever's marking OP's assignment, should they choose to look it up: https://www.google.com/search?q=nyh2p -[]z. -- http://mail.python.org/mailman/listinfo/python-list
Re: A desperate lunge for on-topic-ness
On Sun, Oct 21, 2012 at 7:07 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sat, 20 Oct 2012 14:18:47 +, Grant Edwards wrote: True, but nobody prints source code out on paper do they? I do. There's nothing better than spreading out a dozen sheets of source code over a table to get a good, high-level overview of what does what in preparation to refactoring it. Seriously -- I can't remember the last time I printed souce code... I've never printed souce code either *wink* So what you actually mean is that there's nothing _like_ spreading out c c. I should think that throwing cold water over the code would be better. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: A desperate lunge for on-topic-ness
On Sun, 21 Oct 2012 20:20:41 +1100, Chris Angelico wrote: On Sun, Oct 21, 2012 at 7:07 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sat, 20 Oct 2012 14:18:47 +, Grant Edwards wrote: True, but nobody prints source code out on paper do they? I do. There's nothing better than spreading out a dozen sheets of source code over a table to get a good, high-level overview of what does what in preparation to refactoring it. Seriously -- I can't remember the last time I printed souce code... I've never printed souce code either *wink* So what you actually mean is that there's nothing _like_ spreading out c c. I should think that throwing cold water over the code would be better. Er, no. Note spelling of source code vs souce code. Hence the grin. I seriously do print out source code. When I'm having trouble seeing how the parts of a module fit together, reading print-outs is a good way around the problem. Class browsers don't show you duplicate code, and besides, only works with classes. Reading code on screen is limited in how much you can see at a time. Both of these things play a part in refactoring, and so does printing out the source and having a human being (i.e. me) look at it. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
a prob.. error in prog ..dont knw how to correct
I am new to python and have a little problem to solve .. i have an array with x, y, z co-ordinates in it as a tuple. I am trying to find the distance between each point and sorting the points according to the min distance.. i have tried a prog but m stuck bcoz of this error which I am unable to correct import cv from math import floor, sqrt, ceil from numpy import array, dot, subtract, add, linalg as lin def calcdist(data): for p in data: x = p[0] y = p[1] z = p[2] for i in range(len(data)): dist = sqrt((x[i]-x[i+1])**2 + (y[i]-y[i+1])**2 +(z[i]-z[i+1]**2)) return dist def ReadPointCloud(filename): return [tuple(map(float, l.split()[1:4])) for l in open(filename)] def main (data): for i in range(len(data)): # Finding Neighbours for j in range(len(data)): dist = calcdist(data) print dist if __name__ == '__main__': data = ReadPointCloud(r'C:\Thesis\NEHreflectance_Scanner_1_part.txt') data = data[0:100] main(data) the error m getting is... Traceback (most recent call last): File C:\Users\inshu\Desktop\cal-dist.py, line 29, in module main(data) File C:\Users\inshu\Desktop\cal-dist.py, line 22, in main dist = calcdist(data) File C:\Users\inshu\Desktop\cal-dist.py, line 11, in calcdist dist = sqrt((x[i]-x[i+1])**2 + (y[i]-y[i+1])**2 +(z[i]-z[i+1]**2)) TypeError: 'float' object has no attribute '__getitem__' -- http://mail.python.org/mailman/listinfo/python-list
Re: printing (was: A desperate lunge for on-topic-ness)
On 10/21/12 05:00, Steven D'Aprano wrote: I seriously do print out source code. When I'm having trouble seeing how the parts of a module fit together, reading print-outs is a good way around the problem. I don't print my personal code--both in light of the fact that I know it much more intimately and I longer own a printer. But when trying to wrap my head around other people's code at work, printing helps to get both the big picture and the details at the same time, as well as allows me to annotate it with multi-colored pens/highlighters. Maybe I'll reconsider when I have a 300+ dpi desktop surface that is as large as my desk+walls (where those printouts end up). -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: A desperate lunge for on-topic-ness
On Sunday 21 October 2012 07:02:26 Steven D'Aprano did opine: On Sat, 20 Oct 2012 14:18:47 +, Grant Edwards wrote: On 2012-10-20, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: Strangely, we've gone from 80-character fixed width displays to who-knows-what (if I drop my font size I can probably get nearly 200 characters across in full-screen mode)... But at the same time we've gone from 132-character line-printers using fan-fold 11x17 pages, to office inkjet/laser printers using 8.5x11 paper, defaulting to portrait orientation -- with a 10 character/inch font, and 1/4 left/right margins, we're back to 80 character limitation G True, but nobody prints source code out on paper do they? I do. There's nothing better than spreading out a dozen sheets of source code over a table to get a good, high-level overview of what does what in preparation to refactoring it. Seriously -- I can't remember the last time I printed souce code... I've never printed souce code either *wink* So do I, but I often am looking at assembler listings with the assembler set for 132 chars a line to preserve the src codes comments, so lp gets a use 17 cpi option on the cli that makes the listing. I probably recycle 2 reams of paper a year doing exactly that. Those who won't take advantage of that are doomed to publish buggy code. Cheers, Gene -- There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order. -Ed Howdershelt (Author) My web page: http://coyoteden.dyndns-free.com:85/gene is up! Not all men who drink are poets. Some of us drink because we aren't poets. -- http://mail.python.org/mailman/listinfo/python-list
Python 3.3 can't sort memoryviews as they're unorderable
http://docs.python.org/dev/whatsnew/3.3.html states memoryview comparisons now use the logical structure of the operands and compare all array elements by value. So I'd have thought that you should be able to compare them and hence sort them, but this is the state of play. Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. memoryview(bytearray(range(5))) == memoryview(bytearray(range(5))) True memoryview(bytearray(range(5))) != memoryview(bytearray(range(5))) False memoryview(bytearray(range(5))) memoryview(bytearray(range(5))) Traceback (most recent call last): File stdin, line 1, in module TypeError: unorderable types: memoryview() memoryview() Okay then, let's subclass memoryview to provide the functionality. class Test(memoryview): ... pass ... Traceback (most recent call last): File stdin, line 1, in module TypeError: type 'memoryview' is not an acceptable base type Oh dear. http://docs.python.org/py3k/library/stdtypes.html#typememoryview only gives examples of equality comparisons and there was nothing that I could see in PEP3118 to explain the rationale behind the lack of other comparisons. What have I missed? -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: a prob.. error in prog ..dont knw how to correct
: On 21 October 2012 06:09, inshu chauhan insidesh...@gmail.com wrote: I am new to python and have a little problem to solve .. import cv This module is not used in your code [and isn't part of the standard library]. from math import floor, sqrt, ceil You're only using one of these functions. from numpy import array, dot, subtract, add, linalg as lin You're not using any of this. for p in data: x = p[0] y = p[1] z = p[2] You're repeatedly making assignments in this loop, but because your subsequent loop is not nested inside it, only the last iteration of x, y, z will have anything done with them. for i in range(len(data)): Whenever you find yourself writing for i in range(len(seq)): you're doing something wrong. Instead use something like for a, b, c in seq: or, if you really need the index, for i, (a, b, c) in enumerate(seq): dist = sqrt((x[i]-x[i+1])**2 + (y[i]-y[i+1])**2 +(z[i]-z[i+1]**2)) As previously noted, you're going to be repeatedly working with the last values of x, y and z from the previous loop here. In addition, since x, y and z are, according to your traceback, floats, trying to access their members as though they are sequences isn't going to work. return dist This return statement is inside a loop, and will terminate the function the first time it's called. That might not be what you want. def ReadPointCloud(filename): return [tuple(map(float, l.split()[1:4])) for l in open(filename)] Assuming your file is along these lines: p1 1.23 4.56 7.89 p2 9.87 6.54 3.21 ... ReadPointCloud() ought to work. However, it's not very readable - map() is sometimes useful, but usually a list comprehension is clearer. This is better: def ReadPointCloud(filename): Return a list of 3-tuples from ``filename``. # not tested: points = [] with open(filename) as f: for line in f: point = tuple(float(x) for x in l.split()[1:4]) points.append(point) return points def main (data): for i in range(len(data)): # Finding Neighbours for j in range(len(data)): dist = calcdist(data) print dist This will call calcdist() on everything in data, N**2 times [where N is the number of points you're working with]. That's probably not what you want. if __name__ == '__main__': data = ReadPointCloud(r'C:\Thesis\NEHreflectance_Scanner_1_part.txt') Except for throwaway programs, it's not a good idea to hard-code filenames like this. Better: if __name__ == '__main__': import sys data = ReadPointCloud(sys.argv[1]) In summary: copy-pasting code you don't understand and mashing it together randomly is not generally considered an effective development technique. -[]z. -- http://mail.python.org/mailman/listinfo/python-list
Re: A desperate lunge for on-topic-ness
On Sun, Oct 21, 2012 at 9:00 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Er, no. Note spelling of source code vs souce code. Hence the grin. Ahh. I totally didn't see that, I'm way too used to reading past typos. Sure. Printing out *source* code, that's altogether different. Me, though, I don't print anything. Paper and I are not exactly on speaking terms; the last time we met, he cut me, and that's one of the rudest things you can do to someone. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: a prob.. error in prog ..dont knw how to correct
inshu chauhan writes: I am new to python and have a little problem to solve .. i have an array with x, y, z co-ordinates in it as a tuple. I am trying to find the distance between each point and sorting the points according to the min distance.. i have tried a prog but m stuck bcoz of this error which I am unable to correct You don't need help with your program. You need to learn debugging. Your program is excellent material for that. The first main step is to learn how to launch an interactive Python session. Type in some expressions and learn how the interpreter responds. The second main step is to learn how to send/import your program to such an interactive Python session. Then you can call your own functions on your own data and the interpreter's responses will give you information about your own program. import cv from math import floor, sqrt, ceil from numpy import array, dot, subtract, add, linalg as lin Unused? Remove for the duration of the debugging exercise. def calcdist(data): for p in data: x = p[0] y = p[1] z = p[2] for i in range(len(data)): dist = sqrt((x[i]-x[i+1])**2 + (y[i]-y[i+1])**2 +(z[i]-z[i+1]**2)) return dist This is the one you need to call in your debugging session. When you get that far, consider also adding temporary print statements to show what the function is doing. def ReadPointCloud(filename): return [tuple(map(float, l.split()[1:4])) for l in open(filename)] def main (data): for i in range(len(data)): # Finding Neighbours for j in range(len(data)): dist = calcdist(data) print dist Well done separating the main routine as a function - you can also call this in the interpreter. if __name__ == '__main__': data = ReadPointCloud(r'C:\Thesis\NEHreflectance_Scanner_1_part.txt') data = data[0:100] main(data) Consider using a very small constant data set in the script while you are debugging - one, two, three points. (When you get the program working, make the file name a command line parameter, but that can wait.) the error m getting is... Traceback (most recent call last): File C:\Users\inshu\Desktop\cal-dist.py, line 29, in module main(data) File C:\Users\inshu\Desktop\cal-dist.py, line 22, in main dist = calcdist(data) File C:\Users\inshu\Desktop\cal-dist.py, line 11, in calcdist dist = sqrt((x[i]-x[i+1])**2 + (y[i]-y[i+1])**2 +(z[i]-z[i+1]**2)) TypeError: 'float' object has no attribute '__getitem__' Python version would be useful information, along with the information on how you launch your program. (I don't know Microsoft environments, but other people here do.) Consider renaming your program as caldist.py, without the hyphen. I think Python will complain about invalid syntax if you try to import a module named cal-dist. I get a different message when I try to index a float, saying unsubscriptable or not subcscriptable. Regardless, it seems that your program is asking for x[i] where x is a number, and Python cannot make sense of that. (A 'float' is a type of number that lives in a computer and behaves just a little bit like the real numbers of mathematics.) -- http://mail.python.org/mailman/listinfo/python-list
Re: Interest in seeing sh.py in the stdlib
I'm interested in making sh.py more accessible to help bring Python forward in the area of shell scripting, so I'm interested in seeing if sh would be suitable for the standard library. Is there any other interest in something like this? Pretty slick. My only concern is portability, are there other examples of modules (excepting Win32) that work on some platforms and not others? -- http://mail.python.org/mailman/listinfo/python-list
Re: A desperate lunge for on-topic-ness
On 20/10/12 15:18, Grant Edwards wrote: On 2012-10-20, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: Strangely, we've gone from 80-character fixed width displays to who-knows-what (if I drop my font size I can probably get nearly 200 characters across in full-screen mode)... But at the same time we've gone from 132-character line-printers using fan-fold 11x17 pages, to office inkjet/laser printers using 8.5x11 paper, defaulting to portrait orientation -- with a 10 character/inch font, and 1/4 left/right margins, we're back to 80 character limitation G True, but nobody prints source code out on paper do they? I print source code. Usually when the development has got to a stage that the program works but needs a lot of tidying up. It's a lot more comfortable than scrolling up and down screen to look through pages from the comfort of an armchair. Also I can take the listing to a Café and write notes all over it. Sometimes removing the temptation to immediately hit the keyboard is a good thing. -- http://mail.python.org/mailman/listinfo/python-list
RE: Python does not take up available physical memory
I tried this on a different PC with 12 GB RAM. As expected, this time, reading the data was no issue. I noticed that for large files, Python takes up 2.5x size in memory compared to size on disk, for the case when each line in the file is retained as a string within a Python list. As an anecdote, for MATLAB, the similar overhead is 2x, slightly lower than Python, and each line in the file was retained as string within a MATLAB cell. I'm curious, has any one compared the overhead of data in memory for other languages like for instance Ruby? -Original Message- From: Python-list [mailto:python-list-bounces+pradipto.banerjee=adainvestments@python.org] On Behalf Of Steven D'Aprano Sent: Friday, October 19, 2012 6:12 PM To: python-list@python.org Subject: Re: Python does not take up available physical memory On Fri, 19 Oct 2012 14:03:37 -0500, Pradipto Banerjee wrote: Thanks, I tried that. Still got MemoryError, but at least this time python tried to use the physical memory. What I noticed is that before it gave me the error it used up to 1.5GB (of the 2.23 GB originally showed as available) - so in general, python takes up more memory than the size of the file itself. Well of course it does. Once you read the data into memory, it has its own overhead for the object structure. You haven't told us what the file is or how you are reading it. I'm going to assume it is ASCII text and you are using Python 2. py open(test file, w).write(abcde) py os.stat(test file).st_size 5L py text = open(test file, r).read() py len(text) 5 py sys.getsizeof(text) 26 So that confirms that a five byte ASCII string takes up five bytes on disk but 26 bytes in memory as an object. That overhead will depend on what sort of object, whether Unicode or not, the version of Python, and how you read the data. In general, if you have a huge amount of data to work with, you should try to work with it one line at a time: for line in open(some file): process(line) rather than reading the whole file into memory at once: lines = open(some file).readlines() for line in lines: process(line) -- Steven -- http://mail.python.org/mailman/listinfo/python-list This communication is for informational purposes only. It is not intended to be, nor should it be construed or used as, financial, legal, tax or investment advice or an offer to sell, or a solicitation of any offer to buy, an interest in any fund advised by Ada Investment Management LP, the Investment advisor. Any offer or solicitation of an investment in any of the Funds may be made only by delivery of such Funds confidential offering materials to authorized prospective investors. An investment in any of the Funds is not suitable for all investors. No representation is made that the Funds will or are likely to achieve their objectives, or that any investor will or is likely to achieve results comparable to those shown, or will make any profit at all or will be able to avoid incurring substantial losses. Performance results are net of applicable fees, are unaudited and reflect reinvestment of income and profits. Past performance is no guarantee of future results. All financial data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of Ada Investment Management LP and its affiliates. This transmission may contain information that is confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. -- http://mail.python.org/mailman/listinfo/python-list
get each pair from a string.
I am looking for a good way to get every pair from a string. For example, input: x = 'apple' output 'ap' 'pp' 'pl' 'le' I am not seeing a obvious way to do this without multiple for loops, but maybe there is not :-) In the end I am going to what to get triples, quads... also. Thanks Vincent -- http://mail.python.org/mailman/listinfo/python-list
Re: get each pair from a string.
On 10/21/2012 11:33 AM, Vincent Davis wrote: I am looking for a good way to get every pair from a string. For example, input: x = 'apple' output 'ap' 'pp' 'pl' 'le' I am not seeing a obvious way to do this without multiple for loops, but maybe there is not :-) In the end I am going to what to get triples, quads... also. How far have you gotten? Show us the loops you're trying now and any errors you're getting. Emile -- http://mail.python.org/mailman/listinfo/python-list
Re: get each pair from a string.
On Sun, Oct 21, 2012 at 12:33 PM, Vincent Davis vinc...@vincentdavis.net wrote: I am looking for a good way to get every pair from a string. For example, input: x = 'apple' output 'ap' 'pp' 'pl' 'le' I am not seeing a obvious way to do this without multiple for loops, but maybe there is not :-) Use the pairwaise recipe from the itertools docs: def pairwise(iterable): s - (s0,s1), (s1,s2), (s2, s3), ... a, b = tee(iterable) next(b, None) return izip(a, b) In the end I am going to what to get triples, quads... also. Generalizing: def nwise(iterable, n=2): iters = tee(iterable, n) for i, it in enumerate(iters): for _ in range(i): next(it, None) return izip(*iters) -- http://mail.python.org/mailman/listinfo/python-list
Re: get each pair from a string.
@Emile, I feel a little stupid, in my mind it was more difficult than in reality. x = 'apple' for f in range(len(x)-1): print(x[f:f+2]) @Ian, Thanks for that I was just looking in to that. I wonder which is faster I have a large set of strings to process. I'll try some timings if I get a chance later today. Thanks again! Vincent On Mon, Oct 22, 2012 at 12:45 AM, Emile van Sebille em...@fenx.com wrote: On 10/21/2012 11:33 AM, Vincent Davis wrote: I am looking for a good way to get every pair from a string. For example, input: x = 'apple' output 'ap' 'pp' 'pl' 'le' I am not seeing a obvious way to do this without multiple for loops, but maybe there is not :-) In the end I am going to what to get triples, quads... also. How far have you gotten? Show us the loops you're trying now and any errors you're getting. Emile -- http://mail.python.org/**mailman/listinfo/python-listhttp://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: get each pair from a string.
On 21/10/2012 19:33, Vincent Davis wrote: I am looking for a good way to get every pair from a string. For example, input: x = 'apple' output 'ap' 'pp' 'pl' 'le' I am not seeing a obvious way to do this without multiple for loops, but maybe there is not :-) In the end I am going to what to get triples, quads... also. Thanks Vincent I suggest that you try taking slices out of your apple :) Start here http://docs.python.org/tutorial/introduction.html -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: get each pair from a string.
On 10/21/2012 11:51 AM, Ian Kelly wrote: On Sun, Oct 21, 2012 at 12:33 PM, Vincent Davis vinc...@vincentdavis.net wrote: I am looking for a good way to get every pair from a string. For example, input: x = 'apple' output 'ap' 'pp' 'pl' 'le' I am not seeing a obvious way to do this without multiple for loops, but maybe there is not :-) Use the pairwaise recipe from the itertools docs: def pairwise(iterable): s - (s0,s1), (s1,s2), (s2, s3), ... a, b = tee(iterable) next(b, None) return izip(a, b) In the end I am going to what to get triples, quads... also. Generalizing: def nwise(iterable, n=2): iters = tee(iterable, n) for i, it in enumerate(iters): for _ in range(i): next(it, None) return izip(*iters) Hmmm. And it seemed so straightforward to me as: groupsize=3 a = applesauce for i in range(len(a)-groupsize+1): a[i:i+groupsize] ... 'app' 'ppl' 'ple' 'les' 'esa' 'sau' 'auc' 'uce' Other than adding depth to my knowledge of the ever growing standard library, is there a reason to prefer pairwise over my simple loop? Emile -- http://mail.python.org/mailman/listinfo/python-list
Re: get each pair from a string.
On Sun, Oct 21, 2012 at 12:58 PM, Vincent Davis vinc...@vincentdavis.net wrote: x = 'apple' for f in range(len(x)-1): print(x[f:f+2]) @Ian, Thanks for that I was just looking in to that. I wonder which is faster I have a large set of strings to process. I'll try some timings if I get a chance later today. The solution you came up with is probably faster, but less general -- it will only work on sliceable sequences like strings, not arbitrary iterables. -- http://mail.python.org/mailman/listinfo/python-list
Re: A desperate lunge for on-topic-ness
On Sun, 21 Oct 2012 22:43:07 +1100, Chris Angelico wrote: On Sun, Oct 21, 2012 at 9:00 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Er, no. Note spelling of source code vs souce code. Hence the grin. Ahh. I totally didn't see that, I'm way too used to reading past typos. As a programmer, doesn't that screw up your debugging ability? Sure. Printing out *source* code, that's altogether different. Me, though, I don't print anything. Paper and I are not exactly on speaking terms; the last time we met, he cut me, and that's one of the rudest things you can do to someone. Man, you must have deserved it. Paper, he don't just cut anybody. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: A desperate lunge for on-topic-ness
On 2012-10-21, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sun, 21 Oct 2012 22:43:07 +1100, Chris Angelico wrote: On Sun, Oct 21, 2012 at 9:00 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Er, no. Note spelling of source code vs souce code. Hence the grin. Ahh. I totally didn't see that, I'm way too used to reading past typos. As a programmer, doesn't that screw up your debugging ability? Indeed it does. I spent a half hour the other day trying to figure out what was wrong with a line of PHP code, when it was nothing but a mis-spelled variable name. [I've only been working with PHP a short time, but have quickly grown to dislike it.] -- Grant -- http://mail.python.org/mailman/listinfo/python-list
Re: get each pair from a string.
On 10/21/2012 12:06 PM, Ian Kelly wrote: On Sun, Oct 21, 2012 at 12:58 PM, Vincent Davis vinc...@vincentdavis.net wrote: x = 'apple' for f in range(len(x)-1): print(x[f:f+2]) @Ian, Thanks for that I was just looking in to that. I wonder which is faster I have a large set of strings to process. I'll try some timings if I get a chance later today. The solution you came up with is probably faster, but less general -- it will only work on sliceable sequences like strings, not arbitrary iterables. So the simple loop is the right answer for sliceable sequences like strings, but not if your code needs to deal with arbitrary iterables such as those that the standard library authors are expected to handle. So, as OP's a self confessed newbie asking about slicing, why provide an example requiring knowledge of tee, enumerate, next and izip? def nwise(iterable, n=2): iters = tee(iterable, n) for i, it in enumerate(iters): for _ in range(i): next(it, None) return izip(*iters) It's good that the standard library provides these tools as a convenience, but when all you need is a derringer, why reach for a howitzer? Emile -- http://mail.python.org/mailman/listinfo/python-list
Re: A desperate lunge for on-topic-ness
In article k61i2o$63u$1...@reader1.panix.com, Grant Edwards invalid@invalid.invalid wrote: On 2012-10-21, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sun, 21 Oct 2012 22:43:07 +1100, Chris Angelico wrote: On Sun, Oct 21, 2012 at 9:00 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Er, no. Note spelling of source code vs souce code. Hence the grin. Ahh. I totally didn't see that, I'm way too used to reading past typos. As a programmer, doesn't that screw up your debugging ability? Indeed it does. The human brain is amazingly good at real-time error correction. For the most part, this improves communication since it lets people make all sorts of minor errors in both spoken and written language without seriously degrading comprehension. The down-side is that you hear (and read) what you're expecting to hear (or read). This makes us really suck as things like finding typos in variable names. I spent a half hour the other day trying to figure out what was wrong with a line of PHP code, when it was nothing but a mis-spelled variable name. [I've only been working with PHP a short time, but have quickly grown to dislike it.] Of course, the same can happen in Python. I could do: foo = default value if blah == 47: fooo = some other value print foo No syntax error, no NameError, just the wrong thing printing. This does not in any way detract from the fact that PHP is a horrible language. Trust me, if you continue to use it, your dislike for it will only grow. It is truly evil. Have you discovered unexpected T_PAAMAYIM_NEKUDOTAYIM yet? -- http://mail.python.org/mailman/listinfo/python-list
Re: A desperate lunge for on-topic-ness
On Mon, Oct 22, 2012 at 6:11 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sun, 21 Oct 2012 22:43:07 +1100, Chris Angelico wrote: On Sun, Oct 21, 2012 at 9:00 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Er, no. Note spelling of source code vs souce code. Hence the grin. Ahh. I totally didn't see that, I'm way too used to reading past typos. As a programmer, doesn't that screw up your debugging ability? Reading-past-typos applies mainly to English, which is a pretty redundant language. In code, it would only apply to variable names; with (effectively) single words/tokens standing alone, the automatic correction doesn't really apply. But yes, sometimes I have stared at a piece of code for a long time without knowing why there's an error on line X. (This is another good reason to require that all variables be declared, incidentally. I might have a variable called source but not souce, so using the other causes an instant compile-time failure on the exact line with the bug.) And Grant, I agree; PHP does not make life easy. Sure. Printing out *source* code, that's altogether different. Me, though, I don't print anything. Paper and I are not exactly on speaking terms; the last time we met, he cut me, and that's one of the rudest things you can do to someone. Man, you must have deserved it. Paper, he don't just cut anybody. Perhaps. Also, perhaps I've just finished Hell Week and am behaving less than sanely, with a strong tendency to quote/reference Through The Looking Glass. :) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Python does not take up available physical memory
On 22 October 2012 01:14, Pradipto Banerjee pradipto.baner...@adainvestments.com wrote: I tried this on a different PC with 12 GB RAM. As expected, this time, reading the data was no issue. I noticed that for large files, Python takes up 2.5x size in memory compared to size on disk, for the case when each line in the file is retained as a string within a Python list. As an anecdote, for MATLAB, the similar overhead is 2x, slightly lower than Python, and each line in the file was retained as string within a MATLAB cell. I'm curious, has any one compared the overhead of data in memory for other languages like for instance Ruby? What version of Python were you using? 2.7? 3.2? 3.3? If you can, try running the same program in Python 3.3 and compare the amount of memory used and report it here. It sounds like this might be a case that would greatly benefit from the new string representation in 3.3. If you're using Python 3.x then the byte and bytearray types might be of interest to you: http://docs.python.org/py3k/library/stdtypes.html#binary-sequence-types-bytes-bytearray-memoryview Alternatively, the array type might be useful: http://docs.python.org/py3k/library/array.html As to the core problem, I can only echo what others have said - only hold in memory what you absolutely have to. There are various techniques to avoid holding unnecessary data in memory that have been mentioned. One I haven't seen here yet (I may have missed it) is dumping the data into a database of some form and using it's capabilities. Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list
Re: Interest in seeing sh.py in the stdlib
On 2012-10-21 16:59:16 +, Dennis Lee Bieber said: On Sun, 21 Oct 2012 07:41:52 -0600, Jason Friedman ja...@powerpull.net declaimed the following in gmane.comp.python.general: Pretty slick. My only concern is portability, are there other examples of modules (excepting Win32) that work on some platforms and not others? Just scan the library reference and you'll find a number of modules/functions that, even if available on all OS, behave slightly differently (look up mmap, for example; or readline) I was just getting used to it as PBS :-) Other than really liking your lib… I'm not convinced it would be a good candidate for the stdlib, yet. E.g. Not every good lib belongs in the stdlib. That said, if sh.py continues to gain popularity (akin to e.g. requests) I suspect the right people (core developers?) will see it. I'm also curious how that happens, would a PEP be a good place to propose inclusion in the stdlib? -- Alex Clark · https://www.gittip.com/aclark4life/ -- http://mail.python.org/mailman/listinfo/python-list
Re: A desperate lunge for on-topic-ness
On Mon, Oct 22, 2012 at 7:19 AM, Roy Smith r...@panix.com wrote: Of course, the same can happen in Python. I could do: foo = default value if blah == 47: fooo = some other value print foo No syntax error, no NameError, just the wrong thing printing. Yeah, that's the worst kind of bug. No error, just wrong behaviour. This kind of issue is one of the balancing downsides of the freedom of not requiring variable declarations. For small scripts, it's not a problem, and Python and PHP both save you the hassle of explicitly telling the language that you really do know what you're doing, and that's a Good Thing. For large modules, debugging creeps up in significance, and variable declarations are less of a cost. JaCMaScript in use strict mode and a good linter can catch a lot of these sorts of bugs, though it has its own weirdnesses (why does a 'var' statement apply to the whole function regardless of where it is?). C-derived languages with proper block scope have a good chance of catching bugs of this nature at compile time, but at the cost of demanding code that's mainly there to satisfy the compiler (isn't it OBVIOUS that I want this to be an integer? I'm assigning an integer to it!). This does not in any way detract from the fact that PHP is a horrible language. Trust me, if you continue to use it, your dislike for it will only grow. It is truly evil. Have you discovered unexpected T_PAAMAYIM_NEKUDOTAYIM yet? The double-double-dot-in-Hebrew token name isn't actually a bad error; the only problem is the token name itself. If it said unexpected T_SCOPE or something, it'd be easier to debug. Several of PHP's most annoying issues are solved in version 5.4 (array indexing a function call that returns an array now works), but there's still a huge fundamental that's unsolved: Unicode support. Python FTW there, especially now that PEP 393 means strings are as compact as possible. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: get each pair from a string.
On 21 October 2012 19:33, Vincent Davis vinc...@vincentdavis.net wrote: I am looking for a good way to get every pair from a string. For example, input: x = 'apple' output 'ap' 'pp' 'pl' 'le' I am not seeing a obvious way to do this without multiple for loops, but maybe there is not :-) In the end I am going to what to get triples, quads... also. The best way for *sliceable* objects is probably your way. However, not all items can be sliced. One way is this: Let us say you have a string: my_string = abcdefghijklmnopqrstuvwxyz my_string 'abcdefghijklmnopqrstuvwxyz' If you are to zip that, you get a zip object zip(my_string) zip object at 0x1b67f38 So you want to turn it back into a list: list(zip(my_string)) [('a',), ('b',), ('c',), ('d',), ('e',), ('f',), ('g',), ('h',), ('i',), ('j',), ('k',), ('l',), ('m',), ('n',), ('o',), ('p',), ('q',), ('r',), ('s',), ('t',), ('u',), ('v',), ('w',), ('x',), ('y',), ('z',)] So why would you want zip anyway? Let us see what it does with two inputs. list(zip(my_string, my_string)) [('a', 'a'), ('b', 'b'), ('c', 'c'), ('d', 'd'), ('e', 'e'), ('f', 'f'), ('g', 'g'), ('h', 'h'), ('i', 'i'), ('j', 'j'), ('k', 'k'), ('l', 'l'), ('m', 'm'), ('n', 'n'), ('o', 'o'), ('p', 'p'), ('q', 'q'), ('r', 'r'), ('s', 's'), ('t', 't'), ('u', 'u'), ('v', 'v'), ('w', 'w'), ('x', 'x'), ('y', 'y'), ('z', 'z')] I see. It goes over the first and takes an item, then over the second and takes an item, and then puts them together. It then does this for all the items in each. All we want to do is offset the second item: list(zip(my_string, my_string[1:])) [('a', 'b'), ('b', 'c'), ('c', 'd'), ('d', 'e'), ('e', 'f'), ('f', 'g'), ('g', 'h'), ('h', 'i'), ('i', 'j'), ('j', 'k'), ('k', 'l'), ('l', 'm'), ('m', 'n'), ('n', 'o'), ('o', 'p'), ('p', 'q'), ('q', 'r'), ('r', 's'), ('s', 't'), ('t', 'u'), ('u', 'v'), ('v', 'w'), ('w', 'x'), ('x', 'y'), ('y', 'z')] And then convert the results to single strings: [.join(strs) for strs in zip(my_string, my_string[1:])] ['ab', 'bc', 'cd', 'de', 'ef', 'fg', 'gh', 'hi', 'ij', 'jk', 'kl', 'lm', 'mn', 'no', 'op', 'pq', 'qr', 'rs', 'st', 'tu', 'uv', 'vw', 'wx', 'xy', 'yz'] And this can be generalised in a more complicated way: [.join(strs) for strs in zip(*[my_string[n:] for n in range(4)])] ['abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm', 'klmn', 'lmno', 'mnop', 'nopq', 'opqr', 'pqrs', 'qrst', 'rstu', 'stuv', 'tuvw', 'uvwx', 'vwxy', 'wxyz'] Which can work with iterables: from itertools import islice [.join(strs) for strs in zip(*[islice(my_string, n, None) for n in range(4)])] ['abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm', 'klmn', 'lmno', 'mnop', 'nopq', 'opqr', 'pqrs', 'qrst', 'rstu', 'stuv', 'tuvw', 'uvwx', 'vwxy', 'wxyz'] This will be much *faster* for short sequences made from massive strings and much *slower* for long sequences made from medium-sized strings. The first method *slices*, which copies a part of the whole string. This is slow for large copies. The second method* loops until it reaches the start*. This is slow when the start is a long way in. However, if you want to use slice-able items, the best way is the one you've already worked out, as it does no extra copying or looping. -- http://mail.python.org/mailman/listinfo/python-list
Re: A desperate lunge for on-topic-ness
On 21 October 2012 21:38, Chris Angelico ros...@gmail.com wrote: On Mon, Oct 22, 2012 at 7:19 AM, Roy Smith r...@panix.com wrote: Of course, the same can happen in Python. I could do: foo = default value if blah == 47: fooo = some other value print foo No syntax error, no NameError, just the wrong thing printing. Yeah, that's the worst kind of bug. No error, just wrong behaviour. Au contraire, the *worst* kind is code that is wrong that - for now - happens to work... and you have no clue why. This kind of issue is one of the balancing downsides of the freedom of not requiring variable declarations. For small scripts, it's not a problem, and Python and PHP both save you the hassle of explicitly telling the language that you really do know what you're doing, and that's a Good Thing. For large modules, debugging creeps up in significance, and variable declarations are less of a cost. JaCMaScript in use strict mode and a good linter can catch a lot of these sorts of bugs, though it has its own weirdnesses (why does a 'var' statement apply to the whole function regardless of where it is?). C-derived languages with proper block scope have a good chance of catching bugs of this nature at compile time, but at the cost of demanding code that's mainly there to satisfy the compiler (isn't it OBVIOUS that I want this to be an integer? I'm assigning an integer to it!). This does not in any way detract from the fact that PHP is a horrible language. Trust me, if you continue to use it, your dislike for it will only grow. It is truly evil. Have you discovered unexpected T_PAAMAYIM_NEKUDOTAYIM yet? The double-double-dot-in-Hebrew token name isn't actually a bad error; the only problem is the token name itself. If it said unexpected T_SCOPE or something, it'd be easier to debug. Several of PHP's most annoying issues are solved in version 5.4 (array indexing a function call that returns an array now works), but there's still a huge fundamental that's unsolved: Unicode support. Python FTW there, especially now that PEP 393 means strings are as compact as possible. ChrisA -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: get each pair from a string.
2012/10/21 Vincent Davis vinc...@vincentdavis.net: I am looking for a good way to get every pair from a string. For example, input: x = 'apple' output 'ap' 'pp' 'pl' 'le' I am not seeing a obvious way to do this without multiple for loops, but maybe there is not :-) In the end I am going to what to get triples, quads... also. Thanks Vincent -- http://mail.python.org/mailman/listinfo/python-list Hi, just another - probably less canonical - approach using the new regex library could be (assuming the input sequence is always a string): import regex # http://pypi.python.org/pypi/regex regex.findall(.., abcdefghijklm, overlapped=True) ['ab', 'bc', 'cd', 'de', 'ef', 'fg', 'gh', 'hi', 'ij', 'jk', 'kl', 'lm'] regex.findall(..., abcdefghijklm, overlapped=True) ['abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm'] If the newline \n could appear in the text, an appropriate pattern would be e.g. (?s)... regards, vbr -- http://mail.python.org/mailman/listinfo/python-list
Re: A desperate lunge for on-topic-ness
On Sat, 20 Oct 2012 16:37:23 -0400, Roy Smith wrote: sys.stderr.write(Error: Can't find the file 'settings.py' in the directory containing %r.\nYou'll have to run django-profile.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n % __file__) textwrap.dedent? -- http://mail.python.org/mailman/listinfo/python-list
Recursive Generator Error?
I have a tree-like data structure, the basic elements are hash tables, and they are grouped into lists, like [[{'a':1},[{'b':2}]]]. And I want to flat the lists and visit hash table one by one, like {'a':1}, {'b':2}. But my program didn't work as I wish. When it entered the 2nd flat_yield, it threw a GeneratorExit. Is there anything wrong? Thank you very much! #- - - - - - - - - - def flat_yield(tbl_list): for t in tbl_list: if type(t) == type({}): yield t elif type(t) == type([]): flat_yield(t) a = [[{'a':1},[{'b':2}]]] for i in flat_yield(a): print i -- http://mail.python.org/mailman/listinfo/python-list
Re: Recursive Generator Error?
On 10/21/2012 7:29 PM, David wrote: I have a tree-like data structure, the basic elements are hash tables, and they are grouped into lists, like [[{'a':1},[{'b':2}]]]. And I want to flat the lists and visit hash table one by one, like {'a':1}, {'b':2}. But my program didn't work as I wish. When it entered the 2nd flat_yield, it threw a GeneratorExit. Is there anything wrong? 1. The Python version is not specified. 2. You used 2.x; in 3.3 the code does exactly what I would expect, which is to say, nothing. No output, no error, no traceback ;-) 3. The traceback is missing from this post. #- - - - - - - - - - def flat_yield(tbl_list): for t in tbl_list: if type(t) == type({}): yield t elif type(t) == type([]): flat_yield(t) 4. Think harder about what that expression does. a = [[{'a':1},[{'b':2}]]] for i in flat_yield(a): print i Hint: it calls flat_yield, which returns a generator, which is then discarded. You might have well written 'pass'. Solution: use the recursively called generator and recursively yield what it yields. Replace 'flat_yield(t)' with for item in flat_yield(t): yield item and the output is what you want. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
program loaded in memory
Hello, I need an advice about a small script I run 24/24 7/7. It's a script converted to EXE using py2exe and this script takes - grows 30kb RAM on each loop which means that for 10hours it grows up with 180mb memory. is there something I can do ? From the ini file I'm loading only the URL and the interval of downloading the file The script: import time import urllib exec(open(iccm.ini).read()) loop = 0 while loop == 0: time.sleep(interval*60) try: urllib.urlretrieve (''URL''+/hours.xml, c:\\config\\hours.xml) except IOError: pass Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: program loaded in memory
On 10/21/2012 08:02 PM, Anatoli Hristov wrote: Hello, I need an advice about a small script I run 24/24 7/7. It's a script converted to EXE using py2exe and this script takes - grows 30kb RAM on each loop which means that for 10hours it grows up with 180mb memory. is there something I can do ? From the ini file I'm loading only the URL and the interval of downloading the file The script: import time import urllib exec(open(iccm.ini).read()) This line doesn't do anything useful. And I would start by eliminating the exec() call. loop = 0 while loop == 0: Since nothing ever modifies loop, you should just make it while True: time.sleep(interval*60) NameError: name 'interval' is not defined try: urllib.urlretrieve (''URL''+/hours.xml, c:\\config\\hours.xml) SyntaxError: invalid syntax except IOError: pass Thanks Please post the actual code you're running, as well as the Python version. Also, explain how you decided that it grows by 30kb each loop. You also should try the same code without py2exe; see if it runs any differently. The two errors I show are from Python 2.7. Naturally, if you post an error, you should give the full traceback. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: get each pair from a string.
@vbr Thats interesting. I would never have come up with that. Vincent On Sun, Oct 21, 2012 at 3:48 PM, Vlastimil Brom vlastimil.b...@gmail.comwrote: vbr -- http://mail.python.org/mailman/listinfo/python-list
Re: program loaded in memory
Yes sorry, the name var(interval) is loaded from the ini file and also the Url. The reason is that the ini file will be configured from someone else. Example of the file URL = www # define your url interval = 1 # minutes for sync I see in the task manager each time it downloads the file that it grows up with 30kb. And I'm using Python 2.7 on windows 7 Thanks On 22 Oct 2012, at 02:21, Dave Angel d...@davea.name wrote: On 10/21/2012 08:02 PM, Anatoli Hristov wrote: Hello, I need an advice about a small script I run 24/24 7/7. It's a script converted to EXE using py2exe and this script takes - grows 30kb RAM on each loop which means that for 10hours it grows up with 180mb memory. is there something I can do ? From the ini file I'm loading only the URL and the interval of downloading the file The script: import time import urllib exec(open(iccm.ini).read()) This line doesn't do anything useful. And I would start by eliminating the exec() call. loop = 0 while loop == 0: Since nothing ever modifies loop, you should just make it while True: time.sleep(interval*60) NameError: name 'interval' is not defined try: urllib.urlretrieve (''URL''+/hours.xml, c:\\config\\hours.xml) SyntaxError: invalid syntax except IOError: pass Thanks Please post the actual code you're running, as well as the Python version. Also, explain how you decided that it grows by 30kb each loop. You also should try the same code without py2exe; see if it runs any differently. The two errors I show are from Python 2.7. Naturally, if you post an error, you should give the full traceback. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: get each pair from a string.
To All, I appreciate the range of answers and the time each of you take to think about and answer my question. Whether or not I use them I find them all educational. Thanks again. Vincent On Mon, Oct 22, 2012 at 2:03 AM, Emile van Sebille em...@fenx.com wrote: On 10/21/2012 12:06 PM, Ian Kelly wrote: On Sun, Oct 21, 2012 at 12:58 PM, Vincent Davis vinc...@vincentdavis.net wrote: x = 'apple' for f in range(len(x)-1): print(x[f:f+2]) @Ian, Thanks for that I was just looking in to that. I wonder which is faster I have a large set of strings to process. I'll try some timings if I get a chance later today. The solution you came up with is probably faster, but less general -- it will only work on sliceable sequences like strings, not arbitrary iterables. So the simple loop is the right answer for sliceable sequences like strings, but not if your code needs to deal with arbitrary iterables such as those that the standard library authors are expected to handle. So, as OP's a self confessed newbie asking about slicing, why provide an example requiring knowledge of tee, enumerate, next and izip? def nwise(iterable, n=2): iters = tee(iterable, n) for i, it in enumerate(iters): for _ in range(i): next(it, None) return izip(*iters) It's good that the standard library provides these tools as a convenience, but when all you need is a derringer, why reach for a howitzer? Emile -- http://mail.python.org/**mailman/listinfo/python-listhttp://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Recursive Generator Error?
On Monday, October 22, 2012 7:59:53 AM UTC+8, Terry Reedy wrote: On 10/21/2012 7:29 PM, David wrote: I have a tree-like data structure, the basic elements are hash tables, and they are grouped into lists, like [[{'a':1},[{'b':2}]]]. And I want to flat the lists and visit hash table one by one, like {'a':1}, {'b':2}. But my program didn't work as I wish. When it entered the 2nd flat_yield, it threw a GeneratorExit. Is there anything wrong? 1. The Python version is not specified. 2. You used 2.x; in 3.3 the code does exactly what I would expect, which is to say, nothing. No output, no error, no traceback ;-) 3. The traceback is missing from this post. #- - - - - - - - - - def flat_yield(tbl_list): for t in tbl_list: if type(t) == type({}): yield t elif type(t) == type([]): flat_yield(t) 4. Think harder about what that expression does. a = [[{'a':1},[{'b':2}]]] for i in flat_yield(a): print i Hint: it calls flat_yield, which returns a generator, which is then discarded. You might have well written 'pass'. Solution: use the recursively called generator and recursively yield what it yields. Replace 'flat_yield(t)' with for item in flat_yield(t): yield item and the output is what you want. -- Terry Jan Reedy Hi Terry, thank you! I use Python 2.7, and your solution works! I have thought harder, still not very clear. If I have one yield in function, the function will become generator, and it can only be called in the form like for item in function() or function.next(), and call the function directly will raise error, is it right? -- http://mail.python.org/mailman/listinfo/python-list
Re: program loaded in memory
On 10/21/2012 08:31 PM, Anatoli Hristov wrote: Yes sorry, the name var(interval) is loaded from the ini file and also the Url. The reason is that the ini file will be configured from someone else. Example of the file URL = www # define your url interval = 1 # minutes for sync I see in the task manager each time it downloads the file that it grows up with 30kb. And I'm using Python 2.7 on windows 7 Thanks So now, that eliminates one of the errors. (Though import is much more reasonable than exec(), and some config parser is better yet) To fix the syntax error, you need + signs before and after the variable URL -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Recursive Generator Error?
On Sun, 21 Oct 2012 17:40:41 -0700, David wrote: If I have one yield in function, the function will become generator, Almost correct. The function becomes a *generator function*, that is, a function that returns a generator object. Sometimes people abbreviate that to generator, but that is ambiguous -- the term generator can mean either the function which includes yield in it, or the object that is returned. and it can only be called in the form like for item in function() or function.next(), and call the function directly will raise error, is it right? You can call the function directly, and it will return an generator object. You don't have to iterate over that generator object, although you normally will. Example: py def test(): ... yield 42 ... py test function test at 0xb7425764 py type(test) type 'function' py x = test() py x generator object test at 0xb71d4874 py type(x) type 'generator' -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Preventing crap email from google?
Grant Edwards invalid@invalid.invalid writes: Posts made via the google-groups web site are a problem, and I plonked them all years and years ago... Walter Hurry walterhu...@lavabit.com writes: It is Google bloody Groups which is the problem. I should have plonked posts from there ages ago, and am about to remedy that omission. What narrowly-defined, precise filter rule should be used for this purpose? -- \ “Nothing is more sacred than the facts.” —Sam Harris, _The End | `\ of Faith_, 2004 | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: get each pair from a string.
On 22/10/12 09:03, Emile van Sebille wrote: So, as OP's a self confessed newbie asking about slicing, why provide an example requiring knowledge of tee, enumerate, next and izip? Because not only the newbie will read the thread? I for one was interested to see all the different possible approaches, and their upsides and downsides. Ian -- http://mail.python.org/mailman/listinfo/python-list
[issue15853] IDLE crashes selecting Preferences menu with OS X ActiveState Tcl/Tk 8.5.12.1
Pedro Meirelles added the comment: Hello, I am biologist I am just starting to learn Python. I have a mac and I am using OS X 10.8.2. I have installed Python 2.7.3 and when I try to copy and paste (use command) or go to preferences IDLE crashes. I did what Ned Deily said in msg169739: sudo mv /Library/Frameworks/Tk.framework /Library/Frameworks/Tk_disabled It worked. Now I can copy and paste in IDLE. But when I type quots ( or ') it crashes. What you think I can do to work in IDLE using both command and typing and '? Sorry if my question is too elementary. I appreciate a lot all the comments and answers. It is very useful and enlightening. Kind regards -- nosy: +pedrommeirelles ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15853 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15853] IDLE crashes selecting Preferences menu with OS X ActiveState Tcl/Tk 8.5.12.1
Ned Deily added the comment: Pedro, try installing the older ActiveTcl 8.5.11.1 from here: http://downloads.activestate.com/ActiveTcl/releases/8.5.11.1/ It is not perfect but does not have the Preferences regression and does have fixes for crashes when typing composite input characters. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15853 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15853] IDLE crashes selecting Preferences menu with OS X ActiveState Tcl/Tk 8.5.12.1
Pedro Meirelles added the comment: Thank you very much, Ned! It worked, awesome! All the best 2012/10/20 Ned Deily rep...@bugs.python.org Ned Deily added the comment: Pedro, try installing the older ActiveTcl 8.5.11.1 from here: http://downloads.activestate.com/ActiveTcl/releases/8.5.11.1/ It is not perfect but does not have the Preferences regression and does have fixes for crashes when typing composite input characters. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15853 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15853 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10836] urllib.request.urlretrieve calls URLError with 3 args
Senthil Kumaran added the comment: Here is the patch which captures both HTTPError and URLError at the open_file and thus preventing multiple exceptions to be raised ( URLError and next IOError). This can go in 3.4 and since this is bug, where correct exception is not being caught and wrong args are sent, I think the catching of correct exception can be backported to old versions -- Added file: http://bugs.python.org/file27646/issue10836.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10836 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16284] concurrent.futures ThreadPoolExecutor keeps unnecessary references to worker functions.
Brian Quinlan added the comment: The concurrent.futures stuff looks good to me. Could you add a comment explaining why the delete is necessary? And, as Antoine said, the test should be CPython only. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16284 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15966] concurrent.futures: Executor.submit keyword arguments may not be called 'fn' (or 'self')
Brian Quinlan added the comment: This has come up before. Did you actually bang into this? Because the fix seems pretty ugly to me and the work-around (using functools.partial) is pretty easy. But, if people are actually hitting this, then your is probably the best that we can do. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15966 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13785] Make concurrent.futures.Future state public
Changes by Brian Quinlan br...@sweetapp.com: -- stage: - needs patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13785 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8792] Support Apache extensions to XML-RPC in xmlrpclib
Brian Quinlan added the comment: I'm closing this since the filer hasn't specified exactly what they want. -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8792 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11271] concurrent.futures.ProcessPoolExecutor.map() doesn't batch function arguments by chunks
Changes by Brian Quinlan br...@sweetapp.com: -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11271 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15772] Unresolved symbols in Windows 64-bit python
Silverback Networks added the comment: Boy, do I feel like an idiot now. An update to VC 2010 Express SP1 had clobbered by x64 build capabilities completely, and even reinstalling the SDK did nothing. It turns out that there's a specific hotfix you have to install to get x64 builds working again: http://support.microsoft.com/kb/2519277 When I did that and fixed up the build environment variables, Python extensions all built again, despite the apparently random decorating. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15772 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15522] improve 27 percent performance on stringpbject.c (by prefetch and loop optimization)
Antoine Pitrou added the comment: I'm closing this issue, since the OP since to have lost interest in his/her proposal. Abael, if you want to propose an actual patch, please open a new issue. -- resolution: - rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15522 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16293] curses.ungetch raises OverflowError when given -1
STINNER Victor added the comment: Do you consider this behaviour as a bug? What is the behaviour in C? Le 21 oct. 2012 03:25, Julian Berman rep...@bugs.python.org a écrit : New submission from Julian Berman: The following code now raises an OverflowError on 3.3: import curses def test_screen(screen): screen.nodelay(True) key = screen.getch() screen.nodelay(False) curses.ungetch(key) curses.wrapper(test_screen) or equivalently just def test_screen(screen): curses.ungetch(-1) -- components: Library (Lib) messages: 173425 nosy: Julian, haypo priority: normal severity: normal status: open title: curses.ungetch raises OverflowError when given -1 versions: Python 3.3, Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16293 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16293 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6074] .pyc files created readonly if .py file is readonly, python won't overwrite
Kevin Chen added the comment: Okay just tried it. This is under Windows 7 x64. I created a .py file with read-only permission. When I import the .py module, the created .pyc doesn't have read-only permission. So it works as intended under Windows OS. As long as under posix system the created .pyc files have the same permissions as the .py file, then everything is good. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6074 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16220] wsgiref does not call close() on iterable response
Roundup Robot added the comment: New changeset d5af1b235dab by Antoine Pitrou in branch '2.7': Issue #16220: wsgiref now always calls close() on an iterable response. http://hg.python.org/cpython/rev/d5af1b235dab -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16220 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16294] 8 space indent in tutorial
New submission from Yongzhi Pan: http://docs.python.org/py3k/tutorial/stdlib2.html#weak-references In the code example, the two class funtions' bodies have indents of 8 spaces. All other indents in the docs are 4 spaces. I suggest here we use 4 spaces also. -- assignee: docs@python components: Documentation messages: 173443 nosy: docs@python, fossilet priority: normal severity: normal status: open title: 8 space indent in tutorial type: enhancement versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16294 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16291] Fix some general cross compile issues and some darwin specific ones. Tested with build=linux, host=darwin
Changes by Ray Donnelly mingw.andr...@gmail.com: Removed file: http://bugs.python.org/file27641/0010-DARWIN-CROSS.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16291 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16291] Enable darwin-host cross compilation. Tested with build=linux, host=darwin
Ray Donnelly added the comment: Here's the darwin cross enabling portion. I've also removed the warnings fixes from it as they're not relevant. -- title: Fix some general cross compile issues and some darwin specific ones. Tested with build=linux, host=darwin - Enable darwin-host cross compilation. Tested with build=linux, host=darwin Added file: http://bugs.python.org/file27647/0010-cross-darwin-feature.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16291 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16220] wsgiref does not call close() on iterable response
Roundup Robot added the comment: New changeset eef470032457 by Antoine Pitrou in branch '3.2': Issue #16220: wsgiref now always calls close() on an iterable response. http://hg.python.org/cpython/rev/eef470032457 New changeset 2530acc092d8 by Antoine Pitrou in branch '3.3': Issue #16220: wsgiref now always calls close() on an iterable response. http://hg.python.org/cpython/rev/2530acc092d8 New changeset cf3a739345c6 by Antoine Pitrou in branch 'default': Issue #16220: wsgiref now always calls close() on an iterable response. http://hg.python.org/cpython/rev/cf3a739345c6 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16220 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16220] wsgiref does not call close() on iterable response
Antoine Pitrou added the comment: Your patch is now committed, Brent, thank you! -- resolution: - fixed stage: needs patch - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16220 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1598083] Top-level exception handler writes to stdout unsafely
Antoine Pitrou added the comment: This is certainly a low-priority issue, as it will almost never happen in practice. -- nosy: +pitrou priority: high - low stage: test needed - needs patch versions: +Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1598083 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6074] .pyc files created readonly if .py file is readonly, python won't overwrite
Changes by desolat nuabara...@web.de: -- nosy: -desolat ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6074 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16292] Cross compilation fixes (general)
Roumen Petrov added the comment: duplicate with 15483 and 15484 -- nosy: +rpetrov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16292 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16293] curses.ungetch raises OverflowError when given -1
Julian Berman added the comment: Hi, sorry for being terse :). After checking a bit, man 3 getch says that it returns ERR (-1) in non-blocking mode if no input is available. I think you're right though -- calling ungetch without checking for the error value seems like it should be a bug in the application, and looking at some examples that seems to be correct. The reason this came up though is because the changes to range checking broke bpython, which does something like the code I pasted in the first post. The reason it appears to have worked before is because later on getkey is called, and getkey checks if it got ERR and converts that to an exception, which was being caught and silenced. Now though, the code will fail at the call to ungetch. So, I guess, besides the change in behavior, which I guess is less bug prone before so it's probably desirable, OverflowError sounds scary. Perhaps ungetch should check for -1 and raise a curses.error instead? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16293 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5128] compileall: consider ctime
Brett Cannon added the comment: There is no patch, Djoume, but honestly that's fine since if you want to submit a change to something it should go in a new issue. But honestly compileall needs to be rewritten in Python 3.4 to use importlib and have it control when source code should be rebuilt since the .pyc format changed in Python 3.3 to include source file size. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5128 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12034] check_GetFinalPathNameByHandle() suboptimal
Roundup Robot added the comment: New changeset 8afa3ce5ff3e by Antoine Pitrou in branch 'default': Issue #12034: Fix bogus caching of result in check_GetFinalPathNameByHandle. http://hg.python.org/cpython/rev/8afa3ce5ff3e -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12034] check_GetFinalPathNameByHandle() suboptimal
Antoine Pitrou added the comment: Patch committed, thank you! -- resolution: - fixed stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16034] bz2 module appears slower in Python 3.x versus Python 2.x
Roundup Robot added the comment: New changeset cc02eca14526 by Nadeem Vawda in branch 'default': Issue #16034 follow-up: Apply optimizations to the lzma module. http://hg.python.org/cpython/rev/cc02eca14526 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16264] test_logging failure on Windows 7 buildbot
Roundup Robot added the comment: New changeset 0fb2267897ba by Antoine Pitrou in branch 'default': Try to fix issue #16264 (test_logging failure on some buildbots). http://hg.python.org/cpython/rev/0fb2267897ba -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16264 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14621] Hash function is not randomized properly
Armin Rigo added the comment: Just to make it extra clear: Vlado showed that the -R switch of Python can easily be made fully pointless, with only a bit of extra work. Here is how: * Assume you have an algo that gives you as many strings with colliding hashes as you want, provided you know the last 8 bits of the secret prefix. * Say you want to attack a web server. You send it 256 requests, each with 100 strings that have identical hash for one of the 256 possible values. You measure which one is significantly slower than the others. * From there you are back in the original situation: you know which of the 256 values to pick, so you can make the web server crawl by sending it a large number of strings that have identical hashes for this particular value. It's interesting to note how this whole -R discussion made very long threads on python-dev, and python-dev has subsequently ignored (for the past 6 months!) the fact that their fix can be worked around in a matter of minutes. (For information, I'm sure that if the algorithm is improved to depend on all 32 or 64 bits of the prefix, it would still be easy to crack it. You don't actually need to send 2**32 or 2**64 requests to the web server: with careful design you can send only 32 or 64 requests that each leak one bit of information. Doing that requires a bit more research, but once the recipe is known, it can be freely reused, which seems to defeat the original point.) -- nosy: +arigo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14621 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16264] test_logging failure on Windows 7 buildbot
Antoine Pitrou added the comment: Looks ok now. It's a timing glitch because both SocketHandler's built-in timeout and its default retry delay are one second, so when connect times out once the next retry time is a bit behind time.time(). (note: SocketHandler's implementation looks grotesque. Enough said). -- resolution: - fixed stage: needs patch - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16264 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14621] Hash function is not randomized properly
Armin Rigo added the comment: For reference, the above means that we can implement -R support for PyPy as a dummy ignored flag, and get security that is very close to CPython's. :-) -- keywords: +easy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14621 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14621] Hash function is not randomized properly
Benjamin Peterson added the comment: That doesn't make it any easy CPython issue. :) -- keywords: -easy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14621 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12692] test_urllib2net is triggering a ResourceWarning
Roundup Robot added the comment: New changeset 92656b5df2f2 by Nadeem Vawda in branch 'default': Issue #12692: Fix resource leak in urllib.request. http://hg.python.org/cpython/rev/92656b5df2f2 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12692 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12692] test_urllib2net is triggering a ResourceWarning
Changes by Nadeem Vawda nadeem.va...@gmail.com: -- resolution: - fixed stage: needs patch - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12692 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5148] gzip.open breaks with 'U' flag
Roundup Robot added the comment: New changeset e647229c422b by Nadeem Vawda in branch '2.7': Issue #5148: Ignore 'U' in mode given to gzip.open() and gzip.GzipFile(). http://hg.python.org/cpython/rev/e647229c422b -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5148 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14621] Hash function is not randomized properly
Christian Heimes added the comment: As far as my understanding goes the issue can't be solved with our current hash algorithm. We'd have to use a crypto hash function or at least a hash algorithm that has an increased avalanche effect on the outcome. The current hash algorithm is designed and optimized for speed and not for security. Any other algorithm is going to slow down hashing. Small strings and strings with lots of NUL bytes may leak too many information, too. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14621 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5148] gzip.open breaks with 'U' flag
Nadeem Vawda added the comment: The data corruption issue is now fixed in the 2.7 branch. In 3.x, using a mode containing 'U' results in an exception rather than silent data corruption. Additionally, gzip.open() has supported text modes (rt/wt/at) and newline translation since 3.3 [issue 13989]. -- resolution: - fixed stage: patch review - committed/rejected status: open - closed versions: +Python 2.7 -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5148 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16230] select.select crashes on resized lists
Changes by Serhiy Storchaka storch...@gmail.com: -- keywords: +needs review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16230 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16228] JSON crashes during encoding resized lists
Changes by Serhiy Storchaka storch...@gmail.com: -- keywords: +needs review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16228 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16295] With VS2010 the select extension links against wsock32 instead of ws2_32
New submission from Richard Oudkerk: Using VS2010 _socket links against ws2_32.lib but select links against wsock32.lib. Using VS2008 both extensions link against ws2_32.lib. It appears that the conversion to VS2010 caused the regression. (Compare #10295 and #11750.) -- messages: 173463 nosy: kristjan.jonsson, sbt priority: normal severity: normal stage: needs patch status: open title: With VS2010 the select extension links against wsock32 instead of ws2_32 type: resource usage versions: Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16295 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16288] TextTestResult uses TestCase.__str__() which isn't customisable (vs id() or shortDescription())
Changes by Michael Foord mich...@voidspace.org.uk: -- assignee: - michael.foord ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16288 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16296] Patch to fix building on Win32/64 under VS 2010
New submission from Silverback Networks: Once I got my broken environment fixed, this was the only thing that didn't work. The bug is that VS 2010 no longer creates a manifest by default, despite the documentation, and there are confirmation posts around the internet. /Manifest has to be forced starting with VS 2010. Here is a patch to fix that: --- Lib/distutils/msvc9compiler.py2011-08-14 11:17:42.0 -0700 +++ Lib/distutils/msvc9compiler.py2012-10-21 10:38:42.257682200 -0700 @@ -411,10 +411,16 @@ '/Z7', '/D_DEBUG'] self.ldflags_shared = ['/DLL', '/nologo', '/INCREMENTAL:NO'] +if self.__version = 10: +self.ldflags_shared = ['/DLL', '/nologo', '/INCREMENTAL:NO', '/Manifest'] if self.__version = 7: self.ldflags_shared_debug = [ '/DLL', '/nologo', '/INCREMENTAL:no', '/DEBUG', '/pdb:None' ] +if self.__version = 10: +self.ldflags_shared = [ +'/DLL', '/nologo', '/INCREMENTAL:NO', '/DEBUG', '/pdb:None', '/Manifest' +] self.ldflags_static = [ '/nologo'] self.initialized = True -- components: Build messages: 173464 nosy: silverbacknet priority: normal severity: normal status: open title: Patch to fix building on Win32/64 under VS 2010 type: compile error versions: Python 3.1, Python 3.2, Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16296 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16296] Patch to fix building on Win32/64 under VS 2010
Silverback Networks added the comment: oops, add _debug on the second part of the patch. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16296 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16296] Patch to fix building on Win32/64 under VS 2010
Christian Heimes added the comment: Can you please upload a proper patch files? It makes code review and applying the patch easier for us. -- components: +Windows keywords: +3.3regression nosy: +christian.heimes stage: - patch review versions: -Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16296 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16288] TextTestResult uses TestCase.__str__() which isn't customisable (vs id() or shortDescription())
Robert Collins added the comment: testscenarios copies the tests, it doesn't call the constructor for the class; this makes things a lot simpler than trying to reconstruct whatever state the object may have from scratch again. As for str(test) and test.id() being different - well sure they are today, but I don't know that the str(test) format is /useful/ today, as its not a particularly good str() anyhow. It doesn't identify that its a test instance even. This suggests two alternatives to me: - decide that we want three things: id, friendly-id and shortDescription, and have three non-magic methods, which TextTestRunner can call depending on what the user wants to see. - decide we want two things, id and shortDescription, and TextTestRunner can combine these things to meet the users request. (e.g. id + ' ' + shortDescription) And separately, as the __str__ isn't particularly good anyhow, perhaps we should take the opportunity to think about what we want from it and adjust it. -- type: enhancement - ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16288 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16288] TextTestResult uses TestCase.__str__() which isn't customisable (vs id() or shortDescription())
Changes by Mike Hoy mho...@gmail.com: -- nosy: -mikehoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16288 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16288] TextTestResult uses TestCase.__str__() which isn't customisable (vs id() or shortDescription())
Michael Foord added the comment: So three including str sounds sufficient to me: short description, long description and repr (with str == repr) for debugging. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16288 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16296] Patch to fix building on Win32/64 under VS 2010
Silverback Networks added the comment: Sure. I got this patch from Mercurial, just in case, but it looks the same. -- keywords: +patch Added file: http://bugs.python.org/file27648/msvc9manifest.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16296 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16296] Patch to fix building on Win32/64 under VS 2010
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +brian.curtin, loewis, tim.golden ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16296 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16154] Some minor doc fixes in Doc/library
Changes by Ravi Sinha rss1...@gmail.com: Added file: http://bugs.python.org/file27649/27.doc_lib_Oct21_2012.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16154 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16154] Some minor doc fixes in Doc/library
Changes by Ravi Sinha rss1...@gmail.com: Added file: http://bugs.python.org/file27650/32.doc_lib_Oct21_2012.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16154 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16154] Some minor doc fixes in Doc/library
Changes by Ravi Sinha rss1...@gmail.com: Added file: http://bugs.python.org/file27651/33.doc_lib_Oct21_2012.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16154 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16154] Some minor doc fixes in Doc/library
Ravi Sinha added the comment: Based on what I saw on some other issues, I think there is just a separate patch for each version (coming from separate working repositories), but all attached to the same issue. So I am doing the same. All the changes have been made to files under Doc/library/ - colorsys.rst, filecmp.rst, fractions.rst, math.rst, string.rst and Misc/ACKS. The beginning number for each patch and the description show which version it's meant for. There are some minor differences for 2.7 and 3.2; they either did not need a fix or needed some more tests to be skipped. For 2.7 and 3.2 I don't know how to use the online source browser to link the files directly. Please let me know if the patches are okay or how to go from here. Thanks. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16154 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14398] bz2.BZ2DEcompressor.decompress fail on large files
Roundup Robot added the comment: New changeset ebb8c7d79f52 by Nadeem Vawda in branch '3.2': Issue #14398: Fix size truncation and overflow bugs in bz2 module. http://hg.python.org/cpython/rev/ebb8c7d79f52 New changeset 25fdf297c077 by Nadeem Vawda in branch '3.3': Merge #14398: Fix size truncation and overflow bugs in bz2 module. http://hg.python.org/cpython/rev/25fdf297c077 New changeset d6bf506ea13f by Nadeem Vawda in branch 'default': Merge #14398: Fix size truncation and overflow bugs in bz2 module. http://hg.python.org/cpython/rev/d6bf506ea13f -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14398 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com