Re: inspect bug
On Oct 9, 9:47 am, Gabriel Genellina [EMAIL PROTECTED] wrote: En Thu, 09 Oct 2008 00:24:20 -0300, Aaron Castironpi Brady [EMAIL PROTECTED] escribió: Found this bug. It's in 2.6, too bad. Posting here is not going to help much, it just will be lost. Would be better to file a bug report athttp://bugs.python.org/ -- Gabriel Genellina It is at bugs.python. http://bugs.python.org/msg74595 . -- http://mail.python.org/mailman/listinfo/python-list
Re: default value in __init__
In article [EMAIL PROTECTED], kenneth [EMAIL PROTECTED] wrote: On Oct 9, 10:14 am, Christian Heimes [EMAIL PROTECTED] wrote: kenneth wrote: the 'd' variable already contains the 'self.d' value of the first instance and not the default argument {}. Am I doing some stupid error, or this is a problem ? No, it always contains the default argument because default values are created just ONE TIME.http://effbot.org/pyfaq/why-are-default-values-shared-between-objects.. . Wow, it's a very dangerous behavior ... Just to know, is this written somewhere in the python documentation or one has to discover it when his programs fails to work ;-) ? At least once a week someone discovers this problem, makes a post about it here, and then someone points to the spot in the documentation where it's explained. Seems to me that people often site the important warning in the tutorial. Of course there's no reason anyone would bother going through the tutorial - just for fun I looked in the official Python Reference Manual to see whether they're explicit about this or require the reader to figure it out from something else they say. There's a section titled 7.6 Function definitions. About halfway through that section there's a _bold face_ statement Default parameter values are evaluated when the function definition is executed., followed by an explanation of how that can lead to the sort of problem above. So I guess it _is_ awfully dangerous. They should really explain this aspect of the language's behavior to people who don't read the formal definition and also don't work through the tutorial. Paolo -- David C. Ullrich -- http://mail.python.org/mailman/listinfo/python-list
Re: NameError question - def(self,master) - master not in namespace within class?
[EMAIL PROTECTED] a écrit : OT bieffe, please, learn to snip irrelevant material... /OT On 9 Ott, 17:43, harijay [EMAIL PROTECTED] wrote: (snip) NameError: name 'master' is not defined (snip) #File runner.py #!/usr/bin/python import master import child if __name__==__main__: print RUNNING RUNNER m = master.master(hj,oldhj) s = child.child(m) (snip) #File child.py class child(): def __init__(self,master): print Master name is %s % master.name print Now seeting master name to setnameinchild in child.py tmp = master.trash master.trash = master.name master.name = setnameinchild (snip) You need to have an import master in child.py too. Nope. The 'child' class is passed a 'master' instance when instanciated. You got confused by the bad naming. OP The convention in Python is to name classes in CamelCase. Your classes should be named 'Master' and 'Child'. /OP -- http://mail.python.org/mailman/listinfo/python-list
Re: Inefficient summing
Matt Nordhoff wrote: Chris Rebert wrote: I personally would probably do: from collections import defaultdict label2sum = defaultdict(lambda: 0) FWIW, you can just use: label2sum = defaultdict(int) You don't need a lambda. Indeed, in this case, with two known keys, the defaultdict is not needed either, since the following should work as well to initialize label2sum = {'F1':0,'F2':0} for r in rec: for key, value in r.iteritems(): label2sum[key] += value ratio = label2sum[F1] / label2sum[F2] -- http://mail.python.org/mailman/listinfo/python-list
Re: inspect feature
On Oct 9, 3:48 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Aaron Castironpi Brady a écrit : Hello, The 'inspect' module has this method: inspect.getargvalues(frame) It takes a frame and returns the parameters used to call it, including the locals as defined in the frame, as shown. def f( a, b, d= None, *c, **e ): ... import inspect ... return inspect.getargvalues( inspect.currentframe() ) ... f( 0, 1, 'abc', 'def', ( 3, 2 ), h= 'ghi' ) (['a', 'b', 'd'], 'c', 'e', {'a': 0, 'c': ('def', (3, 2)), 'b': 1, 'e': {'h': 'g hi'}, 'd': 'abc', 'inspect': module 'inspect' from 'C:\Programs \Python26\lib\in spect.pyc'}) However, if you wanted a decorator that examines the parameters to a function, you're out of luck. By the time you have a frame, you're already in the function. Hem... def decorator(func): def _decorator(*args, *kw): print func args are , *args, **kw return func(*args, **kw) return _decorator It is less of a problem without tuple unpacking, but you still have code like: if len( args )= 2: b= args[ 1 ] else: try: b= (somehow check b's default val.) except NoDefaultVal: raise ArgumentError Worse yet, you have it for each parameter. Unless I missed something, this is the only way to mimic/recreate the signature of the decoratee. -- http://mail.python.org/mailman/listinfo/python-list
Re: Safe eval of insecure strings containing Python data structures?
On Oct 9, 1:44 pm, Jason Scheirer [EMAIL PROTECTED] wrote: On Oct 9, 9:01 am, Paul Rubin http://[EMAIL PROTECTED] wrote: Lie Ryan [EMAIL PROTECTED] writes: in python 2.6, ast.literal_eval may be used to replace eval() for literals. What happens on literal_eval('[1]*9') ? The documentation clearly states that it will fail to evaluate and raise a ValueError because there is an operation in the statement. 5*5 is NOT the literal 25, it is the equivalent to operator.mul(5, 5), and the same is true to []*x Kudos to author on creating this function! -- http://mail.python.org/mailman/listinfo/python-list
Re: Traceback not going all the way to the exception?
sert wrote: I just got an exception and the traceback wouldn't go all the way to the statement that threw the exception. I found that out by using the debugger. Contrast the traceback: http://tinyurl.com/5xglde with the debugger output (notice the arrow pointing to the last statement the traceback showed and how the execution went on beyond it): http://tinyurl.com/3fjgrl Is this a known issue or should I submit a bug report? You forgot to specify which version of Python on which computer system. I do not remember anything like this. You can search the items at bugs.python.org. If no one explains this, I suggest a bug report. -- http://mail.python.org/mailman/listinfo/python-list
Re: no unbound methods in py3k
Thomas Heller wrote: Christian Heimes schrieb: Thomas Heller wrote: but this is very ugly, imo. Is there another way? The raw_func instances that I have are not descriptors (they do not implement a __get__() method...) I've written PyInstanceMethod_Type for this use case. It's not (yet) available for Python code. Barry hasn't decided whether he should expose the type so late in the release cycle or not. See http://bugs.python.org/issue3787 and http://docs.python.org/dev/3.0/c-api/method.html?highlight=pyinstancemethod#PyInstanceMethod_Type Ok, so one has to write an extension to access or expose it. Oh, wait - there's ctypes: Python 3.0rc1 (r30rc1:66507, Sep 18 2008, 14:47:08) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. from ctypes import * pythonapi.PyInstanceMethod_New.restype = py_object pythonapi.PyInstanceMethod_New.argtypes = [py_object] instancemethod = pythonapi.PyInstanceMethod_New class Example: ... pass ... Example.id = instancemethod(id) x = Example() x.id() 12597296 id(x) 12597296 A pyCapi module that exposed via ctypes useful C functions not otherwise accessible, with predefinition of restype and argtypes and anything else needed, might make a nice addition to PyPI if not the stdlib. You have done two here and I believe others have posted others. tjr -- http://mail.python.org/mailman/listinfo/python-list
Problem with cPickle and cElementTree
I recently tried switching from ElementTree to cElementTree. My application parses a collection of large XML files and creates indexes based on certain attributes. This entire collection is saved as an instance of my Database class. Using ElementTree and cPickle has allowed me to save these instances and use them later. Using cElementTree significantly reduces parse time (~50%) and memory ~(15%) but cPickle refuses to pickle the database object. I receive: TypeError: expecting string or Unicode object, NoneType found The offending line of code simple shows my invocation of cPickle, which is not helpful. Doing exactly the same thing with ElementTree works fine. It appears that the objects returned by cElementTree do not pickle correctly. Is this a know issue? I was unable to find any reports of this problem. Any info would be appreciated! Barry -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6, GUI not working on vista?
* Mensanator (Thu, 9 Oct 2008 11:03:45 -0700 (PDT)) On Oct 9, 12:36 pm, Thorsten Kampe [EMAIL PROTECTED] wrote: * Mensanator (Tue, 7 Oct 2008 10:58:24 -0700 (PDT)) On Oct 7, 12:40 pm, Thorsten Kampe [EMAIL PROTECTED] wrote: * Lawrence D'Oliveiro (Mon, 06 Oct 2008 23:18:10 +1300) In message [EMAIL PROTECTED], Thorsten Kampe wrote: * Lawrence D'Oliveiro (Sun, 05 Oct 2008 22:13:46 +1300) In message [EMAIL PROTECTED], Michel Claveau - NoSpam SVP ; merci wrote: Another way is to de-activate UAC. Please don't be stupid! He's not stupid. Disabling UAC is the recommended way to get rid of these problems. Disabling UAC is NOT recommended. YOU don't recommend it. I don't recommend it either - all the people I know (and this includes Microsoft techsupport people) do it anyway without recommendation. Be that as it may, it is still enabled by default, isn't it? So advice that requires it to be disabled (or the Administrator account enabled) ought to mention such a pertinent fact, shouldn't it? The fact that it's enabled by default is totally irrelevant for the advise. You're talking about the wrong fact. The advice doesn't mention UAC. Michel's advice did. Here, let me quote it to you: quote Vista Note Administrators installing Python for all users on Windows Vista either need to be logged in as Administrator, or use the runas command, as in: runas /user:Administrator msiexec /i path\file.msi /quote Now, how relevant is the state of the Administrator account for this advice to work? I don't know. I don't care. I couldn't care less. I say, ignore this advice and disable UAC. Thorsten -- http://mail.python.org/mailman/listinfo/python-list
Re: Traceback not going all the way to the exception?
On Oct 9, 3:27 am, sert [EMAIL PROTECTED] wrote: I just got an exception and the traceback wouldn't go all the way to the statement that threw the exception. I found that out by using the debugger. Contrast the traceback: http://tinyurl.com/5xglde with the debugger output (notice the arrow pointing to the last statement the traceback showed and how the execution went on beyond it): http://tinyurl.com/3fjgrl Is this a known issue or should I submit a bug report? Could be you are re-raising an exception by hand instead of with the bare 'raise' statement. Notice the difference in tracebacks shown here: def f(): ... try: ... g() ... except Exception, e: ... raise e ... def g(): ... raise Exception(abc) ... f() Traceback (most recent call last): File stdin, line 1, in module File stdin, line 5, in f Exception: abc def f(): ... try: ... g() ... except Exception, e: ... raise ... f() Traceback (most recent call last): File stdin, line 1, in module File stdin, line 3, in f File stdin, line 2, in g Exception: abc -- http://mail.python.org/mailman/listinfo/python-list
python 3: sorting with a comparison function
Does Python 3 have no way anymore to sort with a comparison function? Both [].sort() and sorted() seem to accept only 'key' and 'reverse' arguments, the 'cmp' argument seems to be gone. Can that be? Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: no unbound methods in py3k
Terry Reedy schrieb: Thomas Heller wrote: Christian Heimes schrieb: I've written PyInstanceMethod_Type for this use case. It's not (yet) available for Python code. Oh, wait - there's ctypes: Python 3.0rc1 (r30rc1:66507, Sep 18 2008, 14:47:08) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. from ctypes import * pythonapi.PyInstanceMethod_New.restype = py_object pythonapi.PyInstanceMethod_New.argtypes = [py_object] instancemethod = pythonapi.PyInstanceMethod_New class Example: ... pass ... Example.id = instancemethod(id) x = Example() x.id() 12597296 id(x) 12597296 A pyCapi module that exposed via ctypes useful C functions not otherwise accessible, with predefinition of restype and argtypes and anything else needed, might make a nice addition to PyPI if not the stdlib. You have done two here and I believe others have posted others. Well, Lenard Lindstrom has some time ago contributed a module like that which is available in the (more or less unmaintained) ctypeslib project: http://svn.python.org/projects/ctypes/trunk/ctypeslib/ctypeslib/contrib/pythonhdr.py However, it was probably more meant to provide a complete Python C api, instead of concentrating on stuff not available to Python otherwise. Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: On the indexing order in (numpy) arrays
Almar Klein wrote: Hi, I was wondering... Say we have a np.ndarray A of two dimensions (a grayscale image for example). If we want to access x:2, y:3, we have to do A[3,2]. Why is the order of x and y reversed? This is reversed in Matlab too, because Matlab is a matrix package and matrix are often used this way. (In Matlab the data is actually stored last-dimensions-first too.) Basically, we want a[i][j] == a[i,j]. Since there is no literal syntax for numpy arrays, we need to be able to convert from a sequence of sequences to an array. The indexing needs to correspond between the two. I suspect numpy has good reasons to do so too, but they are not clear to me. I find myself quite a lot wondering if I have to use (or implement) a method with order x-y-z, or the other way around. And I suspect this can cause quite a lot of confusion and bugs! You get used to it, I've found. If I make a function to do some image operation in a certain dimension: def some_operation(image, dim): Would it make more sense if dim=0 means x, or y? Can anyone shed some light on why this is and how I can determine which order to adopt when I create a function like the one above? Adopt the numpy order. There are many functions in numpy which take an axis= argument just like this. axis=0 means y in the terminology that you are using. If you have more numpy questions, please join us on the numpy mailing list. http://www.scipy.org/Mailing_Lists -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6, GUI not working on vista?
On Oct 9, 2:09 pm, Thorsten Kampe [EMAIL PROTECTED] wrote: * Mensanator (Thu, 9 Oct 2008 11:03:45 -0700 (PDT)) On Oct 9, 12:36 pm, Thorsten Kampe [EMAIL PROTECTED] wrote: * Mensanator (Tue, 7 Oct 2008 10:58:24 -0700 (PDT)) On Oct 7, 12:40 pm, Thorsten Kampe [EMAIL PROTECTED] wrote: * Lawrence D'Oliveiro (Mon, 06 Oct 2008 23:18:10 +1300) In message [EMAIL PROTECTED], Thorsten Kampe wrote: * Lawrence D'Oliveiro (Sun, 05 Oct 2008 22:13:46 +1300) In message [EMAIL PROTECTED], Michel Claveau - NoSpam SVP ; merci wrote: Another way is to de-activate UAC. Please don't be stupid! He's not stupid. Disabling UAC is the recommended way to get rid of these problems. Disabling UAC is NOT recommended. YOU don't recommend it. I don't recommend it either - all the people I know (and this includes Microsoft techsupport people) do it anyway without recommendation. Be that as it may, it is still enabled by default, isn't it? So advice that requires it to be disabled (or the Administrator account enabled) ought to mention such a pertinent fact, shouldn't it? The fact that it's enabled by default is totally irrelevant for the advise. You're talking about the wrong fact. The advice doesn't mention UAC. Michel's advice did. Michel's advice isn't on the download page, is it? Here, let me quote it to you: quote Vista Note Administrators installing Python for all users on Windows Vista either need to be logged in as Administrator, or use the runas command, as in: runas /user:Administrator msiexec /i path\file.msi /quote Now, how relevant is the state of the Administrator account for this advice to work? I don't know. I do. I don't care. I do. I couldn't care less. Because I had to do it. I say, ignore this advice and disable UAC. Fine. Can you then see to it that this is mentioned on the Python download page? Thorsten -- http://mail.python.org/mailman/listinfo/python-list
Re: no unbound methods in py3k
Thomas Heller wrote: Ok, so one has to write an extension to access or expose it. Oh, wait - there's ctypes: I wrote the type to help the Pyrex and Cython developers to port their software to 3.0. I planed to expose the type as __builtin__.instancemethod but forgot it. Maybe we can convince Barry together. He still considers my bug as a release blocker for 3.0. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: Can anyone Pythonize this lexical algorithm?
On Oct 9, 7:29 am, ShashiGowda [EMAIL PROTECTED] wrote: I am writing a package manager and stuck unable to write the version sorting function the algorithm is herehttp://www.linux.gr/cgi-bin/man/man2html?deb-version+5 and all other info is also in it please tell me how to do lexical comparision in python it'll be cool if you just write the code! On Oct 9, 7:29 am, ShashiGowda [EMAIL PROTECTED] wrote: I am writing a package manager and stuck unable to write the version sorting function the algorithm is herehttp://www.linux.gr/cgi-bin/man/man2html?deb-version+5 and all other info is also in it please tell me how to do lexical comparision in python it'll be cool if you just write the code! Step 1. Define a class, call it something like PackageVersion, with an __init__ method that takes an string containing the version string. In the body of __init__, use regular expressions, pyparsing, str methods, whatever, to break up the version into the individual fields. Step 2. Implement a __cmp__ method on PackageVersion that performs the desired version comparison logic. Take a crack at writing some code, and come back with specific questions. I doubt your hopes for coolness will be met. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
book recommendation for Python newbie?
I'm trying to (gently) convince my business partner that we should be adding Python to our core toolset. He's never used it before, apart from poking around in the tutorial a bit at my urging. But he's got a birthday coming up, and I'd like to get him a book that will help him make the transition more smoothly and enjoyably. In case it matters: his background is mainly in databases (originally 4D, more recently MySQL), and his current primary tools are REALbasic (which is a statically typed language with semantics similar to Java) and PHP. He's primarily a Mac user, but occasionally has to dabble in Linux or Windows. If we do make this change, he'll be using Python in a professional capacity to develop commercial apps. There are a lot of Python books out there... which one would you recommend in this case? Thanks, - Joe -- http://mail.python.org/mailman/listinfo/python-list
Re: Using subprocess module to launch a shell shell script that itself forks a process
On Tue, Oct 07, 2008 at 05:43:41PM -0700, Samuel A. Falvo II wrote: p = subprocess.Popen( command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True ) outputChannel = p.stdout output = outputChannel.read() You call read with no arguments. This is highly problematic in the context of interprocess communication, unless you can be 100% positive that none of the children will write anywhere besides STDOUT, and won't try to read from STDIN in the meanwhile. Python's read() with no args reads until the end of file, which in IPC contexts is bad... Normally the child process won't close stdout until it exits. So, if it did any other output in between, say, to STDERR, the child will block waiting for the parent to read STDERR, meanwhile the parent is blocked waiting for input from the child's STDOUT, which results in a deadlock. Both processes sleep forever. The exact same thing can happen if either the shell script or a process started by the shell script tries to read from STDIN. Since Java is launched by the shell script, it inherits the shell script's STDIN, STDOUT, and STDERR file descriptors (i.e. the two processes share the same STDIO). Thus if the java process writes to STDERR, that also could be causing your deadlock. On Wed, Oct 08, 2008 at 11:24:39AM -0700, Samuel A. Falvo II wrote: On Oct 7, 6:23 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: Is your shell script doing something else, apart from invoking the java process? Obviously, yes. It's far from obvious. I can't count the number of scripts I've seen whose sole purpose was to launch a Java program (with the right environment)... You would do well to avoid being dismissive and listen to those who respond with help, when you are the one who obviously doesn't understand the behavior you're getting, and you're the one asking for help. The script is some 150 lines long. But the hang-up occurs because of the forked Java process, not the other lines. I'm betting it's because the Java program is writing warnings to STDERR (more data than will fit in the STDIO buffer), which you're not reading... If not, you could just invoke java directly from Python. Also, you set stdin=PIPE - is your java process expecting some input? you're not writing anything to stdin. It does not expect input from stdin. However, this does not affect any OTHER scripts or commands I run. Irrelevant... Unless any OTHER scripts encompases all possible combinations of process interactions, and you can demontstrate that it does so, this proves nothing. Let's remember to look at the objective facts: for shell scripts that launch child processes of their own, Python hangs. For all other types of commands, it works 100% as expected. These are not facts which are in evidence. We don't know what your script is doing, and it's clear that you yourself are not able to explain the behavior you are seeing, therefore there is no reason for us to conclude that the above statements are true and correct. Most likely, they are not. Anyway, it's better to use the communicate method instead (it uses select to read from both stdout and stderr): That doesn't help me. Please explain why it doesn't. The most likely cause of the behavior you are seeing is the deadlock I described, above. Using select() (i.e. using communicate()) should generally fix about half the cases... The rest would be fixed by redirecting STDIN of the child (or at least the Java process) from /dev/null, most likely. Then of course, there could be other explanations. But this being overwhelmingly the most likely one, if you don't try those solutions, there's no point in trying to help you further... -- Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0x81CFE75D pgp8zdVYVQEhV.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: no unbound methods in py3k
Christian Heimes schrieb: Thomas Heller wrote: Ok, so one has to write an extension to access or expose it. Oh, wait - there's ctypes: I wrote the type to help the Pyrex and Cython developers to port their software to 3.0. I planed to expose the type as __builtin__.instancemethod but forgot it. Maybe we can convince Barry together. He still considers my bug as a release blocker for 3.0. Issue 3787 is marked as release blocker, but for 3.1 IIUC. Would it help if I post my use case to the tracker? Thomas -- http://mail.python.org/mailman/listinfo/python-list
FLexible formatted text involving nested lists?
I'm having trouble getting my head around a solution for a situation where I need to flexibly format some text with a varying number of embedded fields. Here's a simplified description of my challenge... I have a list of lists called bigList: bigList = [ little, small, tiny] The sub-lists have varying sizes. I won't know how many items they have but it will be between 0 and 3 So perhaps little = [3, 2, 7] small = [6,4] tiny = [2] The values in those sub lists correspond to formatted print strings. The formatting strings will change over time and they are in a list called fmts where fmts = [fmtA, fmtB, fmtC] where fmtA = 'oats %0d kilos over %0d days with %0d workers' fmtB = 'barley %0d lbs for %0d hours' fmtC = 'apples %0d baskets' If I knew how many fields were in each 'sub-list' in bigList ahead of time, and it never changed I could awkwardly do this: print fmtA %(little[0], little[1], little[2]) print fmtB %(small[0], small[1]) print fmtC %(tiny[0]) or equivalently, print fmts[0] %(bigList[0][0], bigList[0][1], bigList[0][2]) print fmts[1] %(bigList[1][0], bigList[1][1]) print fmts[2] %(bigList[2][0]) Both approaches would yield: oats 3 kilos over 2 days with 7 workers barley 6 lbs for 4 hours apples 2 baskets Now my challenge: since the number of fields is unknown at design time, my app needs to add be able to flexibly handle this. I though maybe I could use a loop that figures things out as it goes along. e.g... i=0 for fmtString in fmts numbOfFields = len(fmt[i]) print fmtString %(bigList[i][ need for 0 to numbOffields worth of indices!] ) But I don't know how to have a number of items in the print expression that align to the numbOfFields value!? Is there some other approach I can use? I thought perhaps it would accomodate extra elements in the %(...) part of the formatted print expression which would be ignored, but that doesn't work. Maybe I have to break my fmts up and do a field at a time? Any thoughts are appreciated :) -Ross. -- http://mail.python.org/mailman/listinfo/python-list
Re: python 3: sorting with a comparison function
Thomas Heller: the 'cmp' argument seems to be gone. Can that be? Yes, that's a wonderful thing, because from the code I see around 99.9% of people see the cmp and just use it, totally ignoring the presence of the 'key' argument, that allows better and shorter solutions of the sorting problem. So removing the cmp is the only way to rub the nose of programmers on the right solution, and it goes well with the Python There should be one-- and preferably only one -- obvious way to do it.. For most of very uncommon situations where key isn't the right thing, you can use this code by Hettinger: def cmp2key(mycmp): Converts a cmp= function into a key= function class K: def __init__(self, obj, *args): self.obj = obj def __cmp__(self, other): return mycmp(self.obj, other.obj) return K s.sort(key=cmp2key(lambda p, q: cmp(p.lower(), q.lower( That code can't be used in one situation: when the array to be sorted is huge, that situation can be handled by the original true cmp function, but not by that cmp2key(). But I have met such situation so far. When you have an huge amount of data, use an external sort, even Windows has one, even if its usage is a bit tricky (linux sort command is safer). Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: book recommendation for Python newbie?
On Oct 9, 3:00 pm, Joe Strout [EMAIL PROTECTED] wrote: I'm trying to (gently) convince my business partner that we should be adding Python to our core toolset. He's never used it before, apart from poking around in the tutorial a bit at my urging. But he's got a birthday coming up, and I'd like to get him a book that will help him make the transition more smoothly and enjoyably. In case it matters: his background is mainly in databases (originally 4D, more recently MySQL), and his current primary tools are REALbasic (which is a statically typed language with semantics similar to Java) and PHP. He's primarily a Mac user, but occasionally has to dabble in Linux or Windows. If we do make this change, he'll be using Python in a professional capacity to develop commercial apps. There are a lot of Python books out there... which one would you recommend in this case? Thanks, - Joe A lot of people recommend Lutz's Learning Python. While I haven't read it, I have read his follow-up Programming Python and it was good. You might also look at Hetland's Beginning Python or even the Python for Dummies book. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Safe eval of insecure strings containing Python data structures?
Paul Rubin wrote: Lie Ryan [EMAIL PROTECTED] writes: in python 2.6, ast.literal_eval may be used to replace eval() for literals. What happens on literal_eval('[1]*9') ? Easy to try. Since it is not a literal or display, ValueError: malformed string, just as with set({1,2,3]) [1]*9 # or eval('[1]*9') # give a quick MemoryError -- http://mail.python.org/mailman/listinfo/python-list
Re: FLexible formatted text involving nested lists?
Ross, I'm no expert in python, so excuse me if this is inane. What I would do is have fmts be a dictionary where fmts = { 3 = 'oats %0d kilos over %0d days with %0d workers', 2 = 'barley %0d lbs for %0d hours', 1 = 'apples %0d baskets'} then something like for x in bigList: print fmts[len(x)] % x I didn't test this, but in theory it should work. Hope this helps, Kerri On Thu, Oct 9, 2008 at 2:36 PM, RossRGK [EMAIL PROTECTED] wrote: I'm having trouble getting my head around a solution for a situation where I need to flexibly format some text with a varying number of embedded fields. Here's a simplified description of my challenge... I have a list of lists called bigList: bigList = [ little, small, tiny] The sub-lists have varying sizes. I won't know how many items they have but it will be between 0 and 3 So perhaps little = [3, 2, 7] small = [6,4] tiny = [2] The values in those sub lists correspond to formatted print strings. The formatting strings will change over time and they are in a list called fmts where fmts = [fmtA, fmtB, fmtC] where fmtA = 'oats %0d kilos over %0d days with %0d workers' fmtB = 'barley %0d lbs for %0d hours' fmtC = 'apples %0d baskets' If I knew how many fields were in each 'sub-list' in bigList ahead of time, and it never changed I could awkwardly do this: print fmtA %(little[0], little[1], little[2]) print fmtB %(small[0], small[1]) print fmtC %(tiny[0]) or equivalently, print fmts[0] %(bigList[0][0], bigList[0][1], bigList[0][2]) print fmts[1] %(bigList[1][0], bigList[1][1]) print fmts[2] %(bigList[2][0]) Both approaches would yield: oats 3 kilos over 2 days with 7 workers barley 6 lbs for 4 hours apples 2 baskets Now my challenge: since the number of fields is unknown at design time, my app needs to add be able to flexibly handle this. I though maybe I could use a loop that figures things out as it goes along. e.g... i=0 for fmtString in fmts numbOfFields = len(fmt[i]) print fmtString %(bigList[i][ need for 0 to numbOffields worth of indices!] ) But I don't know how to have a number of items in the print expression that align to the numbOfFields value!? Is there some other approach I can use? I thought perhaps it would accomodate extra elements in the %(...) part of the formatted print expression which would be ignored, but that doesn't work. Maybe I have to break my fmts up and do a field at a time? Any thoughts are appreciated :) -Ross. -- http://mail.python.org/mailman/listinfo/python-list -- Yuma Educational Computer Consortium Compass Development Team Kerri Reno [EMAIL PROTECTED] (928) 502-4240 .·:*¨¨*:·. .·:*¨¨*:·. .·:*¨¨*:·. -- http://mail.python.org/mailman/listinfo/python-list
Re: Inefficient summing
beginner [EMAIL PROTECTED] writes: Hi All, I have a list of records like below: rec=[{F1:1, F2:2}, {F1:3, F2:4} ] Now I want to write code to find out the ratio of the sums of the two fields. One thing I can do is: sum(r[F1] for r in rec)/sum(r[F2] for r in rec) But this is slow because I have to iterate through the list twice. Also, in the case where rec is an iterator, it does not work. how about: ratio = (lambda c: c.real/c.imag)(sum(complex(r[F1], r[F2] for r in rec))) ? :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Can anyone Pythonize this lexical algorithm?
ShashiGowda wrote: I am writing a package manager and stuck unable to write the version sorting function the algorithm is here http://www.linux.gr/cgi-bin/man/man2html?deb-version+5 and all other info is also in it please tell me how to do lexical comparision in python it'll be cool if you just write the code! Assuming you want 10.1 to sort after 9.8 and 1.10 after 1.9, you want to compare tuples or lists of ints. -- http://mail.python.org/mailman/listinfo/python-list
Python HTML parser chokes on UTF-8 input
Hello group, I'm trying to use a htmllib.HTMLParser derivate class to parse a website which I fetched via httplib.HTTPConnection().request().getresponse().read(). Now the problem is: As soon as I pass the htmllib.HTMLParser UTF-8 code, it chokes. The code is something like this: prs = self.parserclass(formatter.NullFormatter()) prs.init() prs.feed(website) self.__result = prs.get() prs.close() Now when I take website directly from the parser, everything is fine. However I want to do some modifications before I parse it, namely UTF-8 modifications in the style: website = website.replace(uföö, ubär) Therefore, after fetching the web site content, I have to convert it to UTF-8 first, modify it and convert it back: website = website.decode(latin1) website = website.replace(uföö, ubär) website = website.encode(latin1) This is incredibly ugly IMHO, as I would really like the parser to just accept UTF-8 input. However when I omit the reecoding to latin1: File CachedWebParser.py, line 13, in __init__ self.__process(website) File CachedWebParser.py, line 55, in __process prs.feed(website) File /usr/lib64/python2.5/sgmllib.py, line 99, in feed self.goahead(0) File /usr/lib64/python2.5/sgmllib.py, line 133, in goahead k = self.parse_starttag(i) File /usr/lib64/python2.5/sgmllib.py, line 285, in parse_starttag self._convert_ref, attrvalue) UnicodeDecodeError: 'ascii' codec can't decode byte 0xfc in position 0: ordinal not in range(128) Annoying, IMHO, that the internal html Parser cannot cope with UTF-8 input - which should (again, IMHO) be the absolute standard for such a new language. Can I do something about it? Regards, Johannes -- Meine Gegenklage gegen dich lautet dann auf bewusste Verlogenheit, verlästerung von Gott, Bibel und mir und bewusster Blasphemie. -- Prophet und Visionär Hans Joss aka HJP in de.sci.physik [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: On the indexing order in (numpy) arrays
Almar Klein wrote: Hi, I was wondering... Say we have a np.ndarray A of two dimensions (a grayscale image for example). If we want to access x:2, y:3, we have to do A[3,2]. Why is the order of x and y reversed? Because images are stored by rows, not by columns. So column 3, row 2, is row 2, column 3. The same convention is used for matrix coordinates. Numpy has no idea what names you apply to the dimensions. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6, GUI not working on vista?
On Thu, Oct 9, 2008 at 3:48 PM, Mensanator [EMAIL PROTECTED] wrote: Fine. Can you then see to it that this is mentioned on the Python download page? I'm not sure if anyone has mentioned it in all of the invective, but the right thing to do is to report a bug on http://bugs.python.org. If the documentation for installing under Vista is wrong, file a bug against the docs. If you know the right way to fix the docs, attach a patch. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list
Re: inspect bug
Aaron Castironpi Brady wrote: On Oct 9, 9:47 am, Gabriel Genellina [EMAIL PROTECTED] wrote: En Thu, 09 Oct 2008 00:24:20 -0300, Aaron Castironpi Brady [EMAIL PROTECTED] escribió: Found this bug. It's in 2.6, too bad. Posting here is not going to help much, it just will be lost. Would be better to file a bug report athttp://bugs.python.org/ -- Gabriel Genellina It is at bugs.python. http://bugs.python.org/msg74595 . The issue, as opposed to the message within the issue, is http://bugs.python.org/issue4092 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6, GUI not working on vista?
I say, ignore this advice and disable UAC. Fine. Can you then see to it that this is mentioned on the Python download page? I think Thorsten's advice is helpful (in the sense that it solves the problem, and is IMO pragmatic also), but I *still* wouldn't put it on the Python download page, for fear of the flak from the security folks who start screaming that the PSF should never give such advice. I would personally think they would be wrong, but still revert giving the advise under public pressure. In any case, Python 2.6.1 will approach this problem in a different way. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: On the indexing order in (numpy) arrays
Basically, we want a[i][j] == a[i,j]. Since there is no literal syntax for numpy arrays, we need to be able to convert from a sequence of sequences to an array. The indexing needs to correspond between the two. Thanks for the reply. I guess that explains the *why*... Adopt the numpy order. There are many functions in numpy which take an axis= argument just like this. axis=0 means y in the terminology that you are using. Yes, I agree its best to use the numpy order, and I agree one gets used to it. However, it will always feel a bit unnatural to reverse the order of dimensions (at least to me it does). And I think it can in some situations lead to confusion. I for instance have a class to store sets of points in a nD space. I can index the points, so using points[99,0] selects the *first* dimension of the 99th point. I use this class to store locations of interesting points in 2D and 3D images. But when programming, it can at times be quite confusing switching between reversed and normal indexing. And sometimes I might have a method that does stuff with an image and a point set and I want to indicate an axis. What standard should I use then? I'm not saying numpy should change the indexing order or something. But other people must run into the same confusing situation at times. How do they handle this? In the example above, I think it'll be weird to change the pointset class such that points[99,0] selects the *last* dimension of point 99. Or is it? Cheers, Almar -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6, GUI not working on vista?
You can believe what you want. The people who developed UAC don't have to support it. I know for a fact that the implementation is incomplete. In Windows Installer, there is no way (that I know of) to create an MSI file that conditionally turns on UAC, only when the installation actually needs privilege elevation. There is a static bit in the installer that indicates whether the MSI file will do UAC, and there is no way to toggle this bit, e.g. after asking the user whether this is a for me installation or for all users. I set this bit to no UAC for 2.6, in order to allow non-privileged installation at all - only to find out that (due to an unrelated problem), the for me installation doesn't actually work. I only found out after the release, because nobody bothered reporting this problem during the betas and release candidates. I didn't notice on my Vista machine, because that has VS 2008 installed, in which case the for me installation works just fine. If anybody knows how to make the for me installation work (i.e. how to set up the manifests that a single copy of the CRT is used both by python26.dll, and all extension modules), please let me know. IOW: HELP! HELP!! HELP!!! Meanwhile: just say no to Vista. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Traceback not going all the way to the exception?
Terry Reedy [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: You forgot to specify which version of Python on which computer system. It's on Python 2.6. -- http://mail.python.org/mailman/listinfo/python-list
Re: python 3: sorting with a comparison function
Thomas Heller wrote: Does Python 3 have no way anymore to sort with a comparison function? Both [].sort() and sorted() seem to accept only 'key' and 'reverse' arguments, the 'cmp' argument seems to be gone. Can that be? Yes. When this was discussed, no one could come up with an actual use case in which the compare function was not based on a key function. Calling the key function n times has to be faster than calling a compare function n to O(nlogn) times with 2 keys computed for each call. The main counter argument would be if there is no room in memory for the shadow array of key,index pairs. And that can be at least sometimes handled by putting the original on disk and sorting an overt key,index array. Or by using a database. -- http://mail.python.org/mailman/listinfo/python-list
Re: template strings for matching?
On Oct 9, 5:20 pm, Joe Strout [EMAIL PROTECTED] wrote: Wow, this was harder than I thought (at least for a rusty Pythoneer like myself). Here's my stab at an implementation. Remember, the goal is to add a match method to Template which works like Template.substitute, but in reverse: given a string, if that string matches the template, then it should return a dictionary mapping each template field to the corresponding value in the given string. Oh, and as one extra feature, I want to support a .greedy attribute on the Template object, which determines whether the matching of fields should be done in a greedy or non-greedy manner. #!/usr/bin/python from string import Template import re def templateMatch(self, s): # start by finding the fields in our template, and building a map # from field position (index) to field name. posToName = {} pos = 1 for item in self.pattern.findall(self.template): # each item is a tuple where item 1 is the field name posToName[pos] = item[1] pos += 1 # determine if we should match greedy or non-greedy greedy = False if self.__dict__.has_key('greedy'): greedy = self.greedy # now, build a regex pattern to compare against s # (taking care to escape any characters in our template that # would have special meaning in regex) pat = self.template.replace('.', '\\.') pat = pat.replace('(', '\\(') pat = pat.replace(')', '\\)') # there must be a better way... if greedy: pat = self.pattern.sub('(.*)', pat) else: pat = self.pattern.sub('(.*?)', pat) p = re.compile(pat) # try to match this to the given string match = p.match(s) if match is None: return None out = {} for i in posToName.keys(): out[posToName[i]] = match.group(i) return out Template.match = templateMatch t = Template(The $object in $location falls mainly in the $subloc.) print t.match( The rain in Spain falls mainly in the train. ) This sort-of works, but it won't properly handle $$ in the template, and I'm not too sure whether it handles the ${fieldname} form, either. Also, it only escapes '.', '(', and ')' in the template... there must be a better way of escaping all characters that have special meaning to RegEx, except for '$' (which is why I can't use re.escape). Probably the rest of the code could be improved too. I'm eager to hear your feedback. Thanks, - Joe How about something like: import re def placeholder(m): if m.group(1): return (?P%s.+) % m.group(1) elif m.group(2): return \\$ else: return re.escape(m.group(3)) regex = re.compile(r\$(\w+)|(\$\$)) t = The $object in $location falls mainly in the $subloc. print regex.sub(placeholder, t) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python HTML parser chokes on UTF-8 input
Johannes Bauer wrote: Hello group, I'm trying to use a htmllib.HTMLParser derivate class to parse a website which I fetched via httplib.HTTPConnection().request().getresponse().read(). Now the problem is: As soon as I pass the htmllib.HTMLParser UTF-8 code, it chokes. The code is something like this: I believe you are confusing unicode with unicode encoded into bytes with the UTF-8 encoding. Having a problem feeding a unicode string, not 'UFT-8 code', which in Python can only mean a UTF-8 encoded byte string. prs = self.parserclass(formatter.NullFormatter()) prs.init() prs.feed(website) self.__result = prs.get() prs.close() Now when I take website directly from the parser, everything is fine. However I want to do some modifications before I parse it, namely UTF-8 modifications in the style: website = website.replace(uföö, ubär) Therefore, after fetching the web site content, I have to convert it to UTF-8 first, modify it and convert it back: website = website.decode(latin1) # produces unicode website = website.replace(uföö, ubär) #remains unicode website = website.encode(latin1) # produces byte string in the latin-1 encoding This is incredibly ugly IMHO, as I would really like the parser to just accept UTF-8 input. To me, code that works is prettier than code that does not. In 3.0, text strings are unicode, and I believe that is what the parser now accepts. However when I omit the reecoding to latin1: File CachedWebParser.py, line 13, in __init__ self.__process(website) File CachedWebParser.py, line 55, in __process prs.feed(website) File /usr/lib64/python2.5/sgmllib.py, line 99, in feed self.goahead(0) File /usr/lib64/python2.5/sgmllib.py, line 133, in goahead k = self.parse_starttag(i) File /usr/lib64/python2.5/sgmllib.py, line 285, in parse_starttag self._convert_ref, attrvalue) UnicodeDecodeError: 'ascii' codec can't decode byte 0xfc in position 0: ordinal not in range(128) When you do not bother to specify some other encoding in an encoding operation, sgmllib or something deeper in Python tries the default encoding, which does not work. Stop being annoyed and tell the interpreter what you want. It is not a mind-reader. Annoying, IMHO, that the internal html Parser cannot cope with UTF-8 input - which should (again, IMHO) be the absolute standard for such a new language. The first version of Python came out in 1989, I believe, years before unicode. One of the features of the new 3.0 version is that is uses unicode as the standard for text. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6, GUI not working on vista?
* Martin v. Löwis (Thu, 09 Oct 2008 23:32:42 +0200) I say, ignore this advice and disable UAC. Fine. Can you then see to it that this is mentioned on the Python download page? I think Thorsten's advice is helpful (in the sense that it solves the problem, and is IMO pragmatic also), I can't except this honour, it was Michel's advice and I only seconded. but I *still* wouldn't put it on the Python download page, for fear of the flak from the security folks who start screaming that the PSF should never give such advice. Absolutely correct. Disabling UAC is a major change in the whole security model in Windows - and while one can mention that, it's certainly nothing you should suggest. Thorstn -- http://mail.python.org/mailman/listinfo/python-list
Re: Traceback not going all the way to the exception?
sert [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: It's on Python 2.6. On Windows. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python HTML parser chokes on UTF-8 input
Terry Reedy schrieb: Johannes Bauer wrote: Hello group, I'm trying to use a htmllib.HTMLParser derivate class to parse a website which I fetched via httplib.HTTPConnection().request().getresponse().read(). Now the problem is: As soon as I pass the htmllib.HTMLParser UTF-8 code, it chokes. The code is something like this: I believe you are confusing unicode with unicode encoded into bytes with the UTF-8 encoding. Having a problem feeding a unicode string, not 'UFT-8 code', which in Python can only mean a UTF-8 encoded byte string. I also believe I am. Could you please elaborate further? Do I understand correctly when saying that type 'str' has no associated default encoding, but type 'unicode' does? Does this mean that really the only way of coping with that stuff is doing what I've been doing? This is incredibly ugly IMHO, as I would really like the parser to just accept UTF-8 input. To me, code that works is prettier than code that does not. In 3.0, text strings are unicode, and I believe that is what the parser now accepts. Well, yes, I suppose working code is nicer than non-working code. However I am sure you will agree that explicit encoding conversions are cumbersome and error-prone. UnicodeDecodeError: 'ascii' codec can't decode byte 0xfc in position 0: ordinal not in range(128) When you do not bother to specify some other encoding in an encoding operation, sgmllib or something deeper in Python tries the default encoding, which does not work. Stop being annoyed and tell the interpreter what you want. It is not a mind-reader. How do I tell the interpreter to parse the strings I pass to it as unicode? The way I did or is there some better way? Annoying, IMHO, that the internal html Parser cannot cope with UTF-8 input - which should (again, IMHO) be the absolute standard for such a new language. The first version of Python came out in 1989, I believe, years before unicode. One of the features of the new 3.0 version is that is uses unicode as the standard for text. Hmmm. I suppose you're right there. Python 3.0 really sounds quite nice, do you know when will approximately be ready? Regards, Johannes -- Meine Gegenklage gegen dich lautet dann auf bewusste Verlogenheit, verlästerung von Gott, Bibel und mir und bewusster Blasphemie. -- Prophet und Visionär Hans Joss aka HJP in de.sci.physik [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6, GUI not working on vista?
On Oct 9, 4:41 pm, Martin v. Löwis [EMAIL PROTECTED] wrote: You can believe what you want. The people who developed UAC don't have to support it. I know for a fact that the implementation is incomplete. In Windows Installer, there is no way (that I know of) to create an MSI file that conditionally turns on UAC, only when the installation actually needs privilege elevation. There is a static bit in the installer that indicates whether the MSI file will do UAC, and there is no way to toggle this bit, e.g. after asking the user whether this is a for me installation or for all users. I set this bit to no UAC for 2.6, in order to allow non-privileged installation at all - only to find out that (due to an unrelated problem), the for me installation doesn't actually work. I only found out after the release, because nobody bothered reporting this problem during the betas and release candidates. I posted a problem with Vista on Jul 6 concerning not being able to run IDLE in 2.6b1. No replies. I also noted the successful use and need to use the Administrator account on Sep 12 for 2.6rc1. Again, no replies. What am I supposed to do? File bug reports on things I don't even know are bugs? I didn't notice on my Vista machine, because that has VS 2008 installed, in which case the for me installation works just fine. If anybody knows how to make the for me installation work (i.e. how to set up the manifests that a single copy of the CRT is used both by python26.dll, and all extension modules), please let me know. IOW: HELP! HELP!! HELP!!! Meanwhile: just say no to Vista. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6, GUI not working on vista?
I posted a problem with Vista on Jul 6 concerning not being able to run IDLE in 2.6b1. No replies. Where did you post that? On python-dev? What am I supposed to do? File bug reports on things I don't even know are bugs? You mean, it might have been intentional that IDLE won't run on Vista? Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6, GUI not working on vista?
* Martin v. Löwis (Thu, 09 Oct 2008 23:41:44 +0200) You can believe what you want. The people who developed UAC don't have to support it. I know for a fact that the implementation is incomplete. In Windows Installer, there is no way (that I know of) to create an MSI file that conditionally turns on UAC, only when the installation actually needs privilege elevation. You cannot turn on (or turn off) UAC for a single application or operation. That's the whole point of UAC. There is a static bit in the installer that indicates whether the MSI file will do UAC, and there is no way to toggle this bit, e.g. after asking the user whether this is a for me installation or for all users. I set this bit to no UAC for 2.6, in order to allow non-privileged installation at all - only to find out that (due to an unrelated problem), the for me installation doesn't actually work. I only found out after the release, because nobody bothered reporting this problem during the betas and release candidates. I didn't notice on my Vista machine, because that has VS 2008 installed, in which case the for me installation works just fine. Are you sure it worked with UAC enabled and a non-privileged account? Anyway, here are some links regarding UAC: * http://www.codeproject.com/KB/vista-security/MakingAppsUACAware.aspx * http://en.wikipedia.org/wiki/User_Account_Control#Requesting_elevation ...and for the background: * http://www.faq-o-matic.net/2008/02/22/benutzerkontensteuerung-uac- richtig-einsetzen/ Thorsten -- http://mail.python.org/mailman/listinfo/python-list
Re: Inefficient summing
On Oct 9, 3:53 pm, Alexander Schmolck [EMAIL PROTECTED] wrote: beginner [EMAIL PROTECTED] writes: Hi All, I have a list of records like below: rec=[{F1:1, F2:2}, {F1:3, F2:4} ] Now I want to write code to find out the ratio of the sums of the two fields. One thing I can do is: sum(r[F1] for r in rec)/sum(r[F2] for r in rec) But this is slow because I have to iterate through the list twice. Also, in the case where rec is an iterator, it does not work. how about: ratio = (lambda c: c.real/c.imag)(sum(complex(r[F1], r[F2] for r in rec))) ? :)- Hide quoted text - - Show quoted text - Neat, but I will have a problem if I am dealing with three fields, right? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6, GUI not working on vista?
On Oct 9, 5:48 pm, Martin v. Löwis [EMAIL PROTECTED] wrote: I posted a problem with Vista on Jul 6 concerning not being able to run IDLE in 2.6b1. No replies. Where did you post that? On python-dev? No, right here on comp.lang.python. I don't even know what you're referring to. What am I supposed to do? File bug reports on things I don't even know are bugs? You mean, it might have been intentional that IDLE won't run on Vista? No, as in maybe it's not a bug, maybe it's just me being stupid or there's something wrong with my setup (aside from using Vista in the first place over which I had no control). I'm not a developer, just a lowly end user. I'm not in a position to be able to fix anything. All I can do is report it and if it's legitimate, then hopefully someone who knows what he's doing will fix it. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
subdirectories for sys.path import?
I'm currently sharing a directory on sys.path with another group. We don't have the option to modify sys.path. In order to reduce conflicts between the two group's code, installation procedures, etc, I'd like to make a subdirectory for each group, and have each group manage their own subdirectory. /oursharedpath/lib/python/group1 /oursharedpath/lib/python/group2 Is there a way to import a module from one of these subdirectories? Any other more pythonic ways to approach the situation? Many TIA! Mark -- Mark Harrison Pixar Animation Studios -- http://mail.python.org/mailman/listinfo/python-list
Re: subdirectories for sys.path import?
[EMAIL PROTECTED] wrote: Is there a way to import a module from one of these subdirectories? Any other more pythonic ways to approach the situation? ah, the magic of __init__.py. Thanks all! -- Mark Harrison Pixar Animation Studios -- http://mail.python.org/mailman/listinfo/python-list
Re: On the indexing order in (numpy) arrays
Almar Klein wrote: Basically, we want a[i][j] == a[i,j]. Since there is no literal syntax for numpy arrays, we need to be able to convert from a sequence of sequences to an array. The indexing needs to correspond between the two. Thanks for the reply. I guess that explains the *why*... Adopt the numpy order. There are many functions in numpy which take an axis= argument just like this. axis=0 means y in the terminology that you are using. Yes, I agree its best to use the numpy order, and I agree one gets used to it. However, it will always feel a bit unnatural to reverse the order of dimensions (at least to me it does). And I think it can in some situations lead to confusion. I for instance have a class to store sets of points in a nD space. I can index the points, so using points[99,0] selects the *first* dimension of the 99th point. I use this class to store locations of interesting points in 2D and 3D images. But when programming, it can at times be quite confusing switching between reversed and normal indexing. And sometimes I might have a method that does stuff with an image and a point set and I want to indicate an axis. What standard should I use then? I'm not saying numpy should change the indexing order or something. But other people must run into the same confusing situation at times. How do they handle this? In the example above, I think it'll be weird to change the pointset class such that points[99,0] selects the *last* dimension of point 99. Or is it? shrug It's occasionally annoying, but in my experience, it's just not a big deal. And besides, images aren't always oriented the same way, so there's often some more coordinate conversion that needs to be done. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: Python HTML parser chokes on UTF-8 input
On Thu, Oct 9, 2008 at 4:54 PM, Johannes Bauer [EMAIL PROTECTED] wrote: Hello group, Now when I take website directly from the parser, everything is fine. However I want to do some modifications before I parse it, namely UTF-8 modifications in the style: website = website.replace(uföö, ubär) That's not utf-8, that's unicode. Even if your file is saved as utf-8, you're telling python to convert those from utf-8 encoded bytes to unicode characters, by prefixing them with 'u'. Therefore, after fetching the web site content, I have to convert it to UTF-8 first, modify it and convert it back: You have to convert it to unicode if and only if you are doing manipulation with unicode stings. website = website.decode(latin1) website = website.replace(uföö, ubär) website = website.encode(latin1) This is incredibly ugly IMHO, as I would really like the parser to just accept UTF-8 input. However when I omit the reecoding to latin1: You could just use the precise Latin-1 byte strings you'd like to replace: website = website.replace(f\xf6\xf6, b\xe4r) Or, you could set the encoding of your source file to Latin-1, by putting the following on the first or second line of your source file: # -*- coding: Latin-1 -*- Then use the appropriate literals in your source code, making sure that you save it as Latin-1 in your editor of choice. Truthfully, though, I think your current approach really is the right one. Decode to unicode character strings as soon as they come into your program, manipulate them as unicode, then select your preferred encoding when you write them back out. It's explicit, and only takes two lines of code. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6, GUI not working on vista?
as a 20 year observer of microsoft, I have to say this is not amazing at all... and I do not mean that as a random put down of Microsoft. Microsoft often develops things in response to demand... but they don't always fit in their system well, and thus are not really used in the spirit of the demand... meanwhile, bullet items are added to many a software box and magazine review. I would not presume to know more that Microsoft about that as a business practice, but as an engineering practice, it speaks for itself. -- http://mail.python.org/mailman/listinfo/python-list
Re: About print exception message
On Oct 9, 9:46 pm, Jean-Paul Calderone [EMAIL PROTECTED] wrote: On Thu, 9 Oct 2008 06:37:04 -0700 (PDT), WaterWalk [EMAIL PROTECTED] wrote: Until Python 2.5, the exception object still uses ansi string. Thus, in the following example: f = open(u\u6d4b.log) Suppose the file to open does not exist, the output message of the exception maybe like: [Errno 2] No such file or directory: u'\u6d4b.log' This is not a clear message. I disagree. But if you'd rather see the character (or a replacement character, or possibly an empty box, depending on your environment's text rendering capabilities), it's a bit easier than writing that big function: try: open(u'\N{WHITE SMILING FACE}') ... except IOError, e: print str(e).decode('unicode-escape') ... [Errno 2] No such file or directory: u'☺' Yes, this is a more concise solution. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Crunchy 1.0 alpha 1 released
Hi everyone, Crunchy version 1.0 alpha 1 has been released. Crunchy is an application that transforms normally static Python tutorial (html files, or reStructuredText ones - if docutils is installed on your computer) into interactive sessions within your browser (Firefox). It is available from http://code.google.com/p/crunchy/ This release includes: * Completely revamped user interface * Support for multiple simultaneous users, each being able to set their own preferences * Increased security on multi-users computer (as users now have to log in) * A number of interactive elements including Python interpreters, editors, doctest, unittest (new), integration with code quality analyzers such as pylint, pychecker and pyflakes (all new - you need to have any one of these installed on your computer). * Some experimental features such as an interface to pdb, the Python debugger, and an early prototype (incomplete) for having time-limited exams. * etc. Crunchy now makes use of Pygments to style the code. As a result, it is possible to embed (and style) code snippets in a large number of programming language. However, only Python code can be executed (for now...). Crunchy now also makes use of jQuery and various plugins. As usual, suggestions for improvements, bug reports and other comments are welcome. Cheers, André -- http://mail.python.org/mailman/listinfo/python-list
!!! ...YOU MUST KNOW THIS MAN
In The Name Of Allaah, Most Gracious, Most Merciful YOU MUST KNOW THIS MAN MUHAMMAD (May peace and blessings of God Almighty be upon him) You may be an atheist or an agnostic; or you may belong to anyone of the religious denominations that exist in the world today. You may be a Communist or a believer in democracy and freedom. No matter what you are, and no matter what your religious and political beliefs, personal and social habits happen to be - YOU MUST STILL KNOW THIS MAN! He was by far the most remarkable man that ever set foot on this earth. He preached a religion, founded a state, built a nation, laid down a moral code, initiated numberless social and political reforms, established a dynamic and powerful society to practice and represent his teachings, and completely revolutionized the worlds of human thought and action for all times to come. HIS NAME IS MUHAMMAD, peace and blessings of Almighty God be upon him and he accomplished all these wonders in the unbelievably short span of twenty-three years. Muhammad, peace and blessings of God Almighty be upon him was born in Arabia on the 20th of August, in the year 570 of the Christian era, and when he died after 63 years, the whole of the Arabian Peninsula had changed from paganism and idol-worship to the worship of One God; from tribal quarrels and wars to national solidarity and cohesion; from drunkenness and debauchery to sobriety and piety; from lawlessness and anarchy to disciplined living; from utter moral bankruptcy to the highest standards of moral excellence. Human history has never known such a complete transformation of a people or a place before or since! The Encyclopedia Britannica calls him the most successful of all religious personalities of the world. Bernard Shaw said about him that if Muhammad were alive today he would succeed in solving all those problems which threaten to destroy human civilization in our times. Thomas Carlysle was simply amazed as to how one man, single- handedly, could weld warring tribes and wandering Bedouins into a most powerful and civilized nation in less than two decades. Napoleon and Gandhi never tired of dreaming of a society along the lines established by this man in Arabia fourteen centuries ago. Indeed no other human being ever accomplished so much, in such diverse fields of human thought and behavior, in so limited a space of time, as did Muhammad, peace and blessings of God Almighty be upon him. He was a religious teacher, a social reformer, a moral guide, a political thinker, a military genius, an administrative colossus, a faithful friend, a wonderful companion, a devoted husband, a loving father - all in one. No other man in history ever excelled or equaled him in any of these difficult departments of life. The world has had its share of great personalities. But these were one sided figures who distinguished themselves in but one or two fields such as religious thought or military leadership. None of the other great leaders of the world ever combined in himself so many different qualities to such an amazing level of perfection as did Muhammad, peace and blessings of God Almighty be upon him. The lives and teachings of other great personalities of the world are shrouded in the mist of time. There is so much speculation about the time and the place of their birth, the mode and style of their life, the nature and detail of their teachings and the degree and measure of their success or failure that it is impossible for humanity today to reconstruct accurately and precisely the lives and teachings of those men. Not so this man Muhammad, peace and blessings of God Almighty be upon him. Not only was he born in the fullest blaze of recorded history, but every detail of his private and public life, of his actions and utterances, has been accurately documented and faithfully preserved to our day. The authenticity of the information so preserved is vouched for not only by faithful followers but also by unbiased critics and open-minded scholars. At the level of ideas there is no system of thought and belief-secular or religious, social or political-which could surpass or equal ISLAAM- the system which Muhammad peace and blessings of God Almighty be upon him propounded. In a fast changing world, while other systems have undergone profound transformations, Islaam alone has remained above all change and mutation, and retained its original form for the past 1400 years. What is more, the positive changes that are taking place in the world of human thought and behavior, truly and consistently reflect the healthy influence of Islam in these areas. Further, it is not given to the best of thinkers to put their ideas completely into practice, and to see the seeds of their labors grow and bear fruit, in their own lifetime. Except of course, Muhammad, peace and blessings of God Almighty be upon him, who not only preached the most wonderful ideas but also successfully translated each one of them into practice
Twelve Proofs that Muhammad is a True Prophet
My brothers and sisters everywhere! With this essay, I am not singling out the adherents of Islam - to which I ascribe - but rather I am writing this essay to every man and woman throughout the whole world. I ask Allah that He facilitates tat this essay reaches every ear, falls under the sight of every eye, and is understood by every heart... Muhammad the son of `Abdullah is Allah's Prophet and the Final Messenger Sent by Allah to the Inhabitants of Earth. My brothers and sisters everywhere! You should know that the Messenger, Muhammad the son of `Abdullah (may Allah's blessings and peace be upon him) is Allah's Messenger in reality and truth. The evidences that show his veracity are abundant. None but an infidel, who out of arrogance alone, could deny these signs. Among these proofs: 1. Muhammad (may Allah's blessings and peace be upon him) was raised illiterate, unable to read or write, and remained like that till his death. Among all his people, he was known as being truthful and trustworthy. Before receiving revelation, he had no prior knowledge of Religion or any previously sent Message. He remained like that for his first forty years. Revelation then came to Muhammad with the Koran that we now have between our hands. This Koran mentioned most of the accounts found in the previous scriptures, telling us about these events in the greatest detail as if he witnessed them. These accounts came precisely as they were found in the Torah sent down to Moses and in the Gospel sent down to Jesus. Neither the Jews or Christians were able to belie him regarding anything that he said. 2. Muhammad (may Allah's blessings and peace be upon him) also foretold of everything that would occur to him and his community after him, pertaining to victory, the removal of the tyrannical kingdoms of Chosroes [the royal title for the Zoroastrian kings of Persia] and Caesar, and the establishment of the religion of Islam throughout the earth. These events occurred exactly as Muhammad foretold, as if he was reading the future from an open book. 3. Muhammad (may Allah's blessings and peace be upon him) also brought an Arabic Koran that is the peak of eloquence and clarity. The Koran challenged those eloquent and fluent Arabs of his time, who initially belied him, to bring forth a single chapter like the Koran. The eloquent Arabs of his day were unable to contest this Koran. Indeed, till our day, none has ever dared to claim that he has been able to compose words that equal-or even approach-the order, grace, beauty, and splendor of this Glorious Koran. 4. The life history of this Noble Prophet was a perfect example of being upright, merciful, compassionate, truthful, brave, generous, distant from all evil character, and ascetic in all worldly matters, while striving solely for the reward of the Hereafter. Moreover, in all his actions and dealings, he was ever mindful and fearful of Allah. 5. Allah instilled great love for Muhammad (may Allah's blessings and peace be upon him) in the hearts of all who believed in and met him. This love reached such a degree that any of his companions would willingly sacrifice his (or her) self, mother or father for him. Till today, those who believe in Muhammad honor and love him. Anyone of those who believe in him would ransom his own family and wealth to see him, even if but once. 6. All of history has not preserved the biography of any person in the manner it has preserved the life of Muhammad, who is the most influential human in history. Nor has the entire earth known of anyone whom every morning and evening, and many times thereafter throughout the day, is thought of by those who believe in him. Upon remembering Muhammad, the believers in him will greet him and ask Allah to bless him. They do such with full hearts and true love for him. 7. Nor has there every been a man on earth whom is still followed in all his doings by those who believe in him. Those who believe in Muhammad, sleep in the manner he slept; purify themselves (through ablution and ritual washing) in the manner he purified himself; and adhere to his practice in the way they eat, drink, and clothe themselves. Indeed in all aspects of their lives, the believers in Muhammad adhere to the teachings he spread among them and the path that he traveled upon during his life. During every generation, from his day till our time, the believers in this Noble Prophet have fully adhered to his teachings. With some, this has reached the degree that they desire to follow and adhere to the Prophet's way in his personal matters regarding which Allah has not sought of them to adhere to in worship. For example, some will only eat those specific foods or only wear those specific garments that the Messenger liked. Let alone all that, all those who believe in Muhammad repeat those praises of Allah, special prayers, and invocations that he would say during each of his actions during day and night, like: what he would say when he greeted
Excuse me Would you stop for a moment?!
Excuse me!! Would you stop for a moment?! O...man...Haven't you thought-one day- about yourself ? Who has made it? Have you seen a design which hasn't a designer ?! Have you seen a wonderful,delicate work without a worker ?! It's you and the whole universe!.. Who has made them all ?!! You know who ?.. It's ALLAH,prise be to him. Just think for a moment. How are you going to be after death ?! Can you believe that this exact system of the universe and all of these great creation will end in in nothing...just after death! Have you thought, for a second, How to save your soul from Allah's punishment?! Haven't you thought about what is the right religion?! Read ... and think deeply before you answer.. It is religion of Islam. It is the religion that Mohammad-peace upon him- the last prophet, had been sent by. It is the religion that the right Bible- which is not distorted-has preached. Just have a look at The Bible of (Bernaba). Don't be emstional. Be rational and judge.. Just look..listen...compare..and then judge and say your word. We advise you visiting : http://www.islam-guide.com http://www.thetruereligion.org http://www.beconvinced.com http://www.plaintruth.org http://english.islamway.com http://www.todayislam.com http://www.prophetmuhammed.org http://www.islamtoday.net/english/ http://www.islamunveiled.org http://www.islamic-knowledge.com We willingly recive any inquries at the e-mail : [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Python HTML parser chokes on UTF-8 input
Johannes Bauer wrote: Terry Reedy schrieb: Johannes Bauer wrote: Hello group, I'm trying to use a htmllib.HTMLParser derivate class to parse a website which I fetched via httplib.HTTPConnection().request().getresponse().read(). Now the problem is: As soon as I pass the htmllib.HTMLParser UTF-8 code, it chokes. The code is something like this: I believe you are confusing unicode with unicode encoded into bytes with the UTF-8 encoding. Having a problem feeding a unicode string, not 'UFT-8 code', which in Python can only mean a UTF-8 encoded byte string. I also believe I am. Could you please elaborate further? I am a unicode neophyte. My source of info is the first 3 or so chapters of the unicode specification. http://www.unicode.org/versions/Unicode5.1.0/ I recommend that or other sites for other questions. It took me more than one reading of the same topics in different texts to pretty well 'get it' Do I understand correctly when saying that type 'str' has no associated default encoding, but type 'unicode' does? I am not sure what you mean. Unicode strings in Python are internally stored in USC-2 or UCS-4 format. Does this mean that really the only way of coping with that stuff is doing what I've been doing? Having two text types in 2.x was necessary as a transition strategy but has also been something of a mess. You did it one way. Jerry gave you an alternative that I could not have explained. Your choice. Or use 3.0. .. Hmmm. I suppose you're right there. Python 3.0 really sounds quite nice, do you know when will approximately be ready? For my current purposes, it is ready enough. Developers *really* hope to get 3.0 final out by mid-December. The schedule was pushed back because a) the outside world has not completely and cleanly switched to unicode text and b) some people who just started with the release candidate have found import bugs that earlier testers did not. It still needs more testing from more different users (hint, hint). Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
ANNOUNCE: new package posix_ipc 0.1 available
The package posix_ipc provides a Python interface to POSIX shared memory and named semaphores on platforms that support them (i.e. most Unices). Platform details, source code, sample code and usage instructions are provided at the link below. This package is GPLed. http://semanchuk.com/philip/posix_ipc/ Enjoy Philip -- http://mail.python.org/mailman/listinfo/python-list
epoll socket server
Does anyone have any simple examples of using Python 2.6/3.0's epoll with a simpler socket (tcp) server ? Thanks, cheers James -- -- -- Problems are solved by method -- http://mail.python.org/mailman/listinfo/python-list
!!!!...Hi Hi Hi
Hi My name is fatima I’ve seen many places of the world on TV screen and few that I’ve visited either for fun or/and business As you know when we travel we meet a lot of different cultures and people, I found in many places I’ve been to; that people stereotyped Islam (that's my religion) they prejudge Muslims from what they see in media incidents. Allow me to share with you here some information about Jesus Christ, Muslims believe in Jesus Christ (peace and blessings of (Allah = God) be upon Him as one of the mightiest messengers from (Allah=God), We believe he is born miraculously by the word of Allah without Father Like ADAM Been created without father nor mother, And Marry (mar yam) is his mother the pious, pure female may Allah be pleased with her, In fact there is a chapter in Quraan titled Marry Let me quote here these verses: “BEHOLD! THE ANGELS SAID: O MARY! GOD HATH CHOSEN THEE AND PURIFIED THEE – CHOSEN THEE ABOVE THE WOMEN OF ALL NATIONS ” And this Verse About Jesus: “HE SHALL SPEAK TO THE PEOPLE IN CHILDHOOD AND IN MATURITY, AND SHALL BE (OF THE COMPANY) OF THE RIGHTEOUS.” If this is a Quiz asking you where these Divine verses come from the Bible Torah or elsewhere? THE Answer for your information it is from Quraan 3:45,46 This shows how much we need to know about what others believe. You may visit this link below it’ll give you broad knowledge of Islam in Questions and Answers format , http://www.islam-qa.com Or http://www.islam-online.net/ Or http://www.al-islam.com/ Or http://www.al-sunnah.com/ Listen I am NOT Trying to convert YOU, but isn't it worth it for general Information to know about what other believes? And Allah granted you and me wisdom, brain, and heart to judge for ourselves? Needless to say if you have any comment, question, suggestion I'll be glad to share them with you. -- http://mail.python.org/mailman/listinfo/python-list
This can't get more amazing see for yourself! http://tardis-db.co.uk/
This can't get more amazing see for yourself! http://tardis-db.co.uk/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with cPickle and cElementTree
Barry wrote: I recently tried switching from ElementTree to cElementTree. My application parses a collection of large XML files and creates indexes based on certain attributes. This entire collection is saved as an instance of my Database class. Using ElementTree and cPickle has allowed me to save these instances and use them later. Using cElementTree significantly reduces parse time (~50%) and memory ~(15%) but cPickle refuses to pickle the database object. I receive: TypeError: expecting string or Unicode object, NoneType found The offending line of code simple shows my invocation of cPickle, which is not helpful. Doing exactly the same thing with ElementTree works fine. It appears that the objects returned by cElementTree do not pickle correctly. Is this a know issue? I was unable to find any reports of this problem. Pickling is (almost always) built-in for pure Python classes, but it needs to be implemented explicitly for C classes. cElementTree simply doesn't support this. If you need a fast and memory friendly XML engine *and* want to pickle elements, take a look at lxml.objectify. Note that it's only partially compatible with ElementTree, so you will have to change your code (lxml.etree is mostly compatible, but it doesn't support pickling). It's a very easy-to-use XML library, though. Stefan -- http://mail.python.org/mailman/listinfo/python-list
urlparse import Faillure
Python 2.5.2 (r252:60911, Aug 28 2008, 23:51:17) [GCC 4.3.0 20080428 (Red Hat 4.3.0-8)] on linux2 Type help, copyright, credits or license for more information. import CGIHTTPServer Traceback (most recent call last): File stdin, line 1, in module File /usr/local/lib/python2.5/CGIHTTPServer.py, line 28, in module import urllib File /usr/local/lib/python2.5/urllib.py, line 30, in module from urlparse import urljoin as basejoin File /usr/local/lib/python2.5/urlparse.py, line 3, in module See RFC 1808: Relative Uniform Resource Locators, by R. Fielding, ImportError: cannot import name urlparse urlparse.py Parse (absolute and relative) URLs. See RFC 1808: Relative Uniform Resource Locators, by R. Fielding, UC Irvine, June 1995. __all__ = [urlparse, urlunparse, urljoin, urldefrag, urlsplit, urlunsplit] It points to the third line of the comment. Any ideas on how to proceed with the debugging? -- http://mail.python.org/mailman/listinfo/python-list
[issue4071] ntpath.abspath fails for long str paths
Changes by Jason Day [EMAIL PROTECTED]: -- title: ntpath.abspath can fail on Win Server 2008 (64-bit) - ntpath.abspath fails for long str paths ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4071 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4083] try statement in language reference not updated for v2.6
New submission from Davi Post [EMAIL PROTECTED]: Language Reference for the try statement does not show changes for v2.6, specifically the PEP 3110: Exception-Handling Changes. At least, the grammar should include the except ... as syntax. http://docs.python.org/reference/compound_stmts.html#try http://docs.python.org/whatsnew/2.6.html#pep-3110-exception-handling- changes http://www.python.org/dev/peps/pep-3110/#compatibility -- assignee: georg.brandl components: Documentation messages: 74556 nosy: davipo, georg.brandl severity: normal status: open title: try statement in language reference not updated for v2.6 type: behavior versions: Python 2.6 ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4083 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4084] Decimal.max(NaN, x) gives incorrect results when x is finite and long
New submission from Mark Dickinson [EMAIL PROTECTED]: Here's a snippet from Python 2.6: from decimal import Decimal, getcontext getcontext().prec = 3 Decimal('NaN').max(Decimal('1234')) Decimal('sNaN234') The result here should be Decimal('1.23E+3')---the specification says that the result of comparing a quiet NaN with a finite value should be that finite value, rounded according to the context. This also affects min, max_mag and min_mag. The cause is that non-NaNs are incorrectly being passed to the _fix_nan method. The attached patch fixes this, and adds new testcases to extra.decTest to stop it happening again. It would be good to get this fix into 3.0, if possible. I think it should also be backported to 2.5.3. -- assignee: facundobatista files: decimal_maxbug.patch keywords: patch messages: 74557 nosy: facundobatista, marketdickinson priority: normal severity: normal status: open title: Decimal.max(NaN, x) gives incorrect results when x is finite and long type: behavior versions: Python 2.5.3, Python 2.6, Python 2.7, Python 3.0 Added file: http://bugs.python.org/file11753/decimal_maxbug.patch ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4084 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4085] 2.5.2 whatsnew document corrupts names, by having broken HTML, at least on the Web.
Georg Brandl [EMAIL PROTECTED] added the comment: Your analysis is correct -- the HTML is invalid. However, this problem doesn't occur in new documentation since we don't use the system used until 2.5 anymore. -- resolution: - wont fix status: open - closed ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4085 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3741] DISTUTILS_USE_SDK set causes msvc9compiler.py to raise an exception
Christian Boos [EMAIL PROTECTED] added the comment: Hit the same issue, which is actually only a typo, as self.__path is used nowhere. diff -r 4d10dcbd5f63 Lib/distutils/msvc9compiler.py --- a/Lib/distutils/msvc9compiler.pyThu Oct 09 11:19:40 2008 +0200 +++ b/Lib/distutils/msvc9compiler.pyThu Oct 09 12:01:27 2008 +0200 @@ -316,7 +316,7 @@ self.__version = VERSION self.__root = rSoftware\Microsoft\VisualStudio # self.__macros = MACROS -self.__path = [] +self.__paths = [] # target platform (.plat_name is consistent with 'bdist') self.plat_name = None self.__arch = None # deprecated name -- nosy: +cboos ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1905] PythonLauncher not working correctly on OS X 10.5/Leopad
The Lawnmower man [EMAIL PROTECTED] added the comment: Sorry, but I still have the same problem as Kevin Walzer and I can't understand the solution proposed by Ronald Oussoren. Where is the patch? How can I install it? What I am supposed to do? Thank you very much! -- nosy: +thelawnmowerman ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue1905 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4086] support %z format in time.strftime and _strptime?
New submission from Skip Montanaro [EMAIL PROTECTED]: While responding to a c.l.py question just now I discovered that numeric timezone offsets don't appear to be supported by either the time.strftime function or the _strptime module. I noticed on my Mac's strftime(3) man page that it supports a %Z format for TZ names and a %z format for numeric tz offsets. It seems Python should as well. -- messages: 74570 nosy: skip.montanaro priority: normal severity: normal status: open title: support %z format in time.strftime and _strptime? type: feature request versions: Python 2.6 ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4086 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4082] python2.6 -m site doesn't run site._script() any more
Christian Heimes [EMAIL PROTECTED] added the comment: I build the installation myself and used make altinstall, too. Even the latest checkout of the 2.6 branch fails to print the site information. $ ./configure ... $ make ... $ ./python -m site $ ./python -m platform Linux-2.6.24-19-generic-x86_64-with-debian-lenny-sid $ uname -a Linux hamiller 2.6.24-19-generic #1 SMP Wed Aug 20 17:53:40 UTC 2008 x86_64 GNU/Linux $ LC_ALL=C svn info . Path: . URL: svn+ssh://[EMAIL PROTECTED]/python/branches/release26-maint Repository Root: svn+ssh://[EMAIL PROTECTED] Repository UUID: 6015fed2-1504-0410-9fe1-9d1591cc4771 Revision: 66863 Node Kind: directory Schedule: normal Last Changed Author: georg.brandl Last Changed Rev: 66859 Last Changed Date: 2008-10-08 21:28:36 +0200 (Wed, 08 Oct 2008) ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4082 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4075] Use WCHAR variant of OutputDebugString
Ulrich Eckhardt [EMAIL PROTECTED] added the comment: Roumen, just and explanation on the TCHAR/WCHAR/CHAR issue under win32... In the old days, DOS/Windows was built with 8-bit characters using codepages. So functions like CreateFile() took a char string that used the current local codepage as encoding. Now, since NT 4 (maybe even 3) the internally used char type is a 16-bit type. In order to ease conversion, the function CreateFile() was removed (it still exists in oldnames.lib) and replaced with CreateFileW() and CreateFileA(), which explicitly take either a codepage-encoded 8-bit string or a UCS2/UTF-16 16-bit string. Under win9x, CreateFileW() actually tried to convert to the internally used 8-bit character type, while under NT, CreateFileA() converted from the codepage to the UTF-16 character type. Now, under CE, which is an embedded OS, neither the (legacy/obsolete/deprecated) codepages nor the according CreateFileA() functions exist. They simply have been removed to save space and because they are of limited functionality anyway. Which CE version? All of them, since at least CE3 (CE6 is current). Why not treat all strings as wide string? Because that would actually change the existing meaning of them and make it harder to impossible to create code that is portable. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4075 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4082] python2.6 -m site doesn't run site._script() any more
Nick Coghlan [EMAIL PROTECTED] added the comment: Platform? It works fine for me (system python is 2.5, local python is trunk - the tildes aren't actually in the printout, I subbed them in for my home directory): ~/devel/python$ python -m site sys.path = [ '~/devel/python', '/usr/lib/python25.zip', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/PIL', '/var/lib/python-support/python2.5', '/var/lib/python-support/python2.5/gtk-2.0', ] [EMAIL PROTECTED]:~/devel/python$ ./python -m site sys.path = [ '~/devel/python', '/usr/local/lib/python27.zip', '~/devel/python/Lib', '~/devel/python/Lib/plat-linux2', '~/devel/python/Lib/lib-tk', '~/devel/python/Lib/lib-old', '~/devel/python/Modules', '~/devel/python/build/lib.linux-i686-2.7', ] USER_BASE: '/home/ncoghlan/.local' (exists) USER_SITE: '/home/ncoghlan/.local/lib/python2.7/site-packages' (doesn't exist) ENABLE_USER_SITE: True ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4082 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4082] python2.6 -m site doesn't run site._script() any more
Nick Coghlan [EMAIL PROTECTED] added the comment: Platform? It works fine for me (system python is 2.5, local python is trunk - the tildes aren't actually in the printout, I subbed them in for my home directory): ~/devel/python$ python -m site sys.path = [ '~/devel/python', '/usr/lib/python25.zip', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/PIL', '/var/lib/python-support/python2.5', '/var/lib/python-support/python2.5/gtk-2.0', ] [EMAIL PROTECTED]:~/devel/python$ ./python -m site sys.path = [ '~/devel/python', '/usr/local/lib/python27.zip', '~/devel/python/Lib', '~/devel/python/Lib/plat-linux2', '~/devel/python/Lib/lib-tk', '~/devel/python/Lib/lib-old', '~/devel/python/Modules', '~/devel/python/build/lib.linux-i686-2.7', ] USER_BASE: '~/.local' (exists) USER_SITE: '~/.local/lib/python2.7/site-packages' (doesn't exist) ENABLE_USER_SITE: True ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4082 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4075] Use WCHAR variant of OutputDebugString
Roumen Petrov [EMAIL PROTECTED] added the comment: Which CE version ? Is the patch required for previous/next CE version ? If the CE can't work with char why the compiler don't threat strings as wide characters always ? -- nosy: +rpetrov ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4075 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4082] python2.6 -m site doesn't run site._script() any more
Changes by Nick Coghlan [EMAIL PROTECTED]: ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4082 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4082] python2.6 -m site doesn't run site._script() any more
Changes by Nick Coghlan [EMAIL PROTECTED]: ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4082 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4087] equality involving Decimals is not transitive; strange set behaviour results
New submission from Mark Dickinson [EMAIL PROTECTED]: The Decimal module breaks transitivity of equality: Decimal(2) == 2 and 2 == float(2), but Decimal(2) != float(2). The Python set and dict implementations rely on transitivity of equality for correct operation. These two facts together give some strange results when playing with sets and dicts involving Decimals and floats. For example (with Python 2.6): s = set([Decimal(2), float(2)]) t = set([2]) s | t == t | s False len(s | t) 2 len(t | s) 1 Other strange examples, and possible solutions, were discussed recently on comp.lang.python; see the thread starting at: http://mail.python.org/pipermail/python-list/2008-September/508859.html Possible solutions: (1) Document the problem, making it clear in the language reference that correct set operation relies on transitivity of equality, and adding a note to the decimal documentation indicating that mixing floats and Decimals in a container is asking for trouble. (2) Fix up Decimal so that equal numeric objects compare equal; this would also involve fixing the hash operation. To me, this goes against the philosophy of keeping the Decimal module close to the specification. (3) Terry Reedy suggested (in the c.l.python thread linked to above) a simpler version of (2): allow Decimal(i) == float(i) or Decimal(i) == Fraction(i) to return True for all integers i. (Decimal('0.5') == 0.5 would still return False.) This fixes transitivity, and has the advantage of not requiring any changes to the hash functions: hash(Decimal(i)) == hash(float(i)) is already true for all integers i. My own preference would be simply to document the problem; it doesn't seem like something that's going to affect that vast majority of Python users. Raymond, Facundo: any thoughts? -- messages: 74576 nosy: facundobatista, marketdickinson, rhettinger, tjreedy priority: normal severity: normal status: open title: equality involving Decimals is not transitive; strange set behaviour results type: behavior versions: Python 2.6, Python 2.7, Python 3.0 ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4087 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4075] Use WCHAR variant of OutputDebugString
Ulrich Eckhardt [EMAIL PROTECTED] added the comment: Actually, even _Py_NegativeRefcount() passes a statically sized buffer with 300 chars. Other than that, there is get_ref_type() which uses one with 350 chars, but AFAICT, that's the largest one. Attached accordingly modified patch. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4075 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3724] math.log(x, 10) gives different result than math.log10(x)
Mark Dickinson [EMAIL PROTECTED] added the comment: Mark, is some of the inaccuracy due to double rounding? No, I don't think so; at least, not in the sense of rounding the same value twice (with different precisions). I get similar results on my Core 2 Duo machine, which should be immune to x87 style problems (because Apple's gcc turns sse instructions on by default, I guess). It's just a result of three separate rounds: one for each log, and one for the result of the division. Could we make the two argument form more accurate by allowing the compiler to generate code that uses full internal precision, log(n)/log(d), instead of prematurely forcing the intermediate results to a PyFloat? Seems to me that would only work on older x86 hardware, unless we deliberately use long double in place of double for the intermediate results. Personally, I don't think it's worth the effort of fixing this: the result of log(x, 10) is accurate to within a few ulps anyway, which should be plenty good enough for any well-coded numerical work: any numerically aware programmer should be well aware that it's dangerous to rely on floating-point operations giving exact results. And in any case there's always log10. As a separate issue, it may be worth exposing C99's log2 function in some future version of Python. This, presumably, can be relied upon always to give exact results for powers of 2, which could be useful in some applications. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3724 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4082] python2.6 -m site doesn't run site._script() any more
Changes by Nick Coghlan [EMAIL PROTECTED]: ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4082 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4082] python2.6 -m site doesn't run site._script() any more
Nick Coghlan [EMAIL PROTECTED] added the comment: Hmm, that makes for absolutely identical base systems except that mine is i686 where yours is x86_64. What do you see if you stick some debugging messages at module level in site.py? (e.g. printing out __name__) (I'll be going offline shortly - I'll have another look tomorrow night, but since I can't reproduce this locally I'm probably not going to be much help in figuring out where it is losing the plot) ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4082 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4082] python2.6 -m site doesn't run site._script() any more
Christian Heimes [EMAIL PROTECTED] added the comment: I already added a print __name__ right before the if __name__ == __main__ block. Python 2.5, trunk and 3.0 print: site __main__ while Python 2.6 just prints: site Christian ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4082 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4076] Cannot build non-framework tkinter Python on Mac OS X.5
Dan OD [EMAIL PROTECTED] added the comment: Confusion - apologies - please remove this report. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4076 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3727] poplib module broken by str to unicode conversion
Giampaolo Rodola' [EMAIL PROTECTED] added the comment: As for issue #3911 this is another module for which an actual test suite would be very necessary. -- nosy: +giampaolo.rodola ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3727 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4082] python2.6 -m site doesn't run site._script() any more
Nick Coghlan [EMAIL PROTECTED] added the comment: I'm setting up a 2.6 working area now - we'll see what's to be seen once I have that up and running. None of the runpy or pkgutil stuff has been touched in months though (since PEP 366 was implemented), so I'm a little puzzled how it could be working on the trunk and not on the 2.6 maintenance branch. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4082 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4082] python2.6 -m site doesn't run site._script() any more
Nick Coghlan [EMAIL PROTECTED] added the comment: Platform? It works fine for me (system python is 2.5, local python is trunk - the tildes aren't actually in the printout, I subbed them in for my home directory): ~/devel/python$ python -m site sys.path = [ '~/devel/python', '/usr/lib/python25.zip', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/PIL', '/var/lib/python-support/python2.5', '/var/lib/python-support/python2.5/gtk-2.0', ] ~/devel/python$ ./python -m site sys.path = [ '~/devel/python', '/usr/local/lib/python27.zip', '~/devel/python/Lib', '~/devel/python/Lib/plat-linux2', '~/devel/python/Lib/lib-tk', '~/devel/python/Lib/lib-old', '~/devel/python/Modules', '~/devel/python/build/lib.linux-i686-2.7', ] USER_BASE: '~/.local' (exists) USER_SITE: '~/.local/lib/python2.7/site-packages' (doesn't exist) ENABLE_USER_SITE: True ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4082 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4082] python2.6 -m site doesn't run site._script() any more
Nick Coghlan [EMAIL PROTECTED] added the comment: No joy. 32-bit Ubuntu here, and ./python -m site works fine on the 2.6 branch, as does python2.6 -m site after a make altinstall. Is this an installation you built yourself, or was it packaged by someone else? ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4082 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4082] python2.6 -m site doesn't run site._script() any more
Christian Heimes [EMAIL PROTECTED] added the comment: It's an *installation* of Python 2.6.0 (r26:66714, Oct 2 2008) on Ubuntu Linux AMD64. The feature is broken on the release26-maint branch but it works fine on the trunk. -- versions: -Python 2.7 ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4082 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4082] python2.6 -m site doesn't run site._script() any more
Nick Coghlan [EMAIL PROTECTED] added the comment: Platform? It works fine for me (system python is 2.5, local python is trunk - the tildes aren't actually in the printout, I subbed them in for my home directory): ~/devel/python$ python -m site sys.path = [ '~/devel/python', '/usr/lib/python25.zip', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/PIL', '/var/lib/python-support/python2.5', '/var/lib/python-support/python2.5/gtk-2.0', ] ~/devel/python$ ./python -m site sys.path = [ '~/devel/python', '/usr/local/lib/python27.zip', '~/devel/python/Lib', '~/devel/python/Lib/plat-linux2', '~/devel/python/Lib/lib-tk', '~/devel/python/Lib/lib-old', '~/devel/python/Modules', '~/devel/python/build/lib.linux-i686-2.7', ] USER_BASE: '/home/ncoghlan/.local' (exists) USER_SITE: '/home/ncoghlan/.local/lib/python2.7/site-packages' (doesn't exist) ENABLE_USER_SITE: True ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4082 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4012] Minor errors in multiprocessing docs
David Ripton [EMAIL PROTECTED] added the comment: Also, two of the example code blurbs in that page still refer to the module as processing instead of multiprocessing. (Search for import processing to find them.) -- nosy: +dripton ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4012 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4085] 2.5.2 whatsnew document corrupts names, by having broken HTML, at least on the Web.
New submission from David Jones [EMAIL PROTECTED]: Consider the web page: http://www.python.org/doc/2.5.2/whatsnew/acks.html (the problem appears throughout the whatsnew document, but that page happens to be short and have more than one instance). On my browser, Safari 3.1.2 on Intel OS X 10.4.11, Martin von Löwis has his name corrupted, as does Lars Gustäbel. The problem seems to be because whilst the page is encoded in utf-8 the web server does not transmit a Content-Type header that specifies utf-8: $ curl -I http://www.python.org/doc/2.5.2/whatsnew/acks.html HTTP/1.1 200 OK Date: Thu, 09 Oct 2008 08:51:22 GMT Server: Apache/2.2.3 (Debian) DAV/2 SVN/1.4.2 mod_ssl/2.2.3 OpenSSL/0.9.8c mod_wsgi/2.0 Python/2.4.4 Last-Modified: Fri, 22 Feb 2008 12:58:18 GMT ETag: 12c008-1336-c6b00e80 Accept-Ranges: bytes Content-Length: 4918 Content-Type: text/html Shouldn't that be Content-Type: text/html; charset=UTF-8? Yeah, probably. Shouldn't the browser be using the meta tag in the HTML file itself? Probably, but your broken HTML is preventing Safari from parsing the meta tag correctly. Specifically: $ curl http://www.python.org/doc/2.5.2/whatsnew/acks.html | grep rel=.first. link rel=first href=whatsnew25.html title='What's new in python 2.5' / The title attribute of that link element is incorrect. It features a single-quote inside a single-quoted string. Oopsie. I don't think Safari should be so mean, but bad HTML is bad HTML. Taking a local copy and fixing that title attribute (by using double quotes for example) causes the page to render just fine. -- assignee: georg.brandl components: Documentation messages: 74560 nosy: drj, georg.brandl severity: normal status: open title: 2.5.2 whatsnew document corrupts names, by having broken HTML, at least on the Web. type: behavior versions: Python 2.5 ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4085 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4088] Patch to implement a real poplib test suite
New submission from Giampaolo Rodola' [EMAIL PROTECTED]: poplib module is currently lacking a test suite which actually connects to a server and uses the POP3 class methods and facilities. Bug #3727, discovered just a bunch of days before the stable release of Python 3.0 is an example of how much a test suite is necessary. As done in #3939 for the ftplib module, in attachment I provide a test suite which implements an asyncore-based dummy POP3 server which sends fixed response codes that I used to test all the relevant POP3 class methods. Tests for the POP3_SSL class are also included. Although not that useful (IMHO) I didn't remove the old tests about timeouts. Tested successfully against Python 2.6 on Windows XP SP3, Debian Etch and FreeBSD 7.0. -- components: Tests files: test_poplib.patch keywords: patch messages: 74581 nosy: benjamin.peterson, facundobatista, giampaolo.rodola, gvanrossum severity: normal status: open title: Patch to implement a real poplib test suite versions: Python 2.7, Python 3.0, Python 3.1 Added file: http://bugs.python.org/file11754/test_poplib.patch ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4088 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4089] linking python2.6.dll crash on windows xp
New submission from Manuel [EMAIL PROTECTED]: On some machines, the application (makehuman, an open source software) crash, immediately, as soon the user try to double click on the exe. The problem happen with the version compiled using python 2.6, while the one compiled with 2.5 work fine. We have asked to our users to try the installation of Visual C++ 2005 Redistributable Package, but this hasn't fixed the crash. Both binary files (compiled using gcc and debug symbols with 2.5 and with 2.6) are here: http://www.makehuman.org/tmp/makehuman_test_python25_and_python26.zip Furthermore: Installing full python2.6 it work. Unistalling full python2.6 it don't work. Installing python26 and deleting C:/python26 folder (without unistall it), it work again... thx, Manuel -- components: Windows messages: 74582 nosy: Manuel severity: normal status: open title: linking python2.6.dll crash on windows xp type: crash versions: Python 2.6 ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4089 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4089] linking python2.6.dll crash on windows xp
Manuel [EMAIL PROTECTED] added the comment: gdb output from one of our users: warning: LDR: LdrpWalkImportDescriptor() failed to probe python26.dll for its manifest, ntstatus 0xc0150002 Program received signal SIGSEGV, Segmentation fault. Program received signal SIGSEGV, Segmentation fault. Program received signal SIGSEGV, Segmentation fault. Program exited with code 0305. You can't do that without a process to debug. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4089 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4089] linking python2.6.dll crash on windows xp
Changes by Giampaolo Rodola' [EMAIL PROTECTED]: -- nosy: +giampaolo.rodola ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4089 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3724] math.log(x, 10) gives different result than math.log10(x)
Raymond Hettinger [EMAIL PROTECTED] added the comment: +1 on a log2 function, especially one that has been generalized to work with long integers. It would help with the numbits problem that comes-up all the time. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3724 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4090] Documenting set comparisons and operations
New submission from Terry J. Reedy [EMAIL PROTECTED]: RefMan Expressions Comparisons has a subsection headed Comparison of objects of the same type depends on the type with entries for numbers, bytes, strings, tuples, lists, mappings, and most_other (compared by id). Sets (and dict views) are missing. While sets are similar to dicts, they are different because they also have order comparisons. A problem in defining comparisons for sets is that the usual definitions depend on equality comparisons of the members involved being, as usual, reflexive, symmetric, and transitive. But float('nan') is irreflexive. For integral value i, int(i), float(i) or Fraction(i), and Decimal(i) are (currently) jointly intransitive. See http://bugs.python.org/issue4087 Even without these issues, users are free to write __eq__ methods however they want. So I suggest something like the following: If equality among the set members involved is reflexive, symmetric, and transitive as defined in mathematics, set comparisons have the usual definitions in terms of set inclusion. Otherwise, they are undefined. If dict equality had been defined in terms of equality of the set of (key,value) pairs, it would have the same problem. The algorithmic definition in terms of ordered lists works fine, however. I also suggest a warning be added at the top of the set section in the Lib. Ref. Something like: The usual definitions of set operations, given below, depend on equality testing between the members involved being reflexive, symmetric, and transitive. If this is not true, results are undefined. -- assignee: georg.brandl components: Documentation messages: 74585 nosy: georg.brandl, tjreedy severity: normal status: open title: Documenting set comparisons and operations versions: Python 2.6, Python 2.7, Python 3.0 ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4090 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4087] equality involving Decimals is not transitive; strange set behaviour results
Terry J. Reedy [EMAIL PROTECTED] added the comment: There are two issues involved: 1. documenting set behavior 2. what to do, if anything, about Decimals and other numbers Since users are free to create similar problems, and since sets are missing from the Reference section on comparisons, I opened a separate set documentation issue http://bugs.python.org/issue4090 leaving this as a Decimal-other_number equality issue. The root of the problem is that all members of s are members of t and vice versa. This should make s and t equal, but they are not. This also breaks the definitions of issubset (=), issuperset (=), union (|), and symmetric_difference (^) as shown in the c.l.p thread. Transitivity is also fundamental in logic and the rule of substitution. So I strongly prefer that it be preserved in Python as released. Another way to restore transitivity is (4) make Decimal(1) != int(1) just as Decimal(1) != float(1). Having a Decimal be equal in value to just one of two things that are equal in value is incoherent, and leads to incoherent results. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4087 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4087] equality involving Decimals is not transitive; strange set behaviour results
Facundo Batista [EMAIL PROTECTED] added the comment: (Ok, remember that I'm not a numeric guy before start hitting me, :p ) I think that if we have Decimal(1)==1, and 1==1.0, to have Decimal(1)==1.0. We always rejected comparison with unsupported types, but having this situation, I'd propose to put something like the following at the beggining of __eq__() and similars: def __eq__(self, other): if isinstance(other, float) and int(other)==other: other = int(other) What do you think? ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4087 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com