Re: Lists
Am 15.09.14 04:40, schrieb Seymore4Head: nums=range(1,11) print (nums) I don't understand why the command nums=range(1,11) doesn't work. I would think that print(nums) should be 1,2,3 ect. Instead it prints range(1,11) It does work, but in a different way than you might think. range() does not return a list of numbers, but rather a generator - that is an object which produces the values one after another. But you can transform it into a list: print(list(nums)) should give you what you want. Christian -- https://mail.python.org/mailman/listinfo/python-list
Re: Lists
Seymore4Head wrote: import random nums=range(1,11) print (nums) samp=random.sample(nums,10) top=nums newlist=nums[::-1] tail=newlist for x in range(10): print (Top {:2d}Tail {:2.0f} Sample {:2d} .format(top[x],tail[x],samp[x])) I don't understand why the command nums=range(1,11) doesn't work. Of course it works. It does exactly what you told it to do: set the variable nums to the result of calling range(1, 11). The only question is, what does range(1, 11) do? I would think that print(nums) should be 1,2,3 ect. Instead it prints range(1,11) Did you read the documentation for range? py help(range) class range(object) | range([start,] stop[, step]) - range object | | Returns a virtual sequence of numbers from start to stop by step. [...] range in Python 3 does not return a list. It returns a special object which provides a sequence of numbers, but without actually storing them all in a list. Why does random.sample(nums,10) give me the numbers between 1 and 10. What did you expect it to do? Did you read the documentation? py import random py help(random.sample) Help on method sample in module random: sample(self, population, k) method of random.Random instance Chooses k unique random elements from a population sequence or set. [...] To choose a sample in a range of integers, use range as an argument. This is especially fast and space efficient for sampling from a large population: sample(range(1000), 60) The docs even tell you that (1) sample supports range objects, and (2) using range is more efficient than lists. I am missing something subtle again. range objects behave *like* lists when you index them: py nums = range(1, 100) py nums[0] # First item. 1 py nums[-1] # Last item. 99 They're even smart enough that you can take a slice, and they give you a new range object: py nums[1:10] range(2, 11) When you iterate over them, you get each item in turn: py for i in range(1, 4): ... print(i) ... 1 2 3 range objects are more efficient than lists if the numbers follow the right sort of pattern. While a list can contain any values you like, in any order: py nums = [1, 33, 5, 222, 4, 6, 0, 888, 7] range objects are limited to a linear sequence of: start, start+step, start+2*step, start+3*step, ... up to some end value. The reason range is more efficient is that, unlike lists, it doesn't need to pre-populate all the values required, it can calculate them on the fly when and as required. The reason why lists are more flexible is that the values don't have to be calculated as needed, they can just be stored, ready to use. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Lists
Christian Gollwitzer wrote: range() does not return a list of numbers, but rather a generator Technically, it's not a generator. It's a range object. Generators can return anything, and you have to program them by using yield: def gen(): yield 1 yield 2 if today() is Tuesday: yield 99 yield 3 whereas range() objects are much more specific in what they can do. But otherwise, they behave in a similar fashion. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: CSV methodology
je...@newsguy.com writes: Hello. Back in the '80s, I wrote a fractal generator, which, over the years, I've modified/etc to run under Windows. I've been an Assembly Language programmer for decades. Recently, I decided to learn a new language, and decided on Python, and I just love it, and the various IDEs. Anyway, something I thought would be interesting, would be to export some data from my fractal program (I call it MXP), and write something in Python and its various scientific data analysis and plotting modules, and... well, see what's in there. Tools that are worth mentioning: ipython notebook, pandas For example, http://nbviewer.ipython.org/github/twiecki/financial-analysis-python-tutorial/blob/master/1.%20Pandas%20Basics.ipynb -- Akira -- https://mail.python.org/mailman/listinfo/python-list
Lists
import random nums=range(1,11) print (nums) samp=random.sample(nums,10) top=nums newlist=nums[::-1] tail=newlist for x in range(10): print (Top {:2d}Tail {:2.0f} Sample {:2d} .format(top[x],tail[x],samp[x])) I don't understand why the command nums=range(1,11) doesn't work. I would think that print(nums) should be 1,2,3 ect. Instead it prints range(1,11) Why does random.sample(nums,10) give me the numbers between 1 and 10. I am missing something subtle again. -- https://mail.python.org/mailman/listinfo/python-list
Re: CSV methodology
jayte wrote: Sorry, I neglected to mention the values' significance. The MXP program uses the distance estimate algorithm in its fractal data generation. The values are thus, for each point in a 1778 x 1000 image: Distance, (an extended double) Iterations, (a 16 bit int) zc_x,(a 16 bit int) zc_y (a 16 bit int) Probably a bit too early in your Python career, but you can read raw data with numpy. Something like with open(filename, rb) as f: a = numpy.fromfile(f, dtype=[ (distance, f16), (iterations, i2), (zc_x, i2), (zc_y, i2), ]).reshape(1778, 1000) might do, assuming extended double takes 16 bytes. -- https://mail.python.org/mailman/listinfo/python-list
Re: Lists
Christian Gollwitzer wrote: Am 15.09.14 04:40, schrieb Seymore4Head: nums=range(1,11) print (nums) I don't understand why the command nums=range(1,11) doesn't work. I would think that print(nums) should be 1,2,3 ect. Instead it prints range(1,11) It does work, but in a different way than you might think. range() does not return a list of numbers, but rather a generator - that is an object which produces the values one after another. But you can transform it into a list: print(list(nums)) should give you what you want. Christian I'd call range() an iterable. A generator is a specific kind of iterator. The difference between iterable and iterator is that the latter cannot be restarted: def f(): ... yield 1 ... yield 2 ... g = f() list(g) [1, 2] list(g) [] # empty -- g is an iterator r = range(1, 3) list(r) [1, 2] list(r) [1, 2] # same as before -- r is an iterable -- https://mail.python.org/mailman/listinfo/python-list
something like pyfilesystem, fs.zipfs that works on windows
I need something that is similar to zipfs, but it should work on Windows and Unix too. Requirements: * store a complete directory structure and multiple files in a single file * be able to add, replace and delete files and directories * binary write/append to files is NOT a requirement but it would be good * should work with any file-like object that implements read(), write(), seek(), tell(), close(), flush() and truncate() [e.g. no fileno()] * does not need to store the files in compressed form Is there something like this available? Thanks, Laszlo -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- https://mail.python.org/mailman/listinfo/python-list
List insert at index that is well out of range - behaves like append that too SILENTLY
Hi , Let me demonstrate the problem I encountered : I had a list a = [1, 2, 3] when I did a.insert(100, 100) [1, 2, 3, 100] as list was originally of size 4 and I was trying to insert value at index 100 , it behaved like append instead of throwing any errors as I was trying to insert in an index that did not even existed . Should it not throw IndexError: list assignment index out of range exception as it throws when I attempt doing a[100] = 100 Personal Opinion : Lets see how other languages behave in such a situation : 1. Ruby : a = [1, 2] a[100] = 100 a = [1, 2, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 100] The way ruby handles this is pretty clear and sounds meaningful (and this is how I expected to behave and it behaved as per my expectation) at least to me . Here also it was silently handled but the way it fills non existing indexes in between with nil sounded meaningful . 2. Java : When I do such an action in java by using .add(index.value) on may be arraylist or linkedlist I get java.lang.IndexOutOfBoundException Here instead of handling it silently it throws an error . But the python way of handling such a problem by appending to the end sounds more unexpected to me . This in fact flummoxed me in the beginning making me think it could be a bug . Then when I raised it in stackoverflow I got chance to look at source and found that's the way code is written . Question : 1. Any idea Why it has been designed to silently handle this instead of at least informing the user with an exception(as in java) or attaching null values in empty places (as in ruby) ? Thanks Harish -- https://mail.python.org/mailman/listinfo/python-list
Re: Marco's atexit issue was: Re: ANN: wxPython 3.0.1.1
all the code addressed by the exception is out of my source. I don't have any atexit.register in my code Marco On Friday, September 12, 2014 6:33:09 PM UTC+2, Nathan McCorkle wrote: On Friday, September 12, 2014 1:14:41 AM UTC-7, Marco Prosperi wrote: I'm trying to pass my application from wxpython2.9.4 to 3.0.1 but there seems to be still some of the problems that made me skip wxpy2.9.5: when I close the main window of my application (windows7-64bit, python 2.7) I get exceptions like this below (none with wxpy2.9.4). How can I avoid that my users get this? this happens after my OnExit function is completed Marco Error in atexit._run_exitfuncs: Traceback (most recent call last): File C:\Programmi\Python27\lib\atexit.py, line 24, in _run_exitfuncs func(*targs, **kargs) PyAssertionError: C++ assertion GetEventHandler() == this failed at ..\..\src\ common\wincmn.cpp(478) in wxWindowBase::~wxWindowBase(): any pushed event handle rs must have been removed Error in sys.exitfunc: Traceback (most recent call last): File C:\Programmi\Python27\lib\atexit.py, line 24, in _run_exitfuncs func(*targs, **kargs) wx._core.PyAssertionError: C++ assertion GetEventHandler() == this failed at . .\..\src\common\wincmn.cpp(478) in wxWindowBase::~wxWindowBase(): any pushed eve nt handlers must have been removed Post some code? Sounds like you're trying to interact with a wxPython object in a function using atexit.register(AtExit)... which likely is always going to happen after the wx Destroy method is all done. -- https://mail.python.org/mailman/listinfo/python-list
Re:Lists
Seymore4Head Seymore4Head@Hotmail.invalid Wrote in message: import random nums=range(1,11) print (nums) samp=random.sample(nums,10) top=nums newlist=nums[::-1] tail=newlist for x in range(10): print (Top {:2d}Tail {:2.0f} Sample {:2d} .format(top[x],tail[x],samp[x])) I don't understand why the command nums=range(1,11) doesn't work. I would think that print(nums) should be 1,2,3 ect. Instead it prints range(1,11) You need to specify that you're using python 3.x In python 2, nums would indeed be a list. And range (500) would be a list of 5 million items, taking quite a while and lots of memory to build. So python 3 uses lazy evaluation when it can. In this case it returns a range sequence type, not a list. https://docs.python.org/3/library/stdtypes.html#typesseq-range If you need the ints all at once, simply call list. nums =list (range (1, 11) Why does random.sample(nums,10) give me the numbers between 1 and 10. I am missing something subtle again. It doesn't give you the numbers between 1 and 10, it gives you a list composed of those numbers in an arbitrary order, but with no duplicates. Your question is incomplete. It does that because it's defined to. But clearly you're puzzled. So what is confusing? The fact that there are 10? The fact that they're between 1 and 10 inclusive? Or the fact there are no duplicates? Or something else? You might help your confusion by experimenting. Try 7 instead of 10. Or pick different range limits. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re:protocol.py, brine.py, and compat.py causing trouble
Josh English joshua.r.engl...@gmail.com Wrote in message: I do not know what these three filesare doing, but suddenly they have caught in a loop every time I try to run some code. I grabbed the trace decorator from the python library and this is the last bit of the output: trollvictims.py(129): if self.current_attack: trollvictims.py(130): print returning, self.current_attack, type(self.current_attack) string(532): protocol.py(439): protocol.py(228): protocol.py(229): protocol.py(244): brine.py(366): brine.py(368): brine.py(369): brine.py(369): brine.py(366): brine.py(367): . This is where I managed to send a keybord interrupt. I was working just fine, tweaking a line, running the code, tweaking a line, running the code, until this point. I'm on Windows 7 using Python 2.7.5. I should upgrade, and will do so, but what are these files and why are they suddenly crashing on me? Since they're not part of the stdlib, and you don't remember writing them, you might get a hint by printing import brine print (brine.__brine__) -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.3.2 help
Hi, We are using windows 7 and it is all pupils as they are more restricted than staff. They are using the python 3.3.2 shell and trying to print from there Thank you, David Moorcroft ICT Operations Manager Website Manager Turves Green Girls' School - Original Message - From: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info To: python-list@python.org Sent: Wednesday, 10 September, 2014 1:15:49 PM Subject: Re: Python 3.3.2 help Hello, My response is below, interleaved with your comments. D Moorcroft wrote: Hi, We are running Python 3.3.2 but pupils are unable to print as they cannot use the command prompt. What operating system are you using? Windows, Linux, Mac? Something else? Is it ALL pupils who are unable to print or just some of them? Which command prompt are they using? Can you reproduce the failure to print? If so, please tell us the detailed steps you (and the pupils) go through. E.g. something like this: On Windows XP, choose Run from the Start Menu. Type cmd.exe and press Enter. When the terminal window opens, type print 'Hello World' and Enter. It will help if you can tell us whether your pupils are using IDLE, IPython, or the default Python interactive interpreter. If you can answer these questions, which should have a better chance of diagnosing the problem. Further responses below. An error comes up saying printing failed (exit status Oxff). Based on this, my guess is that your students are accidentally running the DOS print command at the DOS prompt, not Python at all. Perhaps they are forgetting to run the python command first to launch the Python interpreter, and are running directly in the DOS prompt? You can check this by reading the command prompt. If it looks like three greater-than signs then you are running in Python's default interpreter. If it looks something like this: C:\Documents and Settings\user\ or perhaps like this: C:\ then you are still inside the DOS command prompt. Unfortunately, I am not very experienced with Windows, so I cannot tell you the right method to start Python. I would expect there to be a Start menu command, perhaps called IDLE, or Python, but I'm not sure. Is there any way that we can get users who can't see the command prompt to be able to print? I'm not entirely sure I understand this question. Can you explain in more detail? By the way, as you know there are two meanings of print in computing. There is printing to the screen, and printing to sheets of paper with an actual printer. Which are you intending? Regards, -- Steven -- https://mail.python.org/mailman/listinfo/python-list * This message has been checked for viruses by the Birmingham Grid for Learning. For guidance on good e-mail practice, e-mail viruses and hoaxes please visit: http://www.bgfl.org/emailaup * * This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify postmas...@bgfl.org The views expressed within this email are those of the individual, and not necessarily those of the organisation * -- https://mail.python.org/mailman/listinfo/python-list
Re:CSV methodology
je...@newsguy.com Wrote in message: Hello. Back in the '80s, I wrote a fractal generator, which, over the years, I've modified/etc to run under Windows. I've been an Assembly Language programmer for decades. Recently, I decided to learn a new language, and decided on Python, and I just love it, and the various IDEs. Anyway, something I thought would be interesting, would be to export some data from my fractal program (I call it MXP), and write something in Python and its various scientific data analysis and plotting modules, and... well, see what's in there. An example of the data: 1.850358651774470E-0002 32 22 27 ... (this format repeats) So, I wrote a procedure in MXP which converts the data and exports a csv file. So far, here's what I've started with: --- import csv fname = 'E:/Users/jayte/Documents/Python Scripts/XportTestBlock.csv' f = open(fname) reader = csv.reader(f) for flt in reader: x = len(flt) file.close(f) --- This will get me an addressable array, as: flt[0], flt[1], flt[350], etc... from which values can be assigned to other variables, converted... My question: Is there a better way? Do I need to learn more about how csv file are organized? Perhaps I know far too little of Python to be attempting something like this, just yet. Looks to me like your MXP has produced a single line file, with all the values on that single line separated by commas. If the data is really uniform, then it'd be more customary to put one item per line. But your sample seems to imply the data is a float followed by 3 ints. If so, then I'd expect to see a line for each group of 4. The only advantage of a csv is if the data is rectangular. If it's really a single column, it should be one per line, and you'd use readline instead. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re:protocol.py, brine.py, and compat.py causing trouble
Dave Angel da...@davea.name Wrote in message: Josh English joshua.r.engl...@gmail.com Wrote in message: I do not know what these three filesare doing, but suddenly they have caught in a loop every time I try to run some code. I grabbed the trace decorator from the python library and this is the last bit of the output: trollvictims.py(129): if self.current_attack: trollvictims.py(130): print returning, self.current_attack, type(self.current_attack) string(532): protocol.py(439): protocol.py(228): protocol.py(229): protocol.py(244): brine.py(366): brine.py(368): brine.py(369): brine.py(369): brine.py(366): brine.py(367): . This is where I managed to send a keybord interrupt. I was working just fine, tweaking a line, running the code, tweaking a line, running the code, until this point. I'm on Windows 7 using Python 2.7.5. I should upgrade, and will do so, but what are these files and why are they suddenly crashing on me? Since they're not part of the stdlib, and you don't remember writing them, you might get a hint by printing import brine print (brine.__brine__) Oops, meant print (brine.__file__) -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: Shuffle
Michael Torrie torr...@gmail.com Wrote in message: On 09/13/2014 05:47 PM, Seymore4Head wrote: Here is a screenshot of me trying Dave Briccetti's quiz program from the shell and it (the shuffle command) works. https://www.youtube.com/watch?v=VR-yNEpGk3g http://i.imgur.com/vlpVa5i.jpg Two questions If you import random, do you need to from random import shuffle? Why does shuffle work from the command line and not when I add it to this program? import random import shuffle nums=list(range(1,11)) shuffle(nums) print (nums) I get: No module named 'shuffle' You can do it two ways: Refer to it as random.shuffle() or from random import shuffle I tend to use the first method (random.shuffle). That way it prevents my local namespace from getting polluted with random symbols imported from modules. Or a third way: import random shuffle = random.shuffle -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: Shuffle
Dave Angel wrote: Michael Torrie torr...@gmail.com Wrote in message: You can do it two ways: Refer to it as random.shuffle() or from random import shuffle I tend to use the first method (random.shuffle). That way it prevents my local namespace from getting polluted with random symbols imported from modules. Or a third way: import random shuffle = random.shuffle Our three weapons are: (1) fully qualified names: import random random.shuffle (2) unqualified local imports: from random import shuffle (3) local name binding: import random shuffle = random.shuffle (4) messing about under the hood: shuffle = __import__('random', fromlist=['shuffle']).shuffle (5) and a fanatical devotion to the Pope. A serious question -- what is the point of the fromlist argument to __import__? It doesn't appear to actually do anything. https://docs.python.org/3/library/functions.html#__import__ -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.3.2 help
Hello David, and thanks for replying. More comments below. D Moorcroft wrote: Hi, We are using windows 7 and it is all pupils as they are more restricted than staff. They are using the python 3.3.2 shell and trying to print from there What you are describing does not sound like the sort of error the Python shell will give. Are you able to copy and paste the student's exact input and output, including the complete error message? If not, can you take a screenshot and post that? (As a general rule, we prefer text-based communication rather than pictures. For all we know, there could be blind or other visually-impaired users on this forum who can read text via a screen reader, but cannot contribute when it is a screenshot. But if all else fails, a screenshot is better than nothing.) We would love to help you, but without further information we have no idea what is going on. The more concrete information you can pass on to us, the better. Regards, Steve Thank you, David Moorcroft ICT Operations Manager Website Manager Turves Green Girls' School - Original Message - From: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info To: python-list@python.org Sent: Wednesday, 10 September, 2014 1:15:49 PM Subject: Re: Python 3.3.2 help Hello, My response is below, interleaved with your comments. D Moorcroft wrote: Hi, We are running Python 3.3.2 but pupils are unable to print as they cannot use the command prompt. What operating system are you using? Windows, Linux, Mac? Something else? Is it ALL pupils who are unable to print or just some of them? Which command prompt are they using? Can you reproduce the failure to print? If so, please tell us the detailed steps you (and the pupils) go through. E.g. something like this: On Windows XP, choose Run from the Start Menu. Type cmd.exe and press Enter. When the terminal window opens, type print 'Hello World' and Enter. It will help if you can tell us whether your pupils are using IDLE, IPython, or the default Python interactive interpreter. If you can answer these questions, which should have a better chance of diagnosing the problem. Further responses below. An error comes up saying printing failed (exit status Oxff). Based on this, my guess is that your students are accidentally running the DOS print command at the DOS prompt, not Python at all. Perhaps they are forgetting to run the python command first to launch the Python interpreter, and are running directly in the DOS prompt? You can check this by reading the command prompt. If it looks like three greater-than signs then you are running in Python's default interpreter. If it looks something like this: C:\Documents and Settings\user\ or perhaps like this: C:\ then you are still inside the DOS command prompt. Unfortunately, I am not very experienced with Windows, so I cannot tell you the right method to start Python. I would expect there to be a Start menu command, perhaps called IDLE, or Python, but I'm not sure. Is there any way that we can get users who can't see the command prompt to be able to print? I'm not entirely sure I understand this question. Can you explain in more detail? By the way, as you know there are two meanings of print in computing. There is printing to the screen, and printing to sheets of paper with an actual printer. Which are you intending? Regards, -- Steven -- https://mail.python.org/mailman/listinfo/python-list
What's the function location that reads the cached .pyc file from disk.
Hi. what's the location of the function that reads the .pyc file ? I bet it should lie in somewhere in https://hg.python.org/cpython/file/322ee2f2e922/Lib/importlib But what's the actual location? Btw, why I need it? I want to know the structure of a .pyc file. Of course the function that reads the .pyc must know something about it. (I am aware of the structure of a typical .pyc file from some clicks of google pages, but I am interested in the *source* and the most authoritative answer, aka, the source code). Thanks. -- 吾輩は猫である。ホームーページはhttp://introo.me。 -- https://mail.python.org/mailman/listinfo/python-list
__import__(name, fromlist=...), was Re: Shuffle
Steven D'Aprano wrote: A serious question -- what is the point of the fromlist argument to __import__? It doesn't appear to actually do anything. https://docs.python.org/3/library/functions.html#__import__ It may be for submodules: $ mkdir -p aaa/bbb $ tree . └── aaa └── bbb 2 directories, 0 files $ python3 Python 3.4.0 (default, Apr 11 2014, 13:05:11) [GCC 4.8.2] on linux Type help, copyright, credits or license for more information. __import__(aaa).bbb Traceback (most recent call last): File stdin, line 1, in module AttributeError: 'module' object has no attribute 'bbb' __import__(aaa, fromlist=[bbb]).bbb module 'aaa.bbb' (namespace) -- https://mail.python.org/mailman/listinfo/python-list
Re: Lists
On Mon, 15 Sep 2014 09:05:50 -0400 (EDT), Dave Angel da...@davea.name wrote: Seymore4Head Seymore4Head@Hotmail.invalid Wrote in message: import random nums=range(1,11) print (nums) samp=random.sample(nums,10) top=nums newlist=nums[::-1] tail=newlist for x in range(10): print (Top {:2d}Tail {:2.0f} Sample {:2d} .format(top[x],tail[x],samp[x])) I don't understand why the command nums=range(1,11) doesn't work. I would think that print(nums) should be 1,2,3 ect. Instead it prints range(1,11) You need to specify that you're using python 3.x In python 2, nums would indeed be a list. And range (500) would be a list of 5 million items, taking quite a while and lots of memory to build. So python 3 uses lazy evaluation when it can. In this case it returns a range sequence type, not a list. https://docs.python.org/3/library/stdtypes.html#typesseq-range If you need the ints all at once, simply call list. nums =list (range (1, 11) Why does random.sample(nums,10) give me the numbers between 1 and 10. I am missing something subtle again. It doesn't give you the numbers between 1 and 10, it gives you a list composed of those numbers in an arbitrary order, but with no duplicates. Your question is incomplete. It does that because it's defined to. But clearly you're puzzled. So what is confusing? The fact that there are 10? The fact that they're between 1 and 10 inclusive? Or the fact there are no duplicates? Or something else? You might help your confusion by experimenting. Try 7 instead of 10. Or pick different range limits. Actually I do understand that random.sample(nums,10) does give a sample of the numbers in the list. What was throwing me off was that nums=range(1,11) did not appear to be a list ,but sample was still treating it as a list. But I also figured out what I really needed to do was nums=list(range(1,11) Thanks everyone. -- https://mail.python.org/mailman/listinfo/python-list
Re: Lists
On Mon, 15 Sep 2014 16:59:36 +1000, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Seymore4Head wrote: import random nums=range(1,11) print (nums) samp=random.sample(nums,10) top=nums newlist=nums[::-1] tail=newlist for x in range(10): print (Top {:2d}Tail {:2.0f} Sample {:2d} .format(top[x],tail[x],samp[x])) I don't understand why the command nums=range(1,11) doesn't work. Of course it works. It does exactly what you told it to do: set the variable nums to the result of calling range(1, 11). The only question is, what does range(1, 11) do? I would think that print(nums) should be 1,2,3 ect. Instead it prints range(1,11) Did you read the documentation for range? py help(range) class range(object) | range([start,] stop[, step]) - range object | | Returns a virtual sequence of numbers from start to stop by step. [...] range in Python 3 does not return a list. It returns a special object which provides a sequence of numbers, but without actually storing them all in a list. Why does random.sample(nums,10) give me the numbers between 1 and 10. What did you expect it to do? Did you read the documentation? py import random py help(random.sample) Help on method sample in module random: sample(self, population, k) method of random.Random instance Chooses k unique random elements from a population sequence or set. [...] To choose a sample in a range of integers, use range as an argument. This is especially fast and space efficient for sampling from a large population: sample(range(1000), 60) The docs even tell you that (1) sample supports range objects, and (2) using range is more efficient than lists. I am missing something subtle again. range objects behave *like* lists when you index them: py nums = range(1, 100) py nums[0] # First item. 1 py nums[-1] # Last item. 99 They're even smart enough that you can take a slice, and they give you a new range object: py nums[1:10] range(2, 11) When you iterate over them, you get each item in turn: py for i in range(1, 4): ... print(i) ... 1 2 3 range objects are more efficient than lists if the numbers follow the right sort of pattern. While a list can contain any values you like, in any order: py nums = [1, 33, 5, 222, 4, 6, 0, 888, 7] range objects are limited to a linear sequence of: start, start+step, start+2*step, start+3*step, ... up to some end value. The reason range is more efficient is that, unlike lists, it doesn't need to pre-populate all the values required, it can calculate them on the fly when and as required. The reason why lists are more flexible is that the values don't have to be calculated as needed, they can just be stored, ready to use. I see now Thanks everyone -- https://mail.python.org/mailman/listinfo/python-list
Re: Lists
On Mon, Sep 15, 2014 at 1:36 AM, Peter Otten __pete...@web.de wrote: I'd call range() an iterable. I'd even go so far as to call it a sequence. from collections import Sequence issubclass(range, Sequence) True -- https://mail.python.org/mailman/listinfo/python-list
Re: Lists
Ian Kelly wrote: On Mon, Sep 15, 2014 at 1:36 AM, Peter Otten __pete...@web.de wrote: I'd call range() an iterable. I'd even go so far as to call it a sequence. from collections import Sequence issubclass(range, Sequence) True If you want to be as specific as possible call it a range ;) -- https://mail.python.org/mailman/listinfo/python-list
Re: protocol.py, brine.py, and compat.py causing trouble
On 9/13/2014 11:44 PM, Josh English wrote: I do not know what these three filesare doing, but suddenly they have caught in a loop every time I try to run some code. snip This is where I managed to send a keybord interrupt. I was working just fine, tweaking a line, running the code, tweaking a line, running the code, until this point. That's your clue -- I'd take a close look at the last changes you made a result of which caused this failure and apparent looping. It's easy to lay blame on the (whatever) library and look for a root cause there, but I'd first suspect I did something inappropriate as that's much more likely. Emile -- https://mail.python.org/mailman/listinfo/python-list
Re: Storing instances using jsonpickle
On Wednesday, September 3, 2014 7:19:07 PM UTC-7, Ned Batchelder wrote: Typically, you need to decide explicitly on a serialized representation for your data. Even if it's JSON, you need to decide what that JSON looks like. Then you need to write code that converts the JSON-able data structure (dict of lists, whatever) into your object. Often a version number is a good idea so that you have some chance of using old data as your code changes. Right now my cheap workaround is to define a function that saves the instances __dict__ using json, and to recreate the object, I create a new object using the __init__ method and cycle through the rest of the json keys and apply them to the new object using setattr. It's a quick and dirty hack, but it seems to be working. I do have to make sure that everything that lands in the instance's __dict__ is serializable, but that's not so tough. I need to add a version number, though. Good idea, that. Josh -- https://mail.python.org/mailman/listinfo/python-list
PyCharm refactoring tool?
I started up an instance of PyCharm last Friday. It's mostly just been sitting there like a bump on a log. I set things up to use Emacs as my editor. It seems most of its functionality won't be all that useful. Most of my work is on libraries/platforms - stuff which is not runnable in isolation, so the Run menu doesn't look all that useful. I have git, etc integrated into my Emacs environment, so don't need the VCS menu. Most everything else looks fairly genertic. Except the Refactor menu. Before I try to do much/anything with it, I thought I would solicit feedback on its capability. Does it work as intended? I read through the PyCharm help sections on refactoring. It seems to describe a number of code refactorings which aren't available for Python code. For example, I don't see an invert boolean refactoring. How useful is PyCharm's refactoring subsystem? Thx, Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: PyCharm refactoring tool?
It's pretty useful. I use it for some time now and I very much like it. There are some things that might not be available on Python because of it's duck typing behavior (Pycharm perhaps can't confirm that the type is boolean to suggest it's inversion, for instance). The most powerful for me are the rename refactor and extract. Works like charm (no pun intended). On Mon, Sep 15, 2014 at 4:44 PM, Skip Montanaro s...@pobox.com wrote: I started up an instance of PyCharm last Friday. It's mostly just been sitting there like a bump on a log. I set things up to use Emacs as my editor. It seems most of its functionality won't be all that useful. Most of my work is on libraries/platforms - stuff which is not runnable in isolation, so the Run menu doesn't look all that useful. I have git, etc integrated into my Emacs environment, so don't need the VCS menu. Most everything else looks fairly genertic. Except the Refactor menu. Before I try to do much/anything with it, I thought I would solicit feedback on its capability. Does it work as intended? I read through the PyCharm help sections on refactoring. It seems to describe a number of code refactorings which aren't available for Python code. For example, I don't see an invert boolean refactoring. How useful is PyCharm's refactoring subsystem? Thx, Skip -- https://mail.python.org/mailman/listinfo/python-list -- George R. C. Silva SIGMA Consultoria http://www.consultoriasigma.com.br/ -- https://mail.python.org/mailman/listinfo/python-list
Re: PyCharm refactoring tool?
George Silva schrieb am 15.09.2014 um 21:49: It's pretty useful. I use it for some time now and I very much like it. [...] The most powerful for me are the rename refactor and extract. Works like charm (no pun intended). Dito. On Mon, Sep 15, 2014 at 4:44 PM, Skip Montanaro s...@pobox.com wrote: I started up an instance of PyCharm last Friday. It's mostly just been sitting there like a bump on a log. I set things up to use Emacs as my editor. It seems most of its functionality won't be all that useful. Most of my work is on libraries/platforms - stuff which is not runnable in isolation, so the Run menu doesn't look all that useful. I also do most exec stuff on the command line - it needs to work there anyway, so the additional config in PyCharm is really something on top that I often don't do. However, running stuff within PyCharm can still be really handy because it integrates very nicely with py.test and other test runners. You get nice visual feedback for your tests, can rerun failing tests with one click, can visually debug problems, get coverage analysis for free, etc. It's all very nicely integrated. Stefan -- https://mail.python.org/mailman/listinfo/python-list
functools.wraps behaviour
The purpose of 'functools.wraps' is to make a decorated function look like the original function, i.e. such that the __name__, __module__, __doc__ attributes are the same as the wrapped function. However, I've noticed inconsistent behaviour. Given the following: import functools def decorator(func): @functools.wraps(func) def wrapper(self): func(self) return wrapper class Klass: @decorator def method(self): raise Exception('boom!') print('Klass.method:',Klass.method) k = Klass() print('k.method',k.method) try: k.method(1) except Exception as e: print('exception:',e) The output (Python 3.3) is: Klass.method: function Klass.method at 0x7f2d7c454b00 k.method bound method Klass.method of __main__.Klass object at 0x7f2d7c4570d0 exception: wrapper() takes 1 positional argument but 2 were given The first two lines are as expected, using the name of the decorated function. However, the exception uses the name of the decorating wrapper function. Is this a bug in functools? Or is this a language feature? If so, is there a valid argument to change this behaviour? -- isedev -- https://mail.python.org/mailman/listinfo/python-list
python script monitor
I have made an app that is not fully stable and I would like to monitor the performance of the app and try and improve the speed of it. I tried to use the activity monitor on the mac but what I want I'm to see how much ram, cup and other stats on what resources that app is using. Is there any apps to specifically monitor a certain app. I am on Mac is so any suggestions that could work with that would be great. -- https://mail.python.org/mailman/listinfo/python-list
Re: python script monitor
On Tue, Sep 16, 2014 at 10:07 AM, Nicholas Cannon nicholascann...@gmail.com wrote: I have made an app that is not fully stable and I would like to monitor the performance of the app and try and improve the speed of it. I tried to use the activity monitor on the mac but what I want I'm to see how much ram, cup and other stats on what resources that app is using. Is there any apps to specifically monitor a certain app. I am on Mac is so any suggestions that could work with that would be great. If by not fully stable you mean that it sometimes isn't working, then playing with performance is a bad idea. Start by getting it correct, then worry about how fast it is. Otherwise, what do you mean by that? What's not stable about your app? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: functools.wraps behaviour
On Tue, Sep 16, 2014 at 9:15 AM, ISE Development isen...@gmail.com wrote: @functools.wraps(func) def wrapper(self): func(self) return wrapper try: k.method(1) except Exception as e: print('exception:',e) The output (Python 3.3) is: Klass.method: function Klass.method at 0x7f2d7c454b00 k.method bound method Klass.method of __main__.Klass object at 0x7f2d7c4570d0 exception: wrapper() takes 1 positional argument but 2 were given The first two lines are as expected, using the name of the decorated function. However, the exception uses the name of the decorating wrapper function. In your wrapper, you're swallowing all arguments. That means you're consciously rejecting them, and passing none on. If you want a wrapper to let the wrapped function decide about arguments, try this: def decorator(func): @functools.wraps(func) def wrapper(self, *args, **kwargs): func(self, args, kwargs) return wrapper With that change, the error message reports that it's method() that's rejecting the args. So yes, I'd say this is a feature; you can either let the wrapped function make the decision, or you can have the wrapping function deal with args. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: protocol.py, brine.py, and compat.py causing trouble
On Monday, September 15, 2014 12:12:50 PM UTC-7, Emile van Sebille wrote: That's your clue -- I'd take a close look at the last changes you made a result of which caused this failure and apparent looping. It's easy to lay blame on the (whatever) library and look for a root cause there, but I'd first suspect I did something inappropriate as that's much more likely. Emile I deleted the original post because I had figured out what I had changed. The troubleshooting I had done pointed me to those files, which turn out to be part of PyScripter, my IDE. Oddly enough, once I fixed the actual problem (minutes after posting) it still makes no sense... I had a list of things that I processed and returned, but some refactoring left out filling the return list with anything. I'm not sure what happened, except possibly an endless loop. Josh -- https://mail.python.org/mailman/listinfo/python-list
Re: protocol.py, brine.py, and compat.py causing trouble
On Sunday, September 14, 2014 10:59:07 AM UTC-7, Terry Reedy wrote: On 9/14/2014 2:44 AM, Josh English wrote: To the best of my knowledge, protocol.py, brine.py, compat.py, are not part of the stdlib. What have you installed other than Python? What editor/IDE are you using? Check your lib/site-packages directory. From a google search, brine.py is a pickle replacement in the rpyc and dreampie (and other) packages. The other two names are pretty generic and probably common. They turned out to be part of PyScripter, my IDE. I think the problem was an enless loop, and eventually a memory error, but I'm not sure. Thanks, Josh -- https://mail.python.org/mailman/listinfo/python-list
Re: python script monitor
On Sep 15, 2014, at 8:07 PM, Nicholas Cannon nicholascann...@gmail.com wrote: I have made an app that is not fully stable and I would like to monitor the performance of the app and try and improve the speed of it. I tried to use the activity monitor on the mac but what I want I'm to see how much ram, cup and other stats on what resources that app is using. Is there any apps to specifically monitor a certain app. I am on Mac is so any suggestions that could work with that would be great. -- https://mail.python.org/mailman/listinfo/python-list Have you investigated the (long) list of options to the “top” command? I’ve noticed that most Mac users seem to assume that top won’t show anything that Apple’s Activity Monitor doesn’t show. In fact top is WAY more powerful. It should do pretty much what you want. Bill -- https://mail.python.org/mailman/listinfo/python-list
Re: protocol.py, brine.py, and compat.py causing trouble
On Tue, Sep 16, 2014 at 11:02 AM, Josh English joshua.r.engl...@gmail.com wrote: I deleted the original post because I had figured out what I had changed. This is primarily a newsgroup and a mailing list. You can't delete posts. The best thing to do is to send a follow-up explaining that you no longer need answers. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: functools.wraps behaviour
On Mon, Sep 15, 2014 at 5:15 PM, ISE Development isen...@gmail.com wrote: The first two lines are as expected, using the name of the decorated function. However, the exception uses the name of the decorating wrapper function. Is this a bug in functools? Or is this a language feature? If so, is there a valid argument to change this behaviour? I believe this is done in order to have useful stack traces. If it said 'method' in the stack trace, it could mislead the person debugging into thinking that method is actually raising the exception, but here the exception is actually coming from wrapped, and method is not even called. -- https://mail.python.org/mailman/listinfo/python-list
[issue22414] I'd like to add you to my professional network on LinkedIn
New submission from VUIUI: Hi, I#39;d like to add you to my professional network on LinkedIn. - Sói Accept: http://www.linkedin.com/blink?simpleRedirect=38RdP0VczsRe3gQd38ScjsNejkZh4BKrSBQonhFtCVF9z5KjmdKiiQJfnBBiShBsC5EsOpQsSlRpRZBt6BSrCAZqSkConhzbmlQqnpKqiRQsSlRpORIrmkZpSVFqSdxsDgCpnhFtCV9pSlipn9Mfm4CsPgJc3ByumkPc6AJcSlKoT4PbjRBfP9SbSkLrmZzbCVFp6lHrCBIbDtTtOYLeDdMt7hEmsgID=I7888360485_1markAsRead= You received an invitation to connect. LinkedIn will use your email address to make suggestions to our members in features like People You May Know. Unsubscribe here: http://www.linkedin.com/blink?simpleRedirect=pT9Lhj8BrCZEt7BMhj8BsStRoz0Q9nhOrT1BszRIqm5JpipQs64MczxGcTdSpP9IcDoZp6Bx9z4Sc30OfmhF9z4JfmhFripPd2QMem9VpjcMqiQPpmVzsjcJfmhFpipQsSlRpRZBt6BSrCAZqSkCkjoPp4l7q5p6sCR6kk4ZrClHrRhAqmQCsSVRfngCsPgJc3ByumkPc6AJcSlKoT4PbjRBfP9SbSkLrmZzbCVFp6lHrCBIbDtTtOYLeDdMt7hEamp;msgID=I7888360485_1amp;markAsRead= Learn why we included this at the following link: http://www.linkedin.com/blink?simpleRedirect=e3wTd3RAimlIoSBQsC4Ct7dBtmtvpnhFtCVFfmJB9CNOlmlzqnpOpldOpmRLt7dRoPRx9DcQbj0VoDBBcP1FbjdBrCdNcOQZpjYOtyZBbSRLoOVKqmhBqSVFr2VTtTsLbPFMt7hEmsgID=I7888360485_1markAsRead= copy; 2014, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043, USA -- messages: 226897 nosy: VUIUI priority: normal severity: normal status: open title: I'd like to add you to my professional network on LinkedIn ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22414 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22414] I'd like to add you to my professional network on LinkedIn
Changes by Georg Brandl ge...@python.org: -- resolution: - not a bug status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22414 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18159] ConfigParser getters not available on SectionProxy
Changes by Łukasz Langa luk...@langa.pl: -- versions: +Python 3.5 -Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18159 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22406] uu-codec trailing garbage workaround is Python 2 code
Changes by Martin Panter vadmium...@gmail.com: Added file: http://bugs.python.org/file36619/uu_codec ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22406 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22406] uu-codec trailing garbage workaround is Python 2 code
Martin Panter added the comment: Here are two patches: a test and a fix. I’m not sure if it is okay to add a test for the “codecs” module with the tests for the “uu” module; it was easier that way because I am basically running the same test over the two different APIs. -- Added file: http://bugs.python.org/file36618/test ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22406 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21998] asyncio: a new self-pipe should be created in the child process after fork
STINNER Victor added the comment: Is there a use case for sharing an event loop across forking? I don't know if asyncio must have a builtin support for this use case. The minimum is to document the behaviour, or maybe even suggest a recipe to support it. For example, an event loop of asyncio is not thread-safe and we don't want to support this use case. But I wrote a short documentation with code snippets to show how to workaround this issue: https://docs.python.org/dev/library/asyncio-dev.html#concurrency-and-multithreading We need a similar section to explain how to use asyncio with the os.fork() function and the multiprocesing module. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21998 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18159] ConfigParser getters not available on SectionProxy
Łukasz Langa added the comment: The reason I didn't commit that patch before was that I wasn't sure whether making this change wouldn't create any unexpected backwards incompatibility. In fact, if I committed the patch as is, it would. I solved this by leaving getint, getfloat and getboolean on the parser class and keeping _get in use. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18159 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22412] Towards an asyncio-enabled command line
Martin Teichmann added the comment: Hi Guido, thanks for the quick response, so my response to your post: to 1: thanks! to 2: I am trying to put most of the stuff into a 3rd party module, unfortunately I need changes in the python compiler, and given that monkey patching is not so simple in C, changing the compiler would mean to re-write it, I know that has been done, but I figured that starting a project like PyPy or jython is a bit too much for me right now. to 3: I started with the repo head of friday night... apparently I was not fast enough to submit this patch before someone changes the python code to the point that my patch doesn't apply anymore. I'll try to fix that soon. to 4: I'll write some docs. to 5: well, there is a callback function just some lines up which will call future.set_result(None). Maybe that was a bit too slick, I'm open for comments on how to do that better. to 6: the C code I put into readline.c is mostly a merge of readline_until_enter_or_signal (in readline.c) and builtin_input (in bltinmodule.c). You're definitely right that those functions could do with some refactoring, but I didn't dare to since they are full of complicated special code for special platforms, and I have no chance to test the code on a machine which has a completely outdated version of the readline library, so I picked the code I needed. to 6: I thought about writing the input part of my patch as a 3rd party library, but then I saw the state of builtin.input and thought that it would actually be a good idea to shine some light onto the state of that function, it is actually a horrible mess. Just look at all the awful dirty tricks that the people over at IPython have to do to use it (im)properly (I'm talking about IPython.lib.inputhook*). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22412 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22413] Bizarre StringIO(newline=\r\n) translation
Serhiy Storchaka added the comment: See issue20435. -- nosy: +pitrou, serhiy.storchaka versions: +Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22413 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22415] Fix re debugging output
New submission from Serhiy Storchaka: Proposed patch fixes some issues in debugging output of the compiling of regular expression with the re.DEBUG flag. 1. Fixed the handling of the GROUPREF_EXISTS opcode. Example: re.compile(r'(ab)(?(1)cd|ef)', re.DEBUG) Before patch (yes and no branches are not separated): subpattern 1 literal 97 literal 98 subpattern None groupref_exists 1 literal 99 literal 100 literal 101 literal 102 After patch: subpattern 1 literal 97 literal 98 subpattern None groupref_exists 1 literal 99 literal 100 or literal 101 literal 102 2. Got rid of trailing spaces in Python 3. 3. Used named opcode constants instead of inlined strings. 4. Simplified and modernized the code. 5. Updated test to cover more code. -- components: Library (Lib), Regular Expressions files: re_debug.patch keywords: patch messages: 226903 nosy: ezio.melotti, mrabarnett, pitrou, serhiy.storchaka priority: normal severity: normal stage: patch review status: open title: Fix re debugging output type: behavior versions: Python 2.7, Python 3.4, Python 3.5 Added file: http://bugs.python.org/file36620/re_debug.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22415 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22379] Empty exception message of str.join
Yongzhi Pan added the comment: I have updated the test for 3.5. The related tests pass after the patching. Are they OK now? There are two caveats: I did not update test_bytes in 2.7, and I did not add checkraises in test_bytes in 3.5. -- Added file: http://bugs.python.org/file36621/test_for_35-1.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22379 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22416] Pickling compiled re patterns
New submission from Serhiy Storchaka: Compiled re._compile() is used to reconstruct compiled regular expression pattern. re._compile() is private function and can be removed in (long-term) future. I propose to use re.compile() instead. -- components: Library (Lib), Regular Expressions keywords: easy messages: 226905 nosy: ezio.melotti, mrabarnett, pitrou, serhiy.storchaka priority: normal severity: normal status: open title: Pickling compiled re patterns type: enhancement versions: Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22416 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22408] Tkinter doesn't handle Unicode key events on Windows
Drekin added the comment: It seems that it's a problem of dead key combinations rather than modifiers. Unicode characters produced directly (with or without modifiers) work correctly. Only one deadkey on my keyboard doesn't work at all. AltGr + M is a deadkey, but any following key is interpreted as if no deadkey was pressed. On the other hand, other deadkeys including those with modifiers produces the combined characters, however usually returns just ? as if someone applied char = char.encode(mbcs, errors=replace).decode(). E.g. whole Greek alphabet is transformed to question marks but beta is transformed to sharp s and mu to micro sign. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22408 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18159] ConfigParser getters not available on SectionProxy
Łukasz Langa added the comment: The new implementation also automatically covers get*() methods added on subclasses, no need to use converters= in that case. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18159 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18159] ConfigParser getters not available on SectionProxy
Roundup Robot added the comment: New changeset 2c46a4ded259 by Łukasz Langa in branch 'default': Closes #18159: ConfigParser getters not available on SectionProxy https://hg.python.org/cpython/rev/2c46a4ded259 New changeset 5eb95d41ee43 by Łukasz Langa in branch 'default': Closes #18159: ConfigParser getters not available on SectionProxy https://hg.python.org/cpython/rev/5eb95d41ee43 -- nosy: +python-dev resolution: - fixed stage: patch review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18159 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22416] Pickling compiled re patterns
Changes by Serhiy Storchaka storch...@gmail.com: -- keywords: +patch stage: - patch review Added file: http://bugs.python.org/file36622/re_pickle.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22416 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22253] ConfigParser does not handle files without sections
Łukasz Langa added the comment: I don't like the idea to magically introduce a '' section since this behaviour would be confusing for interpolation and not particularly discoverable by programmers. Let alone bikeshedding if this should rather be a None section. Using DEFAULTSECT for this purpose is equally wrong since it would silently inject default values to every section, which may or may not be desirable. All in all, it comes down to the question whether the programmer expects section-less configuration. If not, the '' section will not be helpful anyway. If yes, then it's desirable to be able to specify a section name for global options at *read time*. Symmetrically, the user could specify which section name to omit during configuration writing. I like that since it's explicit and more composable than a blanket global section. It would also be 100% backwards compatible. I'll prepare a patch for this idea so we can see how good this API looks like in practice. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22253 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22412] Towards an asyncio-enabled command line
Martin Teichmann added the comment: As promised, a new patch now for the current head. Last time I apparently got confused with how hg works, sorry. -- Added file: http://bugs.python.org/file36623/patch2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22412 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22166] test_codecs leaks references
Roundup Robot added the comment: New changeset fcf45ec7863e by Nick Coghlan in branch '3.4': Issue #22166: clear codec caches in test_codecs https://hg.python.org/cpython/rev/fcf45ec7863e New changeset 322ee2f2e922 by Nick Coghlan in branch 'default': Merge fix for issue #22166 from 3.4 https://hg.python.org/cpython/rev/322ee2f2e922 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22166 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22166] test_codecs leaks references
Changes by Nick Coghlan ncogh...@gmail.com: -- resolution: - fixed stage: - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22166 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22417] PEP 476: verify HTTPS certificates by default
New submission from Nick Coghlan: Attached minimal patch updates http.client.HTTPSConnection to validate certs by default and adjusts test.test_httplib accordingly. It doesn't currently include any docs changes, or changes to urllib. The process wide revert to the old behaviour hook is to monkeypatch the ssl module: ssl._create_default_https_context = ssl._create_unverified_context To monkeypatch the stdlib to validate *everything* (this one isn't new, just noting it for the record): ssl._create_stdlib_context = ssl.create_default_context -- files: pep476_minimal_implementation.diff keywords: patch messages: 226912 nosy: alex, larry, ncoghlan priority: high severity: normal status: open title: PEP 476: verify HTTPS certificates by default type: enhancement Added file: http://bugs.python.org/file36624/pep476_minimal_implementation.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22417 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16095] urllib2 failing with squid proxy and digest authentication
Alexander Weidinger added the comment: So, I analyzed the error and I think I found the problem. (urllib.request - Python 3.5.0) It all starts with l. 1079, as the 407 error gets handled, everything ok here, in l. 1081 http_error_auth_reqed(...) gets executed. So next, we are in l. 939, also everything correct here, retry_http_digest_auth gets executed in l. 953. (woops, http_digest_auth?!, nah, let's see what comes next) So we are in l. 953 and follow the code to come to the get_authorization(...) call. Now we are in l. 981, and in that part of the code lies the problem. To get the username and password for the proxy, the function find_user_password(realm, req.full_url) gets executed. An example, if my proxy has the address abc.com:8080 and my request is for xyz.com, the function tries to find a password for the xyz.com url, instead of the abc.com:8080 url. So it can't find a password and the whole auth process stops with the 407 error. But if you just change the line, to use the host, normal http digest auth doesn't work anymore, I would suggest? So it's also obvious why the workaround of toobaz works. To solve the Problem, two auth handler would be needed, one for the proxy and one for normal http auth. Two different handlers were used in the basic auth, so I think it would be an consistent solution? -- nosy: +alexwe ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16095 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22166] test_codecs leaks references
STINNER Victor added the comment: IMO test_codecs_fix1.patch is still needed. Review of Nick's change: +interp = PyThreadState_GET()-interp; +if (interp-codec_search_path == NULL) { +return -1; +} I don't think that this line raises an exception. You should use an assertion here (or raises an exception, but it would be overkill). +encodings._cache.pop(self.codec_name, None) +try: +_forget_codec(self.codec_name) +except KeyError: +pass You may move these lines to a private encoding._forget() function. By the way, codecs._forget() should maybe catch and ignore KeyError? _TEST_CODECS.pop(self.codec_name, None) This line may be moved to set_codec() using self.addCleanup(). (Well, it's not directly related to your change.) -- resolution: fixed - status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22166 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22166] test_codecs leaks references
Marc-Andre Lemburg added the comment: On 15.09.2014 15:19, STINNER Victor wrote: STINNER Victor added the comment: IMO test_codecs_fix1.patch is still needed. Review of Nick's change: +interp = PyThreadState_GET()-interp; +if (interp-codec_search_path == NULL) { +return -1; +} I don't think that this line raises an exception. Agreed. Please also add some documentation to the codecs.h file and perhaps a test for the function itself ;-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22166 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22418] ipaddress.py new IPv6 Method for Solicited Multicast Address
New submission from Jason Nadeau: I found it was useful to me to calculate and return an IPv6Address instance of the solicited multicast address for a particular IPv6Address. So I have created patch to do so. I am pretty new to programming in general so critiques are totally welcome. -- components: Library (Lib) files: solicitedMulticastAddress.patch keywords: patch messages: 226916 nosy: Jason.Nadeau priority: normal severity: normal status: open title: ipaddress.py new IPv6 Method for Solicited Multicast Address type: enhancement versions: Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5 Added file: http://bugs.python.org/file36625/solicitedMulticastAddress.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22418 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22139] python windows 2.7.8 64-bit did not install
Henning von Bargen added the comment: Perhaps this issue should be re-opened. I stumbled across a similar issue today, and made some potentially useful observations. On a machine with an existing c:\python27 directory (Python 2.7.5), I installed Python 2.7.8 with the install just for me option into a new directory c:\python278. That's because there are several Python-based applications running; and I want to restrict the new Python version to one of them. The application uses a different executable, LisaReportingAgent.exe. Within the same environment (PATH first entry is c:\python278), calling python.exe, listing sys.path gives the expected output: C:\Lisa\Kronos\reporting\test\binc:\python278\python Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win 32 Type help, copyright, credits or license for more information. import sys for f in sys.path: print f ... C:\Lisa\Kronos\reporting\test c:\python278\python27.zip c:\python278\DLLs c:\python278\lib c:\python278\lib\plat-win c:\python278\lib\lib-tk c:\python278 c:\python278\lib\site-packages c:\python278\lib\site-packages\win32 c:\python278\lib\site-packages\win32\lib c:\python278\lib\site-packages\Pythonwin ^Z Whereas the special executable's output is much different: C:\Lisa\Kronos\reporting\test\bin..\..\bin\win32-x86\LisaReportingAgent.exe Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win 32 Type help, copyright, credits or license for more information. import sys for f in sys.path: print f ... C:\Lisa\Kronos\reporting\test C:\WINDOWS\system32\python27.zip C:\Python278\Lib C:\Python278\DLLs C:\Python278\Lib\lib-tk C:\Python27\Lib C:\Python27\DLLs C:\Python27\Lib\lib-tk C:\Lisa\Kronos\reporting\test\bin C:\Lisa\Kronos\reporting\bin\win32-x86 C:\Python27 C:\Python27\lib\site-packages C:\Python27\lib\site-packages\win32 C:\Python27\lib\site-packages\win32\lib C:\Python27\lib\site-packages\Pythonwin Note the entries with c:\windows and with the different Python installation C:\python27. They are pointing to the old Python installation. The executable is built from the following C code (except for initializing a SWIG-generated Python wrapper for a PDF library): int main( int argc, char* argv[] ) { int rc = 0; /* ... setup a license key ... */ Py_SetProgramName(argv[0]); Py_Initialize(); /* ... init PDF library ... */ rc = Py_Main(argc, argv); Py_Finalize(); /* ... shut down PDF library ... */ return rc; } I've read something that Python 2.7 behaves differently on Windows regarding installation and setup in comparison to 2.6. It seems that the new python.exe performs registry magic? -- nosy: +Henning.von.Bargen ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22139 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22139] python windows 2.7.8 64-bit did not install
Henning von Bargen added the comment: The online help says: When Python is hosted in another .exe (different directory, embedded via COM, etc), the “Python Home” will not be deduced, so the core path from the registry is used. Other “application paths” in the registry are always read. and If the environment variable PYTHONHOME is set, it is assumed as “Python Home”. Otherwise, the path of the main Python executable is used to locate a “landmark file” (Lib\os.py) to deduce the “Python Home”. If a Python home is found, the relevant sub-directories added to sys.path (Lib, plat-win, etc) are based on that folder. Otherwise, the core Python path is constructed from the PythonPath stored in the registry. So I set PYTHONHOME=c:\python278, then call LisaReportingServer.exe again. Now the output for sys.path looks OK to me, but import hmac still fails: C:\Lisa\Kronos\reporting\test\bin..\..\bin\win32-x86\LisaReportingAgent.exe Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win 32 Type help, copyright, credits or license for more information. import sys for f in sys.path: print f ... C:\Lisa\Kronos\reporting\test C:\WINDOWS\system32\python27.zip c:\python278\DLLs c:\python278\lib c:\python278\lib\plat-win c:\python278\lib\lib-tk C:\Lisa\Kronos\reporting\bin\win32-x86 c:\python278 c:\python278\lib\site-packages c:\python278\lib\site-packages\win32 c:\python278\lib\site-packages\win32\lib c:\python278\lib\site-packages\Pythonwin import hmac Traceback (most recent call last): File stdin, line 1, in module File c:\python278\lib\hmac.py, line 8, in module from operator import _compare_digest as compare_digest ImportError: cannot import name _compare_digest -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22139 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22139] python windows 2.7.8 64-bit did not install
Henning von Bargen added the comment: Sorry, of course it's NOT OK, because there's still C:\WINDOWS\system32\python27.zip as the second entry. BTW the relevant environment variables: Path=c:\python278;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\lisa\Kronos\reporting\lib\win32-x86\pdfprint PYTHONHOME=c:\python278 PYTHONPATH=C:\Lisa\Kronos\reporting\test\bin\.. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22139 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22139] python windows 2.7.8 64-bit did not install
Henning von Bargen added the comment: I don't see how this sys.path is related to the online help section 3.3.3. Finding modules. Where does c:\windows\python27.zip come from? And why does Python have to install anything in the Windows directory at all? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22139 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22139] python windows 2.7.8 64-bit did not install
Henning von Bargen added the comment: The only solution I could find was to give up running 2.7.8 next to 2.7.5, then uninstall 2.7.8, then install 2.7.8 with the install for all users option selected. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22139 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22377] %Z in strptime doesn't match EST and others
R. David Murray added the comment: I think its existing behavior is because it doesn't have access to a list of recognized timezones. As you say, this could be fixed by PEP 431. It could also be fixed by adopting the email standard timezones (see email/_parseaddr.py), which is a def-facto standard. Regardless of whether something is done to expand the number of timezone it knows about, though, there's a current doc bug that should be fixed. If someone wants to advocate for expanding the timezone list, that should be a separate issue. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22377 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22379] Empty exception message of str.join
R. David Murray added the comment: The str of the exception will always be nonblank (it will contain the string 'TypeError' at a minimum). So you need to peel off the 'TypeError:' prefix before testing if you want to use str(e). That's why I suggested using args[0], but I suppose that might be a little more fragile. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22379 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22139] python windows 2.7.8 64-bit did not install
Martin v. Löwis added the comment: Henning: if you have installed Python 2.7.5 for all users, then this behavior is expected. Python finds python27.dll in system32, so even if you install 2.7.8 just for me, it will still pick up 2.7.5 from system32. Installing different 2.7 versions on the same machine isn't really supported, although it should work if they are all installed just for me. The operator module comes from python27.dll. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22139 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22139] python windows 2.7.8 64-bit did not install
Henning von Bargen added the comment: Installing different 2.7 versions on the same machine isn't really supported, although it should work if they are all installed just for me. Sigh... I've come to the same conclusion. Nevertheless it seems to me that the actual behavior is different from the online documentation 3.3.3 Finding modules at https://docs.python.org/2/using/windows.html -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22139 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22417] PEP 476: verify HTTPS certificates by default
Changes by Alex Gaynor alex.gay...@gmail.com: -- nosy: +dstufft ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22417 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21472] Fix wsgiref handling of absolute HTTP Request-URI
Guido van Rossum added the comment: Wow. This is interesting. I thought that absolute URL support was only for proxies, but the spec you quote says clearly it should be supported as a transition towards always specifying the full URL. I guess they want to get rid of the Host: header? In any case I would worry (a bit) that this might cause security issues if implemented as naively as shown in your patch -- the other components of the URL should probably be validated against the configuration of the server. Also I am wondering whether specifying a different port or protocol (e.g. HTTPS) should be allowed or not, and what to do with extraneous parts of the path (in particular the #fragment identifier). You should probably also be careful with path-less domain names -- IIRC some URL parsers produce as the path for e.g. http://python.org;. Finally, AFAIK the HTTP 1.1 standard is full of ideas that few server implementations support, for various reasons, and it's possible that a future standard actually rescinds (or discourages) some features. Have you asked for the status of this particular feature? -- nosy: +gvanrossum ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21472 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue672656] securing pydoc server
Devin Cook added the comment: It looks like this bug was reintroduced in a5a3ae9be1fb. -- nosy: +devin ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue672656 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22416] Pickling compiled re patterns
Guido van Rossum added the comment: But who says this isn't intended? I don't know why it was done this way, but the following reasoning might apply: we want to have a stable API for unpickling compiled regexps, but we want to be able to evolve the re.compile() API. Just the fact that '_compile' starts with an underscore doesn't mean that it may involve -- in fact, the fact that it is used by pickles says the opposite. Therefore I think the patch makes things worse (tying the pickle format to the public re.compile() method). At best we should add a comment to _compile explaining that its API is constrained by pickle backward compatibility. -- nosy: +gvanrossum resolution: - not a bug status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22416 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22418] ipaddress.py new IPv6 Method for Solicited Multicast Address
Changes by Ned Deily n...@acm.org: -- nosy: +ncoghlan, pmoody ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22418 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue672656] securing pydoc server
Ned Deily added the comment: Devin, please open a new issue describing the current problem you see. Comments to long-closed issues will likely be overlooked. -- nosy: +ned.deily ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue672656 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22412] Towards an asyncio-enabled command line
Guido van Rossum added the comment: OK. Trying to understand the patch, there seem to be three parts to it: (a) Changes to CPython to add a new flag to the exec/eval flags argument that sets the GENERATOR flag in the resulting code object. This seems the most fundamental, but it also feels the trickiest. It is a change to a built-in function so it must be supported by other Python implementations (esp. PyPy, Jython, IronPython, Cython). It also feels wrong -- it may be the case that you or your colleagues *want* to be able to write yield from XXX at the prompt, but that doesn't make it a good idea. Especially since it will never be supported by the *regular* REPL -- it will only work in your customized REPL, but it isn't particularly obvious why it works there and not elsewhere. Also, I think supporting yield from in the repl() will teach the wrong thing -- people used to this working will attempt to use yield from at the top level in a script or module and be confused why it doesn't work there. I really think that it's must better to give them a helper function such as was sho wn early in the python-ideas thread. (Once imported, it's less typing too!) (b) Changes to the readline module to support some kind of async behavior, so that you can use the readline module's editing behavior from within an asyncio event loop. I can see the advantage of this, and I am not philosophically opposed (as I am for (a)). Without this, your users would either not have the benefit of convenient input editing, or you would have to reimplement the entire set of features of GNU readline afresh, which does sound excessive. However, once you give up on (a), you don't need (b) either. On the pragmatics of the patch, I don't have time to review it in detail, and I don't know if you can easily find anyone who does -- I just want to note that as it stands, there is a bug in the code, at least on OS X, since I get this: import time, readline time.sleep(1); readline._input() asd asd python.exe(67432,0x7fff7d790310) malloc: *** error for object 0x7fc8506046f0: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug Abort trap: 6 (Immediately after the second input line, I quickly typed 'asd' and pressed Return. The 'asd' got echoed, I got a new prompt, and then something crashed.) (c) A new function input() in the asyncio module. If (a) and (b) were accepted in Python, this might as well be part of your third-party module that implements your interactive shell, so there's not strictly a need for this. It also doesn't work on all platforms (e.g. I don't think it will work on Windows). My recommendation to you is to give up on (a) and instead add the suggested helper function to the globals in your own REPL, and tell your users to use that at the top-level. Python doesn't support yield-from at the top level in scripts and modules, and they may as well get used to that idea. You can still, separately, work on (b), but you will have to find someone in the core dev team who is motivated enough to help you make it work properly or fail safely (on platforms where it can't be made to work). For (c), I don't think that's ready for inclusion in the stdlib either (though perhaps we could add some descendant of it to Python 3.5 if you got (b) accepted). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22412 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22419] wsgiref request length
New submission from Devin Cook: BaseHTTPRequestHandler limits request length to prevent DoS. WSGIRequestHandler should probably do the same. See: http://bugs.python.org/issue10714 -- components: Library (Lib) files: wsgiref_request_length.patch keywords: patch messages: 226931 nosy: devin priority: normal severity: normal status: open title: wsgiref request length type: security Added file: http://bugs.python.org/file36626/wsgiref_request_length.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22419 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21998] asyncio: a new self-pipe should be created in the child process after fork
Guido van Rossum added the comment: That sounds about right -- it's a doc issue. Let me propose a paragraph: NOTE: It is not safe to share an asyncio event loop between processes that are related by os.fork(). If an event loop exists in a process, and that process is forked, the only safe operation on the loop in the child process is to call its close() method. (I don't want to have to research what the various polling primitives do on fork(), so I don't want to suggest that it's okay to close the loop in the parent and use it in the child.) A similar note should probably be added to the docs for the selectors module. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21998 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17620] Python interactive console doesn't use sys.stdin for input
Drekin added the comment: I have found another problem. PyOS_Readline can be called from two different places – from Parser/tokenizer.c:tok_nextc (by REPL), which uses sys.stdin.encoding to encode prompt argument, and from Python/bltinmodule.c:builtin_input_impl (by input() function), which uses sys.stdout.encoding. So readline hook cannot be implemented correctly if sys.stdin and sys.stdout don't have the same encoding. Either the tokenizer should have two encodings – one for input and one for output - or better no encoding at all and should use Python string based alternative to PyOS_Readline, which could be added. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17620 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22418] ipaddress.py new IPv6 Method for Solicited Multicast Address
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +neologix ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22418 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22420] Use print(file=sys.stderr) instead of sys.stderr.write() in IDLE
New submission from Serhiy Storchaka: Proposed patch replaces print(file=sys.stderr) by sys.stderr.write() in IDLE for same reason as in issue22384. May be this will eliminate some crashes when IDLE run with pythonw.exe. -- components: IDLE files: idle_print_stderr.patch keywords: patch messages: 226934 nosy: serhiy.storchaka priority: normal severity: normal stage: patch review status: open title: Use print(file=sys.stderr) instead of sys.stderr.write() in IDLE versions: Python 2.7, Python 3.4, Python 3.5 Added file: http://bugs.python.org/file36627/idle_print_stderr.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22420 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22420] Use print(file=sys.stderr) instead of sys.stderr.write() in IDLE
Changes by Serhiy Storchaka storch...@gmail.com: -- nosy: +kbk, roger.serwy, terry.reedy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22420 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22421] securing pydoc server
New submission from Devin Cook: Several years ago a patch was applied to set the default binding of the pydoc server to localhost instead of 0.0.0.0. It appears that the issue was reintroduced in a5a3ae9be1fb. See previous issue: http://bugs.python.org/issue672656 $ ./python -m pydoc -b Server ready at http://localhost:35593/ Server commands: [b]rowser, [q]uit server --- $ netstat -lnp | grep python tcp0 0 0.0.0.0:35593 0.0.0.0:* LISTEN 2780/python As a sidenote, I'm not sure why the localhost lookup breaks the test case on my linux machine, but it does. -- components: Library (Lib) files: pydoc_server_addr.patch keywords: patch messages: 226935 nosy: devin priority: normal severity: normal status: open title: securing pydoc server type: security Added file: http://bugs.python.org/file36628/pydoc_server_addr.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22421 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22253] ConfigParser does not handle files without sections
Terry J. Reedy added the comment: I read the rsyncd.conf doc at http://linux.die.net/man/5/rsyncd.conf (linked from the StackOverflow question). These files are not .ini files. However, I believe the parsing rules are mostly compatible with RawConfigParser, or could be made so by using existing customization options, including subclassing. The sectionless options are called 'global options' for one of two different reasons. Some, selected from a predefined list of startup options, act as if they were in a [STARTUP] section. Others, selected from a predefined list of module options, act as if they were in a [DEFAULT] section. The latter provide alternate default value for options in the various [module] sections. We clearly should not directly support the specialized rules of rsyncd.conf. But if, as kernc requests, RawConfigParser gathered sectionless options into a '' section, users could probably work with these files. The details would be up to them, or a config_unix module writer. The same comment applies to other files, including .ini files with sectionless options. Łukasz, the only one bikeshedding '' is you. I do not see any need for a new API and I think it just confuses this issue. Reading and writing sectionless options via a '' section should be sufficient to work with .ini files. To me, the remaining question is whether to retain configparser.MissingSectionHeaderError. The problem with piggy-backing its optional use on the 'strict' parameter is that someone might want to reject duplicates while reading sectionless options. But it ia a plausible idea. As an aside, the documentation for MissingSectionHeaderError is currently a bit confused. The docstring correctly says Raised when a key-value pair is found before any section header. The doc incorrectly says Exception raised when attempting to parse a file which has no section headers. I tested and it is indeed raised even when there is a section header after an initial option line. The exception message is also wrong: File contains no section headers. The latter two should really say that the files does not *start* with a section header (ignoring comment lines), or use the wording of the docstring. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22253 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22420] Use print(file=sys.stderr) instead of sys.stderr.write() in IDLE
Terry J. Reedy added the comment: You meant it the other way around 'replace sys.stderr.write() by print(file=sys.stderr)'. In the two cases where Idle exits anyway, this will not make any difference (except possible in the return code). In the other cases where Idle tries to continue, this will. The real fix needed is to replace stderr, at least when None, so that the messages are displayed in a gui widget. However, if I cannot do that this week, before 3.4.2, I will apply this. Thanks for the patch. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22420 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue672656] securing pydoc server
Devin Cook added the comment: Sure, thanks. New issue: http://bugs.python.org/issue22421 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue672656 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21965] Add support for Memory BIO to _ssl
Geert Jansen added the comment: Antoine, sorry for the delay, we just had a new kid and I changed jobs :) Let me try if I can create an updated patch that where SSLObject is a mixin for SSLSocket. I think the argument about writing tests once is important. Be back in a few days.. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21965 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22139] python windows 2.7.8 64-bit did not install
Martin v. Löwis added the comment: How so? Every single sentence in this section is absolutely correct. It just doesn't talk about finding builtin modules at all, only about modules found on the Python path (.py and .pyd files). Builtin modules don't have to be found, because they are, well, built in. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22139 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com