ANN: A new version (0.2.9) of the Python module which wraps GnuPG has been released.
A new version of the Python module which wraps GnuPG has been released. What Changed? = This is a minor bug-fix release. See the project website ( http://code.google.com/p/python-gnupg/ ) for more information. Summary: Better support for status messages from GnuPG. A random data file used in testing is no longer shipped with the source distribution, but created by the test suite if needed. The current version passes all tests on Windows (CPython 2.4, 2.5, 2.6, 3.1, 2.7 and Jython 2.5.1) and Ubuntu (CPython 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2). On Windows, GnuPG 1.4.11 has been used for the tests. What Does It Do? The gnupg module allows Python programs to make use of the functionality provided by the Gnu Privacy Guard (abbreviated GPG or GnuPG). Using this module, Python programs can encrypt and decrypt data, digitally sign documents and verify digital signatures, manage (generate, list and delete) encryption keys, using proven Public Key Infrastructure (PKI) encryption technology based on OpenPGP. This module is expected to be used with Python versions = 2.4, as it makes use of the subprocess module which appeared in that version of Python. This module is a newer version derived from earlier work by Andrew Kuchling, Richard Jones and Steve Traugott. A test suite using unittest is included with the source distribution. Simple usage: import gnupg gpg = gnupg.GPG(gnupghome='/path/to/keyring/directory') gpg.list_keys() [{ ... 'fingerprint': 'F819EE7705497D73E3CCEE65197D5DAC68F1AAB2', 'keyid': '197D5DAC68F1AAB2', 'length': '1024', 'type': 'pub', 'uids': ['', 'Gary Gross (A test user) gary.gr...@gamma.com']}, { ... 'fingerprint': '37F24DD4B918CC264D4F31D60C5FEFA7A921FC4A', 'keyid': '0C5FEFA7A921FC4A', 'length': '1024', ... 'uids': ['', 'Danny Davis (A test user) danny.da...@delta.com']}] encrypted = gpg.encrypt(Hello, world!, ['0C5FEFA7A921FC4A']) str(encrypted) '-BEGIN PGP MESSAGE-\nVersion: GnuPG v1.4.9 (GNU/Linux)\n \nhQIOA/6NHMDTXUwcEAf ... -END PGP MESSAGE-\n' decrypted = gpg.decrypt(str(encrypted), passphrase='secret') str(decrypted) 'Hello, world!' signed = gpg.sign(Goodbye, world!, passphrase='secret') verified = gpg.verify(str(signed)) print Verified if verified else Not verified 'Verified' For more information, visit http://code.google.com/p/python-gnupg/ - as always, your feedback is most welcome (especially bug reports, patches and suggestions for improvement). Enjoy! Cheers Vinay Sajip Red Dove Consultants Ltd. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: tabs/spaces
Am 29.03.2012 17:25, schrieb Terry Reedy: I am using Thunderbird, win64, as news client for gmane. The post looked fine as originally received. The indents only disappeared when I hit reply and the s were added. I can confirm this misbehaviour of Thunderbird (version 11.0 here), it strips the leading spaces when you begin a reply. Uli -- http://mail.python.org/mailman/listinfo/python-list
Re: Python is readable
On Fri, 30 Mar 2012 00:38:26 -0400, Nathan Rice wrote: He did no such thing. I challenge you to find me one place where Joel has *ever* claimed that the very notion of abstraction is meaningless or without use. [snip quote] To me, this directly indicates he views higher order abstractions skeptically, Yes he does, and so we all should, but that's not the claim you made. You stated that he fired the broadsides at the very notion of abstraction. He did no such thing. He fired a broadside at (1) software hype based on (2) hyper-abstractions which either don't solve any problems that people care about, or don't solve them any better than more concrete solutions. Mathematics is all about abstraction. There are theories and structures in mathematics that have probably gone over a hundred years before being applied. As an analogy, just because a spear isn't useful while farming doesn't mean it won't save your life when you venture into the woods and come upon a bear. A spear is a concrete application of the principle of leverage, not an abstraction. I also point out leverage was discovered experimentally long before anyone had an abstraction for it. In any case, so what? Who is saying that mathematics is useless? Not me, and not Joel Spolksy. You are hunting strawmen with your non-abstract spear. Spolsky has written at least three times about Architecture Astronauts, and made it abundantly clear that the problem with them is that they don't solve problems, they invent overarching abstractions that don't do anything useful or important, and hype them everywhere. http://www.joelonsoftware.com/articles/fog18.html http://www.joelonsoftware.com/items/2005/10/21.html http://www.joelonsoftware.com/items/2008/05/01.html Jeff Attwood provides a simple test for the difference between a useful abstraction and an Architecture Astronaut hyper-abstraction: Does it solve a useful problem? http://www.codinghorror.com/blog/2004/12/it-came-from-planet-architecture.html You keep reading this as an assault on abstract mathematics, science and knowledge for its on sake. It isn't any of these things. If I'm paid to solve a problem, and instead I build an abstraction that doesn't help solve the problem, then I'm guilty of doing architecture astronauting. and assumes because he does not see meaning in them, they don't hold any meaning. You are making assumptions about his mindset that not only aren't justified by his comments, but are *contradicted* by his comments. He repeatedly describes the people coming up with these hyper-abstractions as great thinkers, clever thinkers, etc. who are seeing patterns in what people do. He's not saying that they're dummies. He's saying that they're seeing patterns that don't mean anything, not that the patterns aren't there. He is basically saying they are too clever for their own good, as a result of being fixated upon purely intellectual constructs. Yes, and he is right to do so, because that is the characteristic of the Architecture Astronaut: being so fixated on over-arching abstract concepts that, far from those abstractions making it easier to solve the problems they are being paid to solve, they actually make them harder. Good abstractions enable problems to be solved. Bad abstractions don't. If I ask you to build me a website, I probably don't want a website- builder, I certainly don't want a website-builder-generator, and I absolutely do not want you to generalise the concept of a compiler and create a whole new abstract language for describing meta-compilers so that I can create a brand new programming language for generating meta- compilers that build compilers that will build factories for building website generators so I can make my own website in just three easy steps (the simplest one of which is about twice as difficult as just building the website would have been). If you are being paid to build abstractions in the ivory tower, on the chance that one in a thousand abstractions turns out to be a game changer, or just because of a love of pure knowledge, that's great. I love abstract mathematics too. I read maths in my free time, you won't find me saying that it is bad or useless or harmful. But does it solve real problems? Well, of course it does, and often in a most surprising places. But that's because out of the hundred thousand abstractions, we see the hundred that actually solve concrete problems. The other 99,999 exist only in forgotten journals, or perhaps the odd book here or there. This is all well and good. It's not meant as an attack on mathematics. You can't tell ahead of time which abstractions will solve real problems. *Somebody* has to be thinking about ways that spherical camels can pass through the eye of a 17-dimensional needle, because you never know when somebody else will say, Hey, that's just what we need to make low-fat chocolate ice cream that doesn't taste like
Pipelining in Python
I decided to withdraw my proposal for streaming programming :) and to fall back to something more conventional. Here's the full story: http://mtomassoli.wordpress.com/2012/03/29/pipelining-in-python/ The new operators are '' which does the pipelining and '-' which links functions Pipelining is function application in reverse order and linking is function composition in reverse order. Therefore, arg f means f(arg) and arg f - g means g(f(arg)) Let's look at some examples: --- 1) range(0,50) filter(lambda i : i%2) map(lambda i : i*i) my_print (Yes, that's currying.) 2) compFunc = filter(lambda i : i%2) - map(lambda i : i*i) range(0,50) compFunc my_print 3) (Sieve of Eratosthenes) # Tells whether x is not a proper multiple of n. notPropMult = cur(lambda n, x : x = n or x % n, 2) def findPrimes(upTo): if (upTo = 5): return [2, 3, 5] filterAll = (findPrimes(floor(sqrt(upTo))) map(lambda x : filter(notPropMult(x))) reduce(lambda f, g : f - g)) return list(range(2, upTo + 1)) filterAll findPrimes(1000) my_print 4) (Finds the approximate number of hrefs in a web page) def do(proc, arg): proc() return arg do = cur(do) cprint = cur(print) (http://python.org; do(cprint(The page http://python.org has about... , end = '')) do(sys.stdout.flush) urlopen cur(lambda x : x.read()) findall(bhref=\) cur(len) cur({} hrefs..format) cprint) --- And here's the complete source code (which includes a class version of /cur/ and the old tests/examples): --- class CurriedFunc: def __init__(self, func, args = (), kwArgs = {}, unique = True, minArgs = None): self.__func = func self.__myArgs = args self.__myKwArgs = kwArgs self.__unique = unique self.__minArgs = minArgs def __call__(self, *args, **kwArgs): if args or kwArgs: # some more args! # Allocates data to assign to the next CurriedFunc. newArgs = self.__myArgs + args newKwArgs = dict.copy(self.__myKwArgs) # If unique is True, we don't want repeated keyword arguments. if self.__unique and not kwArgs.keys().isdisjoint(newKwArgs): raise ValueError(Repeated kw arg while unique = True) # Adds/updates keyword arguments. newKwArgs.update(kwArgs) # Checks whether it's time to evaluate func. if self.__minArgs is not None and self.__minArgs = len(newArgs) + len(newKwArgs): return self.__func(*newArgs, **newKwArgs) # time to evaluate func else: return CurriedFunc(self.__func, newArgs, newKwArgs, self.__unique, self.__minArgs) else: # the evaluation was forced return self.__func(*self.__myArgs, **self.__myKwArgs) def __rrshift__(self, arg): return self.__func(*(self.__myArgs + (arg,)), **self.__myKwArgs) # forces evaluation def __sub__(self, other): if not isinstance(other, CurriedFunc): raise TypeError(Cannot compose a CurriedFunc with another type) def compFunc(*args, **kwArgs): return other.__func(*(other.__myArgs + (self.__func(*args, **kwArgs),)), **other.__myKwArgs) return CurriedFunc(compFunc, self.__myArgs, self.__myKwArgs, self.__unique, self.__minArgs) def cur(f, minArgs = None): return CurriedFunc(f, (), {}, True, minArgs) def curr(f, minArgs = None): return CurriedFunc(f, (), {}, False, minArgs) # Simple Function. def func(a, b, c, d, e, f, g = 100): print(a, b, c, d, e, f, g) # NOTE: '' means this line prints to the screen. # Example 1. f = cur(func) # f is a curried version of func c1 = f(1) c2 = c1(2, d = 4) # Note that c is still unbound c3 = c2(3)(f = 6)(e = 5)# now c = 3 c3()# () forces the evaluation # it prints 1 2 3 4 5 6 100 c4 = c2(30)(f = 60)(e = 50) # now c = 30 c4()# () forces the evaluation # it prints 1 2 30 4 50 60 100 print(\n--\n) # Example 2. f = curr(func) # f is a curried version of func # curr = cur with possibly repeated # keyword args c1 = f(1, 2)(3, 4) c2 = c1(e = 5)(f = 6)(e = 10)() # ops... we repeated 'e' because we # changed our mind about it! # again, () forces the evaluation # it prints 1 2 3 4 10 6 100 print(\n--\n) # Example 3. f = cur(func, 6)# forces the evaluation after 6 arguments c1 = f(1, 2, 3) # num args = 3 c2 = c1(4, f = 6) # num args = 5
Re: errors building python 2.7.3
On 29.03.2012 21:29, David Robinow wrote: Have you included the patch to Include/py_curses.h ? If you don't know what that is, download the cygwin src package for Python-2.6 and look at the patches. Not all of them are still Thanks for the hint. With cygwin's 2.6.5-ncurses-abi6.patch it works with both ncurses and ncursesw. -- Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: tabs/spaces
On 03/30/2012 03:05 AM, Ulrich Eckhardt wrote: Am 29.03.2012 17:25, schrieb Terry Reedy: I am using Thunderbird, win64, as news client for gmane. The post looked fine as originally received. The indents only disappeared when I hit reply and the s were added. I can confirm this misbehaviour of Thunderbird (version 11.0 here), it strips the leading spaces when you begin a reply. Uli But since it doesn't do it on all messages, have you also confirmed that it does it for a text message? My experience seems to be that only the html messages are messed up that way. of course, it could be lots of other things, like which gateways did the message go through, was it originally sent via the google-mars bridge, etc. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Python is readable
Mathematics is all about abstraction. There are theories and structures in mathematics that have probably gone over a hundred years before being applied. As an analogy, just because a spear isn't useful while farming doesn't mean it won't save your life when you venture into the woods and come upon a bear. A spear is a concrete application of the principle of leverage, not an abstraction. I also point out leverage was discovered experimentally long before anyone had an abstraction for it. And an analogy is a device to demonstrate the fundamental character of an argument in a different context. In any case, so what? Who is saying that mathematics is useless? Not me, and not Joel Spolksy. You are hunting strawmen with your non-abstract spear. I don't think it is a strawman. He decries things that aren't immediately useful. That describes almost all pure math. If he had excluded things that have some characteristic of truth, and just talked about overly general systems, I might agree with him. Spolsky has written at least three times about Architecture Astronauts, and made it abundantly clear that the problem with them is that they don't solve problems, they invent overarching abstractions that don't do anything useful or important, and hype them everywhere. I believe in the idea of things should be as simple as possible, but not simpler. Programming as it currently exists is absolutely convoluted. I am called on to help people learn to program from time to time, and I can tell you that we still have a LONG way to go before programming approaches a global optimum in either the semantic or syntactic space. Never mind configuring a build or anything else related to projects. The whole setup really is horrible, and I'm convinced that most of the people who are capable of changing this are more concerned about their personal investment in the way things are than helping others. There are a few exceptions like Alan Kay, but mostly people want to graft shortcuts on to what already exists. You keep reading this as an assault on abstract mathematics, science and knowledge for its on sake. It isn't any of these things. I never said it was an attack on science. Scientists don't really do abstraction, they explain observations. Mathematicians are the ones who discover truth that may be completely disconnected from reality. If I'm paid to solve a problem, and instead I build an abstraction that doesn't help solve the problem, then I'm guilty of doing architecture astronauting. If I ignore everything Joel wrote and just use that definition, I agree with you. He is basically saying they are too clever for their own good, as a result of being fixated upon purely intellectual constructs. Yes, and he is right to do so, because that is the characteristic of the Architecture Astronaut: being so fixated on over-arching abstract concepts that, far from those abstractions making it easier to solve the problems they are being paid to solve, they actually make them harder. Good abstractions enable problems to be solved. Bad abstractions don't. If I ask you to build me a website, I probably don't want a website- builder, I certainly don't want a website-builder-generator, and I absolutely do not want you to generalise the concept of a compiler and create a whole new abstract language for describing meta-compilers so that I can create a brand new programming language for generating meta- compilers that build compilers that will build factories for building website generators so I can make my own website in just three easy steps (the simplest one of which is about twice as difficult as just building the website would have been). Again, I follow the principle of everything should be as simple as possible, but no simpler. I have in the past built website builders rather than build websites (and done a similar thing in other cases), but not because I am trying to discover some fundamental truth of website building, because that would be bullshit. I did it because building websites (or whatever else it was) is a boring, tedious problem, and a website builder, while being more work, is an engaging problem that requires thought. I enjoy challenging myself. If you are being paid to build abstractions in the ivory tower, on the chance that one in a thousand abstractions turns out to be a game changer, or just because of a love of pure knowledge, that's great. I love abstract mathematics too. I read maths in my free time, you won't find me saying that it is bad or useless or harmful. But does it solve real problems? You forget that even abstractions that never directly get turned into something real are almost invariably part of the intellectual discourse that leads to real things. Well, of course it does, and often in a most surprising places. But that's because out of the hundred thousand abstractions, we see the hundred that actually solve concrete problems. The
ANN: A new version (0.2.9) of the Python module which wraps GnuPG has been released.
A new version of the Python module which wraps GnuPG has been released. What Changed? = This is a minor bug-fix release. See the project website ( http://code.google.com/p/python-gnupg/ ) for more information. Summary: Better support for status messages from GnuPG. A random data file used in testing is no longer shipped with the source distribution, but created by the test suite if needed. The current version passes all tests on Windows (CPython 2.4, 2.5, 2.6, 3.1, 2.7 and Jython 2.5.1) and Ubuntu (CPython 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2). On Windows, GnuPG 1.4.11 has been used for the tests. What Does It Do? The gnupg module allows Python programs to make use of the functionality provided by the Gnu Privacy Guard (abbreviated GPG or GnuPG). Using this module, Python programs can encrypt and decrypt data, digitally sign documents and verify digital signatures, manage (generate, list and delete) encryption keys, using proven Public Key Infrastructure (PKI) encryption technology based on OpenPGP. This module is expected to be used with Python versions = 2.4, as it makes use of the subprocess module which appeared in that version of Python. This module is a newer version derived from earlier work by Andrew Kuchling, Richard Jones and Steve Traugott. A test suite using unittest is included with the source distribution. Simple usage: import gnupg gpg = gnupg.GPG(gnupghome='/path/to/keyring/directory') gpg.list_keys() [{ ... 'fingerprint': 'F819EE7705497D73E3CCEE65197D5DAC68F1AAB2', 'keyid': '197D5DAC68F1AAB2', 'length': '1024', 'type': 'pub', 'uids': ['', 'Gary Gross (A test user) gary.gr...@gamma.com']}, { ... 'fingerprint': '37F24DD4B918CC264D4F31D60C5FEFA7A921FC4A', 'keyid': '0C5FEFA7A921FC4A', 'length': '1024', ... 'uids': ['', 'Danny Davis (A test user) danny.da...@delta.com']}] encrypted = gpg.encrypt(Hello, world!, ['0C5FEFA7A921FC4A']) str(encrypted) '-BEGIN PGP MESSAGE-\nVersion: GnuPG v1.4.9 (GNU/Linux)\n \nhQIOA/6NHMDTXUwcEAf ... -END PGP MESSAGE-\n' decrypted = gpg.decrypt(str(encrypted), passphrase='secret') str(decrypted) 'Hello, world!' signed = gpg.sign(Goodbye, world!, passphrase='secret') verified = gpg.verify(str(signed)) print Verified if verified else Not verified 'Verified' For more information, visit http://code.google.com/p/python-gnupg/ - as always, your feedback is most welcome (especially bug reports, patches and suggestions for improvement). Enjoy! Cheers Vinay Sajip Red Dove Consultants Ltd. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python is readable
On Sat, Mar 31, 2012 at 12:46 AM, Nathan Rice nathan.alexander.r...@gmail.com wrote: I believe in the idea of things should be as simple as possible, but not simpler. Programming as it currently exists is absolutely convoluted. I am called on to help people learn to program from time to time, and I can tell you that we still have a LONG way to go before programming approaches a global optimum in either the semantic or syntactic space. Aside from messes of installing and setting up language interpreters/compilers, which are averted by simply having several pre-installed (I think my Linux boxes come with some Python 2 version, Perl, bash, and a few others), that isn't really the case. Starting a Python script is easy. Programming gets convoluted only when, and to the extent that, the task does. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
RE: Python is readable
My aunt makes the best damn lasagna you've ever tasted without any overarching abstract theory of human taste. And if you think that quantum mechanics is more difficult than understanding human perceptions of taste, you are badly mistaken. Taste is subjective, and your aunt probably started from a good recipe and tweaked it for local palates. That recipe could easily be over a hundred years old. An overarching mathematical theory of human taste/mouth perception, if such a silly thing were to exist, would be able to generate new recipes that were perfect for a given person's tastes very quickly. Additionally, just to troll this point some more (fun times!), I would argue that there is an implicit theory of human taste (chefs refer to it indirectly as gastronomy) that is very poorly organized and lacks any sort of scientific rigor. Nonetheless, enough empirical observations about pairings of flavors, aromas and textures have been made to guide the creation of new recipes. Gastronomy doesn't need to be organized or rigorous because fundamentally it isn't very important. I cannot live without eating, I can live just fine without math. Your opinion that gastronomy is fundamentally unimportant is fundamentally flawed. In any case, Spolsky is not making a general attack on abstract science. Your hyperbole is completely unjustified. The mathematics of the 20th century, (from the early 30s onward) tend to get VERY abstract, in just the way Joel decries. Category theory, model theory, modern algebraic geometry, topos theory, algebraic graph theory, abstract algebras and topological complexes are all very difficult to understand because they seem so incredibly abstract, yet most of them already have important applications. I'm 100% positive if you just presented Joel with seminal papers in some of those areas, he would apply the astronaut rubber stamp, because the material is challenging, and he wouldn't get it (I love math, and I've had to read some papers 10+ times before they click). I do not think that you can compare abstract vs real world. Joel talks in the context of solving real-world problems for a living and producing tangible results to justify employment. It is only fair to talk about mathematics in the same context. Or vice-versa. Joining-the-trolling-bandwagon, Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
Re: convert string to bytes without changing data (encoding)
Steven D'Aprano wrote: On Thu, 29 Mar 2012 17:36:34 +, Prasad, Ramit wrote: Technically, ASCII goes up to 256 but they are not A-z letters. Technically, ASCII is 7-bit, so it goes up to 127. No, ASCII only defines 0-127. Values =128 are not ASCII. From https://en.wikipedia.org/wiki/ASCII: ASCII includes definitions for 128 characters: 33 are non-printing control characters (now mostly obsolete) that affect how text and space is processed and 95 printable characters, including the space (which is considered an invisible graphic). Doh! I was mistaking extended ASCII for ASCII. Thanks for the correction. There actually is no such thing as extended ASCII -- there is a whole series of many different extended ASCIIs. If you look at the encodings available in (for example) Thunderbird, many of the ISO-8859-* and Windows-* encodings are extended ASCII in the sense that they extend ASCII to include bytes 128-255. Unfortunately they all extend ASCII in a different way (hence they are different encodings). Yupp. Looking at RFC 1345 some years ago (while having to deal with EBCDIC) made this all pretty clear to me. I appreciate that someone did this heavy work of collecting historical encodings. Ciao, Michael. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python is readable
On Fri, Mar 30, 2012 at 12:20 PM, Chris Angelico ros...@gmail.com wrote: On Sat, Mar 31, 2012 at 12:46 AM, Nathan Rice nathan.alexander.r...@gmail.com wrote: I believe in the idea of things should be as simple as possible, but not simpler. Programming as it currently exists is absolutely convoluted. I am called on to help people learn to program from time to time, and I can tell you that we still have a LONG way to go before programming approaches a global optimum in either the semantic or syntactic space. Aside from messes of installing and setting up language interpreters/compilers, which are averted by simply having several pre-installed (I think my Linux boxes come with some Python 2 version, Perl, bash, and a few others), that isn't really the case. Starting a Python script is easy. Programming gets convoluted only when, and to the extent that, the task does. It is true that program complexity is correlated with problem complexity, language and environment complexity is undeniable. If you want to prove this to yourself, find someone who is intelligent and has some basic level of computer literacy, sit them down at a computer and ask them to solve simple problems using programs. You could even be nice by opening the editor first. Don't help them, just watch them crash and burn. Then sit them in front of code that already works, and ask them to modify it to do something slightly different, and again just watch them crash and burn in all but the simplest of cases. It is painful - most of the time they just give up. These same people almost universally can describe the exact process of steps verbally or in writing to do what is required without any trouble; there might be some neglected edge cases, but if you describe the failed result, often times they will realize their mistake and be able to fix it quickly. Jeff Atwood had an article about programming sheep and non programming goats, and while he views it as a statement about people's failings, I view it as a statement about the failings of programming. Human computer interaction is really important, and the whole prefab GUI concept doesn't scale along any axis; people need to be able to interact with their computers in a flexible manner. In the beginning, we had no choice but to bend our communication to the the machine, but we're moving past that now. The machine should respect the communication of humans. We shouldn't decry natural language because of ambiguity; If we're ambiguous, the machine should let us know and ask for clarification. If we phrase things in a really awkward way, the machine should tell us so, and suggest a more understandable rendition (just like word processors do now). If the machine does something we didn't want based on our instructions, we should be able to state additional requirements in a declarative manner. Restricted natural languages are an active area of current research, and they clearly demonstrate that you can have an expressive formal language that is also valid English. Make no mistake about it, programming is a form of computer human interaction (I figured that would be an accepted mantra here). Think of it as modeling knowledge and systems instead of pushing bits around. You are describing things to the computer. To move from the syntactic domain to my point about programming languages, imagine if one person describes physics to a computer in French, and another person describes chemistry to a computer in English. The creators of the computer made different languages act as disjoint knowledge domains. The computer is incapable of making any inferences in physics which are informed by chemistry, and vice versa, unless someone comes along and re-describes one of the disciplines in the other language. Worse still, if someone that only speaks Mandarin comes along, the computer won't be able to tell him anything about either domain. Now imagine the creators of the computer decided that an acceptable solution was to have people print out statements from one domain in a given language, take it to another computer that scans the printout, translates it to a different language, and prints out the translated copy, then have that person take the translated copy back to the original computer, and scan it again in order to ask a cross cutting question. I hope from that perspective the paucity of our current methods will be more apparent. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python is readable
On Sat, Mar 31, 2012 at 5:15 AM, Nathan Rice nathan.alexander.r...@gmail.com wrote: It is true that program complexity is correlated with problem complexity, language and environment complexity is undeniable. If you want to prove this to yourself, find someone who is intelligent and has some basic level of computer literacy, sit them down at a computer and ask them to solve simple problems using programs. You could even be nice by opening the editor first. Don't help them, just watch them crash and burn. Then sit them in front of code that already works, and ask them to modify it to do something slightly different, and again just watch them crash and burn in all but the simplest of cases. It is painful - most of the time they just give up. These same people almost universally can describe the exact process of steps verbally or in writing to do what is required without any trouble; there might be some neglected edge cases, but if you describe the failed result, often times they will realize their mistake and be able to fix it quickly. This is more a matter of being unable to express themselves appropriately. If I allowed them to write an exact process of steps to do what's required, those steps would either be grossly insufficient for the task, or would BE pseudo-code. There are plenty of people who cannot write those sorts of instructions at all. They're called non-programmers. Anyone who doesn't code but can express a task in such clear steps as you describe is what I would call a non-coding programmer - and such people are VERY easily elevated to full programmer status. I've worked with several like that, and the border between that kind of clear, concise, simple instruction list and actual Python or REXX code is so small as to be almost nonexistent. It's not the programming languages' fault. It's a particular jump in thinking that must be overcome before a person can use them. There are other similar jumps in thinking. On which side of these lines are you? Do you remember making the shift? Or, conversely, do you stare at it with Huh? Why would I do that?? * Source control. Don't just keep daily backups - record specific purposeful changes in a log. * WYSIWYG document editing vs plain-text with a compiler. Pass up Open Office (or worse) in favour of LaTeX, abandon Sibelius in favour of Lilypond. Plays very nicely with source control. * Unicode instead of head-in-the-sand pretending that ASCII is good enough. * Open standards and toolchains instead of expecting monolithic proprietary programs to do your work for you. Etcetera, etcetera. Everyone who's made the jump will see the benefit of the side they're on; most who haven't won't. Same with non-programmers to programmers. Why should I write like that when I could just write English? Simple: Because dedicated programming languages are far more expressive for the job. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: unittest: assertRaises() with an instance instead of a type
Steven D'Aprano wrote: To the degree that the decision of how finely to slice tests is a matter of personal judgement and/or taste, I was wrong to say that is not the right way. I should have said that is not how I would do that test. I believe that a single test is too coarse, and three or more tests is too fine, but two tests is just right. Let me explain how I come to that judgement. If you take a test-driven development approach, the right way to test this is to write testFooWillFail once you decide that foo() should raise MyException but before foo() actually does so. You would write the test, the test would fail, and you would fix foo() to ensure it raises the exception. Then you leave the now passing test in place to detect regressions. Then you do the same for the errorcode. Hence two tests. [snip] So: never remove tests just because they are redundant. Only remove them when they are obsolete due to changes in the code being tested. Very persuasive argument -- I now find myself disposed to writing two tests (not three, nor five ;). ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: convert string to bytes without changing data (encoding)
28.03.12 21:13, Heiko Wundram написав(ла): Reading from stdin/a file gets you bytes, and not a string, because Python cannot automagically guess what format the input is in. In Python3 reading from stdin gets you string. Use sys.stdin.buffer.raw for access to byte stream. And reading from file opened in text mode gets you string too. -- http://mail.python.org/mailman/listinfo/python-list
Re: convert string to bytes without changing data (encoding)
On Sat, Mar 31, 2012 at 6:06 AM, Serhiy Storchaka storch...@gmail.com wrote: 28.03.12 21:13, Heiko Wundram написав(ла): Reading from stdin/a file gets you bytes, and not a string, because Python cannot automagically guess what format the input is in. In Python3 reading from stdin gets you string. Use sys.stdin.buffer.raw for access to byte stream. And reading from file opened in text mode gets you string too. True. But that's only if it's been told the encoding of stdin (which I believe is the normal case on Linux). It's still not automagically guess(ing), it's explicitly told. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Python is readable
This is more a matter of being unable to express themselves appropriately. If I allowed them to write an exact process of steps to do what's required, those steps would either be grossly insufficient for the task, or would BE pseudo-code. There are plenty of people who cannot write those sorts of instructions at all. They're called non-programmers. Anyone who doesn't code but can express a task in such clear steps as you describe is what I would call a non-coding programmer - and such people are VERY easily elevated to full programmer status. I've worked with several like that, and the border between that kind of clear, concise, simple instruction list and actual Python or REXX code is so small as to be almost nonexistent. It's not the programming languages' fault. It's a particular jump in thinking that must be overcome before a person can use them. Your statement that the difference between Python or REXX and pseudo-code is almost non existent is completely false. While people reading Python might be able to guess with higher accuracy what a program does than some other programming languages, there is still a set of VERY specific set of glyphs, words and phrase structures it requires. Pretty much anyone can follow a recipe to make a meal (and there are a lot other examples of this), and conversely given the knowledge of how to make some dish, pretty much everyone could describe the process as a recipe. The same person will fail miserably when trying to create working code that is MUCH simpler from a conceptual standpoint. Non coders are not stupid, they just don't appreciate the multitude of random distinctions and computer specific abstractions programming foists on them for the purpose of writing EFFICIENT code. I'm talking about like multiple int/number types, umpteen different kinds of sequences, tons of different data structures that are used for basically the same things under different circumstances, indices starting at 0 (which makes amazing sense if you think like a machine, and very little if you think like a human), the difference between logical and bitwise operators (union and intersection would be better names for the latter), string encoding, etc. When you combine these with having to communicate in a new (very arbitrary, sometimes nonsensical) vocabulary that doesn't recognize synonyms, using an extremely restricted phrase structure and an environment with very limited interactivity, it should become clear that the people who learn to program are invariably fascinated by computers and very motivated to do so. I'm going to assume that you didn't mean that non coders are incapable of instructing others (even though your statement implies it directly). I think the ability of non coders to describe procedures would surprise you. Things I hear over and over from non coders all tie into people being frustrated that computers don't grasp similarity, and don't try to figure out what they want at all; most people provide instructions in an interactive manner. The computer is too stupid to interact with humans, so you have to tell it what to do, then try to run it, watch it fail, then go back and modify your program, which is highly unnatural. I think you'd find that these non coders would do very well if given the ability to provide instructions in a natural, interactive way. They are not failing us, we are failing them. Etcetera, etcetera. Everyone who's made the jump will see the benefit of the side they're on; most who haven't won't. Same with non-programmers to programmers. Why should I write like that when I could just write English? Simple: Because dedicated programming languages are far more expressive for the job. Really? Or could it be that algorithms for natural language processing that don't fail miserably is a very recent development, restricted natural languages more recent still, and pretty much all commonly used programming languages are all ~20+ years old? Could it also be that most programmers don't see a lot of incentives to make things accessible, since they're already invested in the status quo, and they might lose some personal value if programming stopped being an arcane practice? Creating a programming language is a time consuming and laborious process, the fact that people are doing it constantly is a clear indication that what we have is insufficient. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python is readable
On Sat, Mar 31, 2012 at 6:55 AM, Nathan Rice nathan.alexander.r...@gmail.com wrote: I think you'd find that these non coders would do very well if given the ability to provide instructions in a natural, interactive way. They are not failing us, we are failing them. The nearest thing to natural-language command of a computer is voice navigation, which is another science that's plenty old and yet still current (I first met it back in 1996 and it wasn't new then). You tell the computer what you want it to do, and it does it. Theoretically. The vocabulary's a lot smaller than all of English, of course, but that's not a problem. The problem is that it's really REALLY slow to try to get anything done in English, compared to a dedicated domain-specific language (in the case of typical OS voice navigation, the nearest equivalent would probably be a shell script). Really? Or could it be that algorithms for natural language processing that don't fail miserably is a very recent development, restricted natural languages more recent still, and pretty much all commonly used programming languages are all ~20+ years old? Could it also be that most programmers don't see a lot of incentives to make things accessible, since they're already invested in the status quo, and they might lose some personal value if programming stopped being an arcane practice? Totally. That's why we're all still programming in assembly language and doing our own memory management, because we would lose a lot of personal value if programming stopped being so difficult. If it weren't for all these silly new-fangled languages with their automatic garbage collection and higher order function handling, we would all be commanding much higher salaries. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Python is readable
On 2012-03-30, Nathan Rice nathan.alexander.r...@gmail.com wrote: Restricted natural languages are an active area of current research, and they clearly demonstrate that you can have an expressive formal language that is also valid English. See, for example, Inform 7, which translates a subset of English into Inform 6 code. I never thought too deeply about why I disliked it, assuming it was because I already knew Inform 6. Would you like to write the equivalent, e.g., C code in English? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: Python is readable
On Sat, 31 Mar 2012 07:20:39 +1100 Chris Angelico ros...@gmail.com wrote: ... That's why we're all still programming in assembly language and doing our own memory management, because we would lose a lot of personal value if programming stopped being so difficult. If it weren't for all these silly new-fangled languages with their automatic garbage collection and higher order function handling, we would all be commanding much higher salaries. Back in the 1970's, the magazines were full of ads for never write another line of code again programs. A keystroke here, a keystroke there (those were the days *before* drag-and-drop and point-and-drool), and even managers and executives could write programs. Now, of course, those managers and executives still command higher salaries, so I guess ChrisA is right about us assembly language guys losing our personal value. Dan -- http://mail.python.org/mailman/listinfo/python-list
Re: Python is readable
On Fri, Mar 30, 2012 at 4:20 PM, Chris Angelico ros...@gmail.com wrote: On Sat, Mar 31, 2012 at 6:55 AM, Nathan Rice nathan.alexander.r...@gmail.com wrote: I think you'd find that these non coders would do very well if given the ability to provide instructions in a natural, interactive way. They are not failing us, we are failing them. The nearest thing to natural-language command of a computer is voice navigation, which is another science that's plenty old and yet still current (I first met it back in 1996 and it wasn't new then). You tell the computer what you want it to do, and it does it. Theoretically. The vocabulary's a lot smaller than all of English, of course, but that's not a problem. The problem is that it's really REALLY slow to try to get anything done in English, compared to a dedicated domain-specific language (in the case of typical OS voice navigation, the nearest equivalent would probably be a shell script). I'm sure a ford truck would smoke a twin engine cessna if you compare their speed on the ground. Let the cessna fly and the ford doesn't have a snowball's chance. If you're navigating by going cee dee space slash somefolder slash some other folder slash some third folder slash semicolon emacs somename dash some other name dash something dot something else dot one the analogy would be a boss telling his secretary to reserve him a flight by saying visit site xyz, click on this heading, scroll halfway down, open this menu, select this destination, ... instead of book me a flight to San Jose on the afternoon of the 23rd, and don't spend more than $500. Totally. That's why we're all still programming in assembly language and doing our own memory management, because we would lose a lot of personal value if programming stopped being so difficult. If it weren't for all these silly new-fangled languages with their automatic garbage collection and higher order function handling, we would all be commanding much higher salaries. Did you miss the fact that a 50 year old programming language (which still closely resembles its original form) is basically tied for the title of currently most popular, and the 3 languages following it are both nominal and spiritual successors, with incremental improvements in features but sharing a large portion of the design. Programming language designers purposefully try to make their language C-like, because not being C-like disqualifies a language from consideration for a HUGE portion of programmers, who cower at the naked feeling they get imagining a world without curly braces. Fear of change and the unknown are brutal, and humans are cowardly creatures that will grasp at whatever excuses they can find not to acknowledge their weaknesses. I also mentioned previously, most developers are just trying to graft shortcut after shortcut on to what is comfortable and familiar because we're inherently lazy. Additionally, I'm quite certain that when we finally do have a method for programming/interacting with computers in a natural way, many people invested in previous methods will make snarky comments about how lame and stupid people using the new methods are, just like we saw with command line/keyboard elitists who make fun of people who prefer a mouse/gui, even though in most cases research showed that the people using the mouse/gui actually got work done faster. You can even look at some comments on this thread for evidence of this. -- http://mail.python.org/mailman/listinfo/python-list
Will MySQL ever be supported for Python 3.x?
The MySQLdb entry on SourceForge (http://sourceforge.net/projects/mysql-python/) web site still says the last supported version of Python is 2.6. PyPi says the last supported version is Python 2.5. The last download is from 2007. I realize there are unsupported fourth-party versions from other sources. (http://www.lfd.uci.edu/~gohlke/pythonlibs/) But those are just blind builds; they haven't been debugged. MySQL Connector (http://forge.mysql.com/projects/project.php?id=302) is still pre-alpha. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Will MySQL ever be supported for Python 3.x?
On 30-3-2012 23:20, John Nagle wrote: The MySQLdb entry on SourceForge (http://sourceforge.net/projects/mysql-python/) web site still says the last supported version of Python is 2.6. PyPi says the last supported version is Python 2.5. The last download is from 2007. I realize there are unsupported fourth-party versions from other sources. (http://www.lfd.uci.edu/~gohlke/pythonlibs/) But those are just blind builds; they haven't been debugged. MySQL Connector (http://forge.mysql.com/projects/project.php?id=302) is still pre-alpha. Try Oursql instead http://packages.python.org/oursql/ oursql is a new set of MySQL bindings for python 2.4+, including python 3.x Irmen -- http://mail.python.org/mailman/listinfo/python-list
Re: Python is readable
On Sat, Mar 31, 2012 at 7:58 AM, Nathan Rice nathan.alexander.r...@gmail.com wrote: Programming language designers purposefully try to make their language C-like, because not being C-like disqualifies a language from consideration for a HUGE portion of programmers, who cower at the naked feeling they get imagining a world without curly braces. Fear of change and the unknown are brutal, and humans are cowardly creatures that will grasp at whatever excuses they can find not to acknowledge their weaknesses. Braces are clear delimiters. English doesn't have them, and suffers for it. (Python's indentation is, too, but English doesn't have that either.) It's a lot harder to mark the end of an if block in English than in pretty much any programming language. And be careful of what has to be given up to gain your conveniences. I've used languages that demand variable declarations and ones that don't, and I'm very much a fan of the former. There are many benefits to being explicit about that. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Will MySQL ever be supported for Python 3.x?
On 3/30/2012 2:32 PM, Irmen de Jong wrote: Try Oursql instead http://packages.python.org/oursql/ oursql is a new set of MySQL bindings for python 2.4+, including python 3.x Not even close to being compatible with existing code. Every SQL statement has to be rewritten, with the parameters expressed differently. It's a good approach, but very incompatible. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Advise of programming one of my first programs
** Absolutely! Too bad your version would be considered the more “complicated” version ;) I`m sure about that, but I`am also sure that every beginner passed true that way. ** ** With the main navigation menu I will only have the option to select a nickname and when a nickname is selected then it loads Details of the contact and from loaded details I can choice Edit or back to main screen, like I did it the first time, or else I can do it = when 'e' pressed to ask for a nickname and then edit it. ** I was trying to simplify it to “guide” you to a more correct solution without feeding you the answer. Maybe I should have given you the explanation first to explain why you should be doing it a different way.** ** ** ** Going back to your original program (and your modifications to it), the original menu can cause crashing in more complicated programs and thus is considered a bad style. It was basically using recursion (I will touch on this later) but without any of the benefits. It was endlessly branching instead of a simple loop. Sort of like the following Menu/submenu example. ** ** Menu submenu Menu submenu Menu __ad infinitum__ ** ** How does this matter? Let’s look at some simpler code below. ** ** print ‘start’ function_a() # a function is called print ‘a’# code inside the function print ‘b’# code inside the function a = ‘ something ‘ print a function_b() # another function call print ‘c’ # code inside a different function print ‘d’ # code inside a different function print ‘end’ ** ** Let us pretend we are the computer who executes one line at a time and so basically goes through a list of commands. The list we are going to execute is the following: ** ** print ‘start’ function_a() print ‘a’ print ‘b’ a = ‘ something ‘ print a function_b() print ‘c’ print ‘d’ print ‘end’ ** ** How does the computer know to execute “a = ‘ something ‘” after “print ‘b’”? It does it by storing the location where it was before it proceeds to the function call. That way when the end of the function is reached it returns to the previous spot. In essence: ** ** print ‘start’ function_a() __store this location so I can come back__ print ‘a’ print ‘b’ __return to previous location__ a = ‘ something ‘ print a function_b() __store this location so I can come back__ print ‘c’ print ‘b’ __return to previous location__ print ‘end’ ** ** Now what happens if “function_a” calls “function_a”? By the way, the term for this type of call is recursion. ** ** print ‘start’ function_a() __store this location so I can come back__ print ‘a’ print ‘b’ function_a() __store this location so I can come back__ print ‘a’ print ‘b’ function_a() __store this location so I can come back__ print ‘a’ print ‘b’ function_a() __store this location so I can come back__ print ‘a’ print ‘b’ function_a() __store this location so I can come back__ print ‘a’ print ‘b’ function_a() __store this location so I can come back__ **until the program ends** ** ** Now each __store__ action takes up memory and when the computer (or your program) runs out of memory your computer crashes. Your application is trivial and more likely to be ended by the user instead of going through the tens of thousands if not hundreds of thousands that Python will let you take, but it is a bad practice and a habit to avoid. A real world program would use more memory and quit even faster than yours. Recursion has its place in programming, but not in this case! What you need is a simple loop. That is why I provided you with the menu I did. ** ** The following menu sounds like what you want; there were a couple different ways I could have done this. In this version, if you type anything when asked for a menu choice that is not ‘e’ or ‘q’, the program will automatically ask you for the next book choice. ** ** def mmenu(): # load tbook here while True: book = get_book_choice() details( tbook, book ) choicem = get_menu_choice() if choicem == 'e' or choicem == 'E': edit( tbook, book
Re: Will MySQL ever be supported for Python 3.x?
On 30-3-2012 23:46, John Nagle wrote: On 3/30/2012 2:32 PM, Irmen de Jong wrote: Try Oursql instead http://packages.python.org/oursql/ oursql is a new set of MySQL bindings for python 2.4+, including python 3.x Not even close to being compatible with existing code. Every SQL statement has to be rewritten, with the parameters expressed differently. It's a good approach, but very incompatible. You didn't state that it had to be compatible with existing code. Also, since you asked about Python 3.x, surely there are other incompatibilities you need to take care of in the existing code? (unless it's Python 3.x clean already...) Irmen -- http://mail.python.org/mailman/listinfo/python-list
Re: Python is readable
On Fri, Mar 30, 2012 at 5:45 PM, Chris Angelico ros...@gmail.com wrote: On Sat, Mar 31, 2012 at 7:58 AM, Nathan Rice nathan.alexander.r...@gmail.com wrote: Programming language designers purposefully try to make their language C-like, because not being C-like disqualifies a language from consideration for a HUGE portion of programmers, who cower at the naked feeling they get imagining a world without curly braces. Fear of change and the unknown are brutal, and humans are cowardly creatures that will grasp at whatever excuses they can find not to acknowledge their weaknesses. Braces are clear delimiters. English doesn't have them, and suffers for it. (Python's indentation is, too, but English doesn't have that either.) It's a lot harder to mark the end of an if block in English than in pretty much any programming language. It seems to me that Indented blocks of text are used pretty frequently to denote definition bodies, section subordinate paragraphs and asides. The use of the colon seems pretty natural too. Parentheses are fairly natural for small asides. The notion of character delimiters for large sections of text is actually pretty unnatural with the exception of quotes. And be careful of what has to be given up to gain your conveniences. I've used languages that demand variable declarations and ones that don't, and I'm very much a fan of the former. There are many benefits to being explicit about that. I don't like declarations, my personal preference is to have typed signatures, and implicit declaration with type inference elsewhere. I view it as a matter of personal preference though, the result should be the same, and it should be possible to view the code either way. -- http://mail.python.org/mailman/listinfo/python-list
Threads on google groups not on gmane?
I went onto google groups to do a search and saw three threads (there may be more) that I've never seen on gmane, which I read via thunderbird on windows. The titles are Is programming art or science, breezypythongui: A New Toolkit for Easy GUIs in Python and weird behaviour: pygame plays in shell but not in script. Is anyone else seeing the same thing? -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: CFG for python
On 29/03/2012 06:44, J. Mwebaze wrote: Anyone knows how to create control-flow-graph for python.. After searching around, i found this article, http://www.python.org/dev/peps/pep-0339/#ast-to-cfg-to-bytecode and also a reference to http://doc.pypy.org/en/latest/objspace.html#the-flow-model However, i stil cant figure out what how to create the CFG from the two references. Regards Taking a look at this may help you get going http://alexleone.blogspot.co.uk/2010/01/python-ast-pretty-printer.html -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: help needed to understand an error message.
So the problem is that python doesn't know what you're trying to do. It doesn't know that you meant to say print. When the parser is looking at the word Print, it assumes you are referencing an object named Print, which is completely legal. It's only once you've created the next token, a string literal, that the parser discovers the error: you can't have a string literal following a variable. *You* think your error is that you misspelled print. The parser thinks your error is trying to put a string literal next to a variable. Cheers, Cliff On Mon, 2012-03-26 at 18:22 +0530, Aloke Ghosh wrote: Hi, I am learning Python and do not have programming experience. I was following an exercise from http://learnpythonthehardway.org/book/ex2.html and made a mistake in entry : PrintI like typing this. and got the following error message: In [2]: PrintI like typing this. File ipython console, line 1 PrintI like typing this. ^ SyntaxError: invalid syntax I feel the error is in Capital P in print . However the error indicated with ^ hints at quote at the end of the line. Can any one please help me understand this. -- A.K.Ghosh -- http://mail.python.org/mailman/listinfo/python-list
Re: Python is readable
On 3/30/2012 6:47 AM, Steven D'Aprano wrote: Spolsky has written at least three times about Architecture Astronauts, and made it abundantly clear that the problem with them is that they don't solve problems, they invent overarching abstractions that don't do anything useful or important, and hype them everywhere. http://www.joelonsoftware.com/articles/fog18.html http://www.joelonsoftware.com/items/2005/10/21.html http://www.joelonsoftware.com/items/2008/05/01.html Jeff Attwood provides a simple test for the difference between a useful abstraction and an Architecture Astronaut hyper-abstraction: Does it solve a useful problem? http://www.codinghorror.com/blog/2004/12/it-came-from-planet-architecture.html My strong impression is that theoretical abstract mathematicians also prefer that hi-level abstractions solve some useful-to-mathematicians mathematical problem. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Tools for refactoring/obfuscation
On 03/29/2012 03:04 AM, Javier wrote: Yes, in general I follow clear guidelines for writing code. I just use modules with functions in the same directory and clear use of name spaces. I almost never use classes. I wonder if you use some tool for refactoring. I am mainly intersted in scripting tools, no eclipse-style guis. Just let me know if you use some scripting tool. And, as somebody pointed in this thread obfuscating or refactoring the code are very different things but they can be done with the same tools. trollif you're not using classes, your code is obfuscated already/troll Anyway, I think it's better if you describe why you want such a tool. If you want to keep your code a secret, just distribute the .pyc file. If you want to refactor your code to improve readability, there is rope. -- http://mail.python.org/mailman/listinfo/python-list
[issue14450] Log rotate cant execute in Windows. (logging module)
New submission from shinta.nakayama shinta.nakay...@gmail.com: I found a bug in logging module in Windows. I wrote that at here. https://gist.github.com/2247692 my OS is Windows7 32bit. C:\Python27python Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win 32 Type help, copyright, credits or license for more information. -- components: Library (Lib) messages: 157126 nosy: shinta.nakayama priority: normal severity: normal status: open title: Log rotate cant execute in Windows. (logging module) versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14450 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14435] Remove special block allocation from floatobject.c
Changes by Mark Dickinson dicki...@gmail.com: -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14435 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14450] Log rotate cant execute in Windows. (logging module)
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: Maybe some Antivirus program (or Tortoise) is still scanning the file and python cannot rename it. Can you try to deactivate the antivirus and try again? -- nosy: +amaury.forgeotdarc ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14450 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14435] Remove special block allocation from floatobject.c
Antoine Pitrou pit...@free.fr added the comment: Here is a new patch, with the suggested changes. The variable names and macros are similarly named as those for other objects such as lists. Looks good to me. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14435 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14006] Improve the documentation of xml.etree.ElementTree
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 78038b6e0a85 by Eli Bendersky in branch 'default': Issue #14006: improve the documentation of xml.etree.ElementTree http://hg.python.org/cpython/rev/78038b6e0a85 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14006 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14249] unicodeobject.c: aliasing warnings
Serhiy Storchaka storch...@gmail.com added the comment: I'm sorry. Here is the corrected patch for big-endian plathform. -- Added file: http://bugs.python.org/file25072/utf16_decoder_shift_3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14249 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14435] Remove special block allocation from floatobject.c
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 37ebe64d39d2 by Kristján Valur Jónsson in branch 'default': Issue #14435: Remove special block allocation code from floatobject.c http://hg.python.org/cpython/rev/37ebe64d39d2 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14435 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14435] Remove special block allocation from floatobject.c
Kristján Valur Jónsson krist...@ccpgames.com added the comment: All done. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14435 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14451] sum, min, max only works with iterable
New submission from Fade78 f...@wanadoo.fr: The built-in functions working with iterable should also work with single object that is relevent. For example: max([1,6,5]) - 6 max(6) - TypeError because not an iterable (actual behavior) max(6) - 6 (wanted pythonic behavior) So if I write a generic function like this: def f(x): totalsum+=sum(x) it fails if x is not an iterable. But I want the argument to be anything possible. Using if(type) to separate use cases is not very pythonic. -- components: None messages: 157133 nosy: Fade78 priority: normal severity: normal status: open title: sum, min, max only works with iterable type: behavior versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14451 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14438] _cursesmodule build fails on cygwin
Alexey Luchko l...@ank-sia.com added the comment: It's cygwin's issue. Cygwin's python 2.6 has a patch for it. Just in case: --- origsrc/Python-2.6.5/Include/py_curses.h2009-09-06 16:23:05.0 -0500 +++ src/Python-2.6.5/Include/py_curses.h2010-04-14 15:21:23.008971400 -0500 @@ -17,6 +17,13 @@ #define NCURSES_OPAQUE 0 #endif /* __APPLE__ */ +#ifdef __CYGWIN__ +/* the following define is necessary for Cygwin; without it, the + Cygwin-supplied ncurses.h sets NCURSES_OPAQUE to 1, and then Python + can't get at the WINDOW flags field. */ +#define NCURSES_INTERNALS +#endif /* __CYGWIN__ */ + #ifdef __FreeBSD__ /* ** On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards -- resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14438 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14452] SysLogHandler sends invalid messages when using unicode
New submission from marko kreen mark...@gmail.com: SysLogHandler converts message to utf8 and adds BOM, supposedly to conform with RFC5424, but the implementation is broken: the RFC specifies that the BOM should prefix only unstructured message part, but current Python implementation puts it in the middle of structured part, thus confusing RFC-compliant receivers. Simplest fix would be to just remove the BOM adding. -- components: Library (Lib) messages: 157135 nosy: zmk priority: normal severity: normal status: open title: SysLogHandler sends invalid messages when using unicode versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14452 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14452] SysLogHandler sends invalid messages when using unicode
Changes by marko kreen mark...@gmail.com: -- type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14452 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14065] Element should support cyclic GC
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 0ca32013d77e by Eli Bendersky in branch 'default': Issue #14065: Added cyclic GC support to ET.Element http://hg.python.org/cpython/rev/0ca32013d77e -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14065 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14065] Element should support cyclic GC
Changes by Eli Bendersky eli...@gmail.com: -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14065 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14452] SysLogHandler sends invalid messages when using unicode
Changes by R. David Murray rdmur...@bitdance.com: -- nosy: +vinay.sajip ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14452 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14452] SysLogHandler sends invalid messages when using unicode
Changes by R. David Murray rdmur...@bitdance.com: -- versions: -Python 2.6, Python 3.1, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14452 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14451] sum, min, max only works with iterable
R. David Murray rdmur...@bitdance.com added the comment: The current behavior is how we want the functions to work. If you want to debate the design, the best forum would probably be python-ideas. -- nosy: +r.david.murray resolution: - rejected stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14451 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13007] gdbm 1.9 has new magic that whichdb does not recognize
Niklas Br n.brunb...@gmail.com added the comment: This fix should be included in RC2, right? Because I can't get it to work. Amarok:roller niklas$ ls data.db roller.py Amarok:roller niklas$ python3-32 Python 3.2.3rc2 (v3.2.3rc2:428f05cb7277, Mar 18 2012, 00:08:43) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type help, copyright, credits or license for more information. import shelve file = shelve.open(data.db) Traceback (most recent call last): File stdin, line 1, in module File /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/shelve.py, line 232, in open return DbfilenameShelf(filename, flag, protocol, writeback) File /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/shelve.py, line 216, in __init__ Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback) File /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/dbm/__init__.py, line 83, in open raise error[0](db type could not be determined) dbm.error: db type could not be determined -- nosy: +Niklas.Brunberg ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13007 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13007] gdbm 1.9 has new magic that whichdb does not recognize
R. David Murray rdmur...@bitdance.com added the comment: It is, yes. Can you do some debugging and see why it is failing? It should be simple enough to add a print to see what magic number Python is seeing. -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13007 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13007] gdbm 1.9 has new magic that whichdb does not recognize
R. David Murray rdmur...@bitdance.com added the comment: Oh, actually...are you sure you are running 3.2.3 against the 3.2.3 stdlib? It looks like you might be running against the Apple default installed library, but I don't know enough about OSX to be sure. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13007 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13007] gdbm 1.9 has new magic that whichdb does not recognize
Niklas Br n.brunb...@gmail.com added the comment: I'm new to python so please , how do I print what? This? shelve module 'shelve' from '/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/shelve.py' -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13007 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13007] gdbm 1.9 has new magic that whichdb does not recognize
Niklas Br n.brunb...@gmail.com added the comment: accidentally a or two word there :) …please have patience… was what I wanted to say -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13007 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13007] gdbm 1.9 has new magic that whichdb does not recognize
R. David Murray rdmur...@bitdance.com added the comment: Oh, I meant sticking a print statement into the stdlib code. But I really think your problem is that you aren't running the 3.2.3 stdlib code. Try opening up the file /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/dbm/__init__.py in your favorite editor, and see if there is a line that says: if magic in (0x13579ace, 0x13579acd, 0x13579acf): If it instead says: if magic == 0x13579ace: Then you are using the 3.2 stdlib (which from the traceback filenames it looks like you are). In other words, I'm pretty sure what you have here is a problem with correctly installing or running the 3.2.3RC2 version of python, and you should ask for help on python-list. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13007 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13007] gdbm 1.9 has new magic that whichdb does not recognize
Niklas Br n.brunb...@gmail.com added the comment: Found this: # Check for GNU dbm if magic in (0x13579ace, 0x13579acd, 0x13579acf): return dbm.gnu I suppose the .dmg pre-packaged installer was insufficient, so I tried to download the source and compile locally, but that didn't help either. Thanks for taking time to check in on this! I will look for help elsewhere and not clog up this Issue anymore. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13007 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14453] profile.Profile.calibrate can produce incorrect numbers in some circumstances
New submission from Adam Tomjack adam.tomj...@zuerchertech.com: profile.Profile.calibrate can only produces a bias for the default timer. If you've specified a different timer, it will not be used when calibrating. Additionally, setting profile.Profile.bias will affect the computed bias. It will produce a bias that must be added to profile.Profile.bias and cannot be used independently, which is surprising. The fix is to change p = Profile() to p = Profile(timer=self.timer, bias=0) in _calibrate_inner(). The attached patch makes that change and additionally removes some code that temporarily resets self.bias in calibrate(), as it had no effect. Perhaps Profile.bias was meant instead. At any rate, _calibrate_inner() no longer needs to exist, but is left for backwards compatibility. This will demonstrate the problem with calibrating after setting profile.Profile.bias: import profile profile.Profile.bias = profile.Profile().calibrate(10); print '%+.9f' % profile.Profile.bias profile.Profile.bias = profile.Profile().calibrate(10); print '%+.9f' % profile.Profile.bias -- components: Library (Lib) files: profile-calibrate.patch keywords: patch messages: 157145 nosy: adamtj priority: normal severity: normal status: open title: profile.Profile.calibrate can produce incorrect numbers in some circumstances type: behavior versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4 Added file: http://bugs.python.org/file25073/profile-calibrate.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14453 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14422] Pack PyASCIIObject fields to reduce memory consumption of pure ASCII strings
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14422 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13007] gdbm 1.9 has new magic that whichdb does not recognize
R. David Murray rdmur...@bitdance.com added the comment: Well, that's the correct line. So if that is what is in your /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/dbm/__init__.py, then there is a problem. If so, please put the line: print(magic) just before that if statement, and let us know what it says why you try to open your db file. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13007 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14452] SysLogHandler sends invalid messages when using unicode
Vinay Sajip vinay_sa...@yahoo.co.uk added the comment: the RFC specifies that the BOM should prefix only unstructured message part, but current Python implementation puts it in the middle of structured part, thus confusing RFC-compliant receivers. How do you work that out? The implementation puts the BOM before the message part: prio = '%d' % self.encodePriority(...) prio = prio.encode('utf-8') msg = msg.encode('utf-8') if codecs: msg = codecs.BOM_UTF8 + msg msg = prio + msg Perhaps I've misunderstood you or the RFC5424, but I don't quite see how. I'll mark this as pending and invalid awaiting a clarification from you (ideally with a specific example). -- resolution: - invalid status: open - pending ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14452 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14454] argparse metavar list parameter with nargs=k
New submission from Andy Harrington ahar...@luc.edu: I now set the help string for an argparse option with two parameters: parser.add_argument('-s', '--substitute', nargs=2, help='Replace first string with second', metavar='string') which generates a help message -s string string, --substitute string string Replace first string with second Instead I would *like* to generate the help message -s fromString toString, --substitute fromString toString Replace fromString with toString At present metavar replaces each of multiple parameters with the same thing, but with a fixed number of parameters it makes sense that each may have a different meaning. It seems to me that when nargs=k is set for an integer k, we could have metavar be a list of k strings to go in the k places, as in parser.add_argument('-s', '--substitute', nargs=2, help='Replace fromString with toString', metavar=['fromString', 'toString']) and have this generate my desired help message. There is no need to break the current behavior: The parser can distinguish a list from a single string. The same text is in the attached file. -- components: Library (Lib) files: metavarListEnhancement.txt messages: 157148 nosy: andyharrington priority: normal severity: normal status: open title: argparse metavar list parameter with nargs=k type: enhancement versions: Python 3.3 Added file: http://bugs.python.org/file25074/metavarListEnhancement.txt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14454 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14446] Remove deprecated tkinter functions
Changes by R. David Murray rdmur...@bitdance.com: -- type: - enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14446 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14422] Pack PyASCIIObject fields to reduce memory consumption of pure ASCII strings
R. David Murray rdmur...@bitdance.com added the comment: Looks like this should be closed rejected? -- nosy: +r.david.murray type: - enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14422 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14386] Expose dictproxy as a public type
Changes by R. David Murray rdmur...@bitdance.com: -- type: - enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14386 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14422] Pack PyASCIIObject fields to reduce memory consumption of pure ASCII strings
STINNER Victor victor.stin...@gmail.com added the comment: I consider it important that the data block of a string is well-aligned. I suppose that it doesn't matter for latin1, but it can be a problem for UCS-2 and UCS-4. There are more drawbacks than advantages, so I agree to close this issue. And let's focus on enabling optimizations based on memory alignement like #14419 :-) -- resolution: - wont fix status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14422 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11310] Document byte[s|array]() and byte[s|array](count) in docstrings
R. David Murray rdmur...@bitdance.com added the comment: Duplicate of issue 11231. -- nosy: +r.david.murray resolution: - duplicate stage: - committed/rejected status: open - closed superseder: - bytes() constructor is not correctly documented ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11310 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14455] plistlib unable to read json and binary plist files
New submission from d9pouces pyt...@19pouces.net: Hi, Plist files have actually three flavors : XML ones, binary ones, and now (starting from Mac OS X 10.7 Lion) json one. The plistlib.readPlist function can only read XML plist files and thus cannot read binary and json ones. The binary format is open and described by Apple (http://opensource.apple.com/source/CF/CF-550/CFBinaryPList.c). Here is the diff (from Python 2.7 implementation of plistlib) to transparently read both binary and json formats. API of plistlib remains unchanged, since format detection is done by plistlib.readPlist. An InvalidFileException is raised in case of malformed binary file. 57,58c57 Plist, Data, Dict, InvalidFileException, --- Plist, Data, Dict 64d62 import json 66d63 import os 68d64 import struct 81,89c77,78 header = pathOrFile.read(8) pathOrFile.seek(0) if header == '?xml ve' or header[2:] == '?xml ': #XML plist file, without or with BOM p = PlistParser() rootObject = p.parse(pathOrFile) elif header == 'bplist00': #binary plist file rootObject = readBinaryPlistFile(pathOrFile) else: #json plist file rootObject = json.load(pathOrFile) --- p = PlistParser() rootObject = p.parse(pathOrFile) 195,285d183 # timestamp 0 of binary plists corresponds to 1/1/2001 (year of Mac OS X 10.0), instead of 1/1/1970. MAC_OS_X_TIME_OFFSET = (31 * 365 + 8) * 86400 class InvalidFileException(ValueError): def __str__(self): return Invalid file def __unicode__(self): return Invalid file def readBinaryPlistFile(in_file): Read a binary plist file, following the description of the binary format: http://opensource.apple.com/source/CF/CF-550/CFBinaryPList.c Raise InvalidFileException in case of error, otherwise return the root object, as usual in_file.seek(-32, os.SEEK_END) trailer = in_file.read(32) if len(trailer) != 32: return InvalidFileException() offset_size, ref_size, num_objects, top_object, offset_table_offset = struct.unpack('6xBB4xL4xL4xL', trailer) in_file.seek(offset_table_offset) object_offsets = [] offset_format = '' + {1: 'B', 2: 'H', 4: 'L', 8: 'Q', }[offset_size] * num_objects ref_format = {1: 'B', 2: 'H', 4: 'L', 8: 'Q', }[ref_size] int_format = {0: (1, 'B'), 1: (2, 'H'), 2: (4, 'L'), 3: (8, 'Q'), } object_offsets = struct.unpack(offset_format, in_file.read(offset_size * num_objects)) def getSize(token_l): return the size of the next object. if token_l == 0xF: m = ord(in_file.read(1)) 0x3 s, f = int_format[m] return struct.unpack(f, in_file.read(s))[0] return token_l def readNextObject(offset): read the object at offset. May recursively read sub-objects (content of an array/dict/set) in_file.seek(offset) token = in_file.read(1) token_h, token_l = ord(token) 0xF0, ord(token) 0x0F #high and low parts if token == '\x00': return None elif token == '\x08': return False elif token == '\x09': return True elif token == '\x0f': return '' elif token_h == 0x10: #int result = 0 for k in xrange((2 token_l) - 1): result = (result 8) + ord(in_file.read(1)) return result elif token_h == 0x20: #real if token_l == 2: return struct.unpack('f', in_file.read(4))[0] elif token_l == 3: return struct.unpack('d', in_file.read(8))[0] elif token_h == 0x30: #date f = struct.unpack('d', in_file.read(8))[0] return datetime.datetime.utcfromtimestamp(f + MAC_OS_X_TIME_OFFSET) elif token_h == 0x80: #data s = getSize(token_l) return in_file.read(s) elif token_h == 0x50: #ascii string s = getSize(token_l) return in_file.read(s) elif token_h == 0x60: #unicode string s = getSize(token_l) return in_file.read(s * 2).decode('utf-16be') elif token_h == 0x80: #uid return in_file.read(token_l + 1) elif token_h == 0xA0: #array s = getSize(token_l) obj_refs = struct.unpack('' + ref_format * s, in_file.read(s * ref_size)) return map(lambda x: readNextObject(object_offsets[x]), obj_refs) elif token_h == 0xC0: #set s = getSize(token_l) obj_refs = struct.unpack('' + ref_format * s, in_file.read(s * ref_size)) return set(map(lambda x: readNextObject(object_offsets[x]), obj_refs)) elif token_h == 0xD0: #dict result = {} s = getSize(token_l) key_refs = struct.unpack('' + ref_format * s, in_file.read(s * ref_size))
[issue10423] s/args/options in arpgarse Upgrading optparse code
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset dee1597b3ce3 by R David Murray in branch '3.2': #10423: clarify options vs args in argparse discussion of optparse http://hg.python.org/cpython/rev/dee1597b3ce3 New changeset 7ad1728691b2 by R David Murray in branch 'default': Merge #10423: clarify options vs args in argparse discussion of optparse http://hg.python.org/cpython/rev/7ad1728691b2 New changeset cb5214e6c287 by R David Murray in branch '2.7': #10423: clarify options vs args in argparse discussion of optparse http://hg.python.org/cpython/rev/cb5214e6c287 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10423 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10423] s/args/options in arpgarse Upgrading optparse code
Changes by R. David Murray rdmur...@bitdance.com: -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10423 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14455] plistlib unable to read json and binary plist files
R. David Murray rdmur...@bitdance.com added the comment: Thanks for the patch. Could you upload it as a context diff? -- nosy: +r.david.murray stage: - patch review versions: +Python 3.3 -Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14455 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14455] plistlib unable to read json and binary plist files
d9pouces pyt...@19pouces.net added the comment: Here is the new patch. I assumed that you meant to use diff -c instead of the raw diff command. -- keywords: +patch Added file: http://bugs.python.org/file25076/context.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14455 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14417] dict RuntimeError workaround
Changes by Gregory P. Smith g...@krypto.org: -- nosy: +gregory.p.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14417 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14456] Relation between threads and signals unclear
New submission from Sven Marnach s...@marnach.net: The documentation of the 'signal' module states on the one hand [T]he main thread will be the only one to receive signals (this is enforced by the Python signal module, even if the underlying thread implementation supports sending signals to individual threads). On the other hand, it provides the function 'pthread_kill()': Send the signal signum to the thread thread_id, another thread in the same process as the caller. The signal is asynchronously directed to thread. These two passages are in contradiction to each other. The documentation also states that only the main thread can set signal handlers -- if this is true, it is utterly unclear how sending signals to other threads is useful. Probably the documentation wasn't fully updated when the above function was introduced. -- assignee: docs@python components: Documentation messages: 157156 nosy: docs@python, smarnach priority: normal severity: normal status: open title: Relation between threads and signals unclear versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14456 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8407] expose pthread_sigmask(), pthread_kill(), sigpending() and sigwait() in the signal module
Sven Marnach s...@marnach.net added the comment: The documentation has been left in a confusing state by this patch -- at least confusing to me. I've created issue14456 with further details. -- nosy: +smarnach ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8407 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14456] Relation between threads and signals unclear
Sven Marnach s...@marnach.net added the comment: For reference: the functions 'pthread_kill()' etc. were intrduced in issue8407. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14456 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14455] plistlib unable to read json and binary plist files
R. David Murray rdmur...@bitdance.com added the comment: Hmm. Apparently what I meant was -u instead of -c (unified diff). I just use the 'hg diff' command myself, which does the right thing :) Of course, to do that you need to have a checkout. (We can probably use the context diff.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14455 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14456] Relation between threads and signals unclear
STINNER Victor victor.stin...@gmail.com added the comment: These two passages are in contradiction to each other. By default, a thread signal can receive any signal and the signal handler implemented in C will be called in the context of the thread. CPython ensures that a signal handler implemented in Python and installed by signal.signal() will be called in the main thread. It uses a signal handler implemented in C which only store the notification and will be the Python signal handler later (as early as possible). pthread_sigmask() can be used to mask some signals (or all signals) on a specific thread. -- nosy: +haypo, neologix ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14456 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14457] Unattended Install doesn't populate registry
New submission from Paul Klapperich python@bobpaul.org: Steps to reproduce: 1. python-2.7.2.msi /qb 2. Check registry for HKLM\SOFTWARE\Python or HKLM\SOFTWARE\Wow6432Node\Python Expected behavior: The key will exist and contain a key for 2.7 providing information such as the installation path. Observed behavior: The key and its subkeys are not created at all. Workaround: Don't use the /passive, /quiet, or /qX options. Additional information: * Running msiexec /fm python-2.7.2.msi does not insert the missing registry entries. * Running python-2.7.2.msi without options after install and choosing repair /also/ fails to insert the missing registry entries. * Aside from inserting the entries by hand, uninstalling and re-installing with the interactive GUI seems to be the only way to populate them. I've tested this on 64bit Windows 7 with 32bit Python 2.7.2 msi package only. -- components: Installation, Windows messages: 157161 nosy: Paul.Klapperich priority: normal severity: normal status: open title: Unattended Install doesn't populate registry versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14457 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14457] Unattended Install doesn't populate registry
Changes by Paul Klapperich python@bobpaul.org: -- type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14457 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14454] argparse metavar list parameter with nargs=k
Andy Harrington ahar...@luc.edu added the comment: Withdrawn. My error. I missed the part of the documentation that says a *tuple*, not the list that I tried, does just what I wanted. -- assignee: - docs@python components: +Documentation -Library (Lib) nosy: +docs@python resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14454 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14433] Python 3 interpreter crash on windows when stdin closed in Python shell
Terry J. Reedy tjre...@udel.edu added the comment: 64 bit win 7, 3.3.0a1 crashes also. Idle shell just says that fd 0 is not valid, which I expect is correct for the socket replacement for sys.stdout. -- nosy: +terry.reedy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14433 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14440] Close background process if IDLE closes abnormally.
Terry J. Reedy tjre...@udel.edu added the comment: You need to specify os (with version) *nix? There have been issues like this before, for earlier Python version, at least for Windows XP, which have been fixed, at least for Windows. I think last patch (a year ago? before 3.2 I think) switched to using subprocess instead of older methods. If I kill Idle with task manager, the other, background pythonw process dies in under half a second. (If background process dies, IDLE restarts.) -- nosy: +terry.reedy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14440 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13007] gdbm 1.9 has new magic that whichdb does not recognize
Ned Deily n...@acm.org added the comment: Niklas, the Python 2 and 3 binaries for Mac OS X provided by the python.org installers are not built with support for gdbm, nor are the Apple-supplied system Pythons; Apple does not ship gdbm with OS X. So you can't open a shelve file created in another Python that does use gdbm. -- nosy: +ned.deily ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13007 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14455] plistlib unable to read json and binary plist files
Changes by Ned Deily n...@acm.org: -- nosy: +ned.deily ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14455 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14457] Unattended Install doesn't populate registry
Changes by Ned Deily n...@acm.org: -- nosy: +brian.curtin, loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14457 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com