Re: Help with some python homework...
On 1 February 2014 14:17, David bouncingc...@gmail.com wrote: Scott's message quoted above did not reach me, only Chris's quote of it, so I say: Scott once you begin a discussion on a mailing list like this one, please make sure that every reply you make goes to python-list@python.org and not to the individual. That way we can all participate in the discussion, that is best for everyone especially you. Please disregard the above paragraph Scott. Because 8 messages from you were just delivered to me, including that one, all via the list, some were 5 hours old. Sorry for any confusion I caused due to that delay. -- https://mail.python.org/mailman/listinfo/python-list
Re: __init__ is the initialiser
On 01/31/2014 09:51 PM, Steven D'Aprano wrote: On Sat, 01 Feb 2014 15:35:17 +1100, Chris Angelico wrote: The two methods could have been done as a single method, __construct__, in which you get passed a cls instead of a self, and you call self=super().__construct__() and then initialize stuff. That would be called __new__ in Python. There's no *need* to use __init__ for anything (except old-style classic classes in Python 2). While there may not be a /need/ for two, having two is quite handy. Having __new__ take care of the nuts and bolts (or foundation, as Terry put it), and being able to further customize with __init__ (where the kitchen goes, how many bedrooms, to follow along with Terry) is quite useful. One of my favorite Enum recipes uses that pattern to have some basic behavior, with some other behavior that is easily overridable/extendable [1]. -- ~Ethan~ [1] http://stackoverflow.com/q/19330460/208880 -- https://mail.python.org/mailman/listinfo/python-list
Re: Python shell wont open idle or an exisiting py file
On 2/1/2014 2:26 AM, Chris Angelico wrote: On Sat, Feb 1, 2014 at 4:46 PM, Terry Reedy tjre...@udel.edu wrote: On 1/31/2014 10:36 PM, Chris Angelico wrote: On Sat, Feb 1, 2014 at 1:54 PM, MRAB pyt...@mrabarnett.plus.com wrote: I think that some years ago I heard about a variation on UTF-8 (Microsoft?) where codepoint U+ is encoded as 0xC0 0x80 so that the null byte can be used as the string terminator. I had a look on Wikipedia found this: http://en.wikipedia.org/wiki/Null-terminated_string Yeah, it's a common abuse of UTF-8. It's a violation of spec, but an understandable one. However, I don't understand why the first part - why should \0 become U+ but (presumably) the \a later on (...cs\accel...) doesn't become U+0007, etc? Because only \0 has a special meaning in a C string, I should have added 'to C itself', as the string terminator. and Tk is written in C and uses C strings. Eh? I've used \a in C programs (not often but I have used it). It's possible that \0 is the only one that actually bombs anything (because of C0 80 representation). \0 can bomb C byte processing by terminating it sooner than it should. Its unexpected replacement bombs utf-8 decoding. But since \7 and \a both represent 0x07 in a C string, I would expect there to be other problems, if it's interpreting it as source. Ah well! Weird weird. While other control codes may have special meaning to a terminal or other device, to do not have special meaning to the operation of C string functions themselves (except possible for a 'getline' function looking for n -- but I do not remember is the C stdlib has any such functions). I am speaking from my memory of C. I have not looked at the Tk C code to see just what it did where to create the exception. I am just happy that Serhiy was able to fixed tkinter without causing another test to fail. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Python shell wont open idle or an exisiting py file
On Sat, Feb 1, 2014 at 7:51 PM, Terry Reedy tjre...@udel.edu wrote: I should have added 'to C itself', as the string terminator. Oh, right. Yes, in that sense \0 is special. It's still wrong that an incoming text string gets interpreted as code, but that's probably just a consequence of the jump from Python to Tcl. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: fseek In Compressed Files
Ayushi Dalmia ayushidalmia2...@gmail.com Wrote in message: The size of this file will be 10 GB. The version of Python I am using is 2.7.2. Yes, performance is an important issue. Then the only viable option is to extract the entire file and write it to a temp location. Perhaps as you extract it, you could also build a list of offsets, so the seeking by line number can be efficient. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
C++ to python for LED Matrix
Hey folks, So the last week or so I've been searching this site for information on how to control and program a LED Matrix (or a number of them) for a project. A few Topics have caught my eye, with me originally having in mind using a Maxim MAX7221 to control the matrix, but none more than Klaas's: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=41713. This was almost perfect for me, until I saw the code was in C++ and from the title all I know is Python. So after checking the code out and trying to figure how this language works I just couldn't break it down and Unfortunately I don't have a lot of time to learn C++ ( would be great if I could but I don't have that luxury right now). So if anyone is willing to check Klaas's topic and code and convert it into python that would be awesome, even if someone would explain how the code is working that would be great, oh and don't be scared to comment on ways of going about this project. Note: Hoping I could achieve something like this but with the Pi: http://www.youtube.com/watch?v=FzHT-L-7jIA Cheers! Lknott :-D -- https://mail.python.org/mailman/listinfo/python-list
piping with subprocess
I spent half a day trying to convert this bash script (on Mac) textutil -convert html $1 -stdout | pandoc -f html -t markdown -o $2 into Python using subprocess pipes. It works if I save the above into a shell script called convert.sh and then do subprocess.check_call([convert.sh, file, markdown_file]) where file and markdown_file are variables. But otherwise my piping attempts fail. Could someone show me how to pipe in subprocess. Yes, I've read the doc, especially http://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline But I'm a feeble hobbyist, not a computer scientist. Thanks RD -- https://mail.python.org/mailman/listinfo/python-list
Re: __init__ is the initialiser
On 1/31/14 10:42 PM, Steven D'Aprano wrote: On Fri, 31 Jan 2014 14:52:15 -0500, Ned Batchelder wrote: Why can't we call __init__ the constructor and __new__ the allocator? __new__ constructs the object, and __init__ initialises it. What's wrong with calling them the constructor and initialiser? Is this such a difficult concept that the average programmer can't learn it? I've met people who have difficulty with OOP principles, at least at first. But once you understand the idea of objects, it isn't that hard to understand the idea that: - first, the object has to be created, or constructed, or allocated if you will; - only then can it be initialised. Thus, two methods. __new__ constructs (creates, allocates) a new object; __init__ initialises it after the event. (In hindsight, it was probably a mistake for Python to define two create- an-object methods, although I expect it was deemed necessary for historical reasons. Most other languages make do with a single method, Objective-C being an exception with alloc and init methods.) Earlier in this post, you wrote: But that distinction [between __new__ and __init__] isn't useful in most programs. Well, I don't know about that. I guess it depends on what sort of objects you're creating. If you're creating immutable objects, then the distinction is vital. If you're subclassing from immutable built-ins, of which there are a few, the distinction may be important. If you're using the object-pool design pattern, the distinction is also vital. It's not *rare* to care about these things. The thing most people mean by constructor is the method that gets invoked right at the beginning of the object's lifetime, where you can add code to initialize it properly. That describes __init__. Most people. I presume you've done a statistically valid survey then *wink* It *better* describes __new__, because it is *not true* that __init__ gets invoked right at the beginning of the object's lifetime. Before __init__ is invoked, the object's lifetime has already begun, inside the call to __new__. Excluding metaclass shenanigans, the object lifetime goes: Prior to the object existing: - static method __new__ called on the class[1] - __new__ creates the object[2] === start of object lifetime Within the object's lifetime: - the rest of the __new__ method runs, which may perform arbitrarily complex manipulations of the object; - __new__ exits, returning the object - __init__ runs So __init__ does not occur *right at the beginning*, and it is completely legitimate to write your classes using only __new__. You must use __new__ for immutable objects, and you may use __new__ for mutable ones. __init__ may be used by convention, but it is entirely redundant. I do not buy the argument made by some people that Python ought to follow whatever (possibly inaccurate or misleading) terminology other languages use. Java and Ruby have the exact same argument passing conventions as Python, but one calls it call by value and the other call by reference, and neither is the same meaning of call by value/reference as used by Pascal, C, Visual Basic, or other languages. So which terminology should Python use? Both C++ and Haskell have functors, but they are completely different things. What Python calls a class method, Java calls a static method. We could go on for days, just listing differences in terminology. In Python circles, using constructor for __new__ and initialiser for __init__ are well-established. In the context of Python, they make good sense: __new__ creates (constructs) the object, and __init__ _init_ialises it. Missing the opportunity to link the method name __init__ to *initialise* would be a mistake. We can decry the fact that computer science has not standardised on a sensible set of names for concepts, but on the other hand since the semantics of languages differ slightly, it would be more confusing to try to force all languages to use the same words for slightly different concepts. The reality is, if you're coming to Python from another language, you're going to have to learn a whole lot of new stuff anyway, so having to learn a few language-specific terms is just a small incremental cost. And if you have no idea about other languages, then it is no harder to learn that __new__ / __init__ are the constructor/initialiser than it would be to learn that they are the allocator/constructor or preformulator/ postformulator. I care about using the right terminology that will cause the least amount of cognitive dissonance to users' understanding of Python, not whether they have to learn new terminology, and in the context of Python's object module, constructor and initialiser best describe what __new__ and __init__ do. My summary of our two views is this: I am trying to look at things from a typical programmer's point of view. The existence of __new__ is an advanced topic that many programmers never encounter. Taking a quick scan through some
Re: piping with subprocess
Rick Dooling wrote: I spent half a day trying to convert this bash script (on Mac) textutil -convert html $1 -stdout | pandoc -f html -t markdown -o $2 into Python using subprocess pipes. It works if I save the above into a shell script called convert.sh and then do subprocess.check_call([convert.sh, file, markdown_file]) where file and markdown_file are variables. But otherwise my piping attempts fail. It is always a good idea to post your best effort failed attempt, if only to give us an idea of your level of expertise. Could someone show me how to pipe in subprocess. Yes, I've read the doc, especially http://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline But I'm a feeble hobbyist, not a computer scientist. Try to convert the example from the above page output=`dmesg | grep hda` # becomes p1 = Popen([dmesg], stdout=PIPE) p2 = Popen([grep, hda], stdin=p1.stdout, stdout=PIPE) p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. output = p2.communicate()[0] to your usecase. Namely, replace [dmesg] -- [textutil, -convert, html, infile, -stdout] [grep, hda] -- [pandoc, -f, html, -t, marktown, -o, outfile] Don't forget to set infile = ... outfile = ... to filenames (with absolute paths, to avoid one source of error). If that doesn't work post the code you wrote along with the error messages. -- https://mail.python.org/mailman/listinfo/python-list
Re: piping with subprocess
Try this: from subprocess import check_output import sys check_output(textutil -convert html %s -stdout | pandoc -f html -t markdown -o %s % sys.argv[1:3], shell=True) On Sat, Feb 1, 2014 at 7:19 AM, Rick Dooling rpdool...@gmail.com wrote: I spent half a day trying to convert this bash script (on Mac) textutil -convert html $1 -stdout | pandoc -f html -t markdown -o $2 into Python using subprocess pipes. It works if I save the above into a shell script called convert.sh and then do subprocess.check_call([convert.sh, file, markdown_file]) where file and markdown_file are variables. But otherwise my piping attempts fail. Could someone show me how to pipe in subprocess. Yes, I've read the doc, especially http://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline But I'm a feeble hobbyist, not a computer scientist. Thanks RD -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: piping with subprocess
On Saturday, February 1, 2014 6:54:09 AM UTC-6, Peter Otten wrote: Rick Dooling wrote: I spent half a day trying to convert this bash script (on Mac) textutil -convert html $1 -stdout | pandoc -f html -t markdown -o $2 into Python using subprocess pipes. It works if I save the above into a shell script called convert.sh and then do subprocess.check_call([convert.sh, file, markdown_file]) where file and markdown_file are variables. But otherwise my piping attempts fail. It is always a good idea to post your best effort failed attempt, if only to give us an idea of your level of expertise. Could someone show me how to pipe in subprocess. Yes, I've read the doc, especially http://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline But I'm a feeble hobbyist, not a computer scientist. Try to convert the example from the above page output=`dmesg | grep hda` # becomes p1 = Popen([dmesg], stdout=PIPE) p2 = Popen([grep, hda], stdin=p1.stdout, stdout=PIPE) p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. output = p2.communicate()[0] to your usecase. Namely, replace [dmesg] -- [textutil, -convert, html, infile, -stdout] [grep, hda] -- [pandoc, -f, html, -t, marktown, -o, outfile] Don't forget to set infile = ... outfile = ... to filenames (with absolute paths, to avoid one source of error). If that doesn't work post the code you wrote along with the error messages. p1 = subprocess.Popen([textutil, -convert, html, file], stdout=subprocess.PIPE) p2 = subprocess.check_call([pandoc, -f, html, -t, markdown, -o, markdown_file], stdin=p1.stdout, stdout=subprocess.PIPE) p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. output = p2.communicate()[0] Errors Traceback (most recent call last): File /Users/me/Python/any2pandoc.py, line 70, in module convert_word_file(file, markdown_file) File /Users/me/Python/any2pandoc.py, line 59, in convert_word_file output = p2.communicate()[0] AttributeError: 'int' object has no attribute 'communicate' I get a markdown_file created but it's empty. Thanks, RD ps - Daniel's works fine but I still don't learn to pipe :) -- https://mail.python.org/mailman/listinfo/python-list
Re: piping with subprocess
On Saturday, February 1, 2014 7:54:34 AM UTC-6, Rick Dooling wrote: On Saturday, February 1, 2014 6:54:09 AM UTC-6, Peter Otten wrote: Rick Dooling wrote: I spent half a day trying to convert this bash script (on Mac) textutil -convert html $1 -stdout | pandoc -f html -t markdown -o $2 into Python using subprocess pipes. It works if I save the above into a shell script called convert.sh and then do subprocess.check_call([convert.sh, file, markdown_file]) where file and markdown_file are variables. But otherwise my piping attempts fail. It is always a good idea to post your best effort failed attempt, if only to give us an idea of your level of expertise. Could someone show me how to pipe in subprocess. Yes, I've read the doc, especially http://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline But I'm a feeble hobbyist, not a computer scientist. Try to convert the example from the above page output=`dmesg | grep hda` # becomes p1 = Popen([dmesg], stdout=PIPE) p2 = Popen([grep, hda], stdin=p1.stdout, stdout=PIPE) p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. output = p2.communicate()[0] to your usecase. Namely, replace [dmesg] -- [textutil, -convert, html, infile, -stdout] [grep, hda] -- [pandoc, -f, html, -t, marktown, -o, outfile] Don't forget to set infile = ... outfile = ... to filenames (with absolute paths, to avoid one source of error). If that doesn't work post the code you wrote along with the error messages. p1 = subprocess.Popen([textutil, -convert, html, file], stdout=subprocess.PIPE) p2 = subprocess.check_call([pandoc, -f, html, -t, markdown, -o, markdown_file], stdin=p1.stdout, stdout=subprocess.PIPE) p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. output = p2.communicate()[0] Errors Traceback (most recent call last): File /Users/me/Python/any2pandoc.py, line 70, in module convert_word_file(file, markdown_file) File /Users/me/Python/any2pandoc.py, line 59, in convert_word_file output = p2.communicate()[0] AttributeError: 'int' object has no attribute 'communicate' I get a markdown_file created but it's empty. Thanks, RD ps - Daniel's works fine but I still don't learn to pipe :) Okay, sorry. I fixed that obvious goof p1 = subprocess.Popen([textutil, -convert, html, file], stdout=subprocess.PIPE) p2 = subprocess.Popen([pandoc, -f, html, -t, markdown, -o, markdown_file], stdin=p1.stdout, stdout=subprocess.PIPE) p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. output = p2.communicate()[0] Now I get no errors, but I still get a blank markdown file. -- https://mail.python.org/mailman/listinfo/python-list
generator slides review
I'm giving a talk tomorrow @Fosdem about generators/iterators/iterables.. The slides are here (forgive the strange Chinese characters): https://dl.dropboxusercontent.com/u/3183120/talks/generators/index.html#3 and the code I'm using is: https://github.com/AndreaCrotti/generators/blob/master/code/generators.py and the tests: https://github.com/AndreaCrotti/generators/blob/master/code/test_generators.py If anyone has any feedback or want to point out I'm saying something stupid I'd love to hear it before tomorrow (or also later I might give this talk again). Thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: piping with subprocess
On 01/02/2014 13:54, Rick Dooling wrote: On Saturday, February 1, 2014 6:54:09 AM UTC-6, Peter Otten wrote: Rick Dooling wrote: I spent half a day trying to convert this bash script (on Mac) textutil -convert html $1 -stdout | pandoc -f html -t markdown -o $2 into Python using subprocess pipes. It works if I save the above into a shell script called convert.sh and then do subprocess.check_call([convert.sh, file, markdown_file]) where file and markdown_file are variables. But otherwise my piping attempts fail. It is always a good idea to post your best effort failed attempt, if only to give us an idea of your level of expertise. Could someone show me how to pipe in subprocess. Yes, I've read the doc, especially http://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline But I'm a feeble hobbyist, not a computer scientist. Try to convert the example from the above page output=`dmesg | grep hda` # becomes p1 = Popen([dmesg], stdout=PIPE) p2 = Popen([grep, hda], stdin=p1.stdout, stdout=PIPE) p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. output = p2.communicate()[0] to your usecase. Namely, replace [dmesg] -- [textutil, -convert, html, infile, -stdout] [grep, hda] -- [pandoc, -f, html, -t, marktown, -o, outfile] Don't forget to set infile = ... outfile = ... to filenames (with absolute paths, to avoid one source of error). If that doesn't work post the code you wrote along with the error messages. Would you please read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing the double line spacing above, thanks. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: __init__ is the initialiser
In article mailman.6275.1391257695.18130.python-l...@python.org, Ned Batchelder n...@nedbatchelder.com wrote: The existence of __new__ is an advanced topic that many programmers never encounter. Taking a quick scan through some large projects (Django, edX, SQLAlchemy, mako), the ratio of __new__ implementations to __init__ implementations ranges from 0% to 1.5%, which falls into rare territory for me. From our own codebase: $ find . -name '*.py' | xargs grep 'def.*__new__' | wc -l 1 $ find . -name '*.py' | xargs grep 'def.*__init__' | wc -l 228 Doing the same searches over all the .py files in our virtualenv, I get 2830 (__init__) vs. 50 (__new__). -- https://mail.python.org/mailman/listinfo/python-list
Re: __init__ is the initialiser
On 01/02/2014 14:40, Roy Smith wrote: In article mailman.6275.1391257695.18130.python-l...@python.org, Ned Batchelder n...@nedbatchelder.com wrote: The existence of __new__ is an advanced topic that many programmers never encounter. Taking a quick scan through some large projects (Django, edX, SQLAlchemy, mako), the ratio of __new__ implementations to __init__ implementations ranges from 0% to 1.5%, which falls into rare territory for me. From our own codebase: $ find . -name '*.py' | xargs grep 'def.*__new__' | wc -l 1 $ find . -name '*.py' | xargs grep 'def.*__init__' | wc -l 228 Doing the same searches over all the .py files in our virtualenv, I get 2830 (__init__) vs. 50 (__new__). You could remove all 228 __init__ and still get your code to work by scattering object attributes anywhere you like, something I believe you can't do in C++/Java. I doubt that you could remove the single __new__ and get your code to work. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Python prime numbers
Hi i'm new in programming and in python and i have an assignment that i cant complete. I have to Write a Python program to compute and print the first 200 prime numbers. The output must be formatted with a title and the prime numbers must be printed in 5 properly aligned columns . I have used this code so far : numprimes = raw_input('Prime Numbers ') count = 0 potentialprime = 2 def primetest(potentialprime): divisor = 2 while divisor = potentialprime: if potentialprime == 2: return True elif potentialprime % divisor == 0: return False break while potentialprime % divisor != 0: if potentialprime - divisor 1: divisor += 1 else: return True while count int(numprimes): if primetest(potentialprime) == True: print potentialprime count += 1 potentialprime += 1 else: potentialprime += 1 but i get the result in a single column . How can i get it in 5 rows? Can someone help please -- https://mail.python.org/mailman/listinfo/python-list
Re: piping with subprocess
On Saturday, February 1, 2014 8:00:59 AM UTC-6, Rick Dooling wrote: On Saturday, February 1, 2014 7:54:34 AM UTC-6, Rick Dooling wrote: On Saturday, February 1, 2014 6:54:09 AM UTC-6, Peter Otten wrote: Rick Dooling wrote: I spent half a day trying to convert this bash script (on Mac) textutil -convert html $1 -stdout | pandoc -f html -t markdown -o $2 into Python using subprocess pipes. It works if I save the above into a shell script called convert.sh and then do subprocess.check_call([convert.sh, file, markdown_file]) where file and markdown_file are variables. But otherwise my piping attempts fail. It is always a good idea to post your best effort failed attempt, if only to give us an idea of your level of expertise. Could someone show me how to pipe in subprocess. Yes, I've read the doc, especially http://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline But I'm a feeble hobbyist, not a computer scientist. Try to convert the example from the above page output=`dmesg | grep hda` # becomes p1 = Popen([dmesg], stdout=PIPE) p2 = Popen([grep, hda], stdin=p1.stdout, stdout=PIPE) p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. output = p2.communicate()[0] to your usecase. Namely, replace [dmesg] -- [textutil, -convert, html, infile, -stdout] [grep, hda] -- [pandoc, -f, html, -t, marktown, -o outfile] Don't forget to set infile = ... outfile = ... to filenames (with absolute paths, to avoid one source of error). If that doesn't work post the code you wrote along with the error messages. p1 = subprocess.Popen([textutil, -convert, html, file], stdout=subprocess.PIPE) p2 = subprocess.check_call([pandoc, -f, html, -t, markdown, -o, markdown_file], stdin=p1.stdout, stdout=subprocess.PIPE) p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. output = p2.communicate()[0] Errors Traceback (most recent call last): File /Users/me/Python/any2pandoc.py, line 70, in module convert_word_file(file, markdown_file) File /Users/me/Python/any2pandoc.py, line 59, in convert_word_file output = p2.communicate()[0] AttributeError: 'int' object has no attribute 'communicate' I get a markdown_file created but it's empty. Thanks, RD ps - Daniel's works fine but I still don't learn to pipe :) Okay, sorry. I fixed that obvious goof p1 = subprocess.Popen([textutil, -convert, html, file], stdout=subprocess.PIPE) p2 = subprocess.Popen([pandoc, -f, html, -t, markdown, -o, markdown_file], stdin=p1.stdout, stdout=subprocess.PIPE) p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. output = p2.communicate()[0] Now I get no errors, but I still get a blank markdown file. Okay, blank lines removed. Apologies. I didn't know Google inserted them. RD -- https://mail.python.org/mailman/listinfo/python-list
Re: Python prime numbers
On Saturday, February 1, 2014, Panagiotis Anastasiou panas...@gmail.com wrote: Hi i'm new in programming and in python and i have an assignment that i cant complete. I have to Write a Python program to compute and print the first 200 prime numbers. The output must be formatted with a title and the prime numbers must be printed in 5 properly aligned columns . I have used this code so far : numprimes = raw_input('Prime Numbers ') count = 0 potentialprime = 2 def primetest(potentialprime): divisor = 2 while divisor = potentialprime: if potentialprime == 2: return True elif potentialprime % divisor == 0: return False break while potentialprime % divisor != 0: if potentialprime - divisor 1: divisor += 1 else: return True while count int(numprimes): if primetest(potentialprime) == True: print potentialprime count += 1 potentialprime += 1 else: potentialprime += 1 but i get the result in a single column . How can i get it in 5 rows? Can someone help please If you put a comma at the end of the print statement it will suppress the newline. -- https://mail.python.org/mailman/listinfo/python-list
Re: piping with subprocess
On 01/02/2014 15:35, Rick Dooling wrote: Okay, blank lines removed. Apologies. I didn't know Google inserted them. RD No problem, the whole snag is people don't know about this flaw in this tool until they're told about it. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: __init__ is the initialiser
On 01/02/2014 14:40, Roy Smith wrote: In article mailman.6275.1391257695.18130.python-l...@python.org, Ned Batchelder n...@nedbatchelder.com wrote: The existence of __new__ is an advanced topic that many programmers never encounter. Taking a quick scan through some large projects (Django, edX, SQLAlchemy, mako), the ratio of __new__ implementations to __init__ implementations ranges from 0% to 1.5%, which falls into rare territory for me. From our own codebase: $ find . -name '*.py' | xargs grep 'def.*__new__' | wc -l 1 $ find . -name '*.py' | xargs grep 'def.*__init__' | wc -l 228 Doing the same searches over all the .py files in our virtualenv, I get 2830 (__init__) vs. 50 (__new__). In article mailman.6280.1391267257.18130.python-l...@python.org, Mark Lawrence breamore...@yahoo.co.uk wrote: You could remove all 228 __init__ and still get your code to work by scattering object attributes anywhere you like, something I believe you can't do in C++/Java. Why not? Here's a simple C++ program which uses a constructor: #include stdio.h class Foo { public: int i; Foo() : i(42) {} }; int main(int, char**) { Foo foo; printf(foo.i = %d\n, foo.i); } If I wanted to, I could remove the constructor and still get my code to work by scattering object attributes anywhere I like: #include stdio.h class Foo { public: int i; }; int main(int, char**) { Foo foo; foo.i = 42; printf(foo.i = %d\n, foo.i); } I doubt that you could remove the single __new__ and get your code to work. Perhaps. Looking at our own code, the one place we use __new__ is in a metaclass, which I think pretty well reinforces Ned's assertion that __new__ is an advanced topic. -- https://mail.python.org/mailman/listinfo/python-list
Re: generator slides review
On Saturday, February 1, 2014 6:12:28 AM UTC-8, andrea crotti wrote: I'm giving a talk tomorrow @Fosdem about generators/iterators/iterables.. The slides are here (forgive the strange Chinese characters): https://dl.dropboxusercontent.com/u/3183120/talks/generators/index.html#3 and the code I'm using is: https://github.com/AndreaCrotti/generators/blob/master/code/generators.py and the tests: https://github.com/AndreaCrotti/generators/blob/master/code/test_generators.py If anyone has any feedback or want to point out I'm saying something stupid I'd love to hear it before tomorrow (or also later I might give this talk again). Thanks My 2 cents: slide 4: [i*2 for i in range(10)] slide 9: while True: try: it = next(g) body(it) except StopIteration: break slide 21: from itertools import count, ifilterfalse def divided_by(p): return lambda n: n % p == 0 def primes(): nums = count(2) while True: p = next(nums) yield p nums = ifilterfalse(divided_by(p), nums) Another resource you can point to is http://www.dabeaz.com/generators/ Good luck. -- https://mail.python.org/mailman/listinfo/python-list
Re: piping with subprocess
Rick Dooling wrote: On Saturday, February 1, 2014 6:54:09 AM UTC-6, Peter Otten wrote: Try to convert the example from the above page output=`dmesg | grep hda` # becomes p1 = Popen([dmesg], stdout=PIPE) p2 = Popen([grep, hda], stdin=p1.stdout, stdout=PIPE) p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. output = p2.communicate()[0] to your usecase. Namely, replace [dmesg] -- [textutil, -convert, html, infile, -stdout] [grep, hda] -- [pandoc, -f, html, -t, marktown, -o, outfile] Don't forget to set infile = ... outfile = ... to filenames (with absolute paths, to avoid one source of error). If that doesn't work post the code you wrote along with the error messages. p1 = subprocess.Popen([textutil, -convert, html, file], stdout=subprocess.PIPE) p2 = subprocess.check_call([pandoc, -f, html, -t, markdown, -o, markdown_file], stdin=p1.stdout, stdout=subprocess.PIPE) p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. output = p2.communicate()[0] Errors Traceback (most recent call last): File /Users/me/Python/any2pandoc.py, line 70, in module convert_word_file(file, markdown_file) File /Users/me/Python/any2pandoc.py, line 59, in convert_word_file output = p2.communicate()[0] AttributeError: 'int' object has no attribute 'communicate' I get a markdown_file created but it's empty. Well, you replaced the Popen() from the example with a check_call() which uses a Popen instance internally, but does not expose it. I recommend that you stick as closely to the example as possible until you have a working baseline version. I'd try textutil = subprocess.Popen( [textutil, -convert, html, file], stdout=subprocess.PIPE) pandoc = subprocess.Popen( [pandoc, -f, html, -t, markdown, -o, markdown_file], stdin=textutil.stdout) textutil.stdout.close() pandoc.communicate() -- https://mail.python.org/mailman/listinfo/python-list
Chris Miles? TGBooleanFormWidget?
trying to install zoner. Needs http://www.psychofx.com/TGBooleanFormWidget/http://www.psychofx.com/TGBooleanFormWidget/ but that's giving 502 Bad Gateway can't find TGBooleanFormWidget anywhere else. Suggestions? Thanks Len -- https://mail.python.org/mailman/listinfo/python-list
Re: Help with some python homework...
On Fri, 31 Jan 2014 18:14:31 -0700, Scott W Dunning wrote: little different from a few things you guys had mentioned. For one, I got the correct time by calculating the number of time run and converting that into seconds then back out to hr:mn:sc. I didn’t calculate from midnight. SECONDS = 1 MINUTES = 60 * SECONDS HOURS = 60 * MINUTES time_left_house = 6 * HOURS + 52 * MINUTES This does actually calculate the time in seconds since midnight that you left the house miles_run_easy_pace = 2 * (8 * MINUTES + 15 * SECONDS) miles_run_fast_pace = 3 * (7 * MINUTES + 12 * SECONDS) time_returned_home = miles_run_easy_pace + miles_run_fast_pace + time_left_house And this calculates the time in seconds since midnight that you returned home So although you don't realise it, you are actually working in seconds since midnight, and then converting seconds back into hours, minutes and seconds. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Tkinter widgets into classes.
I was wandering if I could dynamically change my GUI and after a few searches on Google found the grid_remove() function. What I'm wandering now is if there is a way to group a lot of widgets up into one, and then use the one grid_remove function which will remove them all. Is it possible to do this in a class like this? class group1: label1=Label(text=Upon clicking the button).grid(row=0,column=0) label2=Label(text=The menu will dynamically change).grid(row=1,column=0) group1.grid_remove() -- https://mail.python.org/mailman/listinfo/python-list
Re: Help with some python homework...
On Fri, 31 Jan 2014 22:18:34 -0700, Scott W Dunning wrote: Any chance you guys could help with another question I have? Below is a code to a different problem. The only thing I don’t understand is why when calculating the 'discounted price’ you have to subtract 1? Thanks again guys! price_per_book = 24.95 discount = .40 quantity = 60 discounted_price = (1-discount) * price_per_book shipping = 3.0 + (60 - 1) * .75 total_price = 60 * discounted_price + shipping print total_price, 'Total price' You subtract 1 from the shipping price (which should be quantity - 1) to allow for the fact that the first book costs 3.0 snargles to ship, and extra books in the same shipment cost 0.75 snargles each. So if the quantity is greater than one, the shipping cost is 3 snargles for the first book plus 0.75 snargles times (quantity minus one) The discounted price needs to be the cost, not the discount. If the discount is 0.4 (or 40%), then the cost is 0.6 (or 60%) of the list price. You are trying to calculate the cost, not the discount. list_price = discounted_price + discount_amount 1.0 * list_price = 0.6 * list_price + 0.4 * list_price Hence: discounted_price = list_price - discount_amount 0.6 * list_price = 1.0 * list_price - 0.4 * list_price so discounted_price = ( 1.0 - 0.4 ) * list_price where 0.4 is the decimal fraction of the discount -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter widgets into classes.
On Saturday, 1 February 2014 19:43:18 UTC, Lewis Wood wrote: I was wandering if I could dynamically change my GUI and after a few searches on Google found the grid_remove() function. What I'm wandering now is if there is a way to group a lot of widgets up into one, and then use the one grid_remove function which will remove them all. Is it possible to do this in a class like this? class group1: label1=Label(text=Upon clicking the button).grid(row=0,column=0) label2=Label(text=The menu will dynamically change).grid(row=1,column=0) group1.grid_remove() -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter widgets into classes.
You become less of a a faget and stop sucking granni tranni pussi dis shud help u lewl -- https://mail.python.org/mailman/listinfo/python-list
Re: __init__ is the initialiser
On 1 February 2014 23:28, Ned Batchelder n...@nedbatchelder.com wrote: You are looking at things from an accurate-down-to-the-last-footnote detailed point of view (and have provided some footnotes!). That's a very valuable and important point of view. It's just not how most programmers approach the language. This is the *language reference* that is being discussed. It documents the intended semantics of the language. We most certainly should strive to ensure that it is accurate-down-to-the-last-footnote - any difference between the reference documentation and the implementation is a bug in either the documentation or the implementation. Tim Delaney -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter widgets into classes.
Oh and another question, say I make another window in the program itself using this: def secondwindow(): root2=Tk() root2.mainloop() Would it be possible for me to use some code which would return True if one of these windows is currently up, or return False if the window is not up? -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter widgets into classes.
Lewis Wood fluttershy...@gmail.com Wrote in message: Oh and another question, say I make another window in the program itself using this: def secondwindow(): root2=Tk() root2.mainloop() Would it be possible for me to use some code which would return True if one of these windows is currently up, or return False if the window is not up? No need. Only one at a time can be running, and you won't return from this function till it's done. To put it another way, you only want one mainloop in your code. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re:Python prime numbers
Panagiotis Anastasiou panas...@gmail.com Wrote in message: Hi i'm new in programming and in python and i have an assignment that i cant complete. I have to Write a Python program to compute and print the first 200 prime numbers. The output must be formatted with a title and the prime numbers must be printed in 5 properly aligned columns . I have used this code so far : numprimes = raw_input('Prime Numbers ') count = 0 potentialprime = 2 def primetest(potentialprime): divisor = 2 while divisor = potentialprime: if potentialprime == 2: return True elif potentialprime % divisor == 0: return False break while potentialprime % divisor != 0: if potentialprime - divisor 1: divisor += 1 else: return True while count int(numprimes): if primetest(potentialprime) == True: print potentialprime count += 1 potentialprime += 1 else: potentialprime += 1 but i get the result in a single column . How can i get it in 5 rows? Can someone help please -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re:Python prime numbers
Panagiotis Anastasiou panas...@gmail.com Wrote in message: Hi i'm new in programming and in python and i have an assignment that i cant complete. I have to Write a Python program to compute and print the first 200 prime numbers. The output must be formatted with a title and the prime numbers must be printed in 5 properly aligned columns . I have used this code so far : numprimes = raw_input('Prime Numbers ') count = 0 potentialprime = 2 def primetest(potentialprime): divisor = 2 while divisor = potentialprime: if potentialprime == 2: return True elif potentialprime % divisor == 0: return False break while potentialprime % divisor != 0: if potentialprime - divisor 1: divisor += 1 else: return True There are several things wrong with this function, and it's redundant enough that maybe none of them matter. I'd test it carefully. while count int(numprimes): if primetest(potentialprime) == True: print potentialprime count += 1 potentialprime += 1 else: potentialprime += 1 but i get the result in a single column . How can i get it in 5 rows? Can someone help please As has been pointed out, you can use a trailing comma to suppress the implied newline for each print. Then you can add it back in every five items by checking count. But you have a bigger problem, lining up the columns. Try using the string modulus operator, or 'format'. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter widgets into classes.
On Saturday, 1 February 2014 21:52:51 UTC, Dave Angel wrote: Lewis Wood fluttershy...@gmail.com Wrote in message: Oh and another question, say I make another window in the program itself using this: def secondwindow(): root2=Tk() root2.mainloop() Would it be possible for me to use some code which would return True if one of these windows is currently up, or return False if the window is not up? No need. Only one at a time can be running, and you won't return from this function till it's done. To put it another way, you only want one mainloop in your code. -- DaveA But I can click the button Multiple times and it will create multiple windows? -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter widgets into classes.
Lewis Wood fluttershy...@gmail.com Wrote in message: (deleting doublespaced googlegroups trash) To put it another way, you only want one mainloop in your code. -- DaveA But I can click the button Multiple times and it will create multiple windows? Not using the function you showed. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter widgets into classes.
On Saturday, 1 February 2014 22:26:17 UTC, Dave Angel wrote: Lewis Wood fluttershy...@gmail.com Wrote in message: (deleting doublespaced googlegroups trash) To put it another way, you only want one mainloop in your code. -- DaveA But I can click the button Multiple times and it will create multiple windows? Not using the function you showed. -- DaveA It does, this is the whole code: from tkinter import * root=Tk() root.title(Second Root Testing) def secondwindow(): root2=Tk() root2.mainloop() button1=Button(root,text=Root2,command=secondwindow).grid(row=0,column=0) root.mainloop() -- https://mail.python.org/mailman/listinfo/python-list
Re: Python prime numbers
On Sat, 1 Feb 2014 07:33:47 -0800 (PST), Panagiotis Anastasiou wrote: Hi i'm new in programming and in python and i have an assignment that i cant complete. I have to Write a Python program to compute and print the first 200 prime numbers. The output must be formatted with a title and the prime numbers must be printed in 5 properly aligned columns . I have used this code so far : Hi, try out this code: for i in range(200): print '{0:5}'.format(i), if (i-4) % 5 == 0: print Or maybe, if it's still unclear, try execute these lines: print 'Hello {0}'.format('world') print '|{0:30}|'.format('right') print '|{0:30}|'.format('left') print '|{0:^30}|'.format('center') print '|{0:16}|'.format('right'), print '|{0:16}|'.format('left'), print '|{0:^16}|'.format('center') But still, it might be hard to implement this printing for..in loop while you're verifying primes (in another loop), so maybe think about getting first 200 primes in while loop like you do (and only storing them in a list), and then printing them out from this list in external for..in loop. Now, to your primetest() function. It may be good for small primes, but try to verify with it, if 832475734579 is a prime. :) def primetest(potentialprime): divisor = 2 while divisor = potentialprime: First of all, see that you rarely use this loop - you check this condition at most two times. You end up for good in the second while loop. if potentialprime == 2: return True elif potentialprime % divisor == 0: return False break 'break' after return is redundant - never executes while potentialprime % divisor != 0: if potentialprime - divisor 1: divisor += 1 else: return True So, this is your main loop. Very inefficient. Think about that: a) do you really have to check divisors up to the potentialprime? Maybe there is a point, where you may say, that you've checked all possibilities? Remember that a * b = b * a b) do you really have to check every divisor? I mean, increasing it by 1 in every step? -- Best regards, Wiktor Matuszewski 'py{}@wu{}em.pl'.format('wkm', 'ka') -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter widgets into classes.
On Sun, 02 Feb 2014 00:07:00 +0100, Lewis Wood fluttershy...@gmail.com wrote: On Saturday, 1 February 2014 22:26:17 UTC, Dave Angel wrote: Lewis Wood fluttershy...@gmail.com Wrote in message: (snip) DaveA It does, this is the whole code: from tkinter import * root=Tk() root.title(Second Root Testing) def secondwindow(): root2=Tk() root2.mainloop() this may seem to work, but you're starting a new event loop here instead of using the current one. I think you want to create another TopLevel() window here, not a new Tk instance. button1=Button(root,text=Root2,command=secondwindow).grid(row=0,column=0) Note that if you want to be able to actually use the button1 symbol, you have to break this statement up: button1=Button(root,text=Root2,command=secondwindow) button1.grid(row=0,column=0) You can't shortcut this because grid() returns None. root.mainloop() -- Vriendelijke groeten / Kind regards, Albert Visser Using Opera's mail client: http://www.opera.com/mail/ -- https://mail.python.org/mailman/listinfo/python-list
Re: generator slides review
On 2/1/2014 9:12 AM, andrea crotti wrote: I'm giving a talk tomorrow @Fosdem about generators/iterators/iterables.. The slides are here (forgive the strange Chinese characters): https://dl.dropboxusercontent.com/u/3183120/talks/generators/index.html#3 and the code I'm using is: https://github.com/AndreaCrotti/generators/blob/master/code/generators.py and the tests: https://github.com/AndreaCrotti/generators/blob/master/code/test_generators.py If anyone has any feedback or want to point out I'm saying something stupid I'd love to hear it before tomorrow (or also later I might give this talk again). Comments: The use is assert in the first slide seem bad in a couple of different respects. The use of 'gen_even' before it is defined. A generator expression evaluates (better than 'yields') to a generator, not just an iterator. The definition of 'generator' copies the wrong and confused glossary entry. Generator functions return generators, which are iterators with extra behavior. I would leave out For loop(2). The old pseudo-getitem iterator protocol is seldom explicitly used any more, in the say you showed. In 'Even numbers', I have no idea what the complication of next_even() is about. 'Lazyness drawbacks' overflow_list is bizarre and useless. overflow_gen is bizarre and buggy. If you are intentionally writing buggy code to make a point, label it as such on the slide. Iterators just produce values. Generators can consume as well as produce values, which is why they can act as both iterators and coroutines. @monocle -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter widgets into classes.
Idle, which used tkinter, runs multiple windows in one process with one event loop. There is no reason I know of to run multiple event loops in one process, and if you do, the results will not be documented and might vary between runs or between different systems. Idle can also be run multiple times in multiple processes, each with its own event loop. But there is seldom a reason to do that with the same version. On the other hand, I routinely have more than one version running in order to test code with multiple versions. I can even have the same file open in multiple versions. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: __init__ is the initialiser
On Sun, 02 Feb 2014 07:09:14 +1100, Tim Delaney wrote: On 1 February 2014 23:28, Ned Batchelder n...@nedbatchelder.com wrote: You are looking at things from an accurate-down-to-the-last-footnote detailed point of view (and have provided some footnotes!). That's a very valuable and important point of view. It's just not how most programmers approach the language. This is the *language reference* that is being discussed. It documents the intended semantics of the language. We most certainly should strive to ensure that it is accurate-down-to-the-last-footnote - any difference between the reference documentation and the implementation is a bug in either the documentation or the implementation. +1 -- Steven -- https://mail.python.org/mailman/listinfo/python-list
mapping objects
Hello, I want to learn more about ORMs so I stumbled upon, SqlAlchemy. If i had a JSON document (or XML, CSV, etc.._) is it possible to convert it to a SQLAlchemy objects? I like the ability to query/filter ( http://docs.sqlalchemy.org/en/rel_0_9/orm/tutorial.html#common-filter-operators) the data assuming I set up the proper schema. Also, is this a valid way to use an ORM suite? -- --- Get your facts first, then you can distort them as you please.-- -- https://mail.python.org/mailman/listinfo/python-list
Re: C++ to python for LED Matrix
Yes you could use Python for this sort of thing. The link you posted is just using a kernel spi driver that Python can write to just as well as C++ can (via it's /dev/spidev0.0 file). There is a python library that can talk to SPI in Python on the pi: http://www.100randomtasks.com/simple-spi-on-raspberry-pi You still need to know some low-level stuff though. Like hexadecimal, binary bit-wise operations, etc. Definitely talk to people on the Raspberry Pi forum. They are doing this stuff frequently. Also don't be afraid of C. Learn it. You'll be glad. The code you linked to looks more complicated than it really is. The ioctl stuff looks complicated. But everything else is easy. If it weren't for the ioctl stuff, which I know can be translated to Python directly but I'm not quite sure how at the moment, the rest of that code could be transliterated into Python in very short order. The trick is to make the code more pythonic, and use classes when appropriate to encapsulate things. I'd make a class that talks to SPI, for example. It would open the file, set the ioctls, and then provide a basic interface for writing to the bus. Then from that I'd build another class that implements the matrix abstraction, using SPI class for the low-level stuff. -- https://mail.python.org/mailman/listinfo/python-list
Re: __init__ is the initialiser
Ned Batchelder n...@nedbatchelder.com writes: My summary of our two views is this: I am trying to look at things from a typical programmer's point of view. Do you think the typical programmer will be looking in the language reference? I don't. The existence of __new__ is an advanced topic that many programmers never encounter. But when they do, the language reference had better be very clear on the purpose of “__init__” and “__new__”. You are looking at things from an accurate-down-to-the-last-footnote detailed point of view (and have provided some footnotes!). That's a very valuable and important point of view. It's just not how most programmers approach the language. Won't most programmers approach the language through (a) some example code, (b) the tutorial, (c) the library reference? Those are appropriate places for helpful simplifications and elisions. We are also both trying to reduce cognitive dissonance, but again, you are addressing language mavens who understand the footnotes, and I am trying to help the in-the-trenches people who have never encountered __new__ and are wondering why people are using funny words for the code they are writing. Then I think your attempt to sacrifice precise terminology in the langauge reference is misplaced. The in-the-trenches people won't see it; and, when they go looking for it, they're likely to be wanting exact language-maven-directed specifications. Finding names for things is hard, and it's impossible to please both ends of this spectrum. Very true. That's why we have different documents for different audiences. But yes, the terminology needs to hold up for both ends of the spectrum, and naming is difficult. -- \ “If nature has made any one thing less susceptible than all | `\others of exclusive property, it is the action of the thinking | _o__) power called an idea” —Thomas Jefferson | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Help with some python homework...
Yeah you’re right I didn’t even notice that. For some reason I just added the 60 instead of using quantity which had been defined. On Feb 1, 2014, at 8:50 AM, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Fri, 31 Jan 2014 22:18:34 -0700, Scott W Dunning swdunn...@cox.net declaimed the following: Any chance you guys could help with another question I have? Below is a code to a different problem. The only thing I don’t understand is why when calculating the 'discounted price’ you have to subtract 1? Thanks again guys! Because the discount rate you have is the amount taken OFF the price. But you need the price AFTER removing the discount amount 100% (1.0) - 40% (0.4) discount = 60% (0.6) final price price_per_book = 24.95 discount = .40 quantity = 60 discounted_price = (1-discount) * price_per_book shipping = 3.0 + (60 - 1) * .75 total_price = 60 * discounted_price + shipping print total_price, 'Total price' You defined quantity but then never used it in the shipping and total_price lines. -- Wulfraed Dennis Lee Bieber AF6VN wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/ -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: mapping objects
On 01Feb2014 20:46, Rita rmorgan...@gmail.com wrote: I want to learn more about ORMs so I stumbled upon, SqlAlchemy. If i had a JSON document (or XML, CSV, etc.._) is it possible to convert it to a SQLAlchemy objects? I like the ability to query/filter ( http://docs.sqlalchemy.org/en/rel_0_9/orm/tutorial.html#common-filter-operators) the data assuming I set up the proper schema. Well, not as directly as you might hope. As I recall, SQLAlchemy ORMs provide an easy way to make objects representing database entities and whose methods automatically drive the necessary SQL actions to manipulate them. On that basis, you won't get anywhere without loading up the JSON/XML/etc, parsing it for relevant information (trivial with CSV, less so for structured data like JSON or XML), and storing it in a database. To which you then point SQLAlchemy. So you're already doing the fiddly bit just to get stuff into the database. The neat filter operations you cite are actually done by special methods on the objects representing tables and columns. For example, User.name == None is done via the __eq__ method of User.name. And they return strings: bare SQL. The beauty of this is that one can write almost idiomatic python, and SQLA will generate correct SQL in the right dialect for the database backend, and with all the values correctly escaped. However, it does presume you _already_ have a backend that can be queried with SQL. Also, is this a valid way to use an ORM suite? Well, in principle sure. But SQLA won't do it for you directly. It really is for data already stored in an SQL queriable database. Your point about using SQLA's filter operations is right, _provided_ you have already loaded the original data into a database with the right schema. If you've done that work, then SQLA may well serve you well from that point on. Cheers, -- Cameron Simpson c...@zip.com.au We knew Army cadets were involved because they cut through two fences to get to the goats, and 15 feet away there was an unlocked gate. - a director of sports information in the Navy, regarding the theft of some mascots from the Naval Academy by Army rivals -- https://mail.python.org/mailman/listinfo/python-list
[issue12915] Add inspect.locate and inspect.resolve
Vinay Sajip added the comment: Another question to consider: is inspect the best place for this? I don't think it is, because (a) It's not really an inspection facility (b) Importing inspect to get this functionality would pull in lots of stuff which wouldn't be used in the typical use case. I think it makes more sense for it to be in importlib. Accordingly adding Brett to nosy, for his thoughts. -- nosy: +brett.cannon ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12915 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20471] test_signature_on_class() of test_inspect fails on AMD64 FreeBSD 9.0 3.x buildbot
Changes by Yury Selivanov yselivanov...@gmail.com: -- nosy: +yselivanov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20471 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20473] inspect.Signature no longer handles builtin classes correctly
Yury Selivanov added the comment: OK, I'll take a look tomorrow. Don't think it's related to #20471 though, as in there, if fails to find a signature for the 'builtin.object' (but I may be wrong). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20473 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18622] reset_mock on mock created by mock_open causes infinite recursion
Changes by Berker Peksag berker.pek...@gmail.com: -- nosy: +berker.peksag ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18622 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20472] test_write_pty() of test_asyncio fails on x86 Tiger 3.x buildbot
Ned Deily added the comment: FYI, besides 10.4 (Tiger), the test also fails on OS X 10.5 but appears to pass on 10.6 and later releases. -- nosy: +ned.deily ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20472 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20473] inspect.Signature no longer handles builtin classes correctly
Yury Selivanov added the comment: OK, there was no unit-test for this... looking into the problem, the first questing is: why is __text_signature__ is on the '_pickle.Pickler' object, not on '_pickle.Pickler.__init__'? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20473 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20474] test_socket failures on OS X due to fixed expected failures
New submission from Ned Deily: Three send timeout test cases in test_socket were changed by a4e4facad164 for Issue12958 to be expected failures on OS X because of observed failures on the OS X buildbots running OS X 10.6 (Snow Leopard) and earlier. testInterruptedSendTimeout (test.test_socket.InterruptedSendTimeoutTest) ... unexpected success testInterruptedSendmsgTimeout (test.test_socket.InterruptedSendTimeoutTest) ... unexpected success testInterruptedSendtoTimeout (test.test_socket.InterruptedSendTimeoutTest) ... unexpected success It seems that the platform bugs causing the failures were fixed in OS X 10.7 so that the expected failures no longer fail. However, the change in behavior had not been noticed because, until the recent change to unittest in Issue20165, unittest did not fail when there were unexpected successes. Now it does fail, causing test_socket to fail on OS X 10.7+ for 3.4. On 3.3 the unexpected success failures are silently skipped. The attached patch changes the test cases to be skipped for OS X versions prior to 10.7 rather than to always expect failure on OS X. -- components: Tests messages: 209882 nosy: larry, ncoghlan, ned.deily priority: high severity: normal stage: patch review status: open title: test_socket failures on OS X due to fixed expected failures versions: Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20474 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20474] test_socket failures on OS X due to fixed expected failures
Changes by Ned Deily n...@acm.org: -- keywords: +patch Added file: http://bugs.python.org/file33842/issue20474.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20474 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20474] test_socket failures on OS X due to fixed expected failures
Changes by Ned Deily n...@acm.org: Added file: http://bugs.python.org/file33843/issue20474.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20474 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20474] test_socket failures on OS X due to fixed expected failures
Changes by Ned Deily n...@acm.org: Removed file: http://bugs.python.org/file33842/issue20474.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20474 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20473] inspect.Signature no longer handles builtin classes correctly
Larry Hastings added the comment: Because slots like tp_init and tp_call don't have docstrings. So it has to go in the class's docstring. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20473 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12958] test_socket failures on Mac OS X
Ned Deily added the comment: FYI, the OS X platform bugs causing the three send timeout test failures were fixed in OS X 10.7 causing those test cases to have previously silently skipped unexpected successes. See Issue20474 for more details. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12958 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20471] test_signature_on_class() of test_inspect fails on AMD64 FreeBSD 9.0 3.x buildbot
Stefan Krah added the comment: The build is --without-doc-strings. That should do the trick. -- nosy: +skrah ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20471 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20473] inspect.Signature no longer handles builtin classes correctly
Larry Hastings added the comment: I meant to say slots like tp_new and tp_init. But fwiw it's true of tp_call too. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20473 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20473] inspect.Signature no longer handles builtin classes correctly
Larry Hastings added the comment: And, I don't see how your changes to inspect.py could have caused the failures on the buildbot either. But, then, I don't see how *anything* could cause the failures on the buildbot. And your changes to inspect.py happened at (I think) roughly the same time. Correlation isn't causation, but it's all I have to go on right now. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20473 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20471] test_signature_on_class() of test_inspect fails on AMD64 FreeBSD 9.0 3.x buildbot
Larry Hastings added the comment: Good thinking! I don't know when I can get to it though, maybe Sunday. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20471 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20471] test_signature_on_class() of test_inspect fails on AMD64 FreeBSD 9.0 3.x buildbot
Stefan Krah added the comment: I think you just need to use the @requires_docstrings decorator for the test. -- To me the failure looks expected if there aren't any docstrings. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20471 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20473] inspect.Signature no longer handles builtin classes correctly
Larry Hastings added the comment: Stefan Krah suggests that the failure in 20473 is because that platform builds without docstrings, and the test requires them. So that should be an easy fix. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20473 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20456] Argument Clinic rollup patch, 2014/01/31
Vajrasky Kok added the comment: The converters argument in command line is still broken. [sky@localhost cpython3.4]$ hg pull -u pulling from http://hg.python.org/cpython searching for changes no changes found [sky@localhost cpython3.4]$ ./python Tools/clinic/clinic.py --converters Legacy converters: Traceback (most recent call last): File Tools/clinic/clinic.py, line 4131, in module sys.exit(main(sys.argv[1:])) File Tools/clinic/clinic.py, line 4063, in main print('' + ' '.join(c for c in legacy if c[0].isupper())) File Tools/clinic/clinic.py, line 4063, in genexpr print('' + ' '.join(c for c in legacy if c[0].isupper())) IndexError: string index out of range Unit test for exercising Tools/clinic/clinic.py using assert_python_ok would be good, but that deserves a dedicated ticket. Here is the patch to fix the bug. -- nosy: +vajrasky Added file: http://bugs.python.org/file33844/fix_clinic_converters_cmd_line.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20456 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2008] cookielib lacks FileCookieJar class for Safari
Hendrik added the comment: I found a solution for reading Safari cookies, but struggling around with hg diff. Because always when i typ hg diff Lib/http/cookiejar.py it returns me the complete file not only my changes.. -- nosy: +Hendrik ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2008 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12915] Add inspect.locate and inspect.resolve
Brett Cannon added the comment: importlib.util.resolve_name() already exists for resolving an explicit relative import name to an absolute one, so closing this as out of date. -- resolution: - out of date status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12915 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20440] Use Py_REPLACE/Py_XREPLACE macros
Martin v. Löwis added the comment: I think Raymond's original concern still applies: The macros do add to the learning curve. I would personally expect that Py_REPLACE(op, op2) does an INCREF on op2, but it does not. Explicit is better than implicit. -- nosy: +loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20440 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12915] Add inspect.locate and inspect.resolve
Vinay Sajip added the comment: importlib.util.resolve_name() already exists But that's not what the proposed functionality is for, is it? This covers finding values inside an imported module which can be accessed via a dotted path from the module globals. -- resolution: out of date - status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12915 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17159] Remove explicit type check from inspect.Signature.from_function()
Stefan Behnel added the comment: Hmm, I now notice that I was mistaken about this working: ''' import inspect def test_isfunction(): test_isfunction() True return inspect.isfunction(test_isfunction) ''' It only worked in Cython's test suite because its test runner monkey patches inspect.isfunction, and I had completely forgotten about it. Sorry for the confusion. The thing is that Cython's function type isn't really a Python function (obviously), it inherits from PyCFunction, so it should return True for isbuiltin(). A problem on our side prevented that. If I fix it up, then the newly added duck-typing code actually ends up not being used, because signature() tests for isbuiltin() first and runs into Signature.from_builtin(), which is the Argument Clinic code path that expects a textual signature representation. Cython functions don't have that, because they are compatible with Python functions. This situation could be helped in inspect.signature() by reversing the test order, i.e. by changing this code if _signature_is_builtin(obj): return Signature.from_builtin(obj) if isfunction(obj) or _signature_is_functionlike(obj): # If it's a pure Python function, or an object that is duck type # of a Python function (Cython functions, for instance), then: return Signature.from_function(obj) into this: if isfunction(obj) or _signature_is_functionlike(obj): # If it's a pure Python function, or an object that is duck type # of a Python function (Cython functions, for instance), then: return Signature.from_function(obj) if _signature_is_builtin(obj): return Signature.from_builtin(obj) Would this be ok? I would also argue that the implementation of _signature_is_builtin() is, well, not ideal, because what it should test for according to the comment at the top of the function is the existance of __text_signature__. Instead, it does several type tests, one of which goes wrong in this case. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17159 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19683] test_minidom has many empty tests
Roundup Robot added the comment: New changeset fed468670866 by Mark Dickinson in branch '2.7': Issue #19683: Add __closure__ and other missing attributes to function docs. http://hg.python.org/cpython/rev/fed468670866 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19683 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19863] Missing function attributes in 2.7 docs.
Mark Dickinson added the comment: New changeset fed468670866 by Mark Dickinson in branch '2.7': Issue #19683: Add __closure__ and other missing attributes to function docs. http://hg.python.org/cpython/rev/fed468670866 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19863 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19683] test_minidom has many empty tests
Mark Dickinson added the comment: Whoops; wrong issue number. That commit message was for issue 19863. -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19683 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19863] Missing function attributes in 2.7 docs.
Changes by Mark Dickinson dicki...@gmail.com: -- resolution: - fixed stage: commit review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19863 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10740] sqlite3 module breaks transactions and potentially corrupts data
Ronny Pfannschmidt added the comment: could we please get the option to opt-out of that behaviour, as a extra connection option maybe with the normal python sqlite bindings its impossible to have database migrations work safely which IMHO makes this a potential data-loss issue -- nosy: +Ronny.Pfannschmidt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10740 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10740] sqlite3 module breaks transactions and potentially corrupts data
R. David Murray added the comment: Opt out of what behavior? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10740 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12915] Add inspect.locate and inspect.resolve
Brett Cannon added the comment: Importlib already has importlib.import_module() (since Python 2.7) and that's as far as I'm willing to go for finding a module by name. Anything past that is a getarr() call on the resulting module and thus not worth adding to importlib. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12915 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12915] Add inspect.locate and inspect.resolve
Vinay Sajip added the comment: and thus not worth adding to importlib. Okay, fair enough. It's not purely an import function, though partly related to imports. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12915 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17159] Remove explicit type check from inspect.Signature.from_function()
Changes by Yury Selivanov yselivanov...@gmail.com: -- status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17159 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10740] sqlite3 module breaks transactions and potentially corrupts data
Ronny Pfannschmidt added the comment: the sqlite binding deciding how to handle transactions -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10740 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17444] multiprocessing.cpu_count() should use hw.availcpu on Mac OS X
Antoine Pitrou added the comment: The current os.cpu_count implementation calls sysconf(_SC_NPROCESSORS_ONLN), which is apparently defined under OS X, and returns the number of online CPUs (logical?): https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/sysconf.3.html multiprocessing has been modified to re-use os.cpu_count(), so I suggest closing this issue as out-of-date. -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17444 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20473] inspect.Signature no longer handles builtin classes correctly
Yury Selivanov added the comment: Stefan Krah suggests that the failure in 20473 is because that platform builds without docstrings, and the test requires them. So that should be an easy fix. Good news ;) OK, I'll decorate the test. Because slots like tp_init and tp_call don't have docstrings. So it has to go in the class's docstring. So what's going on and why is it broken: - from_builtin wasn't checking the incoming 'func' argument's type, it started to work with its '__text_signature__' right away. That was fixed. - in 'inspect.signature' we checked (isinstance(obj, _NonUserDefinedCallables) or ismethoddescriptor(obj) or isinstance(obj, type)) so *classes* were tried in 'from_builtin' too. And that's why it worked. Any class (even used-defined in pure Python) that had '__text_signature__' was passed to the 'Signature.from_builtin' and it did the right job. Now, I don't want to completely rollback my commits, as I still think that 'from_builtin' should strictly check what object is it working with, and raise appropriate exceptions. What we need to do is to separate parsing of '__text_signature__' into a private inspect module helper, so that 'from_builtin' becomes a tiny wrapper. Then, in 'signature.inspect' we need to find a way of testing if the given object is a builtin class, and call the parsing helper on it if it has the '__text_signature__' attribute. I'm looking into this. BTW, are you sure we can't somehow add '__text_signature__' to builtin class' '__init__'? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20473 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17159] Remove explicit type check from inspect.Signature.from_function()
Yury Selivanov added the comment: Would this be ok? Probably. I need to take a closer look. I'm not sure I like the idea that Cython functions are chimeras of some sort, i.e. they have a type of python builtin functions, hence, logically, Signature.from_builtin should work on them (and they have to follow __text_signature__ API), and on the other hand, they try to mimic pure python functions (being a builtin type) with all its guts like '__code__' object etc. Perhaps, what we need to do, is to modify 'Signature.from_builtin' to check for pure-python function duck type too, and fallback to 'Signature.from_function' in this case. Larry, Nick, what do you think? I would also argue that the implementation of _signature_is_builtin() is, well, not ideal, because what it should test for according to the comment at the top of the function is the existance of __text_signature__. Instead, it does several type tests, one of which goes wrong in this case. 'from_builtin' needs to have those type checks. Duck typing is good, but some minimal type safety is good too. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17159 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20471] test_signature_on_class() of test_inspect fails on AMD64 FreeBSD 9.0 3.x buildbot
Roundup Robot added the comment: New changeset b1f214165471 by Yury Selivanov in branch 'default': inspect.tests: Fix tests to work on python built with '--without-doc-strings' #20471 http://hg.python.org/cpython/rev/b1f214165471 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20471 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20471] test_signature_on_class() of test_inspect fails on AMD64 FreeBSD 9.0 3.x buildbot
Changes by Yury Selivanov yselivanov...@gmail.com: -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20471 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20471] test_signature_on_class() of test_inspect fails on AMD64 FreeBSD 9.0 3.x buildbot
Yury Selivanov added the comment: Should be OK now. Thank you guys for the report and for the hint of what was going on ;) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20471 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20473] inspect.Signature no longer handles builtin classes correctly
Changes by Yury Selivanov yselivanov...@gmail.com: -- nosy: +ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20473 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17159] Remove explicit type check from inspect.Signature.from_function()
Stefan Behnel added the comment: I'm not sure I like the idea that Cython functions are chimeras of some sort, i.e. they have a type of python builtin functions, hence, logically, Signature.from_builtin should work on them (and they have to follow __text_signature__ API), and on the other hand, they try to mimic pure python functions (being a builtin type) with all its guts like '__code__' object etc. That's one way of looking at it. The way I see it is that CPython's builtin functions should rather behave exactly like Python functions. The fact that there is such a thing as a __text_signature__ and general special casing of builtins is IMHO a rather annoying but truly long standing bug. The only necessary difference is that one of them contains byte code and the other doesn't, everything else should eventually be aligned. Perhaps, what we need to do, is to modify 'Signature.from_builtin' to check for pure-python function duck type too, and fallback to 'Signature.from_function' in this case. In any case, I think that a complete Python function(-like) interface should always be preferred to work-arounds like __text_signature__, regardless of where it comes from. 'from_builtin' needs to have those type checks. Duck typing is good, but some minimal type safety is good too. I don't really see why. The code doesn't seem to be doing that much more than text processing of the __text_signature__, plus a tiny bit of optional(!) attribute checking (__module__ and __self__). The restrictive type checks appear to be the only thing that prevents users from doing this: class myfunc: __text_signature__ = '(a,b,c,d)' sig = Signature.from_builtin(myfunc()) Granted, the name of that method doesn't really fit well in that case, and a simpler interface than having to define a class would also not hurt. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17159 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20288] HTMLParse handing of non-numeric charrefs broken
Ezio Melotti added the comment: Here's a patch against 2.7. -- keywords: +patch Added file: http://bugs.python.org/file33845/issue20288.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20288 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20445] HAVE_BROKEN_NICE detected incorrectly due to configure.ac typo
George Kouryachy added the comment: Oops, looks like my local build system artifact. Thank you for your attention, all-clear. -- resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20445 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17159] Remove explicit type check from inspect.Signature.from_function()
Yury Selivanov added the comment: That's one way of looking at it. The way I see it is that CPython's builtin functions should rather behave exactly like Python functions. The fact that there is such a thing as a __text_signature__ and general special casing of builtins is IMHO a rather annoying but truly long standing bug. The only necessary difference is that one of them contains byte code and the other doesn't, everything else should eventually be aligned. I see your point. I think that modifying 'from_builtin' as I suggested in my previous comment is the right thing to do. I'll make a new patch soon. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17159 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20288] HTMLParse handing of non-numeric charrefs broken
Roundup Robot added the comment: New changeset 0d50b5851f38 by Ezio Melotti in branch '2.7': #20288: fix handling of invalid numeric charrefs in HTMLParser. http://hg.python.org/cpython/rev/0d50b5851f38 New changeset 32097f193892 by Ezio Melotti in branch '3.3': #20288: fix handling of invalid numeric charrefs in HTMLParser. http://hg.python.org/cpython/rev/32097f193892 New changeset 92b3928bfde1 by Ezio Melotti in branch 'default': #20288: merge with 3.3. http://hg.python.org/cpython/rev/92b3928bfde1 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20288 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17159] Remove explicit type check from inspect.Signature.from_function()
Stefan Behnel added the comment: Attached is a minimal patch that does what I think you meant. -- Added file: http://bugs.python.org/file33846/divert_from_builtin.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17159 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20475] pystone.py in 3.4 still uses time.clock(), even though it's marked as deprecated since 3.3
New submission from Paul Sokolovsky: http://docs.python.org/3.3/library/time.html#time.clock says that it's deprecated, but pystone.py in Python-3.4.0b3 tarball still uses it. Please kindly consider switching it to plain time.time() and not to some other novelties. My usecase is: I'm working on alternative Python implementation, I of course want to benchmark it, and of course want to claim that I ran unmodified pystone.py. Now to achieve that, I need to implement deprecated function. -- messages: 209916 nosy: pfalcon priority: normal severity: normal status: open title: pystone.py in 3.4 still uses time.clock(), even though it's marked as deprecated since 3.3 type: enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20475 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20475] pystone.py in 3.4 still uses time.clock(), even though it's marked as deprecated since 3.3
Changes by Paul Sokolovsky pfal...@users.sourceforge.net: -- components: +Benchmarks versions: +Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20475 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10740] sqlite3 module breaks transactions and potentially corrupts data
R. David Murray added the comment: As noted above you get that by setting isolation_level to None. That feature has always been available. (With isolation_level set to None, the sqlite wrapper module itself never issues any BEGIN statements.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10740 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17159] Remove explicit type check from inspect.Signature.from_function()
Yury Selivanov added the comment: Stefan, Please try the attached patch (sig_cython_01.patch) -- Added file: http://bugs.python.org/file33847/sig_cython_01.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17159 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20475] pystone.py in 3.4 still uses time.clock(), even though it's marked as deprecated since 3.3
Changes by STINNER Victor victor.stin...@gmail.com: -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20475 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20400] Add create_read_pipe_protocol/create_write_pipe_protocol to asyncio.SubprocessProtocol
Roundup Robot added the comment: New changeset d7ac90c0463a by Victor Stinner in branch 'default': Issue #20400: Merge Tulip into Python: add the new asyncio.subprocess module http://hg.python.org/cpython/rev/d7ac90c0463a -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20400 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com