Re: Unicode issue with Python v3.3
On Apr 10, 10:06 am, rusi rustompm...@gmail.com wrote: An interesting case of two threads: On Apr 10, 9:46 am, Chris Angelico ros...@gmail.com wrote: On Wed, Apr 10, 2013 at 2:25 PM, Steven D'Aprano Obviously you know what the problem is much better than the Python interpreter. I just went to the page and it started playing sound. Between that and this arrogant refusal to believe either the interpreter or the people who are freely donating time to assist, I'm done. No more looking at Nikos's home page to try to figure out his problems. Have fun, Nikos. ChrisA Some swans are black Some homo sapiens have negative IQ Hmm I see some cut-paste goofup on my part. I was meaning to juxtapose this thread where we put up with inordinate amount of nonsense from OP along with the recent thread in which a newcomer who thinks he has found a bug in pdb is made fun of. Then thought better of it and deleted the stuff. However I did not do a good delete-job so I better now say what I avoided saying: If those who habitually post rubbish are given much of our time and effort, whereas newcomers and first-timers are treated rudely, the list begins to smell like a club of old farts. -- http://mail.python.org/mailman/listinfo/python-list
Re: While loop help
On 04/09/2013 09:49 AM, thomasancill...@gmail.com wrote: So what would be the proper way to perform a loop of this program. I still can't quite figure out the best way to do it. My suggestion... (pseudocode) # Print a heading/introduction here while True: # Print menu, with an added selection to quit # Get the user's choice (as an int) if choice == 1: # Print prompt for this choice # Enter the value (as float, not int. Why limit your values to ints anyway?) # Display the calculated result elif choice == 2: # Same procedure as above elif ... etc # etc elif choice == (value for quit): break# This breaks out of the while loop else: # Invalid choice, print error message # End of loop Further suggestion: Since each of the choices use the same basic procedure, it could be written as a separate single function. It would just need to be passed the appropriate prompt string(s) and conversion factor. The results display _could_ be in this function also, but that would require passing even more strings. It would probably be better to simply return the two values (the input value and the converted value) back to the calling block and print the results there. Also, don't use the round function here, that does NOT guarantee it will be _printed_ to two decimal places. Use string formatting in the print statements. For example: (using your original variable names, and assuming they are now both floats) old style: print '%.2f inches = %.2f meters' % (number, calc) or new style: print '{:.2f} inches = {:.2f} meters'.format(number, calc) You also mentioned that you don't like the editor you're using. For a simple substitute you might try Idle (which normally comes with Python). This gives you the advantage of an interactive environment as will as an editor. There are many other choices, of course, but as a newbie you might find this more comfortable than what you're currently using. I hope this jump-starts your thinking. Keep at it, it's worth the effort. -=- Larry -=- -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode issue with Python v3.3
rusi rustompmody at gmail.com writes: Hmm I see some cut-paste goofup on my part. I was meaning to juxtapose this thread where we put up with inordinate amount of nonsense from OP along with the recent thread in which a newcomer who thinks he has found a bug in pdb is made fun of. Then thought better of it and deleted the stuff. However I did not do a good delete-job so I better now say what I avoided saying: If those who habitually post rubbish are given much of our time and effort, whereas newcomers and first-timers are treated rudely, the list begins to smell like a club of old farts. +1. If you think you have something intelligent to say to jmfauth, you might as well start a private discussion with him. As far as I'm concerned, python-list is *already* of club of old farts. Many regular posters are more interested in being right on the Internet rather than helping people out. (this is where the StackOverflow mechanics probably work better, sadly) Regards Antoine. -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode issue with Python v3.3
Τη Τετάρτη, 10 Απριλίου 2013 7:25:21 π.μ. UTC+3, ο χρήστης Steven D'Aprano έγραψε: What does os.environ['REMOTE_ADDR'] give? Until you answer that question, you won't make any progress. I insists stevv. Look at what 'python3 metrites.py' gives me !-- The above is a description of an error in a Python program, formatted for a Web browser because the 'cgitb' module was enabled. In case you are not reading this in a Web browser, here is the original traceback: Traceback (most recent call last): File metrites.py, line 34, in lt;modulegt; userinfo = os.environ['HTTP_USER_AGENT'] File /root/.local/lib/python2.7/lib/python3.3/os.py, line 669, in __getitem__ value = self._data[self.encodekey(key)] KeyError: b'HTTP_USER_AGENT' -- -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode issue with Python v3.3
Here is the whole code for metrites.py in case someone wants to take allok. Everything is correct after altering it to meet python 3.3, everythign aprt from the weird unicode error thing. http://pastebin.com/5Mpjx5Fd please take a look. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode issue with Python v3.3
On Tue, 09 Apr 2013 23:04:35 -0700, rusi wrote: Hmm I see some cut-paste goofup on my part. I was meaning to juxtapose this thread where we put up with inordinate amount of nonsense from OP along with the recent thread in which a newcomer who thinks he has found a bug in pdb is made fun of. Curious. Is this making fun of the newcomer? If you are able to supply more details, we might be able to follow up on the registration problem. And, as someone else suggested, you could post the details of the pdb problem here. Note, there are already a number of currently open issues with pdb reported on the bug tracker. If you haven't already, you could search for pdb and see if your problem has been reported. Thanks for bringing the problem(s) up! Or perhaps this is making fun of them? Post the 10-line program here, so others can verify whether it is a bug. I think it is quite unfair of you to mischaracterise the entire community response in this way. One person made a light-hearted, silly, unhelpful response. (As sarcasm, I'm afraid it missed the target.) Two people made good, sensible responses -- and you were not either of them. If you want to be helpful, how about leading by example and taking on some of the less coherent newbie questions, instead of just bitching that others don't? It's easy, and a pleasure, to give good answers to well- written, carefully thought out questions. It's much harder to do the same for those questions which are... shall we say... less optimal. We could do with a few more people who make an effort to be helpful and friendly, instead of scolds who just tell us off when we stumble. Then thought better of it and deleted the stuff. However I did not do a good delete-job so I better now say what I avoided saying: If those who habitually post rubbish are given much of our time and effort, whereas newcomers and first-timers are treated rudely, the list begins to smell like a club of old farts. It's often the newcomers who are posting rubbish. Should we ignore them for posting rubbish, or welcome them for being newcomers? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
People in the python community [was Re: Unicode issue with Python v3.3]
On Wed, 10 Apr 2013 08:28:55 +, Steven D'Aprano wrote: If you want to be helpful, how about leading by example and taking on some of the less coherent newbie questions [...] On that note, I think I'll take the opportunity to give thanks to Peter Otten, who (if I remember correctly) has been here for longer than I have, and I've been here for a long time. In all that time, I don't think I've ever seen him snap at or be rude to anyone, not even those who deserved it, and he doesn't shy away from answering even the most poorly written questions. Peter, I don't know how you do it, but you're doing a fantastic job. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
extract HTML table in a structured format
Hi, I wonder if there is a nice way to extract a whole HTML table and have the result in a nice structured format. What I want is to have the lifetime table at the bottom of this page: http://en.wikipedia.org/wiki/List_of_Ubuntu_releases (then figure out with a script until when my Ubuntu release is supported). I could do it with BeautifulSoup or lxml but is there a better way? There should be :) Thanks, Laszlo -- http://mail.python.org/mailman/listinfo/python-list
use a loop to create lists
Hi! I would like to create a list containing lists. I need each list to have a differente name and i would like to use a loop to name the list. But as the name, is a string, i cannot asign it to a value... how can I do that?? global_list=[] for i in range (20): (list_+i)=[] #These would be the name of the list... global_list.append(list_+i) Thank you! -- http://mail.python.org/mailman/listinfo/python-list
Re: use a loop to create lists
On Wed, Apr 10, 2013 at 6:40 PM, martaamu...@gmail.com wrote: Hi! I would like to create a list containing lists. I need each list to have a differente name and i would like to use a loop to name the list. But as the name, is a string, i cannot asign it to a value... how can I do that?? global_list=[] for i in range (20): (list_+i)=[] #These would be the name of the list... global_list.append(list_+i) They don't need unique names. Just use the same name inside the loop: global_list=[] for i in range(20): current_list=[] # Presumably you do something with it here global_list.append(current_list) That'll work fine, and you can reference the lists by their positions in global_list. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
name lookup failure using metaclasses with unittests
Hi! I'm having problems using a metaclass to generate test functions. This works when I try to run all tests from the module or test case, but it fails when I'm trying to specify a single test function. My environment is Python 2.7.3 on MS Windows 7 at the moment. It should be upgraded to at least 2.7.4 or better to 3, but see the notes on Python 3 below. # my_module.py import unittest class X(unittest.TestCase): def __metaclass__(name, bases, dict): # attach function def test(self): pass dict['test_1'] = test dict['test_2'] = test # create class return type(name, bases, dict) The error when I'm trying to run python -m unittest my_module.X.test_1 is: Value error: no such test method in class 'my_module.X': test. The astonishing part is that it claims that test is not found while I asked it to run test_1. The name it complains about is the name of the function inside the metaclass function. In all other cases, like e.g. giving -v it reports the correct function name. My question here is whether I'm doing something wrong or whether I discovered a bug. Now, concerning Python 3, it fails to detect any test case at all! My guess is that the unittest library was changed to use metaclasses itself in order to detect classes derived from unittest.TestCase. Therefore, overriding the metaclass breaks test case discovery. My question in that context is how do I extend metaclasses instead of overriding it? In other words, what is the equivalent to super() for class creation? Thank you for your help! Uli -- http://mail.python.org/mailman/listinfo/python-list
Re: People in the python community [was Re: Unicode issue with Python v3.3]
On 10/04/2013 09:34, Steven D'Aprano wrote: On that note, I think I'll take the opportunity to give thanks to Peter Otten, who (if I remember correctly) has been here for longer than I have, and I've been here for a long time. In all that time, I don't think I've ever seen him snap at or be rude to anyone, not even those who deserved it, and he doesn't shy away from answering even the most poorly written questions. Peter, I don't know how you do it, but you're doing a fantastic job. Seconded. For those who don't know Peter is always responding to queries on the tutor mailing list as well. Definite case of the patience of a saint. -- If you're using GoogleCrap™ please read this http://wiki.python.org/moin/GoogleGroupsPython. Mark Lawrence -- http://mail.python.org/mailman/listinfo/python-list
guessthenumber print games left
Could anyone tell me how to make the program tell me how many games are left before the first game and second game? For example, after one game of guess the number, I want it to tell me that i get one more game. P.S. I'm totally new to python (obviously), and I just added numberofgames variable in hopes of solving this problem. am I on the right track? Thanks for any assistance! numberofgames=1 while numberofgames4: numberofgames=numberofgames+2 import random print ('type name') name=input() print ('guess a number between 1 and 20, ' + name) number=random.randint(1,20) guessestaken=0 while guessestaken5: guessestaken=guessestaken+1 guess=input() guess=int(guess) if guessnumber: print ('your guess is too low') if guessnumber: print ('your guess is too high0') if guess==number: break if guess==number: print ('you win!') if guess!=number: number=str(number) print ('you lose. the number was ' + number) -- http://mail.python.org/mailman/listinfo/python-list
Re: guessthenumber print games left
On Wed, Apr 10, 2013 at 7:39 PM, eschneide...@comcast.net wrote: Could anyone tell me how to make the program tell me how many games are left before the first game and second game? For example, after one game of guess the number, I want it to tell me that i get one more game. P.S. I'm totally new to python (obviously), and I just added numberofgames variable in hopes of solving this problem. am I on the right track? Thanks for any assistance! numberofgames=1 while numberofgames4: numberofgames=numberofgames+2 First off, why are you adding two? Is this a typo? You have here a counter, but it's counting up. To figure out how many games are left, just subtract the numberofgames from the total number of games that you'll be allowing - that's how many there are left. Do you know how to do that? ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: name lookup failure using metaclasses with unittests
Ulrich Eckhardt wrote: Hi! I'm having problems using a metaclass to generate test functions. This works when I try to run all tests from the module or test case, but it fails when I'm trying to specify a single test function. My environment is Python 2.7.3 on MS Windows 7 at the moment. It should be upgraded to at least 2.7.4 or better to 3, but see the notes on Python 3 below. # my_module.py import unittest class X(unittest.TestCase): def __metaclass__(name, bases, dict): # attach function def test(self): pass dict['test_1'] = test dict['test_2'] = test # create class return type(name, bases, dict) The error when I'm trying to run python -m unittest my_module.X.test_1 is: Value error: no such test method in class 'my_module.X': test. The astonishing part is that it claims that test is not found while I asked it to run test_1. The name it complains about is the name of the function inside the metaclass function. In all other cases, like e.g. giving -v it reports the correct function name. My question here is whether I'm doing something wrong or whether I discovered a bug. Here's a simpler demo of the problem: $ cat tmp.py import unittest class X(unittest.TestCase): def test_1(self): pass test_1.__name__ = test_2 $ python -m unittest -v tmp test_1 (tmp.X) ... ok -- Ran 1 test in 0.001s OK $ python -m unittest -v tmp.X.test_1 Traceback (most recent call last): File /usr/lib/python2.7/runpy.py, line 162, in _run_module_as_main __main__, fname, loader, pkg_name) File /usr/lib/python2.7/runpy.py, line 72, in _run_code exec code in run_globals File /usr/lib/python2.7/unittest/__main__.py, line 12, in module main(module=None) File /usr/lib/python2.7/unittest/main.py, line 94, in __init__ self.parseArgs(argv) File /usr/lib/python2.7/unittest/main.py, line 149, in parseArgs self.createTests() File /usr/lib/python2.7/unittest/main.py, line 158, in createTests self.module) File /usr/lib/python2.7/unittest/loader.py, line 128, in loadTestsFromNames suites = [self.loadTestsFromName(name, module) for name in names] File /usr/lib/python2.7/unittest/loader.py, line 109, in loadTestsFromName return self.suiteClass([parent(obj.__name__)]) File /usr/lib/python2.7/unittest/case.py, line 191, in __init__ (self.__class__, methodName)) ValueError: no such test method in class 'tmp.X': test_2 It looks like this particular invocation relies on class attribute and function __name__ being identical. Please file a bug report. Now, concerning Python 3, it fails to detect any test case at all! My guess is that the unittest library was changed to use metaclasses itself in order to detect classes derived from unittest.TestCase. Therefore, overriding the metaclass breaks test case discovery. My question in that context is how do I extend metaclasses instead of overriding it? In other words, what is the equivalent to super() for class creation? Python 3 does not recognize the __metaclass__ attribute as the metaclass. You need to provide it like so: def __metaclass__(name, bases, dict): ... class X(unittest.TestCase, metaclass=__metaclass__): pass -- http://mail.python.org/mailman/listinfo/python-list
Re: People in the python community [was Re: Unicode issue with Python v3.3]
os.environ['HTTP_USER_AGENT'] is only set when running from browser. so i faked it by using: userinfo = os.environ.get('HTTP_USER_AGENT', 'some default') but the encoding issues are still there. -- http://mail.python.org/mailman/listinfo/python-list
Re: People in the python community [was Re: Unicode issue with Python v3.3]
Thank you just altered it but i still get the same encoding issues. please its only a matter of simple alternation that iam not able to see. When you have the time plz take a look. Thank you! -- http://mail.python.org/mailman/listinfo/python-list
pymysql KeyError
Hello everyone, greetings from Hong Kong. I'm a relative noob with Python and have managed to break it. I'm hoping someone would be kind enough to help out, or perhaps just point me in the right direction. I've written a program which pulls in an XML document from an API on a server and populates the data into a MySQL table which I will then use to create reports. Everything is fine up until the point it tries to write the record to MySQL with this statement: dbcur.execute(INSERT INTO BackupJobs (bj_bsname, bj_bsid, bj_startdate, bj_starttime, bj_enddate, bj_endtime, bj_status, bj_uploadsize) values (%s,%s,%s,%s,%s,%s,%s,%s), newrecord) which borks with this: Traceback (most recent call last): File ./blahblahblah.py, line 99, in module dbcur.execute(INSERT INTO BackupJobs (bj_bsname, bj_bsid, bj_startdate, bj_starttime, bj_enddate, bj_endtime, bj_status, bj_uploadsize) values (%s,%s,%s,%s,%s,%s,%s,%s), newrecord) File /usr/local/lib/python3.2/dist-packages/pymysql/cursors.py, line 100, in execute escaped_args = tuple(conn.escape(arg) for arg in args) File /usr/local/lib/python3.2/dist-packages/pymysql/cursors.py, line 100, in genexpr escaped_args = tuple(conn.escape(arg) for arg in args) File /usr/local/lib/python3.2/dist-packages/pymysql/connections.py, line 650, in escape return escape_item(obj, self.charset) File /usr/local/lib/python3.2/dist-packages/pymysql/converters.py, line 31, in escape_item encoder = encoders[type(val)] KeyError: class 'builtin_function_or_method' I can dump out the (dummy) contents of the table using: for r in dbcur: print(r) ...so it seems the connection itself is working. User ID has full permissions, I'm pretty sure the data types are correct for each field. I can provide more code snippets if necessary. I'd be very grateful for any help. And if you're in Hong Kong and have helped me through this I'll buy you a beer too :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: People in the python community [was Re: Unicode issue with Python v3.3]
Steven D'Aprano wrote: On Wed, 10 Apr 2013 08:28:55 +, Steven D'Aprano wrote: If you want to be helpful, how about leading by example and taking on some of the less coherent newbie questions [...] On that note, I think I'll take the opportunity to give thanks to Peter Otten, who (if I remember correctly) has been here for longer than I have, and I've been here for a long time. In all that time, I don't think I've ever seen him snap at or be rude to anyone, not even those who deserved it, and he doesn't shy away from answering even the most poorly written questions. Peter, I don't know how you do it, but you're doing a fantastic job. Thank you :) -- http://mail.python.org/mailman/listinfo/python-list
Re: People in the python community [was Re: Unicode issue with Python v3.3]
Mark Lawrence wrote: On 10/04/2013 09:34, Steven D'Aprano wrote: On that note, I think I'll take the opportunity to give thanks to Peter Otten, who (if I remember correctly) has been here for longer than I have, and I've been here for a long time. In all that time, I don't think I've ever seen him snap at or be rude to anyone, not even those who deserved it, and he doesn't shy away from answering even the most poorly written questions. Peter, I don't know how you do it, but you're doing a fantastic job. Seconded. For those who don't know Peter is always responding to queries on the tutor mailing list as well. Definite case of the patience of a saint. You're invited as a speaker to my funeral ;) -- http://mail.python.org/mailman/listinfo/python-list
Re: pymysql KeyError
Chris Green wrote: Hello everyone, greetings from Hong Kong. I'm a relative noob with Python and have managed to break it. I'm hoping someone would be kind enough to help out, or perhaps just point me in the right direction. I've written a program which pulls in an XML document from an API on a server and populates the data into a MySQL table which I will then use to create reports. Everything is fine up until the point it tries to write the record to MySQL with this statement: dbcur.execute(INSERT INTO BackupJobs (bj_bsname, bj_bsid, bj_startdate, bj_starttime, bj_enddate, bj_endtime, bj_status, bj_uploadsize) values (%s,%s,%s,%s,%s,%s,%s,%s), newrecord) which borks with this: Traceback (most recent call last): File ./blahblahblah.py, line 99, in module dbcur.execute(INSERT INTO BackupJobs (bj_bsname, bj_bsid, bj_startdate, bj_starttime, bj_enddate, bj_endtime, bj_status, bj_uploadsize) values (%s,%s,%s,%s,%s,%s,%s,%s), newrecord) File /usr/local/lib/python3.2/dist-packages/pymysql/cursors.py, line 100, in execute escaped_args = tuple(conn.escape(arg) for arg in args) File /usr/local/lib/python3.2/dist-packages/pymysql/cursors.py, line 100, in genexpr escaped_args = tuple(conn.escape(arg) for arg in args) File /usr/local/lib/python3.2/dist-packages/pymysql/connections.py, line 650, in escape return escape_item(obj, self.charset) File /usr/local/lib/python3.2/dist-packages/pymysql/converters.py, line 31, in escape_item encoder = encoders[type(val)] KeyError: class 'builtin_function_or_method' I can dump out the (dummy) contents of the table using: for r in dbcur: print(r) ...so it seems the connection itself is working. User ID has full permissions, I'm pretty sure the data types are correct for each field. I can provide more code snippets if necessary. I'd be very grateful for any help. And if you're in Hong Kong and have helped me through this I'll buy you a beer too :-) Add a print(newrecord) before the dbcur.execute(...) line and tell us what it shows. I'm guessing that for one of the values in it you forgot to call a method written in C, e. g. [42].pop built-in method pop of list object at 0x7f86f70bc950 type(_) class 'builtin_function_or_method' instead of [42].pop() 42 -- http://mail.python.org/mailman/listinfo/python-list
Re: use a loop to create lists
On 04/10/2013 04:40 AM, martaamu...@gmail.com wrote: Hi! I would like to create a list containing lists. I need each list to have a differente name and i would like to use a loop to name the list. But as the name, is a string, i cannot asign it to a value... how can I do that?? global_list=[] for i in range (20): (list_+i)=[] #These would be the name of the list... global_list.append(list_+i) Thank you! The fact that the content of the outer list also happens to be lists is irrelevant to your question. I believe the real question here is how to create an arbitrary bunch of new names, and bind them to elements of he list. In general, you can't. But more importantly, in general you don't want to. If you come up with a convoluted way to fake it, you'll have to use the same convoluted way to access those names, so there's no point. As Chris says, just reference them by index. On the other hand, if the outer list happens to have exactly 7 elements, and you know that ahead of time, then it may well make sense to assign names to them. Not list_0 through list_6, but name, addr1, ec. global_list = [] for i in range(7): global_list.append[] first_name, mid_name, last_name, addr1, addr2, city, town = global_list Incidentally, that's approximately what a collections.namedtuple is all about, giving names to items that are otherwise considered elements of a tuple. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: People in the python community [was Re: Unicode issue with Python v3.3]
Anyone please? -- http://mail.python.org/mailman/listinfo/python-list
Re: xlrd 0.9.2 released!
On Apr 9, 3:38 pm, Chris Withers ch...@simplistix.co.uk wrote: Hi All, I'm pleased to announce the release of xlrd 0.9.2: http://pypi.python.org/pypi/xlrd/0.9.2 This release includes the following changes: - Fix some packaging issues that meant docs and examples were missing from the tarball. - Fixed a small but serious regression that caused problems opening .xlsx files. If you find any problems, please ask about them on the python-ex...@googlegroups.com list, or submit an issue on GitHub: https://github.com/python-excel/xlrd/issues Full details of all things Python and Excel related can be found here: http://www.python-excel.org/ cheers, Chris -- Simplistix - Content Management, Batch Processing Python Consulting -http://www.simplistix.co.uk Thanks from me (and I am sure many others). -- http://mail.python.org/mailman/listinfo/python-list
Really throwing this out there - does anyone have a copy of my old Dancer web browser?
About... er, a few years ago (1994!) I wrote a very basic web browser called Dancer. My FTP site at Indiana is long gone. Grail is based on at least some of the ideas of Dancer (but not the code itself.) I'm wondering if anyone perchance has a copy of the code. I know it will not run in any recent version of Python; it's just for my records. Thanks, Steve -- http://mail.python.org/mailman/listinfo/python-list
Re: People in the python community [was Re: Unicode issue with Python v3.3]
On 10/04/2013 15:43, Νίκος Γκρ33κ wrote: Anyone please? I have already shown my support for Peter Otten on this thread. Are you asking for more people to do so? -- If you're using GoogleCrap™ please read this http://wiki.python.org/moin/GoogleGroupsPython. Mark Lawrence -- http://mail.python.org/mailman/listinfo/python-list
Re: People in the python community [was Re: Unicode issue with Python v3.3]
On Thu, Apr 11, 2013 at 1:15 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: On 10/04/2013 15:43, Νίκος Γκρ33κ wrote: Anyone please? I have already shown my support for Peter Otten on this thread. Are you asking for more people to do so? Sure, I can! He's one of the people who keeps this list/ng productive and helpful. People can come here with Python problems and get Python solutions. (I wouldn't normally me too a thread, but hey, with that opening!) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Really throwing this out there - does anyone have a copy of my old Dancer web browser?
On Thu, Apr 11, 2013 at 1:03 AM, steven.mi...@gmail.com wrote: About... er, a few years ago (1994!) I wrote a very basic web browser called Dancer. My FTP site at Indiana is long gone. Grail is based on at least some of the ideas of Dancer (but not the code itself.) I'm wondering if anyone perchance has a copy of the code. I know it will not run in any recent version of Python; it's just for my records. Have you tried the Wayback Machine at http://www.archive.org/ ? They mainly crawl HTTP, not FTP, so it's a bit of a long shot, but if you remember the address you had it hosted at, it's worth a try! Alas, back in 1994 I wasn't doing much on the internet. We'd put together our own LAN by that time, but our uplink was over a modem and not shared to all computers. Wasn't for a few more years after that that I actually really got a usable connection, much less got involved in things like this. So I can't help any more than that, sorry. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: use a loop to create lists
On Apr 10, 1:40 pm, martaamu...@gmail.com wrote: Hi! I would like to create a list containing lists. I need each list to have a differente name and i would like to use a loop to name the list. But as the name, is a string, i cannot asign it to a value... how can I do that?? global_list=[] for i in range (20): (list_+i)=[] #These would be the name of the list... global_list.append(list_+i) Thank you! If as Chris points out you dont actually need names, a list should suffice (with indexing serving as 'naming') If however there are a fixed (at program-writing time) small set of names, you can do as Dave suggests and use unpacking assignment. [Some people like to use objects for this] If however you need an arbitrary set of names, unknown at programming time, a dictionary is typically what is appropriate: For dictionary d - get the value of name n with d[n] - set (bind) name n to value v in dict d with d[n] = v Which of these options you should follow is not clear from your question; you need to tell us a bit more about what you are trying to do. -- http://mail.python.org/mailman/listinfo/python-list
Re: While loop help
On Apr 9, 8:47 pm, thomasancill...@gmail.com wrote: ... and if you have any ideas for me to improve my coding that will prevent me from learning python in a sloppy way. I'd like to learn it correctly the first time! Not perhaps a direct answer... Anyways there is style in which python is best used which people coming from more traditional languages are usually not familiar with: its called 'playing around in the interpreter' Here is a small session based on your code that shows this interaction with the interpreter: - $ python Python 2.7.3 (default, Jan 2 2013, 16:53:07) [GCC 4.7.2] on linux2 Type help, copyright, credits or license for more information. def inch2meter(i): return round(i*.254,2) ... inch2meter(1) 0.25 def milliliter2pint(m): return round(number * 0.0021134,2) ... milliliter2pint(100) Traceback (most recent call last): File stdin, line 1, in module File stdin, line 1, in milliliter2pint NameError: global name 'number' is not defined def milliliter2pint(m): return round(m * 0.0021134,2) ... milliliter2pint(100) 0.21 - Notice some things here: 1. I check out the code as soon as its written. So when I cutpasted from your code, without keeping names (m - number) consistent, I get an error, correct it and continue 2. There is not a single print statement. Not just the functions have no prints, even the code that calls them has none. Just call get answer. This point needs to be underscored: In C or java you cannot write any useful code without doing IO ie printf/scanf etc. In python you can and you should try to. -- http://mail.python.org/mailman/listinfo/python-list
RE: pymysql KeyError
Add a print(newrecord) before the dbcur.execute(...) line and tell us what it shows. I'm guessing that for one of the values in it you forgot to call a method written in C, e. g. [42].pop built-in method pop of list object at 0x7f86f70bc950 type(_) class 'builtin_function_or_method' instead of [42].pop() 42 Thank you Peter - that got me back on track. Indeed, my date and time values were coded incorrectly. I read up properly on datetime to fix that, then ran straight into a pymysql bug. After swapping that out for MySQL Connector/Python everything instantly sprang to life. So a bit convoluted but I got there in the end! -- http://mail.python.org/mailman/listinfo/python-list
Re: People in the python community [was Re: Unicode issue with Python v3.3]
I'am not sure i follow you. How did my topic changed?! Is this possible? How about the oce i posted at patebin.com. Did anyone by any chnace had a look into? It's only a single thing iam missing for the encoding and the the script will load properly with python 3.3 -- http://mail.python.org/mailman/listinfo/python-list
Re: extract HTML table in a structured format
On 10 April 2013 09:44, Jabba Laci jabba.l...@gmail.com wrote: Hi, I wonder if there is a nice way to extract a whole HTML table and have the result in a nice structured format. What I want is to have the lifetime table at the bottom of this page: http://en.wikipedia.org/wiki/List_of_Ubuntu_releases (then figure out with a script until when my Ubuntu release is supported). I could do it with BeautifulSoup or lxml but is there a better way? There should be :) Instead of parsing HTML, you could just parse the source of the page (available via action=raw): -- import urllib2 url = ( 'http://en.wikipedia.org/w/index.php' '?title=List_of_Ubuntu_releasesaction=raw' ) source = urllib2.urlopen(url).read() # Table rows are separated with the line |- # Then there is a line starting with | potential_rows = source.split(\n|-\n|) rows = [] for row in potential_rows: # Rows in the table start with a link (' [[ ... ]]') if row.startswith( [[): row = [item.strip() for item in row.split(\n|)] rows.append(row) -- import pprint pprint.pprint(rows) [['[[Warty Warthog|4.10]]', 'Warty Warthog', '20 October 2004', 'colspan=2 {{Version |o |30 April 2006}}', '2.6.8'], ['[[Hoary Hedgehog|5.04]]', 'Hoary Hedgehog', '8 April 2005', 'colspan=2 {{Version |o |31 October 2006}}', '2.6.10'], ['[[Breezy Badger|5.10]]', 'Breezy Badger', '13 October 2005', 'colspan=2 {{Version |o |13 April 2007}}', '2.6.12'], ['[[Ubuntu 6.06|6.06 LTS]]', 'Dapper Drake', '1 June 2006', '{{Version |o | 14 July 2009}}', '{{Version |o | 1 June 2011}}', '2.6.15'], ['[[Ubuntu 6.10|6.10]]', 'Edgy Eft', '26 October 2006', 'colspan=2 {{Version |o | 25 April 2008}}', '2.6.17'], [...] ] That should give you the info you need (until the wiki page changes too much!) -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode issue with Python v3.3
On Wed, 10 Apr 2013 00:23:46 -0700, nagia.retsina wrote: Look at what 'python3 metrites.py' gives me File /root/.local/lib/python2.7/lib/python3.3/os.py, line 669, ... ^^^ ^^^ -- http://mail.python.org/mailman/listinfo/python-list
Re: extract HTML table in a structured format
Hi, Thanks, it's a great idea to parse the wiki source. Since then I have found a command for this particular task called ubuntu-support-status that shows what I need. But the idea to extract an HTML table from a webpage in a structured format could be an interesting (and useful) project idea. Best, Laszlo On Wed, Apr 10, 2013 at 8:11 PM, Arnaud Delobelle arno...@gmail.com wrote: On 10 April 2013 09:44, Jabba Laci jabba.l...@gmail.com wrote: Hi, I wonder if there is a nice way to extract a whole HTML table and have the result in a nice structured format. What I want is to have the lifetime table at the bottom of this page: http://en.wikipedia.org/wiki/List_of_Ubuntu_releases (then figure out with a script until when my Ubuntu release is supported). I could do it with BeautifulSoup or lxml but is there a better way? There should be :) Instead of parsing HTML, you could just parse the source of the page (available via action=raw): -- import urllib2 url = ( 'http://en.wikipedia.org/w/index.php' '?title=List_of_Ubuntu_releasesaction=raw' ) source = urllib2.urlopen(url).read() # Table rows are separated with the line |- # Then there is a line starting with | potential_rows = source.split(\n|-\n|) rows = [] for row in potential_rows: # Rows in the table start with a link (' [[ ... ]]') if row.startswith( [[): row = [item.strip() for item in row.split(\n|)] rows.append(row) -- import pprint pprint.pprint(rows) [['[[Warty Warthog|4.10]]', 'Warty Warthog', '20 October 2004', 'colspan=2 {{Version |o |30 April 2006}}', '2.6.8'], ['[[Hoary Hedgehog|5.04]]', 'Hoary Hedgehog', '8 April 2005', 'colspan=2 {{Version |o |31 October 2006}}', '2.6.10'], ['[[Breezy Badger|5.10]]', 'Breezy Badger', '13 October 2005', 'colspan=2 {{Version |o |13 April 2007}}', '2.6.12'], ['[[Ubuntu 6.06|6.06 LTS]]', 'Dapper Drake', '1 June 2006', '{{Version |o | 14 July 2009}}', '{{Version |o | 1 June 2011}}', '2.6.15'], ['[[Ubuntu 6.10|6.10]]', 'Edgy Eft', '26 October 2006', 'colspan=2 {{Version |o | 25 April 2008}}', '2.6.17'], [...] ] That should give you the info you need (until the wiki page changes too much!) -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode issue with Python v3.3
Τη Τετάρτη, 10 Απριλίου 2013 9:08:38 μ.μ. UTC+3, ο χρήστης Nobody έγραψε: On Wed, 10 Apr 2013 00:23:46 -0700, nagia.retsina wrote: Look at what 'python3 metrites.py' gives me File /root/.local/lib/python2.7/lib/python3.3/os.py, line 669, ... ^^^ ^^^ Yes i see it in the traceback but i dont know what it means. Please explain to me. Tahnk you. -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode issue with Python v3.3
On Wed, Apr 10, 2013 at 12:25 PM, Νίκος Γκρ33κ nikos.gr...@gmail.com wrote: Τη Τετάρτη, 10 Απριλίου 2013 9:08:38 μ.μ. UTC+3, ο χρήστης Nobody έγραψε: On Wed, 10 Apr 2013 00:23:46 -0700, nagia.retsina wrote: Look at what 'python3 metrites.py' gives me File /root/.local/lib/python2.7/lib/python3.3/os.py, line 669, ... ^^^ ^^^ Yes i see it in the traceback but i dont know what it means. Please explain to me. Tahnk you. It means that there is something very strange about the way that your Python 3.3 is installed, as the libraries appear to be installed under your Python 2.7 library directory. -- http://mail.python.org/mailman/listinfo/python-list
Re: guessthenumber print games left
On Wednesday, April 10, 2013 5:44:20 AM UTC-4, Chris Angelico wrote: On Wed, Apr 10, 2013 at 7:39 PM, eschneide...@comcast.net wrote: Could anyone tell me how to make the program tell me how many games are left before the first game and second game? For example, after one game of guess the number, I want it to tell me that i get one more game. P.S. I'm totally new to python (obviously), and I just added numberofgames variable in hopes of solving this problem. am I on the right track? Thanks for any assistance! numberofgames=1 while numberofgames4: numberofgames=numberofgames+2 First off, why are you adding two? Is this a typo? You have here a counter, but it's counting up. To figure out how many games are left, just subtract the numberofgames from the total number of games that you'll be allowing - that's how many there are left. Do you know how to do that? ChrisA Thanks for the quick reply. I've been trying your advice but I can't figure it out. If anyone could show me how to do it in program form, it would be much obliged. -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange files??
On Wednesday 10 Apr 2013 14:16:23 Joe Hill wrote: Recently I installed Python 3.3 successfully. Yesterday - I have a bunch of PY files such as thesaurus.py, some *.p7s files, some signature files and an index.fpickle. A total of 23 files. Where do they come from and how do they end up as incoming mail??? Are any of these needed for anything? As a rule I sort out or delete all incoming attachments every day. j What do you mean, you have them? Did someone email them to you? If so, surely they're nothing to do with installing Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: Print to an IPP printer (pkipplib?)
On Wed, 2010-10-20 at 14:45 +, Martin Gregorie wrote: On Fri, 15 Oct 2010 15:28:10 -0400, Adam Tauno Williams wrote: I've found the module pkipplib which seems to work well for things like interrogating an IPP (CUPS) server. But is there a way to send a print job to an IPP print queue? [and no, the local system knows nothing about the print architecture so popenlp is not an option]. I just want to send the data from a file handle to a remote IPP queue as a print job. See RFC 2910. Queuing a file directly to an IPP server is possible using pycups. https://pypi.python.org/pypi/pycups Example: https://sourceforge.net/p/coils/code/ci/default/tree/coils/logic/workflow/actions/doc/ipp_print.py -- http://mail.python.org/mailman/listinfo/python-list
python-noob - which container is appropriate for later exporting into mySql + matplotlib ?
Hi, Here's my data: --- 20130315T071500 39000. 10 26 48000. 1 40 20130315T071501 39000. 10 26 48000. 2 42 20130315T071501 39000. 10 26 47520. 15 69 20130315T071501 39000. 10 26 47160. 1 70 20130315T071501 39000. 10 26 47000. 1 72 20130315T071501 39000. 10 26 47000. 2 81 20130315T071501 39000. 10 26 47000. 6 85 20130315T071501 39000. 10 26 46520. 10 95 20130315T071501 43000. 10 36 46520. 10 95 20130315T071501 43200. 4 43 46520. 10 104 20130315T071501 44040. 1 45 46520. 10 108 20130315T071501 44080. 3 48 46520. 10 109 20130315T071501 44080. 3 48 46520. 11 113 20130315T071501 44080. 3 48 46400. 2 131 20130315T071501 45080. 1 51 46400. 2 145 20130315T071501 45080. 1 51 46200. 1 147 20130315T071501 45080. 1 60 46120. 1 182 20130315T071501 45520. 1 65 46120. 1 225 20130315T071501 45520. 1 73 46120. 2 247 20130315T08 45760. 1 133 46120. 2 378 20130315T080241 45760. 2 199 46120. 2 453 20130315T080945 45760. 3 217 46120. 2 456 20130315T081103 45760. 3 217 46080. 1 457 20130315T081105 45760. 3 218 46080. 2 458 20130315T081106 45760. 4 222 46080. 2 458 20130315T081107 45800. 1 229 46080. 2 458 20130315T082754 45800. 8 266 46080. 2 514 . ... etc. --- The first column is date + time. I know how to use simple tuples, list's and dict's. But I don't think it's a good idea to make each line an element in a list/dict ? I want to put this table into an appropriate container such that afterwards I want to: 1) Put the data into a mySql-table 2) Be able to easily plot column 1 vs. either of the other columns using matplotlib etc... I consider myself a python-newbie so I'm not that good with containers... I found something here: http://docs.python.org/dev/library/collections.html but I'm not really sure what is a good pythonic way of storing this data? I also think that maybe I ought to convert the first data+time column into a single number, because right now it's a string (because there's a T in the middle of column 1)... Letting the date+time-column (=column 1) become entirely numbers, makes it easier to plot in matplotlib afterwards... I'm not sure how to store this in an efficient manner... What (=how?) would you do it? Thanks... -- http://mail.python.org/mailman/listinfo/python-list
Re: guessthenumber print games left
On Thu, Apr 11, 2013 at 7:01 AM, eschneide...@comcast.net wrote: On Wednesday, April 10, 2013 5:44:20 AM UTC-4, Chris Angelico wrote: On Wed, Apr 10, 2013 at 7:39 PM, eschneide...@comcast.net wrote: You have here a counter, but it's counting up. To figure out how many games are left, just subtract the numberofgames from the total number of games that you'll be allowing - that's how many there are left. Do you know how to do that? Thanks for the quick reply. I've been trying your advice but I can't figure it out. If anyone could show me how to do it in program form, it would be much obliged. Set your current code aside, and just make a program that counts games without actually playing them. Start with this part of your existing code: numberofgames=1 while numberofgames4: numberofgames=numberofgames+2 That will run, but do nothing. Now add a print call to the loop, and see if you can work out how to make it count how many games are left. If you get stuck, post the code for just this program and we'll see where it takes us! ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Python pdb bug, followed by bug in bugs.python.org
Ned Deily wrote: There is a meta tracker for problems with the Python issuer tracker itself: http://psf.upfronthosting.co.za/roundup/meta/ but you do have to register for that tracker (a separate registration). You mean there's no meta-meta-tracker for reporting problems registering with the meta-tracker? There should be meta-trackers all the way up! -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode issue with Python v3.3
On 10 April 2013 09:28, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Tue, 09 Apr 2013 23:04:35 -0700, rusi wrote: [...] I think it is quite unfair of you to mischaracterise the entire community response in this way. One person made a light-hearted, silly, unhelpful response. (As sarcasm, I'm afraid it missed the target.) Two people made good, sensible responses -- and you were not either of them. Enough already with the thought police. It was me who made the silly reply to the guy who was ranting about everything being broken, giving us nothing to help in on, ending his message in an edifying and in my judgement, largely rhetorical Suggestions?. So I gave him some silly suggestions (*not* intended to be sarcasm), and I'm not apologising for it. At least I'm not presuming to take the moral high ground at every half-opportunity. Recently I gave a very quick reply to someone who was wondering why he couldn't get the docstring from his descriptor - I didn't have the time to expand because two of my kids had jumped on my knees almost as soon as I'd got on the computer. I decided to post the reply anyway as I thought it would give the OP something to get started on and nobody else seemed to have replied so far - but I got remonstrated for not being complete enough in my reply! What is that about? AFAIK, this is not Python Customer Service, but a place for people who are interested in Python to discuss problems and *freely* exchange thoughts about the language and its ecosystem. Over the year I've posted the occasional silly message but I think my record is overwhelmingly that I've tried to be helpful, and when I've needed some help myself, I've got some great advice. My first question on this list was answered by Alex Martelli and nowadays I get most excellent and concise tips from Peter Otten - thanks, Peter! If there's one person on this list I don't want to offend, it's you! So here's to lots more good and bad humour on this list, and the occasional slightly un-pc remark even! Cheers, -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Functional vs. Object oriented API
Hi, I'm currently learning Python, and it's going great. I've dabbled before, but really getting into it is good fun. To test myself, and not detract too much from my actual studies (mathematics), I've been writing my own package to do linear algebra, and I am unsure about how best to structure my API. For example, I have a vector class, that works like so: a = Vector([2, 7, 4]) b = Vector.j # unit vector in 3D y direction I also have a function to generate the dot product of these two vectors. In Java, such a function would be put as a method on the class and I would do something like: a.dot_product(b) 7 and that would be the end of it. But in Python, I can also have: dot_product(a, b) 7 Which of these two are preferred in Python? And are there any general guidelines for choosing between the two styles, or is it largely a matter of personal preference? Thanks for reading, Max. -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode issue with Python v3.3
On 10Apr2013 01:06, Νίκος Γκρ33κ nikos.gr...@gmail.com wrote: | Here is the whole code for metrites.py in case someone wants to take allok. | | Everything is correct after altering it to meet python 3.3, | everythign aprt from the weird unicode error thing. | | http://pastebin.com/5Mpjx5Fd | | please take a look. From looking at the HTML source of the page: http://superhost.gr/ I see near the start: b'!DOCTYPE html I'd say you have a bytes object that you've fed to print(). In python2, str is effectively bytes. In python3, str is a sequence of Unicode code points, and bytes are arrays of small integers. If you feed a bytes object to print it will print a strig represenation of it, starting with b' The question is: where did the bytes object come from? A cursory glance through your pastebin code doesn't show me anthing very obvious. I'd start by asking: where does the string !DOCTYPE come from? Wherever that is, it seems to be bytes rather than str. Start with that. Cheers, -- Cameron Simpson c...@zip.com.au You don't have to live on the edge, but you have to know where it is. - Scott Lilliott, c...@swl.msd.ray.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Functional vs. Object oriented API
Hi Max, In Python, we prefer readability over anything else. The simpler you can write it, the better it can be understood. That said, I've never considered using (i, j, k) as a vector component before. I've always done something akin to: vector = Vector(2, 4, 6) print (vector.normalize().y) However, if you use the mathematical definition of a vector, with standard symbols: v = x*i + y*j + z*k Then I believe vector.j is a much choice. As long as your documentation states it's read-only, I think most mathematicians will love that notation. . As far as dot products go, there isn't really a big difference between the two forms you have there. Both are equally as readable. When C++ was invented people had already debated about the two forms. There isn't a general consensus on this debate, but most would probably agree that overloading the * operator of a vector to do dot product is a bad idea, since some people want cross product, or per-component multiplication. At the end of the day, dot() or dot_product() is more readable, and it doesn't matter if you have it as a function in or outside of a vector's class. Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list
Re: Functional vs. Object oriented API
On Wed, Apr 10, 2013 at 5:16 PM, Max Bucknell mpwb...@york.ac.uk wrote: I also have a function to generate the dot product of these two vectors. In Java, such a function would be put as a method on the class and I would do something like: a.dot_product(b) 7 and that would be the end of it. But in Python, I can also have: dot_product(a, b) 7 Which of these two are preferred in Python? And are there any general guidelines for choosing between the two styles, or is it largely a matter of personal preference? The advantage to the latter is that it potentially allows you to implement dot products for other types using the same function. Using the method, a must be a Vector instance, but using the function it remains unrestricted. This is useful because functions are first-class objects in Python. Suppose that you find yourself wanting to pass that dot_product operation to some other function, e.g. map(). Using the function version you just pass in dot_product -- map(dot_product, seq1, seq2) -- and the mapped sequences can then contain any types that dot_product has been implemented to handle. Using the method version, you would have to pass in the unbound Vector.dot_product method -- map(Vector.dot_product, seq1, seq2), and then the method will only accept Vector instances in seq1. -- http://mail.python.org/mailman/listinfo/python-list
Re: extract HTML table in a structured format
On Thu, Apr 11, 2013 at 4:15 AM, Jabba Laci jabba.l...@gmail.com wrote: Hi, Thanks, it's a great idea to parse the wiki source. Since then I have found a command for this particular task called ubuntu-support-status that shows what I need. That sounds like an even better option. Anything that depends on parsing a wiki is vulnerable to format changes at a moment's notice, even worse than other web page parsing. But the idea to extract an HTML table from a webpage in a structured format could be an interesting (and useful) project idea. There are, unfortunately, too many different ways this can be done. Too many differences in HTML that a human eye would read as the same thing. I'd recommend either BeautifulSoup or specifically looking at the HTML to be parsed and finding a shortcut from that. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
performance of script to write very long lines of random chars
Dear pythonistas, I am writing a tiny utility to produce a file consisting of a specified number of lines of a given length of random ascii characters. I am hoping to find a more time and memory efficient way, that is still fairly simple clear, and _pythonic_. I would like to have something that I can use at both extremes of data: 32M chars per line * 100 lines or 5 chars per line * 1e8 lines. E.g., the output of bigrand.py for 10 characters, 2 lines might be: gw2+M/5t. S[[db/l?Vx I'm using python 2.7.0 on linux. I need to use only out-of-the box modules, since this has to work on a bunch of different computers. At this point I'm especially concerned with the case of a few very long lines, since that seems to use a lot of memory, and take a long time. Characters are a slight subset of the printable ascii's, specified in the examples below. My first naive try was: from sys import stdout import random nchars = 3200 rows = 10 avail_chrs = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$% \'()*+,-./:;=?@[\\]^_`{}' def make_varchar(nchars): return (''.join([random.choice(avail_chrs) for i in range(nchars)])) for l in range(rows): stdout.write(make_varchar(nchars)) stdout.write('\n') This version used around 1.2GB resident/1.2GB virtual of memory for 3min 38sec. My second try uses much less RAM, but more CPU time, and seems rather, umm, un-pythonic (the array module always seems a little un pythonic...) from sys import stdout from array import array import random nchars = 3200 rows = 10 avail_chrs = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$% \'()*+,-./:;=?@[\\]^_`{}' a = array('c', 'X' * nchars) for l in range(rows): for i in xrange(nchars): a[i] = random.choice(avail_chrs) a.tofile(stdout) stdout.write('\n') This version using array took 4 min, 29 sec, using 34MB resident/110 virtual. So, much smaller than the first attempt, but a bit slower. Can someone suggest a better code? And help me understand the performance issues here? -- George -- http://mail.python.org/mailman/listinfo/python-list
Re: python-noob - which container is appropriate for later exporting into mySql + matplotlib ?
someone wrote: I want to put this table into an appropriate container such that afterwards I want to: 1) Put the data into a mySql-table 2) Be able to easily plot column 1 vs. either of the other columns using matplotlib etc... Consider editing your data file into a csv file named someone.csv 20130315T071500,39000.,10,26,48000.,1,40 20130315T071501,39000.,10,26,48000.,2,42 20130315T071501,39000.,10,26,47520.,15,69 20130315T071501,39000.,10,26,47160.,1,70 20130315T071501,39000.,10,26,47000.,1,72 20130315T071501,39000.,10,26,47000.,2,81 20130315T071501,39000.,10,26,47000.,6,85 20130315T071501,39000.,10,26,46520.,10,95 20130315T071501,43000.,10,36,46520.,10,95 20130315T071501,43200.,4,43,46520.,10,104 20130315T071501,44040.,1,45,46520.,10,108 20130315T071501,44080.,3,48,46520.,10,109 20130315T071501,44080.,3,48,46520.,11,113 20130315T071501,44080.,3,48,46400.,2,131 20130315T071501,45080.,1,51,46400.,2,145 20130315T071501,45080.,1,51,46200.,1,147 20130315T071501,45080.,1,60,46120.,1,182 20130315T071501,45520.,1,65,46120.,1,225 20130315T071501,45520.,1,73,46120.,2,247 20130315T08,45760.,1,133,46120.,2,378 20130315T080241,45760.,2,199,46120.,2,453 20130315T080945,45760.,3,217,46120.,2,456 20130315T081103,45760.,3,217,46080.,1,457 20130315T081105,45760.,3,218,46080.,2,458 20130315T081106,45760.,4,222,46080.,2,458 20130315T081107,45800.,1,229,46080.,2,458 20130315T082754,45800.,8,266,46080.,2,514 # --- # # The csv data can be loaded using the csv module # # named tuples might be used # for convenience to access # individual columns #!/usr/bin/env python import csv from collections import namedtuple as NT file_source = open( 'someone.ssv' ) # --- individual column names --- nt = NT( 'csv_data' , 'date time col1 col2 col3 col4 col5 col6' ) list_tuples = [ ] for this_row in csv.reader( file_source ) : # unpack the current row zed , one , two , tre , fur , fiv , six = this_row # split the date and time d , t = zed.split( 'T' ) # convert individual columns in row to a named tuple this_tuple = nt( d , t , float( one ) , int( two ) , int( tre ) , float( fur ) , int( fiv ) , int( six ) ) # save the current named tuple into a list list_tuples.append( this_tuple ) # update_data_base( this_tuple ) # or # update_data_base( choose individual columns ) # individual elements of the named tuples # can be accessed by name # # this might be convenient for settup up # data for plots of diffeent columns print for row in list_tuples : print ' ' , row.date , row.time , row.col1 , row.col3 , row.col4 file_source.close() -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: performance of script to write very long lines of random chars
On Thu, Apr 11, 2013 at 11:21 AM, gry georgeryo...@gmail.com wrote: avail_chrs = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$% \'()*+,-./:;=?@[\\]^_`{}' Is this exact set of characters a requirement? For instance, would it be acceptable to instead use this set of characters? avail_chrs = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' Your alphabet has 92 characters, this one only 64... the advantage is that it's really easy to work with a 64-character set; in fact, for this specific set, it's the standard called Base 64, and Python already has a module for working with it. All you need is a random stream of eight-bit characters, which can be provided by os.urandom(). So here's a much simpler version of your program, following the cut-down character set I offer: import os import base64 nchars = 3200 rows = 10 # Note: If nchars is one higher than a multiple of 4 (eg 5, 9, 101), # the lines will be one character short (4, 8, 100). nchars = nchars * 3 // 4 for l in range(rows): print(base64.b64encode(os.urandom(nchars)).strip(b'=')) If you can guarantee that your nchars will always be a multiple of 4, you can drop the .strip() call. This is going to be *immensely* faster than calling random.choice() for every character, but it depends on a working os.urandom (it'll raise NotImplementedError if there's no suitable source). I know it's available on OS/2, Windows, and Linux, but don't have others handy to test. If by a bunch of different computers you mean exclusively Linux computers, this should be fine. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: performance of script to write very long lines of random chars
On 04/10/2013 07:21 PM, gry wrote: from sys import stdout from array import array import random nchars = 3200 rows = 10 avail_chrs = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$% \'()*+,-./:;=?@[\\]^_`{}' a = array('c', 'X' * nchars) for l in range(rows): for i in xrange(nchars): a[i] = random.choice(avail_chrs) a.tofile(stdout) stdout.write('\n') This version using array took 4 min, 29 sec, using 34MB resident/110 virtual. So, much smaller than the first attempt, but a bit slower. Can someone suggest a better code? And help me understand the performance issues here? Why are you using an array? Why not just rely on the OS to buffer the output. Just write your characters straight to stdout instead of placing them in an array. At that point I believe this program will be as fast as is possible in Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: performance of script to write very long lines of random chars
On Apr 10, 9:52 pm, Michael Torrie torr...@gmail.com wrote: On 04/10/2013 07:21 PM, gry wrote: from sys import stdout from array import array import random nchars = 3200 rows = 10 avail_chrs = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$% \'()*+,-./:;=?@[\\]^_`{}' a = array('c', 'X' * nchars) for l in range(rows): for i in xrange(nchars): a[i] = random.choice(avail_chrs) a.tofile(stdout) stdout.write('\n') This version using array took 4 min, 29 sec, using 34MB resident/110 virtual. So, much smaller than the first attempt, but a bit slower. Can someone suggest a better code? And help me understand the performance issues here? Why are you using an array? Why not just rely on the OS to buffer the output. Just write your characters straight to stdout instead of placing them in an array. At that point I believe this program will be as fast as is possible in Python. Appealing idea, but it's slower than the array solution: 5min 13 secs. vs 4min 30sec for the array: for l in range(rows): for i in xrange(nchars): stdout.write(random.choice(avail_chrs)) stdout.write('\n') os.urandom does look promising -- I have to have full control over the charset, but urandom is very fast at generating big random strings... stay tuned... -- http://mail.python.org/mailman/listinfo/python-list
Re: While loop help
On 04/09/2013 11:44 PM, Larry Hudson wrote: On 04/09/2013 09:49 AM, thomasancill...@gmail.com wrote: So what would be the proper way to perform a loop of this program. I still can't quite figure out the best way to do it. My suggestion... (pseudocode) # Print a heading/introduction here while True: # Print menu, with an added selection to quit # Get the user's choice (as an int) if choice == 1: # Print prompt for this choice # Enter the value (as float, not int. Why limit your values to ints anyway?) # Display the calculated result elif choice == 2: # Same procedure as above elif ... etc # etc elif choice == (value for quit): break# This breaks out of the while loop else: # Invalid choice, print error message # End of loop Further suggestion: Since each of the choices use the same basic procedure, it could be written as a separate single function. It would just need to be passed the appropriate prompt string(s) and conversion factor. The results display _could_ be in this function also, but that would require passing even more strings. It would probably be better to simply return the two values (the input value and the converted value) back to the calling block and print the results there. Also, don't use the round function here, that does NOT guarantee it will be _printed_ to two decimal places. Use string formatting in the print statements. For example: (using your original variable names, and assuming they are now both floats) old style: print '%.2f inches = %.2f meters' % (number, calc) or new style: print '{:.2f} inches = {:.2f} meters'.format(number, calc) You also mentioned that you don't like the editor you're using. For a simple substitute you might try Idle (which normally comes with Python). This gives you the advantage of an interactive environment as will as an editor. There are many other choices, of course, but as a newbie you might find this more comfortable than what you're currently using. I hope this jump-starts your thinking. Keep at it, it's worth the effort. -=- Larry -=- On a little further thought, I realized the single function I suggested is even easier than I originally thought -- even with the results printed in the function. Here's an example: def convert(frm, to, factor): # frm and to are strings, factor is a float print 'Converting {} to {}:'.format(frm, to) value = float(raw_input('How many {}? '.format(frm))) print '{:.2f} {} is {:.2f} {}'.format(value, frm, value * factor, to) You would use it like: convert('inches', 'meters', 0.0254) or convert('meters', 'inches', 39.37) -=- Larry -=- -- http://mail.python.org/mailman/listinfo/python-list
Re: performance of script to write very long lines of random chars
On 11/04/2013 02:21, gry wrote: Dear pythonistas, I am writing a tiny utility to produce a file consisting of a specified number of lines of a given length of random ascii characters. I am hoping to find a more time and memory efficient way, that is still fairly simple clear, and _pythonic_. I would like to have something that I can use at both extremes of data: 32M chars per line * 100 lines or 5 chars per line * 1e8 lines. E.g., the output of bigrand.py for 10 characters, 2 lines might be: gw2+M/5t. S[[db/l?Vx I'm using python 2.7.0 on linux. I need to use only out-of-the box modules, since this has to work on a bunch of different computers. At this point I'm especially concerned with the case of a few very long lines, since that seems to use a lot of memory, and take a long time. Characters are a slight subset of the printable ascii's, specified in the examples below. My first naive try was: from sys import stdout import random nchars = 3200 rows = 10 avail_chrs = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$% \'()*+,-./:;=?@[\\]^_`{}' def make_varchar(nchars): return (''.join([random.choice(avail_chrs) for i in range(nchars)])) for l in range(rows): stdout.write(make_varchar(nchars)) stdout.write('\n') This version used around 1.2GB resident/1.2GB virtual of memory for 3min 38sec. My second try uses much less RAM, but more CPU time, and seems rather, umm, un-pythonic (the array module always seems a little un pythonic...) from sys import stdout from array import array import random nchars = 3200 rows = 10 avail_chrs = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$% \'()*+,-./:;=?@[\\]^_`{}' a = array('c', 'X' * nchars) for l in range(rows): for i in xrange(nchars): a[i] = random.choice(avail_chrs) a.tofile(stdout) stdout.write('\n') This version using array took 4 min, 29 sec, using 34MB resident/110 virtual. So, much smaller than the first attempt, but a bit slower. Can someone suggest a better code? And help me understand the performance issues here? Names in the global scope are stored in a dict, but local to a function are stored in slots and can be accessed more quickly. 'avail_chrs' and 'random.choice' are referred to many times, so making 'avail_chrs' local and making a local reference to 'random.choice' will help. from sys import stdout from array import array import random def generate(): avail_chrs = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%\'()*+,-./:;=?@[\\]^_`{}' rnd = random.choice for l in range(rows): stdout.write(''.join([rnd(avail_chrs) for i in xrange(nchars)])) stdout.write('\n') nchars = 3200 rows = 10 generate() -- http://mail.python.org/mailman/listinfo/python-list
Re: performance of script to write very long lines of random chars
On Thu, Apr 11, 2013 at 12:40 PM, gry georgeryo...@gmail.com wrote: Appealing idea, but it's slower than the array solution: 5min 13 secs. vs 4min 30sec for the array: for l in range(rows): for i in xrange(nchars): stdout.write(random.choice(avail_chrs)) stdout.write('\n') os.urandom does look promising -- I have to have full control over the charset, but urandom is very fast at generating big random strings... stay tuned... Without actually profiling it, my first guess would be that calling random.choice() for every character is an optimization target. (NOTE: Do profile it, if the urandom method isn't sufficient straight-off.) You may want to consider, for instance, generating larger random numbers and doing some kind of translation on them - which is fundamentally what the urandom/b64encode method is doing. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode issue with Python v3.3
Firtly thank uou for taking a look into the code. the doctype is coming form the attempt of script metrites.py to open and read the 'index.html' file. But i don't know how to try to open it as a byte file instead of an tetxt file. -- http://mail.python.org/mailman/listinfo/python-list
Re: performance of script to write very long lines of random chars
On Thu, 11 Apr 2013 11:45:31 +1000, Chris Angelico wrote: On Thu, Apr 11, 2013 at 11:21 AM, gry georgeryo...@gmail.com wrote: avail_chrs = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$% \'()*+,-./:;=?@[\\]^_`{}' Is this exact set of characters a requirement? For instance, would it be acceptable to instead use this set of characters? avail_chrs = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' Your alphabet has 92 characters, this one only 64... the advantage is that it's really easy to work with a 64-character set; in fact, for this specific set, it's the standard called Base 64, and Python already has a module for working with it. All you need is a random stream of eight-bit characters, which can be provided by os.urandom(). I was originally going to write that using the base64 module would introduce bias into the random strings, but after a little investigation, I don't think it does. Or at least, if it does, it's a fairly subtle bias, and not detectable by the simple technique I used: inspect the mean, and the mean deviation from the mean. from os import urandom from base64 import b64encode data = urandom(100) m = sum(data)/len(data) md = sum(abs(v - m) for v in data)/len(data) print(Mean and mean deviation of urandom:, m, md) encoded = b64encode(data).strip(b'=') chars = (b'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef' b'ghijklmnopqrstuvwxyz0123456789+/') values = [chars.index(v) for v in encoded] m = sum(values)/len(values) md = sum(abs(v - m) for v in values)/len(values) print(Mean and mean deviation of encoded data:, m, md) When I run this, it prints: Mean and mean deviation of urandom: 127.451652 63.95331188965717 Mean and mean deviation of encoded data: 31.477027511486245 15.991177272527072 I would expect 127 64 and 32 16, so we're pretty close. That's not to say that there aren't any other biases or correlations in the encoded data, but after a simplistic test, it looks okay to me. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: guessthenumber print games left
On Wednesday, April 10, 2013 5:39:23 AM UTC-4, eschne...@comcast.net wrote: Could anyone tell me how to make the program tell me how many games are left before the first game and second game? For example, after one game of guess the number, I want it to tell me that i get one more game. P.S. I'm totally new to python (obviously), and I just added numberofgames variable in hopes of solving this problem. am I on the right track? Thanks for any assistance! numberofgames=1 while numberofgames4: numberofgames=numberofgames+2 import random print ('type name') name=input() print ('guess a number between 1 and 20, ' + name) number=random.randint(1,20) guessestaken=0 while guessestaken5: guessestaken=guessestaken+1 guess=input() guess=int(guess) if guessnumber: print ('your guess is too low') if guessnumber: print ('your guess is too high0') if guess==number: break if guess==number: print ('you win!') if guess!=number: number=str(number) print ('you lose. the number was ' + number) I can't figure out how to make it count down by itself and state how many are left. -- http://mail.python.org/mailman/listinfo/python-list
Re: guessthenumber print games left
(Didn't mean to post the last bit.) Is this possibly what you meant? If it is I still can't figure out how to apply it to the guessthenumber program. numberofgames=1 while numberofgames4: numberofgames=numberofgames+2 print (4-numberofgames) if numberofguesses3: print(numberofgames) -- http://mail.python.org/mailman/listinfo/python-list
Re: guessthenumber print games left
On Thu, Apr 11, 2013 at 3:41 PM, eschneide...@comcast.net wrote: (Didn't mean to post the last bit.) Is this possibly what you meant? If it is I still can't figure out how to apply it to the guessthenumber program. numberofgames=1 while numberofgames4: numberofgames=numberofgames+2 print (4-numberofgames) if numberofguesses3: print(numberofgames) That's close to it. I still don't understand why you're adding two, and the last print seems to be unnecessary. But if you just add one, then yes, that would be exactly what you want. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: performance of script to write very long lines of random chars
On Thu, Apr 11, 2013 at 3:33 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I was originally going to write that using the base64 module would introduce bias into the random strings, but after a little investigation, I don't think it does. Assuming that os.urandom() returns bytes with perfectly fair distribution (exactly equal chance of any value 00-FF - it probably does, or close to it), and assuming that you work with exact multiples of 3 bytes and 4 output characters, base64 will give you perfectly fair distribution of result characters. You take three bytes (24 bits) and turn them into four characters (6 bits per character, = 24 bits). You might see some bias if you use less than a full set of four output characters, though; I haven't dug into the details to check that. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
[issue17683] socket.getsockname() inconsistent return type with AF_UNIX
Antoine Pitrou added the comment: Well, couldn't we simply return a string in that case? We just have to be more careful than in the patch :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17683 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17674] All examples for concurrent.futures fail with BrokenProcessPool
gjwebber added the comment: Damn, this was my screw up. It was a combination of two things that threw me off: 1. I was running my (saved) code un-gaurded, but was getting the same error as with the example code. I thought the problem was elsewhere. 2. As it was just example code, I was copy-pasting it into my IDE and running it. This caused the slightly weird looking Traceback that Richard Oudkerk pointed out and the same error message. After saving and running the standard example, everything worked as expected. After this, I added the 'main' guard to my code and that fixed the problem there. Sorry about that, looks like there's no problem after all. Tested at home on Win 7 and on my works machine (XP Pro). Regards, Gareth -- resolution: - rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17674 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17683] socket.getsockname() inconsistent return type with AF_UNIX
Charles-François Natali added the comment: Well, couldn't we simply return a string in that case? We just have to be more careful than in the patch :-) Probably, provided that: - s.bind(addr).getsockname() == addr - it doesn't break existing code :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17683 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16427] Faster hash implementation
Mark Dickinson added the comment: Note that the patch uses type punning through a union: while GCC allows this, it's not allowed by ANSI. I believe it's legal under C99 + TC3. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16427 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17661] documentation of '%r' links to the wrong repr
Antoine Pitrou added the comment: It just highlights the mistake we made calling a builtin module the same name as a builtin function :) But shouldn't the highlighting be handled by Pygments? ;) -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17661 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17679] sysconfig generation uses some env variables multiple times
Bohuslav Slavek Kabrda added the comment: I'm attaching a patch that I'm currently using to solve this. It works, but it's a bit aggressive - in the sense that it only adds a string to the sysconfig variable iff this string is not a substring of current variable value. So it may corrupt some values, e.g. it wouldn't add python to variable if that variable already had /usr/lib/python. But it seems to get all the values just fine for me. -- keywords: +patch Added file: http://bugs.python.org/file29763/00178-dont-duplicate-flags-in-sysconfig.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17679 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17684] Skip tests in test_socket like testFDPassSeparate on OS X
Richard Oudkerk added the comment: On 10/04/2013 6:32am, Charles-François Natali wrote: Richard, IIRC, you said somewhere that FD passing failures on OS X could be made to work by passing a FD at a time, or something like that. What do you think of those faiilures? I think sending one *array* at a time works as well. These two failures send two arrays, so they are expected. (Also, the sending process should wait for some sort of notification that the receiving process has received the fds before continuing: closing the socket prematurely causes problems.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17684 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17684] Skip tests in test_socket like testFDPassSeparate on OS X
Antoine Pitrou added the comment: Indeed, it has been decided that @expectedFailure would only work when applied to the test methods run by unittest. In that light, the patch is a correct solution to the issue. (I don't think expected failures are a very useful concept myself :-)) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17684 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17685] Frozenset literal?
New submission from Edd: Hi, I am willing to bet that this has been discussed before, but I don't see any related bugs. I have been using Python for a while now as a prototyping language for scientific applications. Most recently I have been using it for prototype program analyses. In this kind of work you are usually transcribing pseudo-code, defined in terms of sets, vectors and mappings into Python syntax. Inevitably, you need to store sets of sets, or you need to do some other operation that requires a hashable data structure. As a result, I never use sets. I usually resort to using frozensets, which are hashable, yet the syntax for creating these is very verbose: frozenset([e1, e2, ...]) To counter this, I usually use the following hack: fs = frozenset then frozensets can be instantiated like this: fs([e1, e2, ...]) But this is not ideal. I can't help wondering why there is not a frozenset literal. I see that the mutable set recently got a literal, but why not frozenset? Cheers! -- components: Interpreter Core messages: 186486 nosy: vext01 priority: normal severity: normal status: open title: Frozenset literal? type: enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17685 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17683] socket.getsockname() inconsistent return type with AF_UNIX
Antoine Pitrou added the comment: Apparently the current code is a result of Guido's changeset 980308fbda29 which changed normal Unix sockets to use unicode objects, but Linux abstract namespace sockets to use bytes objects. I don't know if a lot of thought was given to the issue in that changeset; I would favour using PyUnicode_DecodeFSDefaultAndSize for Linux abstract namespace sockets too. -- nosy: +gvanrossum ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17683 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15518] Provide test coverage for filecmp.dircmp.report methods.
Eli Bendersky added the comment: Thanks, looks much better now. I left a couple of small comments in the code review. Other than that, it makes sense to me to update the existing tests to follow this scheme as well. Thanks! On a related note, since you've obviously studied the filecmp module's operation to a great depth, your input on http://bugs.python.org/issue15430 would be appreciated. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15518 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17685] Frozenset literal?
Mark Dickinson added the comment: See the (inconclusive) python-ideas thread starting here: http://mail.python.org/pipermail/python-ideas/2013-February/019205.html I'm going to close this issue: the python-ideas mailing list is better suited for this kind of open-ended discussions (though it would be fine to re-open an issue with a specific, detailed proposal for a change---one that a patch could reasonably be written for). You could resurrect that python-ideas thread, or start a new one, if you want to renew the discussion. -- nosy: +mark.dickinson resolution: - wont fix status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17685 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17656] Python 2.7.4 breaks ZipFile extraction of zip files with unicode member paths
Benjamin Peterson added the comment: Yes; I won't have time for a few days, though. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17656 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17686] Doc using/unix broken link (http://linuxmafia.com/)
New submission from Masato HASHIMOTO: In Doc/using/unix.rst, the following link is broken: 31: http://linuxmafia.com/pub/linux/suse-linux-internals/chapter35.html (See also for OpenSuse users) -- assignee: docs@python components: Documentation messages: 186491 nosy: docs@python, hashimo priority: normal severity: normal status: open title: Doc using/unix broken link (http://linuxmafia.com/) versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17686 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17685] Frozenset literal?
Changes by Barry A. Warsaw ba...@python.org: -- nosy: +barry ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17685 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17666] Extra gzip headers breaks _read_gzip_header
Georg Brandl added the comment: Serhiy, do you want to fix this also in 3.2? I'll roll a brown-paper-bag release of 3.2 and 3.3 together with 2.7.5. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17666 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17656] Python 2.7.4 breaks ZipFile extraction of zip files with unicode member paths
Georg Brandl added the comment: I guess I will join with 3.2 and 3.3 for #17666. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17656 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17656] Python 2.7.4 breaks ZipFile extraction of zip files with unicode member paths
Ned Deily added the comment: Perhaps we should hold off for a week or two to see if any other critical problems show up. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17656 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17675] show addresses in socket.__repr__
Roundup Robot added the comment: New changeset 1410b7790de6 by Giampaolo Rodola' in branch 'default': Fix issue #17675: make socket repr() provide local and remote addresses (if any). http://hg.python.org/cpython/rev/1410b7790de6 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17675 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17675] show addresses in socket.__repr__
Changes by Giampaolo Rodola' g.rod...@gmail.com: -- assignee: - giampaolo.rodola resolution: - fixed stage: - committed/rejected status: open - closed type: - enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17675 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17656] Python 2.7.4 breaks ZipFile extraction of zip files with unicode member paths
Georg Brandl added the comment: Yes, although the new releases will get the standard rc period anyway. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17656 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17683] socket.getsockname() inconsistent return type with AF_UNIX
Guido van Rossum added the comment: Sorry, I don't think I have anything to add. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17683 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17430] missed peephole optimization
Ezio Melotti added the comment: ISTM that we were trying to moving towards an AST optimizer and away from the peephole, so I'm not sure it's a good idea to add more optimization to it. #11549 has patches about the AST optimizer. -- nosy: +benjamin.peterson, rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17430 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17607] missed peephole optimization (unnecessary jump at end of function after yield)
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti versions: +Python 3.4 -Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17607 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17620] Python interactive console doesn't use sys.stdin for input
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17620 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17683] socket.getsockname() inconsistent return type with AF_UNIX
Giampaolo Rodola' added the comment: Note that if we pass bytes to bind(), getsockname() will return str anyway: s = socket.socket(socket.AF_UNIX) s.bind(b'hello') s.getsockname() 'hello' That said, it seems more consistent to me to return str also in case of abstract namespace. As per: http://blog.eduardofleury.com/archives/2007/09/13 ...one is supposed to set only the first byte to null, and the rest of the path is supposed to be a 'plain' string. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17683 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17654] IDLE only customizes correctly for OS X when using framework build
Ronald Oussoren added the comment: The trigger for the customizations is probably too specific. The primary reason for a having a check that's more specific than 'if sys.platform == darwin' is to avoid using the customizations when someone uses an X11 build of Tk and I didn't know (and still don't) a way to check for a native Tk port. -- nosy: +ronaldoussoren ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17654 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17687] Undeclared symbol in _struct.c
New submission from Andreas Kloeckner: This line in the _struct module references a PyStructType that isn't declared anywhere. This is only apparent when the file is compiled without -DNDEBUG. http://hg.python.org/cpython/file/1410b7790de6/Modules/_struct.c#l43 -- components: Extension Modules messages: 186501 nosy: inducer priority: normal severity: normal status: open title: Undeclared symbol in _struct.c type: compile error versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17687 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17635] Doc of multiprocessing.connection mentions answerChallenge instead of answer_challenge
Roundup Robot added the comment: New changeset 54532684dbed by Ezio Melotti in branch '2.7': #17635: fix wrong function name in multiprocessing docs. http://hg.python.org/cpython/rev/54532684dbed -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17635 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17687] Undeclared symbol in _struct.c
Mark Dickinson added the comment: Isn't it declared on line 12? -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17687 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17635] Doc of multiprocessing.connection mentions answerChallenge instead of answer_challenge
Roundup Robot added the comment: New changeset 5d39d459b90d by Ezio Melotti in branch '3.3': #17635: fix wrong function name in multiprocessing docs. http://hg.python.org/cpython/rev/5d39d459b90d New changeset 1a935e932152 by Ezio Melotti in branch 'default': #17635: merge with 3.3. http://hg.python.org/cpython/rev/1a935e932152 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17635 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17635] Doc of multiprocessing.connection mentions answerChallenge instead of answer_challenge
Ezio Melotti added the comment: Fixed, thanks for the report! -- assignee: docs@python - ezio.melotti nosy: +ezio.melotti resolution: - fixed stage: - committed/rejected status: open - closed type: - enhancement versions: +Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17635 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17637] Mention What's New in devguide's patch guidelines
Ezio Melotti added the comment: The What's new is already mentioned briefly in http://docs.python.org/devguide/committing.html#news-entries. Would it be enough to rephrase that part and clarify that committers are expected to update it? Another option is to add a new item to make patchcheck (and to http://docs.python.org/devguide/committing.html#patch-checklist), but I'm not sure it's worth doing it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17637 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15964] SyntaxError in asdl when building 2.7 with system Python 3
Ezio Melotti added the comment: I left a review. To test it you could try to reproduce the steps described in the first message and see what happens. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15964 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17661] documentation of '%r' links to the wrong repr
Éric Araujo added the comment: You can always use a ref role instead of func. func tries to find a module, class or function in the global Sphinx index, but ref lets you link to one specific target (see the table at the top of library/functions.rst for an example). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17661 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17668] re.split loses characters matching ungrouped parts of a pattern
Tomasz J. Kotarba added the comment: The example I gave was the simplest possible to illustrate my point but yes, you are correct, I often match the whole string as I do recursive matches. I do use non-capturing groups but they would not solve the problem I talked about. Anyway, I had solved my problem before I reported this issue so I would be all right with whatever the outcome of this discussion was but I am glad we have managed to contribute to improving the docs. Thanks and nice talking to you :)! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17668 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17687] Undeclared symbol in _struct.c
Andreas Kloeckner added the comment: Whoops. I'm an idiot. Forget I said anything. -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17687 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com