Re: learnpython.org - an online interactive Python tutorial
Dave Angel wrote: time echo scale = 1010; 16 * a(1/5) - 4 * a(1/239) |bc -lq Wouldn't it be shorter to say: time echo scale = 1010; 4 * a(1) |bc -lq Well, you can check it out by doing the math... (its fun...) ... you will notice that 'time' is called first, which on *nix systems clocks the processing, breaking out the system and user times... right? ... so try these 10,000 comparisons on your *nix system: time echo scale = 10010; 16 * a(1/5) - 4 * a(1/239) |bc -lq time echo scale = 10010; 4 * a(1) |bc -lq (those will take a few minutes, if your processor is running 2-3Ghz...) ... then try these 100,000 runs: time echo scale = 100010; 16 * a(1/5) - 4 * a(1/239) |bc -lq time echo scale = 100010; 4 * a(1) |bc -lq (Those will take some time, probably less than 20 - 30 minutes... ) After your time comparisons, tell me whether you want to use a(1)*4 ?? Leonard Euler came up with the formula I'm using here... and used it himself for paper 'n pencil arithmetic... because the arctan(n) infinite series converges much quicker (by orders of magnitude) for values of (n) 0. (the smaller the (n) the better) We can make the entire function run even faster by using smp and splitting the 'a(1/5)' and 'a(1/239)' across two cores, having the arctan series' running in parallel. This is important if your 'big num' is going to be hundreds of thousands or millions of places. On my baby Beowulf cluster I have played a bit with running this on two separate systems and then bringing the result together in the end... fun for playtime... interesting to see how many digits (in how much time) can be achieved *without* using a super-computer You can also try these formula for comparison sake: PI = 20 * a(1/7) + 8 * a(3/79) or PI = 8 * a(1/3) + 4 * a(1/7) or PI = 24 * a(1/8) + 8 * a(1/57) + 4 * a(1/239) Happy Easter, and have a slice of pie on me :) kind regards, m harris -- http://mail.python.org/mailman/listinfo/python-list
Re: learnpython.org - an online interactive Python tutorial
Steven D'Aprano wrote: It seems to me that weak typing is a Do What I Mean function, and DWIM is a notoriously bad anti-pattern that causes far more trouble than it is worth. I'm even a little suspicious of numeric coercions between integer and float. (But only a little.) I'm wondering about that as well... (a little)... I mean, maybe the way to be really consistent (especially with the Zen of Python, explicit is better than implicit) that int -- float -- complex (imaginary) should not occur either ! I think folks would baulk at that though... big-time. :) So, bottom line here... if my students want to get numbers into their programs in 3.x then the correct way to handle the imput() would be: n = int(input(enter num )) ... and then let the interpreter throw an exception if the input cannot be type cast to int? kind regards, m harris -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors
On Monday 25 April 2011 12:59:38 rusi wrote: On Apr 25, 4:49 am, Robert Kern robert.k...@gmail.com wrote: On 4/22/11 7:32 PM, Algis Kabaila wrote: On Saturday 23 April 2011 06:57:23 sturlamolden wrote: On Apr 20, 9:47 am, Algis Kabailaakaba...@pcug.org.au wrote: Are there any modules for vector algebra (three dimensional vectors, vector addition, subtraction, multiplication [scalar and vector]. Could you give me a reference to such module? NumPy Or one of these libraries (ctypes or Cython): BLAS (Intel MKL, ACML, ACML-GPU, GotoBLAS2, or ATLAS) Intel VML ACML-VM Thanks for that. Last time I looked at numpy (for Python3) it was available in source only. I know, real men do compile, but I am an old man... I will compile if it is unavoidable, but in case of numpy it does not seem a simple matter. Am I badly mistaken? On UNIX machines with compilers and headers properly installed, it's really pretty straightforward. Mostly (on ubuntu/debian) that means do this [Untested] $ aptitude build-dep python-numpy Then you should be ready to build/compile numpy from source Thank you, Robert and Rusi, I will try it RSN, but first the latest version of ubuntu that should become available this week (including today?!). OldAl. -- Algis http://akabaila.pcug.org.au/StructuralAnalysis.pdf -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectors
On Apr 20, 2:43 pm, Andreas Tawn andreas.t...@ubisoft.com wrote: Algis Kabaila akaba...@pcug.org.au writes: Are there any modules for vector algebra (three dimensional vectors, vector addition, subtraction, multiplication [scalar and vector]. Could you give me a reference to such module? NumPy has array (and matrix) types with support for these basic operations you mention. See the tutorial athttp://numpy.scipy.org/ You might also want to considerhttp://code.google.com/p/pyeuclid/ Cheers, Drea Stealing this from Casey Duncan's recent post to the Grease users list: - (ab)use complex numbers for 2D vectors (only). Very fast arithmetic and built-in to Python. Downside is lack of abstraction. - Use pyeuclid (pure python) if ultimate speed isn't an issue, or if compiled extensions are. It supports 3D and has a nice api - vectypes is a more recent project from the same author as pyeuclid. It offers a more consistent 'GLSL' like interface, including swizzling, and internally seems to have more maintainable code because it generates various sizes of vector and matrix from a single template. This is done without performance penalty because the generation is done at design time, not runtime. - Use pyeigen if you want fast vectors, and don't mind compiling some C/C++. I don't know how the Python api looks though - Use numpy if you want fast batch operations -- http://mail.python.org/mailman/listinfo/python-list
Re: Function __defaults__
On 24-Apr-11 13:07 PM, Ken Seehart wrote: On 4/24/2011 2:58 AM, Steven D'Aprano wrote: Consider this in Python 3.1: def f(a=42): ... return a ... f() 42 f.__defaults__ = (23,) f() 23 Is this an accident of implementation, or can I trust that changing function defaults in this fashion is guaranteed to work? This is documented in python 3, so I would expect it to be stable (until python 4, that is) http://docs.python.org/py3k/whatsnew/3.0.html#operators-and-special-methods http://docs.python.org/py3k/library/inspect.html#types-and-members The f.__defaults__ attribute was previously known as f.func_defaults (in python 2.x), which has been around, documented and stable for quite a while. So it's probably just as safe as any other monkey patching technique. :) Best of luck, Ken Wouldn't it make more sense to return a dictionary instead of a tuple? Colin W. -- http://mail.python.org/mailman/listinfo/python-list
Re: Function __defaults__
On 4/25/2011 4:59 AM, Colin J. Williams wrote: On 24-Apr-11 13:07 PM, Ken Seehart wrote: On 4/24/2011 2:58 AM, Steven D'Aprano wrote: Consider this in Python 3.1: def f(a=42): ... return a ... f() 42 f.__defaults__ = (23,) f() 23 Is this an accident of implementation, or can I trust that changing function defaults in this fashion is guaranteed to work? This is documented in python 3, so I would expect it to be stable (until python 4, that is) http://docs.python.org/py3k/whatsnew/3.0.html#operators-and-special-methods http://docs.python.org/py3k/library/inspect.html#types-and-members The f.__defaults__ attribute was previously known as f.func_defaults (in python 2.x), which has been around, documented and stable for quite a while. So it's probably just as safe as any other monkey patching technique. :) Best of luck, Ken Wouldn't it make more sense to return a dictionary instead of a tuple? Colin W. I assume you mean making the value of f.__defaults__ a dictionary instead of a tuple. A dictionary would be slower to process since it would have to iterate the dictionary keys and assign arguments by name. Since argument defaults can only be applied to the rightmost contiguous sequence of zero or more parameters (excluding *args,**kwargs), a tuple is sufficient to cover all cases, so a dictionary would provide no advantage. Also, a dictionary would produce an unnecessary error case (if a key in the dictionary is not the name of an argument). Good question though. Cheers, Ken -- http://mail.python.org/mailman/listinfo/python-list
Changing baud rate doesn't allow second command
hi - I need to open a serial port in 9600 and send a command followed by closing it, open serial port again and send a second command at 115200. I have both commands working separately from the python command line but it won't work in the script. Any idea why? import serial from time import sleep ser = serial.Serial(0, baudrate=9600) status = ser.isOpen() print baud bitch: ser.isOpen() #init to TIPY ser.write('\x00\x00\x00\x00\xE0\xE0\xE0\xE0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x13\x00\x02\x00\xEB\xFD\xFF \x10\x87\x02\xFE\x10\x03\x10\x87\x02\xFE\x10\x03') #hex command msg ser.close() sleep(5) #wait ser = serial.Serial(0, baudrate=115200) ser.baudrate ser.write('\x10\x1C\x0D\x02\x0B\x0B\x02\x01\x21\x06\x00\x13\x07\x18\x7F \x10\x03') ser.close() #import os #program = 'C:\Program Files\Program.exe'+'-start' #os.system(r'program) -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing baud rate doesn't allow second command
In article 224f6621-2fc4-4827-8a19-3a12371f3...@l14g2000pre.googlegroups.com, rjmccorkle robert.mccor...@gmail.com wrote: hi - I need to open a serial port in 9600 and send a command followed by closing it, open serial port again and send a second command at 115200. I have both commands working separately from the python command line but it won't work in the script. I've never used this module (I assume you're talking about http://pyserial.sourceforge.net/), but my guess is that if it works when you type it in but not when you run it as a script, there's probably some kind of race condition around the driver resetting the bit rate. I would try a 1 second sleep after every call that touches the device driver (including the serial.Serial() calls) and see if that helps. It's a bit of a shot in the dark, but doesn't cost anything to try. Another possibility is that the UART (I assume such things still exist?) sends a few bits of gibberish onto the line when the bit rate changes, and this is corrupting your data. It shouldn't, but you never know with this stuff. If that's the case, you're probably screwed. Just out of curiosity, what are you trying to do? Serial ports are pretty much ancient history these days. -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing baud rate doesn't allow second command
Am 25.04.2011 14:46, schrieb rjmccorkle: hi - I need to open a serial port in 9600 and send a command followed by closing it, open serial port again and send a second command at 115200. I have both commands working separately from the python command line but it won't work in the script. Any idea why? What does won't work mean? I can't see any issues in the code. I suppose the string sent with 9600 tells the device to change the speed. Are you sure that it is received correctly? Additionally, maybe you have output issues. E.g. you just write ser.baudrate instead of print ser.baudrate, so that could be a source of behavioral differences. #import os #program = 'C:\Program Files\Program.exe'+'-start' #os.system(r'program) I suppose this doesn't belong to the problem? Thomas -- http://mail.python.org/mailman/listinfo/python-list
MIDI message sending and receiving, MID file manipulation
Hello, I'd like to experiment with Python, connecting my Linux PC with MIDI device (standard synthesiser keyboard). I am pretty new to the Python world, so the questions that crop up, I assume, could be pretty basic to someone who had spent some time with it. So, here comes: 1) Is everything what could be done with Python in some IDE (Eclipse for me), can be accomplished in the interactive console? I mean, perhaps Python could be used just as programming language and compiled in binary code, thus allowing access to some binary libraries what might not be accessible from within the interpreter. 2) Is there a way how to run Python script in event-driven mode, ie, run the script, it registers some function as keyboard event handler, and then calls that function whenever I press any key. Is such behaviour possible in the interactive mode? Since I want to test the MIDI message exchange, having a function sitting on the timer event is what I'll need for playback, and an event that is triggered by incoming MIDI message for recording. 3) Of course, I need some Python module to actually get this MIDI communication happen. Sending and receiving MIDI messages to and from my MIDI device. 4) As for manipulating the MIDI files in Python, I have searched up this: http://www.mxm.dk/products/public/pythonmidi However, this lib doesn't try to provide actual communication with MIDI device. -- http://mail.python.org/mailman/listinfo/python-list
Re: Function __defaults__
On 25-Apr-11 08:30 AM, Ken Seehart wrote: On 4/25/2011 4:59 AM, Colin J. Williams wrote: On 24-Apr-11 13:07 PM, Ken Seehart wrote: On 4/24/2011 2:58 AM, Steven D'Aprano wrote: Consider this in Python 3.1: def f(a=42): ... return a ... f() 42 f.__defaults__ = (23,) f() 23 Is this an accident of implementation, or can I trust that changing function defaults in this fashion is guaranteed to work? This is documented in python 3, so I would expect it to be stable (until python 4, that is) http://docs.python.org/py3k/whatsnew/3.0.html#operators-and-special-methods http://docs.python.org/py3k/library/inspect.html#types-and-members The f.__defaults__ attribute was previously known as f.func_defaults (in python 2.x), which has been around, documented and stable for quite a while. So it's probably just as safe as any other monkey patching technique. :) Best of luck, Ken Wouldn't it make more sense to return a dictionary instead of a tuple? Colin W. I assume you mean making the value of f.__defaults__ a dictionary instead of a tuple. A dictionary would be slower to process since it would have to iterate the dictionary keys and assign arguments by name. Since argument defaults can only be applied to the rightmost contiguous sequence of zero or more parameters (excluding *args,**kwargs), a tuple is sufficient to cover all cases, so a dictionary would provide no advantage. Also, a dictionary would produce an unnecessary error case (if a key in the dictionary is not the name of an argument). Good question though. Cheers, Ken I doubt that this functionality would be used in time critical work and so I suggest that efficiency is not a key consideration. Loss of information is perhaps more important. With the tuple being returned, the user is not informed that the value is associated with the name a Colin W. -- http://mail.python.org/mailman/listinfo/python-list
Re: Argument of the bool function
Am 10.04.2011 18:21, schrieb Mel: Chris Angelico wrote: Who would use keyword arguments with a function that takes only one arg anyway? It's hard to imagine. Maybe somebody trying to generalize function calls (trying to interpret some other language using a python program?) # e.g. input winds up having the effect of .. function = bool name = 'x' value = 'the well at the end of the world' ## ... actions.append ((function, {name:value})) ## ... for function, args in actions: results.append (function (**args)) Wrong structure. Better do function = bool value = 'the well at the end of the world' ## ... actions.append((function, (value,), {})) ## ... for function, args, kwargs in actions: results.append(function(*args, **kwargs)) or maybe even better (taking care for closures): function = bool value = 'the well at the end of the world' ## ... actions.append(lambda val=value: function(val)) ## ... for function in actions: results.append(function()) Not something I, for one, do every day. But regularity in a language is good when you can get it, especially for abstract things like that. I can sort of guess that `dir` was perhaps coded in C for speed and doesn't spend time looking for complicated argument lists. Python is a pragmatic language, so all the rules come pre-broken. Mel. -- http://mail.python.org/mailman/listinfo/python-list
Re: dict.setdefault()
Am 12.04.2011 04:58, schrieb rantingrick: That's sounds good MRAB! After you mentioned this i had an epiphany... why not just add an extra argument to dict.update? dict.update(D, clobberexistingkeys=False) This is AFAICS inconsistent to the possibility to do dict.update(a, k1=v1, k2=v2). Then you cannot set the key clobberexistingvalues to False via the update method any longer... Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing baud rate doesn't allow second command
On Apr 25, 7:06 am, Thomas Rachel nutznetz-0c1b6768-bfa9-48d5- a470-7603bd3aa...@spamschutz.glglgl.de wrote: Am 25.04.2011 14:46, schrieb rjmccorkle: hi - I need to open a serial port in 9600 and send a command followed by closing it, open serial port again and send a second command at 115200. I have both commands working separately from the python command line but it won't work in the script. Any idea why? What does won't work mean? I can't see any issues in the code. I suppose the string sent with 9600 tells the device to change the speed. Are you sure that it is received correctly? Additionally, maybe you have output issues. E.g. you just write ser.baudrate instead of print ser.baudrate, so that could be a source of behavioral differences. #import os #program = 'C:\Program Files\Program.exe'+'-start' #os.system(r'program) I suppose this doesn't belong to the problem? Thomas The code is fine but it seems it won't switch baud rates using pyserial. I have to initiate the first msg in 9600 to change the setting of the gps And then send the second command in 115200 because it's in configuration mode on the unit. I can see hooking two pcs together via null modem that the command is sent but I don't see the next msg go across. I'll try sleeps but even w a 15 sec sleep after close connection to allow for configuration mode to set (Which only takes about 4 seconds) it wasn't sending the second command. Weird. My buddy suggested I make two files for the separate calls but I wouldn't think that would make a diff or be necessary... -- http://mail.python.org/mailman/listinfo/python-list
Re: learnpython.org - an online interactive Python tutorial
On 4/25/2011 2:20 AM, harrismh777 wrote: Steven D'Aprano wrote: It seems to me that weak typing is a Do What I Mean function, and DWIM is a notoriously bad anti-pattern that causes far more trouble than it is worth. I'm even a little suspicious of numeric coercions between integer and float. (But only a little.) I'm wondering about that as well... (a little)... I mean, maybe the way to be really consistent (especially with the Zen of Python, explicit is better than implicit) that int -- float -- complex (imaginary) should not occur either ! I think folks would baulk at that though... big-time. :) Guido regards the number classes as subtypes of abstract number. Given a==d, and b==e, he believes that after c = a op b f = d op e then c == f should be true (in so far as possible). This is why he wanted to change int division. In other words, he wants Python math to pretty much imitate calculators, on the basis that this is what most users expect and want. This goes along with Python's general polymorphism/genericity/duck-typing philosophy. It is no different from the fact that one can write generic algorithms that give equivalent answers for equivalent inputs of ordered collections or indexable sequences. So, bottom line here... if my students want to get numbers into their programs in 3.x then the correct way to handle the imput() would be: n = int(input(enter num )) Yes. ... and then let the interpreter throw an exception if the input cannot be type cast to int? Converted (not cast) to int or float or complex or anything else other than strl. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing baud rate doesn't allow second command
Am 25.04.2011 16:41, schrieb rjmccorkle: The code is fine but it seems it won't switch baud rates using pyserial. I have to initiate the first msg in 9600 to change the setting of the gps And then send the second command in 115200 because it's in configuration mode on the unit. Ok. I can see hooking two pcs together via null modem that the command is sent but I don't see the next msg go across. The receiver changes speed as well, I suppose? I'll try sleeps but even w a 15 sec sleep after close connection to allow for configuration mode to set (Which only takes about 4 seconds) it wasn't sending the second command. mmm... strange. My buddy suggested I make two files for the separate calls but I wouldn't think that would make a diff or be necessary... Normally not, but it might worth trying. Anyway, have you tried to use setBaudrate() instead of close() and creating a new connection? I can't see why it should make a difference, but I as well can't see why your approach is not working, especially as it works if you do it manually... Maybe your target device expects to get something signalled via the status lines? Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: Input() in Python3
Westley Martínez wrote: On Fri, Apr 22, 2011 at 10:08:20AM -0400, Mel wrote: [ ... ] But sys.exit() doesn't return a string. My fave is Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type help, copyright, credits or license for more information. import sys a = int (input ('enter a number ')) enter a number sys.setrecursionlimit(1) Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in type 'exceptions.RuntimeError' ignored [ ... ] What? I guess sys.setrecursionlimit was meant to be called with a large number. Calling it with a small one roadblocks the interpreter. Luckily, there can be just enough room to call setrecursionlimit again with something reasonable to get it all back. Not enough room for `eval (sys.setrecursionlimit (2000)`, though. Mel. -- http://mail.python.org/mailman/listinfo/python-list
Re: Argument of the bool function
On Tue, Apr 26, 2011 at 12:29 AM, Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa...@spamschutz.glglgl.de wrote: for function in actions: results.append(function()) Can this become: results = [function() for function in actions] Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: About threads in python
On Fri, 22 Apr 2011 12:19:56 -0700 (PDT), sturlamolden sturlamol...@yahoo.no wrote: : To optimise computational code, notice that Python itself : gives you a 200x performance penalty. That is much more : important than not using all 4 cores on a quadcore processor. : In this case, start by identifying bottlenecks using the : profiler. Then apply C libraries or these or rewrite to Cython. : If that is not sufficient, you can start to think about using : more hardware (e.g. multithreading in C or Cython). This advice : only applies to computational code though. And not necessarily even there. The extra programmers to recode in C come with more than a 200x cost factor. It is almost trivial to make a multithread map implementation which could have exploited umpteen core box were it not for GIL. That would be a cheap gain. It matters little that you could gain 100x more at 200x cost ... Besides, the bottleneck is likely to be deeply embedded in some library like numpy or scipy already. -- :-- Hans Georg -- http://mail.python.org/mailman/listinfo/python-list
sockets: bind to external interface
Is there a simple way to find the external interface and bind a socket to it, when the hostname returned by socket.gethostname() maps to localhost? What seems to be the standard ubuntu configuration lists the local hostname with 127.0.0.1 in /etc/hosts. (I checked this on two ubuntu boxen, on only one of which I am root.) Thus, the standard solution of binding to whatever socket.gethostname() returns does not work. Has anyone found a simple solution that can be administered without root privileges? I mean simpler than passing the ip address manually :-) TIA -- :-- Hans Georg -- http://mail.python.org/mailman/listinfo/python-list
Re: sockets: bind to external interface
On Tue, Apr 26, 2011 at 5:37 AM, Hans Georg Schaathun h...@schaathun.net wrote: Has anyone found a simple solution that can be administered without root privileges? I mean simpler than passing the ip address manually :-) You can run 'ifconfig' without being root, so there must be a way. At very worst, parse ifconfig's output. The way you talk of the external interface, I'm assuming this computer has only one. Is there a reason for not simply binding to INADDR_ANY aka 0.0.0.0? Do you specifically need to *not* bind to 127.0.0.1? Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: sockets: bind to external interface
On Apr 25, 3:49 pm, Chris Angelico ros...@gmail.com wrote: On Tue, Apr 26, 2011 at 5:37 AM, Hans Georg Schaathun h...@schaathun.net wrote: Has anyone found a simple solution that can be administered without root privileges? I mean simpler than passing the ip address manually :-) You can run 'ifconfig' without being root, so there must be a way. At very worst, parse ifconfig's output. The way you talk of the external interface, I'm assuming this computer has only one. Is there a reason for not simply binding to INADDR_ANY aka 0.0.0.0? Do you specifically need to *not* bind to 127.0.0.1? Chris Angelico Binding to 0.0.0.0 is usually the right thing to do. The OP should probably do that unless he has some particular reason for doing otherwise. The comment about the standard solution of binding to whatever socket.gethostname() returns suggests that perhaps he wasn't aware that actually the standard solution is to bind to 0.0.0.0. However, the system stack can usually be tricked into revealing some more information this way: import socket s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(('1.2.3.4', 1234)) s.getsockname() ('192.168.1.148', 47679) Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: sockets: bind to external interface
On Tue, 26 Apr 2011 05:49:07 +1000, Chris Angelico ros...@gmail.com wrote: : You can run 'ifconfig' without being root, so there must be a way. At : very worst, parse ifconfig's output. Of course, but I am not sure that's simpler than the manual solution. Especially since there is more than one version of ifconfig ... : The way you talk of the external interface, I'm assuming this : computer has only one. Is there a reason for not simply binding to : INADDR_ANY aka 0.0.0.0? Ah. That's what I really wanted. Thanks a lot. I wonder why that was not mentioned in the tutorial I used ... -- :-- Hans Georg -- http://mail.python.org/mailman/listinfo/python-list
Re: sockets: bind to external interface
On Mon, 25 Apr 2011 21:14:51 +0100, Hans Georg Schaathun h...@schaathun.net wrote: : : The way you talk of the external interface, I'm assuming this : : computer has only one. Is there a reason for not simply binding to : : INADDR_ANY aka 0.0.0.0? : : Ah. That's what I really wanted. Thanks a lot. I wonder why that : was not mentioned in the tutorial I used ... Hmmm. socket.INADDR_ANY is an integer and bind insists on a string for the hostname (Python 2.6). Is there any use for the integer constant? 0.0.0.0 does exactly what I wanted though. Thanks again. -- :-- Hans Georg -- http://mail.python.org/mailman/listinfo/python-list
Re: sockets: bind to external interface
On Tue, Apr 26, 2011 at 6:14 AM, Hans Georg Schaathun h...@schaathun.net wrote: : The way you talk of the external interface, I'm assuming this : computer has only one. Is there a reason for not simply binding to : INADDR_ANY aka 0.0.0.0? Ah. That's what I really wanted. Thanks a lot. I wonder why that was not mentioned in the tutorial I used ... If you don't care what port you use, you don't need to bind at all. That may be why it's not mentioned - the classic TCP socket server involves bind/listen/accept, and the classic TCP client has just connect; bind/connect is a lot less common. Incidentally, interfaces don't have to correspond 1:1 to network cards. At work, we have a system of four IP addresses for each server, even though it has only one NIC - it's used for traffic management and routing. Binding to a specific address is sometimes important there. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing baud rate doesn't allow second command
On Apr 25, 10:09 am, Thomas Rachel nutznetz-0c1b6768-bfa9-48d5- a470-7603bd3aa...@spamschutz.glglgl.de wrote: Am 25.04.2011 16:41, schrieb rjmccorkle: The code is fine but it seems it won't switch baud rates using pyserial. I have to initiate the first msg in 9600 to change the setting of the gps And then send the second command in 115200 because it's in configuration mode on the unit. Ok. I can see hooking two pcs together via null modem that the command is sent but I don't see the next msg go across. The receiver changes speed as well, I suppose? I'll try sleeps but even w a 15 sec sleep after close connection to allow for configuration mode to set (Which only takes about 4 seconds) it wasn't sending the second command. mmm... strange. My buddy suggested I make two files for the separate calls but I wouldn't think that would make a diff or be necessary... Normally not, but it might worth trying. Anyway, have you tried to use setBaudrate() instead of close() and creating a new connection? I can't see why it should make a difference, but I as well can't see why your approach is not working, especially as it works if you do it manually... Maybe your target device expects to get something signalled via the status lines? Thomas Ya the gps box goes into configuration and expected another carriage return. Added \r before the second write and it works like a charm. I only found that by having to run the second write twice to discover it was wanting a second command from me... It worked to send the command twice but that's sloppy cuz it just needed a \r. Thanks for everyones help -- http://mail.python.org/mailman/listinfo/python-list
Python login script
I have written a python script that should log me in to a website. For the time being I want to login to gmail.com. My script pulls up the gmail webpage but does not input the login id and the password in the fields and does not log me in. I assume I am missing on something in my script. Can some body have a look as to what I am missing on. import cookielib import urllib import urllib2 import httplib if __name__ == '__main__': urlLogin = 'http://www.gmail.com' id= 'u2' passw = 'p2' fieldId = 'Email' fieldPass = 'passwd' cj = cookielib.CookieJar() data = urllib.urlencode({fieldId:id, fieldPass:passw}) opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) urllib2.install_opener(opener) usock = opener.open(urlLogin) usock = opener.open(urlLogin, data) pageSource = usock.read() usock.close() print(pageSource)-- http://mail.python.org/mailman/listinfo/python-list
windows 7 x64 shutdown
does anyone know a solution to shutting down windows 7 x64 via python script? the win32 obviously doesn't work... something similar? -- http://mail.python.org/mailman/listinfo/python-list
Re: sockets: bind to external interface
On Tue, Apr 26, 2011 at 6:24 AM, Hans Georg Schaathun h...@schaathun.net wrote: Hmmm. socket.INADDR_ANY is an integer and bind insists on a string for the hostname (Python 2.6). Is there any use for the integer constant? 0.0.0.0 does exactly what I wanted though. Thanks again. Apologies - I've done most of my sockets programming in C, where the integer constant is applicable. 0.0.0.0 means the exact same thing. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: Python login script
On Tue, Apr 26, 2011 at 7:15 AM, nusrath ahmed nusrathah...@yahoo.com wrote: I have written a python script that should log me in to a website. For the time being I want to login to gmail.com. My script pulls up the gmail webpage but does not input the login id and the password in the fields and does not log me in. I assume I am missing on something in my script. Can some body have a look as to what I am missing on. Look at the gmail page and see where it sends its form response. And please, can you continue the thread that already exists rather than open a new one with nearly-identical text? It gets very difficult to follow the changes, other than by pulling up your previous email and doing a visual diff. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: sockets: bind to external interface
Am 25.04.2011 22:14 schrieb Hans Georg Schaathun: On Tue, 26 Apr 2011 05:49:07 +1000, Chris Angelico ros...@gmail.com wrote: : The way you talk of the external interface, I'm assuming this : computer has only one. Is there a reason for not simply binding to : INADDR_ANY aka 0.0.0.0? Ah. That's what I really wanted. Thanks a lot. I wonder why that was not mentioned in the tutorial I used ... Generally, it seems better to use '' instead of '0.0.0.0' in this case in order to stay compatible with other address families, especially INET6. Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: sockets: bind to external interface
Am 25.04.2011 22:30, schrieb Chris Angelico: If you don't care what port you use, you don't need to bind at all. That may be why it's not mentioned - the classic TCP socket server involves bind/listen/accept, and the classic TCP client has just connect; bind/connect is a lot less common. That is right, but I cannot see where he mentions the direction of the socket. My fist thought was that he tries to have a server socket... (BTW: bind can be omitted on server sockets as well; listen() seems to includes a bind(('', 0)) if not called explicitly before. In this case, the port is assigned randomly. Can be useful in some cases, where the port number is not fixed...) Incidentally, interfaces don't have to correspond 1:1 to network cards. At work, we have a system of four IP addresses for each server, even though it has only one NIC - it's used for traffic management and routing. Binding to a specific address is sometimes important there. If you use IPv6 and activate the privacy extensions (in order to periodically create a new IP address), a NIC will have even more addresses - the ones which aren't used any longer will be kept for a certain time on order not to kill any existing connections. Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: Argument of the bool function
Am 25.04.2011 16:29, schrieb Thomas Rachel: or maybe even better (taking care for closures): function = bool value = 'the well at the end of the world' ## ... actions.append(lambda val=value: function(val)) ## ... for function in actions: results.append(function()) Or yet even better: class Job(object): def __init__(self, target, *args, **kwargs): self.target = lambda: target(*args, **kwargs) def __call__(self): return self.target() in order to do actions.append(Job(function, val)) actions.append(Job(function, x=val)) and then (thanks, Chris...) results = [function() for function in actions] or maybe (additionally or alternatively) class ActionQueue(list): def addJob(self, target, *args, **kwargs): self.append(lambda: target(*args, **kwargs)) def __call__(self): if 0: # first thought for job in self: yield job() else: # second thought - clean up... while self: job = self.pop(0) yield job() with actions = ActionQueue() actions.addJob(function, val) actions.addJob(function, x=val) results = list(actions()) # for collecting them and having them at once # with generator, all call results can as well be emitted as soon as they are available - depending what shall be done with the results mmm... too much imagination I think... ;-) Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: sockets: bind to external interface
On Tue, Apr 26, 2011 at 7:18 AM, Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa...@spamschutz.glglgl.de wrote: Am 25.04.2011 22:30, schrieb Chris Angelico: If you don't care what port you use, you don't need to bind at all. That may be why it's not mentioned - the classic TCP socket server involves bind/listen/accept, and the classic TCP client has just connect; bind/connect is a lot less common. That is right, but I cannot see where he mentions the direction of the socket. My fist thought was that he tries to have a server socket... (BTW: bind can be omitted on server sockets as well; listen() seems to includes a bind(('', 0)) if not called explicitly before. In this case, the port is assigned randomly. Can be useful in some cases, where the port number is not fixed...) Yes; for FTP data sockets, it doesn't matter what the port is, as long as you tell the other end. Same as you can bind/connect, you can not-bind and listen/accept. This is why I'm glad the socket subsystem allows unusual behaviours (I've used bind/connect in a few places). Give the programmer the tools and let him do what he chooses! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: Python login script
Look this code! Perhaps, It can help you with login. http://segfault.in/2010/12/sending-gmail-from-python/ 2011/4/25 Chris Angelico ros...@gmail.com On Tue, Apr 26, 2011 at 7:38 AM, Jayme Proni Filho listas.programa...@gmail.com wrote: I can be wrong but I think you can not login in gmail with urllib because I think gmail uses another kind of auth. Ultimately it should be possible to do the exact same form-fillout and follow the redirects, just as a browser would. Eventually it'll get you a cookie. But burying the uid/pwd in the cookie will almost certainly be wrong. ChrisA -- --- Jayme Proni Filho Skype: jaymeproni Twitter: @jaymeproni Phone: +55 - 17 - 3631 - 6576 Mobile: +55 - 17 - 9605 - 3560 e-Mail: jaymeproni at yahoo dot com dot br Blogs (Em construção) Programandor: http://jaymeproni.wordpress.com Sociedade em Ação: http://sociedaemacao.wordpress.com --- -- http://mail.python.org/mailman/listinfo/python-list
Re: strange use of %s
On 4/18/2011 1:44 AM, Tim Golden wrote: On 18/04/2011 09:29, Tracubik wrote: Hi all, i'm reading a python tutorial in Ubuntu's Full Circle Magazine and i've found this strange use of %s: sql = SELECT pkid,name,source,servings FROM Recipes WHERE name like '%%%s% %' %response response is a string. I've newbie in sql. why do the coder use %%%s%% instead of a simple %s? why he also use the ''? Two parts to this answer. The straightforward one: because the SQL string needs to end up looking like this: ... WHERE name LIKE '%abcd%' and since it's being generated by Python's string substitution, the surrounding percents need to be doubled up in the original string to be left as single in the final string. An alternative in a modern Python might be to use string formatting: ... WHERE name LIKE '%{}%'.format (response) HOWEVER... this is not the best way to introduce Python values into a SQL string. It's better to use the db module's string substitution flag (often ? or :field or, confusingly, %s). This is because the approach above lends itself to what's called SQL injection. Obligatory xkcd reference: http://xkcd.com/327/ The code would be better if written something like this: sql = SELECT ... WHERE name LIKE '%' + ? + '%' q = db.cursor () q.execute (sql, [response]) (The details will vary according to the database being used etc.) (For those of you who don't know, % is a wildcard character in MySQL.) That's written for MySQL as searchkey = smith # Whatever you're looking for. sql = SELECT ... WHERE name LIKE CONCAT('%',%s,'%') values = (searchkey,) q = db.cursor () q.execute (sql, searchkey) MySQLdb will fill in the %s with the value from searchkey, and there's no possibility of MySQL injection. Note that such a search requires scanning the entire table. LIKE with wildcards at the beginning can't use indices. So this is very slow for large tables. Don't worry about having MySQL do the CONCAT. That happens once during query parsing here, because all the arguments to CONCAT are defined in the statement. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Input() in Python3
Hey! Try to use like this: http://sprunge.us/RcYb change values for understanding code. Good ideas guys! --- Jayme Proni Filho Skype: jaymeproni Twitter: @jaymeproni Phone: +55 - 17 - 3631 - 6576 Mobile: +55 - 17 - 9605 - 3560 e-Mail: jaymeproni at yahoo dot com dot br --- -- http://mail.python.org/mailman/listinfo/python-list
Re: strange use of %s
On Tue, Apr 26, 2011 at 8:01 AM, John Nagle na...@animats.com wrote: Don't worry about having MySQL do the CONCAT. That happens once during query parsing here, because all the arguments to CONCAT are defined in the statement. Good point. Although the abstraction is still a little leaky in that you can't use this to search for a percent character anywhere in the string (come to think of it, how _would_ you do that? I think you'd have to backslash-escape it, prior to escaping it for the string, but I'd have to check), so it doesn't make a lot of difference where the percent signs are added. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: windows 7 x64 shutdown
On 25-4-2011 23:15, rjmccorkle wrote: does anyone know a solution to shutting down windows 7 x64 via python script? the win32 obviously doesn't work... something similar? http://goo.gl/5tVPj (a recipe on activestate, First hit on Google for 'python ctypes shutdown') Works fine on my win7 x64 system. I don't think that using 32-bits API will stop you from doing stuff like this. -irmen -- http://mail.python.org/mailman/listinfo/python-list
Re: Argument of the bool function
Chris Angelico ros...@gmail.com writes: results = [function() for function in actions] results = map(apply, actions) -- http://mail.python.org/mailman/listinfo/python-list
Re: Argument of the bool function
On Mon, Apr 25, 2011 at 3:28 PM, Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa...@spamschutz.glglgl.de wrote: Am 25.04.2011 16:29, schrieb Thomas Rachel: or maybe even better (taking care for closures): function = bool value = 'the well at the end of the world' ## ... actions.append(lambda val=value: function(val)) ## ... for function in actions: results.append(function()) Or yet even better: class Job(object): def __init__(self, target, *args, **kwargs): self.target = lambda: target(*args, **kwargs) def __call__(self): return self.target() in order to do actions.append(Job(function, val)) actions.append(Job(function, x=val)) from functools import partial actions.append(partial(function, val)) actions.append(partial(function, x=val)) Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list
Simple map/reduce utility function for data analysis
Here's a handy utility function for you guys to play with: http://code.activestate.com/recipes/577676/ Raymond twitter: @raymondh -- http://mail.python.org/mailman/listinfo/python-list
Re: MIDI message sending and receiving, MID file manipulation
On Mon, 25 Apr 2011 14:17:50 +0100, Passiday passi...@gmail.com wrote: Hello, I'd like to experiment with Python, connecting my Linux PC with MIDI device (standard synthesiser keyboard). I am pretty new to the Python world, so the questions that crop up, I assume, could be pretty basic to someone who had spent some time with it. So, here comes: 1) Is everything what could be done with Python in some IDE (Eclipse for me), can be accomplished in the interactive console? I mean, perhaps Python could be used just as programming language and compiled in binary code, thus allowing access to some binary libraries what might not be accessible from within the interpreter. This is two, or possibly three, distinct unrelated questions as best I can tell. 1a) Yes, anything you can do in an IDE you can do at the Python interactive command line prompt. Or by running your script directly in a terminal window. Personally I find it less hassle to do it that way, since IDEs usually don't work the way I want them to. 1b) Python can be compiled down to binary if you try hard, with utilities like Py2exe. You don't usually want to do that, though. 1c) ...because there are plenty of ways of wrapping up libraries so that Python scripts can use them. ctypes (in the standard library) is a good place to start. 2) Is there a way how to run Python script in event-driven mode, ie, run the script, it registers some function as keyboard event handler, and then calls that function whenever I press any key. Is such behaviour possible in the interactive mode? Since I want to test the MIDI message exchange, having a function sitting on the timer event is what I'll need for playback, and an event that is triggered by incoming MIDI message for recording. Probably. It sounds like what you really want is a framework of some sort that knows about things like the timer event, and using it from the interactive prompt won't be for the faint of heart! Someone must have walked this path before, though. 3) Of course, I need some Python module to actually get this MIDI communication happen. Sending and receiving MIDI messages to and from my MIDI device. 4) As for manipulating the MIDI files in Python, I have searched up this: http://www.mxm.dk/products/public/pythonmidi However, this lib doesn't try to provide actual communication with MIDI device. The Python In Music wiki page (http://wiki.python.org/moin/PythonInMusic) has an entire section on MIDI packages. I've never used any of them, so I can't comment. -- Rhodri James *-* Wildebeest Herder to the Masses -- http://mail.python.org/mailman/listinfo/python-list
Re: learnpython.org - an online interactive Python tutorial
harrismh777 wrote: maybe the way to be really consistent (especially with the Zen of Python, explicit is better than implicit) that int -- float -- complex (imaginary) should not occur either ! Applying parts of the Zen selectively can be dangerous. Practicality also beats purity. I've used a language where there was no automatic promotion from ints to floats, and it was a pain in the backside. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Argument of the bool function
On Mon, 25 Apr 2011 16:26:37 -0700, Paul Rubin wrote: Chris Angelico ros...@gmail.com writes: results = [function() for function in actions] results = map(apply, actions) Sadly not in Python 3, where map is lazy and you need to add a call to list to make it equivalent to the list comp. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple map/reduce utility function for data analysis
Raymond Hettinger pyt...@rcn.com writes: Here's a handy utility function for you guys to play with: http://code.activestate.com/recipes/577676/ Cute, but why not use collections.defaultdict for the return dict? Untested: d = defaultdict(list) for key,value in ifilter(bool,imap(mapper, data)): d[key].append(value) ... -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple map/reduce utility function for data analysis
On Mon, 25 Apr 2011 16:48:42 -0700, Raymond Hettinger wrote: Here's a handy utility function for you guys to play with: http://code.activestate.com/recipes/577676/ Nice. That's similar to itertools.groupby except that it consolidates all the equal key results into one list, instead of in consecutive runs. Also groupby returns iterators instead of lists, which makes it a PITA to work with. map_reduce is much more straightforward to use. Example given in the code: map_reduce(range(30), even_odd) {0: [10, 12, 14, 16, 18, 20], 1: [11, 13, 15, 17, 19]} [(key[0], list(group)) for key,group in groupby(range(30), even_odd) if key is not None] [(0, [10]), (1, [11]), (0, [12]), (1, [13]), (0, [14]), (1, [15]), (0, [16]), (1, [17]), (0, [18]), (1, [19]), (0, [20])] So... when can we expect map_reduce in the functools module? :) -- Steven -- http://mail.python.org/mailman/listinfo/python-list
De-tupleizing a list
I have an SQLite query that returns a list of tuples: [('0A',), ('1B',), ('2C',), ('3D',),... What is the most Pythonic way to loop through the list returning a list like this?: ['0A', '1B', '2C', '3D',... -- Gnarlie -- http://mail.python.org/mailman/listinfo/python-list
Re: De-tupleizing a list
On Apr 25, 11:28 pm, Gnarlodious gnarlodi...@gmail.com wrote: I have an SQLite query that returns a list of tuples: [('0A',), ('1B',), ('2C',), ('3D',),... What is the most Pythonic way to loop through the list returning a list like this?: ['0A', '1B', '2C', '3D',... -- Gnarlie For just this case, if returned_list is your list above, how about?: flat_list = [item[0] for item in returned_list] -- http://mail.python.org/mailman/listinfo/python-list
Re: De-tupleizing a list
What is the most Pythonic way to loop through the list returning a list like this?: here's how I'd do it: i [(1, 'a'), (2, 'b'), (3, 'c')] for item in i: ... a+=list(item) ... ... a [1, 'a', 2, 'b', 3, 'c'] -- http://mail.python.org/mailman/listinfo/python-list
Re: De-tupleizing a list
On Apr 25, 9:42 pm, CM wrote: flat_list = [item[0] for item in returned_list] HA! So easy. Thanks. -- Gnarlie -- http://mail.python.org/mailman/listinfo/python-list
Re: De-tupleizing a list
On Apr 25, 2011, at 11:28 PM, Gnarlodious wrote: I have an SQLite query that returns a list of tuples: [('0A',), ('1B',), ('2C',), ('3D',),... What is the most Pythonic way to loop through the list returning a list like this?: ['0A', '1B', '2C', '3D',... This works for me - result = [('0A',), ('1B',), ('2C',), ('3D',), ] result = [row[0] for row in result] Cheers Philip -- http://mail.python.org/mailman/listinfo/python-list
Re: De-tupleizing a list
Gnarlodious gnarlodi...@gmail.com writes: I have an SQLite query that returns a list of tuples: [('0A',), ('1B',), ('2C',), ('3D',),... What is the most Pythonic way to loop through the list returning a list like this?: ['0A', '1B', '2C', '3D',... Try: tlist = [('0A',), ('1B',), ('2C',), ('3D',)] alist = [x for (x,) in tlist] -- http://mail.python.org/mailman/listinfo/python-list
Re: De-tupleizing a list
itertools can help you do this too: import itertools tl = [('0A',), ('1B',), ('2C',), ('3D',)] itertools.chain.from_iterable(tl) itertools.chain object at 0x11f7ad0 list(itertools.chain.from_iterable(tl)) ['0A', '1B', '2C', '3D'] Checkout http://docs.python.org/library/itertools.html#itertools.chain for more info. On Mon, Apr 25, 2011 at 11:08 PM, Paul Rubin no.email@nospam.invalid wrote: Gnarlodious gnarlodi...@gmail.com writes: I have an SQLite query that returns a list of tuples: [('0A',), ('1B',), ('2C',), ('3D',),... What is the most Pythonic way to loop through the list returning a list like this?: ['0A', '1B', '2C', '3D',... Try: tlist = [('0A',), ('1B',), ('2C',), ('3D',)] alist = [x for (x,) in tlist] -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: De-tupleizing a list
On Mon, 25 Apr 2011 20:28:22 -0700, Gnarlodious wrote: I have an SQLite query that returns a list of tuples: [('0A',), ('1B',), ('2C',), ('3D',),... What is the most Pythonic way to loop through the list returning a list like this?: ['0A', '1B', '2C', '3D',... Others have pointed you at a list comprehension, but just for completion, there's also this: from operator import itemgetter map(itemgetter(0), list_of_tuples) In Python 3, map becomes lazy and returns an iterator instead of a list, so you have to wrap it in a call to list(). -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: De-tupleizing a list
On Apr 26, 9:59 am, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: On Mon, 25 Apr 2011 20:28:22 -0700, Gnarlodious wrote: I have an SQLite query that returns a list of tuples: [('0A',), ('1B',), ('2C',), ('3D',),... What is the most Pythonic way to loop through the list returning a list like this?: ['0A', '1B', '2C', '3D',... Others have pointed you at a list comprehension, but just for completion, there's also this: from operator import itemgetter map(itemgetter(0), list_of_tuples) In Python 3, map becomes lazy and returns an iterator instead of a list, so you have to wrap it in a call to list(). Going the other way: Given that most lists are processed and discarded you can stop at the second step. [A 3-way overloading of '()' here that may be a bit unnerving at first...] l = [('0A',), ('1B',), ('2C',), ('3D',)] l_gen = (x for (x,) in l) list(l_gen) ['0A', '1B', '2C', '3D'] -- http://mail.python.org/mailman/listinfo/python-list
Re: sockets: bind to external interface
On Mon, 25 Apr 2011 23:18:05 +0200, Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa...@spamschutz.glglgl.de wrote: : That is right, but I cannot see where he mentions the direction of the : socket. My fist thought was that he tries to have a server socket... Quite right. I thought it was implied by the need to bind :-) Sorry for the lack of detail. -- :-- Hans Georg -- http://mail.python.org/mailman/listinfo/python-list
[issue8040] It would be nice if documentation pages linked to other versions of the same document
Changes by anatoly techtonik techto...@gmail.com: -- nosy: +techtonik ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8040 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9523] Improve dbm modules
ysj.ray ysj@gmail.com added the comment: Sorry, previous patch(issue_9523_4.diff) missed a file(Lib/test/dbm_tests.py) Here is an intact one. -- Added file: http://bugs.python.org/file21769/issue_9523_5.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9523 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11908] Weird `slice.stop or sys.maxint`
ysj.ray ysj@gmail.com added the comment: `step` argument for xrange() could not be 0. But `s.stop or sys.maxint` is really a problem, in the case of `s.stop == 0`. So the given `Equivalent to` python code in the doc is not precisely equivalent to the c implementation. The doc needs a fix. -- nosy: +ysj.ray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11908 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11912] Python shouldn't use the mprotect() system call
Nils Breunese n...@breun.nl added the comment: I contacted the author of iotop and he told me iotop does not use mprotect (but it does use dlopen). Guess I'll have to do some more digging to find what is exactly doing the call to mprotect. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11912 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11908] Weird `slice.stop or sys.maxint`
Raymond Hettinger raymond.hettin...@gmail.com added the comment: I've got from here. Thanks. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11908 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11849] glibc allocator doesn't release all free()ed memory
kaifeng cafe...@gmail.com added the comment: Sorry for the later update. Valgrind shows there is no memory leak (see attached valgrind.log). The following code, while True: XML(gen_xml()) has an increasing memory usage in the first 5~8 iterations, and waves around a constant level afterwards. So I guess there's a component, maybe libc, Python interpreter, ElementTree/pyexpat module or someone else, hold some memory until process ends. -- Added file: http://bugs.python.org/file21770/valgrind.log ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11849 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11882] test_imaplib failed on x86 ubuntu
ysj.ray ysj@gmail.com added the comment: Guess the problem is with time.mktime() and time.localtime(). Could you debug into the Internaldate2Tuple() function and see at which step the time value(a time_struct or a float which represents seconds) is wrong? -- nosy: +ysj.ray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11882 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11662] Redirect vulnerability in urllib/urllib2
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11662 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3561] Windows installer should add Python and Scripts directories to the PATH environment variable
Changes by Jonathan Hartley tart...@tartley.com: -- nosy: +jonathan.hartley ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3561 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11917] Test Error
New submission from Hamid abbaszade...@gmail.com: == CPython 3.2 (r32:88445, Apr 24 2011, 14:27:42) [GCC 4.4.4 20100726 (Red Hat 4.4.4-13)] == Linux-2.6.32-71.el6.x86_64-x86_64-with-redhat-6.0-Santiago little-endian == /usr/local/src/Python-3.2/build/test_python_2976 Testing with flags: sys.flags(debug=0, division_warning=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0) [1/1] test_whatever test test_whatever crashed -- class 'ImportError': No module named test_whatever Traceback (most recent call last): File /usr/local/src/Python-3.2/Lib/test/regrtest.py, line 962, in runtest_inner the_package = __import__(abstest, globals(), locals(), []) ImportError: No module named test_whatever 1 test failed: test_whatever -- components: Tests messages: 134377 nosy: Abbaszadeh priority: normal severity: normal status: open title: Test Error type: compile error versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11917 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11856] Optimize parsing of JSON numbers
Jesús Cea Avión j...@jcea.es added the comment: Patch seems OK. Please, commit. -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11856 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11877] Change os.fsync() to support physical backing store syncs
Steffen Daode Nurpmeso sdao...@googlemail.com added the comment: I'll attach 11877.4.diff: - Docu change (i hope to be better) - Kept NetBSD after looking into http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/vfs_syscalls.c?rev=1.423content-type=text/x-cvsweb-markuponly_with_tag=MAIN because fsync_range() with FDISKSYNC set causes a FSYNC_CACHE flag to be passed through to VOP_FSYNC() in addition to FSYNC_WAIT, which is what plain fsync() passes exclusively. (I have not furtherly discovered that. FDISKSYNC was introduced 2005. I believe existence of such a flag will sooner or later force somebody to make a difference in wether it is set or not.) - Drop of AIX. According to the systems manual (link in msg134213) there does not seem to be a difference in between fsync() and fsync_range() - Drop of Linux sync_file_range() (see messages above). By the way, does Linux still require -- Added file: http://bugs.python.org/file21771/11877.4.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11877 ___diff --git a/Doc/library/os.rst b/Doc/library/os.rst --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -798,7 +798,7 @@ Availability: Unix. -.. function:: fsync(fd) +.. function:: fsync(fd, full_fsync=False) Force write of file with filedescriptor *fd* to disk. On Unix, this calls the native :c:func:`fsync` function; on Windows, the MS :c:func:`_commit` function. @@ -807,6 +807,12 @@ ``f.flush()``, and then do ``os.fsync(f.fileno())``, to ensure that all internal buffers associated with *f* are written to disk. + The POSIX standart only requires that :c:func:`fsync` must transfer the + buffered data to the storage device, not that the data is actually + written by the device itself. On operating systems where it is + necessary and possible the optional *full_fsync* argument can be used to + initiate additional steps to synchronize the physical backing store. + Availability: Unix, and Windows. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -2119,13 +2119,55 @@ #ifdef HAVE_FSYNC PyDoc_STRVAR(posix_fsync__doc__, -fsync(fildes)\n\n\ -force write of file with filedescriptor to disk.); - -static PyObject * -posix_fsync(PyObject *self, PyObject *fdobj) -{ -return posix_fildes(fdobj, fsync); +fsync(fildes, full_fsync=False)\n\n +force write of file buffers with fildes to disk;\n +full_fsync forces flush of disk caches in case fsync() alone is not enough.); + +static PyObject * +posix_fsync(PyObject *self, PyObject *args, PyObject *kwargs) +{ +PyObject *retval = NULL; +auto PyObject *fdobj; +auto int full_fsync = 1; +static char *keywords[] = {fd, full_fsync, NULL }; + +if (!PyArg_ParseTupleAndKeywords(args, kwargs, O|i, keywords, + fdobj, full_fsync)) +goto jleave; + +/* See issue 11877 discussion */ +# if ((defined __APPLE__ defined F_FULLFSYNC) || \ + (defined __NetBSD__ defined FDISKSYNC)) +if (full_fsync != 0) { +int res, fd = PyObject_AsFileDescriptor(fdobj); +if (fd 0) +goto jleave; +if (!_PyVerify_fd(fd)) { +retval = posix_error(); +goto jleave; +} + +Py_BEGIN_ALLOW_THREADS +# ifdef __APPLE__ +res = fcntl(fd, F_FULLFSYNC); +# endif +# ifdef __NetBSD__ +res = fsync_range(fd, FFILESYNC|FDISKSYNC, 0, 0); +# endif +Py_END_ALLOW_THREADS + +if (res 0) { +retval = posix_error(); +goto jleave; +} +Py_INCREF(Py_None); +retval = Py_None; +} else +# endif +retval = posix_fildes(fdobj, fsync); + +jleave: +return retval; } #endif /* HAVE_FSYNC */ @@ -9470,7 +9512,8 @@ {fchdir, posix_fchdir, METH_O, posix_fchdir__doc__}, #endif #ifdef HAVE_FSYNC -{fsync, posix_fsync, METH_O, posix_fsync__doc__}, +{fsync, (PyCFunction)posix_fsync, METH_VARARGS|METH_KEYWORDS, +posix_fsync__doc__}, #endif #ifdef HAVE_SYNC {sync,posix_sync, METH_NOARGS, posix_sync__doc__}, ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11917] Test Error
Changes by Hamid abbaszade...@gmail.com: -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11917 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11849] glibc allocator doesn't release all free()ed memory
Charles-Francois Natali neolo...@free.fr added the comment: The MALLOC_MMAP_THRESHOLD improvement is less visible here: Are you running on 64-bit ? If yes, it could be that you're exhausting M_MMAP_MAX (malloc falls back to brk when there are too many mmap mappings). You could try with MALLOC_MMAP_THRESHOLD_=1024 MALLOC_MMAP_MAX_=16777216 ../opt/python issue11849_test.py By the way, never do that in real life, it's a CPU and memory hog ;-) I think the root cause is that glibc's malloc coalescing of free chunks is called far less often than in the original ptmalloc version, but I still have to dig some more. By the way, I noticed that dictionnaries are never allocated through pymalloc, since a new dictionnary takes more than 256B... On 64-bit builds indeed. pymalloc could be improved to handle allocations up to 512B. Want to try and write a patch? Sure. I'll open another issue. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11849 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9319] imp.find_module('test/badsyntax_pep3120') causes segfault
STINNER Victor victor.stin...@haypocalc.com added the comment: Correctly merging #9319 into 3.3? No, this issue was fixed differently in Python 3.3. I see that you reverted (bb62908896fe) this merge (except the test, which is a good idea). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9319 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11882] test_imaplib failed on x86 ubuntu
R. David Murray rdmur...@bitdance.com added the comment: Yeah, I looked at the source of calendar.gmtime, and it turns out it ignores the isdst flag, which it also seems should be irrelevant anyway, looking at the test code again. I tried setting my /etc/localtime to /usr/share/zoneinfo/posix/Asia/Calcutta, which gives me IST/GMT +5:30, but test_imaplib still passes for me on default. Here is what an interpreter session looks like for me with my timezone set to IST: import calendar calendar.timegm((2000, 1, 1, 0, 0, 0, -1, -1, -1)) 946684800 import imaplib x = imaplib.Internaldate2tuple(b'25 (INTERNALDATE 01-Jan-2000 00:00:00 +)') x time.struct_time(tm_year=2000, tm_mon=1, tm_mday=1, tm_hour=5, tm_min=30, tm_sec=0, tm_wday=5, tm_yday=1, tm_isdst=0) import time time.mktime(x) 946684800.0 Can you show us what yours looks like? Comparing the above numbers to yours, it appears to be your mktime that is giving the anomalous results. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11882 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11917] Test Error
R. David Murray rdmur...@bitdance.com added the comment: For the record: yes this is the way regrtest works when a test named on the command line doesn't exist. Not pretty, I'll grant you. Maybe someone will propose a patch/feature request to improve the error message some day. -- nosy: +r.david.murray resolution: - invalid stage: - committed/rejected type: compile error - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11917 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11918] Drop OS/2 and VMS support in Python 3.3
New submission from STINNER Victor victor.stin...@haypocalc.com: Because we don't have any OS/2 and VMS maintainer for Python 3, I propose to drop OS/2 and VMS support in Python 3.3: OSes unsupported in 3.3, code removed in 3.4 (see the PEP 11 for the process). -- components: Interpreter Core messages: 134384 nosy: haypo priority: normal severity: normal status: open title: Drop OS/2 and VMS support in Python 3.3 versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11918 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8326] Cannot import name SemLock on Ubuntu
Barry A. Warsaw ba...@python.org added the comment: Is this still a problem for people? Ubuntu 11.04's python2.7 has been fixed: @neurotica[~:1000]% type python2.7 python2.7 is /usr/bin/python2.7 @neurotica[~:1001]% python2.7 -c 'from _multiprocessing import SemLock' @neurotica[~:1002]% The Launchpad bug for the issue is here: https://bugs.launchpad.net/ubuntu/+source/python2.7/+bug/672209 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8326 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10616] Change PyObject_AsCharBuffer() error message
Antoine Pitrou pit...@free.fr added the comment: +1 to Victor's proposal (expected bytes, bytearray or buffer compatible object). -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10616 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11919] test_imp failures
New submission from Antoine Pitrou pit...@free.fr: http://www.python.org/dev/buildbot/all/builders/AMD64%20Leopard%203.2/builds/215/steps/test/logs/stdio http://www.python.org/dev/buildbot/all/builders/AMD64%20Leopard%203.x/builds/1223/steps/test/logs/stdio == ERROR: test_issue9319 (test.test_imp.ImportTests) -- Traceback (most recent call last): File /Users/pythonbuildbot/buildarea/3.2.hansen-osx-x86-2/build/Lib/test/test_imp.py, line 175, in test_issue9319 imp.find_module, test/badsyntax_pep3120) File /Users/pythonbuildbot/buildarea/3.2.hansen-osx-x86-2/build/Lib/unittest/case.py, line 574, in assertRaises callableObj(*args, **kwargs) ImportError: No module named test/badsyntax_pep3120 -- assignee: haypo components: Tests messages: 134387 nosy: haypo, pitrou priority: high severity: normal stage: needs patch status: open title: test_imp failures type: behavior versions: Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11919 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11849] glibc allocator doesn't release all free()ed memory
Antoine Pitrou pit...@free.fr added the comment: The MALLOC_MMAP_THRESHOLD improvement is less visible here: Are you running on 64-bit ? Yes. If yes, it could be that you're exhausting M_MMAP_MAX (malloc falls back to brk when there are too many mmap mappings). You could try with MALLOC_MMAP_THRESHOLD_=1024 MALLOC_MMAP_MAX_=16777216 ../opt/python issue11849_test.py It isn't better. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11849 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11917] Test Error
Hamid abbaszade...@gmail.com added the comment: Dear sir; I will try to compile python-3.2 in REDHAT EL 6.0. There are a lot of failure in make test. How can I fix them? for example test_import, test_httpserver, Thanks Abbaszadeh On Mon, Apr 25, 2011 at 6:36 PM, R. David Murray rep...@bugs.python.orgwrote: R. David Murray rdmur...@bitdance.com added the comment: For the record: yes this is the way regrtest works when a test named on the command line doesn't exist. Not pretty, I'll grant you. Maybe someone will propose a patch/feature request to improve the error message some day. -- nosy: +r.david.murray resolution: - invalid stage: - committed/rejected type: compile error - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11917 ___ -- Added file: http://bugs.python.org/file21772/unnamed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11917 ___div dir=ltrfont size=2font face=tahoma,sans-serifDear sir;brbrI will try to compile python-3.2 in REDHAT EL 6.0. There are a lot of failure in quot;make testquot;. How can I fix them?brbrfor example test_import, test_httpserver, br brThanksbrAbbaszadehbr/font/fontbrdiv class=gmail_quoteOn Mon, Apr 25, 2011 at 6:36 PM, R. David Murray span dir=ltrlt;a href=mailto:rep...@bugs.python.org;rep...@bugs.python.org/agt;/span wrote:br blockquote class=gmail_quote style=margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;br R. David Murray lt;a href=mailto:rdmur...@bitdance.com;rdmur...@bitdance.com/agt; added the comment:br br For the record: yes this is the way regrtest works when a test named on the command line doesn#39;t exist. Not pretty, I#39;ll grant you. Â Maybe someone will propose a patch/feature request to improve the error message some day.br br --br nosy: +r.david.murraybr resolution: Â -gt; invalidbr stage: Â -gt; committed/rejectedbr type: compile error -gt; behaviorbr divdiv/divdiv class=h5br ___br Python tracker lt;a href=mailto:rep...@bugs.python.org;rep...@bugs.python.org/agt;br lt;a href=http://bugs.python.org/issue11917; target=_blankhttp://bugs.python.org/issue11917/agt;br ___br /div/div/blockquote/divbrbr clear=allbr-- brdiv dir=ltrbiHamid Abbaszadeh/i/bbrwebsite: a href=http://www.respinar.com; target=_blankwww.respinar.com/abremail: a href=mailto:i...@respinar.com; target=_blanki...@respinar.com/abr /divbr /div ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10616] Change PyObject_AsCharBuffer() error message
Sijin Joseph sijinjos...@gmail.com added the comment: Looking at object.h the buffer interface is defined as /* buffer interface */ typedef struct bufferinfo { void *buf; PyObject *obj;/* owned reference */ Py_ssize_t len; Py_ssize_t itemsize; /* This is Py_ssize_t so it can be pointed to by strides in simple case.*/ int readonly; int ndim; char *format; Py_ssize_t *shape; Py_ssize_t *strides; Py_ssize_t *suboffsets; Py_ssize_t smalltable[2]; /* static store for shape and strides of mono-dimensional buffers. */ void *internal; } Py_buffer; typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); typedef void (*releasebufferproc)(PyObject *, Py_buffer *); typedef struct { getbufferproc bf_getbuffer; releasebufferproc bf_releasebuffer; } PyBufferProcs; The code that's throwing that error looks like if (pb == NULL || pb-bf_getbuffer == NULL) { PyErr_SetString(PyExc_TypeError, expected an object with the buffer interface); I would argue that the error message gives appropriate information because it is expecting the object to have a bf_getbuffer member. Maybe the friendly error message is best handled at a higher level? -- nosy: +sijinjoseph ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10616 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11917] Test Error
R. David Murray rdmur...@bitdance.com added the comment: Your best resources would probably be the python mailing list (python-list, see http://mail.python.org) which is also comp.lang.python, or the #python irc channel on freenode. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11917 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11849] glibc allocator doesn't release all free()ed memory
Charles-Francois Natali neolo...@free.fr added the comment: It isn't better. Requests above 256B are directly handled by malloc, so MALLOC_MMAP_THRESHOLD_ should in fact be set to 256 (with 1024 I guess that on 64-bit every mid-sized dictionnary gets allocated with brk). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11849 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11920] ctypes: Strange bitfield structure sizing issue
New submission from Steve Thompson steve.f.thomp...@gmail.com: Consider the following: import ctypes class struct1( ctypes.Structure ): _pack_ = 1 _fields_ = [ ( first, ctypes.c_uint8, 1 ), ( second, ctypes.c_uint8, 1 ), ( third, ctypes.c_uint8, 1 ), ( fourth, ctypes.c_uint8, 1 ), ( fifth, ctypes.c_uint8, 1 ), ( pad,ctypes.c_uint16, 11 ), ] s1 = struct1() print ctypes.sizeof( s1 ) class struct2( ctypes.Structure ): _pack_ = 1 _fields_ = [ ( first, ctypes.c_uint16, 1 ), ( second, ctypes.c_uint16, 1 ), ( third, ctypes.c_uint16, 1 ), ( fourth, ctypes.c_uint16, 1 ), ( fifth, ctypes.c_uint16, 1 ), ( pad,ctypes.c_uint16, 11 ), ] s2 = struct2() print ctypes.sizeof( s2 ) The output is: 3 2 I'm generating python code from real c code. The compiler I'm using for the real c code packs both of these structures into two bytes. I need a way to make the first example work in python like the compiler without having to modify the source code. Is this possible? -- components: ctypes messages: 134393 nosy: Steve.Thompson priority: normal severity: normal status: open title: ctypes: Strange bitfield structure sizing issue versions: Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11920 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11921] distutils2 should be able to compile an Extension based on the Python implementation version
New submission from dholth dho...@fastmail.fm: It might be useful to be able to declare optional Extensions that for example won't attempt to compile on Jython or any implementation of Python for which the extension (a) doesn't work or (b) would be slower than the Python fallback. I suppose this could be accomplished without changing anything by packaging the extension separately and using the extant ; plat=win32 style dependency qualifiers? -- assignee: tarek components: Distutils2 messages: 134394 nosy: alexis, dholth, eric.araujo, tarek priority: normal severity: normal status: open title: distutils2 should be able to compile an Extension based on the Python implementation version versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11921 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2736] datetime needs an epoch method
Roundup Robot devnull@devnull added the comment: New changeset b55eac85e39c by Alexander Belopolsky in branch 'default': Issue #2736: Documented how to compute seconds since epoch. http://hg.python.org/cpython/rev/b55eac85e39c -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2736 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2736] datetime needs an epoch method
Changes by Alexander Belopolsky belopol...@users.sourceforge.net: -- components: +Documentation -Library (Lib) resolution: - fixed stage: test needed - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2736 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11918] Drop OS/2 and VMS support in Python 3.3
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11918 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11856] Optimize parsing of JSON numbers
Roundup Robot devnull@devnull added the comment: New changeset d60f9d9983bb by Antoine Pitrou in branch 'default': Issue #11856: Speed up parsing of JSON numbers. http://hg.python.org/cpython/rev/d60f9d9983bb -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11856 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11856] Optimize parsing of JSON numbers
Changes by Antoine Pitrou pit...@free.fr: -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11856 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11918] Drop OS/2 and VMS support in Python 3.3
Changes by Nadeem Vawda nadeem.va...@gmail.com: -- nosy: +nadeem.vawda ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11918 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11834] wrong module installation dir on Windows
Bryce Verdier bryceverd...@gmail.com added the comment: Here is a patch for the documentation. I'm not quite sure about the scripts and data part. Tested with Paramiko and a new install of 2.7 to see what would happen and that was the result. -- keywords: +patch nosy: +louiscipher Added file: http://bugs.python.org/file21773/issue133572.py33.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11834 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11922] Add General Index to Windows .chm help file Contents
New submission from Terry J. Reedy tjre...@udel.edu: The Windows distribution comes with the docs in a very nice Windows help file .chm form. When displayed, they is a left side bar with a Contents tab. The top entry is 'Python vx.y documentation' followed by 'Python Module Index' and 'What's New in Python' and so on down to 'History and Licence'. Everything on the Python vx.y documentation' page is listed in the Contents EXCEPT the General Index. Consequently, if one only uses the contents lists, one might not even know it exists. In any case, it is harder to get to than anything else. I presume the omission is unintentional. In any case, I would like to see it fixed, with 'General Index' added right after the module index entry. I presume this should be easy for someone who knows how the contents list is generated. -- assignee: docs@python components: Documentation, Windows keywords: easy messages: 134398 nosy: docs@python, terry.reedy priority: normal severity: normal stage: needs patch status: open title: Add General Index to Windows .chm help file Contents versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11922 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11901] Docs for sys.hexversion should give the algorithm
Sijin Joseph sijinjos...@gmail.com added the comment: Patch attached. -- keywords: +patch nosy: +sijinjoseph Added file: http://bugs.python.org/file21774/11901.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11901 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11901] Docs for sys.hexversion should give the algorithm
Changes by Sijin Joseph sijinjos...@gmail.com: Removed file: http://bugs.python.org/file21774/11901.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11901 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11901] Docs for sys.hexversion should give the algorithm
Sijin Joseph sijinjos...@gmail.com added the comment: Fixed minor typo. -- Added file: http://bugs.python.org/file21775/11901.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11901 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11908] Weird `slice.stop or sys.maxint`
Changes by Terry J. Reedy tjre...@udel.edu: -- versions: -Python 2.5, Python 2.6, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11908 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11920] ctypes: Strange bitfield structure sizing issue
Changes by Santoso Wijaya santoso.wij...@gmail.com: -- nosy: +santa4nt type: - behavior versions: +Python 2.7, Python 3.1, Python 3.2, Python 3.3 -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11920 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11846] Remove non-guaranteed implementation details from docs.
Terry J. Reedy tjre...@udel.edu added the comment: The range of interned ints was once much smaller, but it was expanded upwards to 256 so that the bytes extracted from bytes and bytearray objects, as when indexing or iterating, would *all* be pre-allocated objects. I should presume that their indexers and iterators are cognizant of this and take advantage of this to bypass int() creation and directly index into the the array of preallocated ints without a range check. As for space and some time saving, just on startup, a nearly fresh IDLE shell shows sum((sys.getrefcount(i) for i in range(-5, 257))) 4432 There are hundreds of references for each of 0 and 1. -- nosy: +terry.reedy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11846 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11920] ctypes: Strange bitfield structure sizing issue
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: The output is: 3 2 on windows. It is 2 2 on the linux 64bit I tried. This is consistent with what the usual compilers do on these platforms: MSVC on windows, and gcc on linux. The specification of the C language specifies that If an adjacent bitfield will not fit into the remainder of the unit, the implementation defines whether bitfields are allowed to span units or whether another unit is allocated for the second bitfield Are you using gcc on windows? In this case I suggest to always use the largest type to declare the bitfields. -- nosy: +amaury.forgeotdarc Added file: http://bugs.python.org/file21776/bitfields.c ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11920 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com