RedNotebook 1.6.2
A new RedNotebook version has been released. You can get the tarball, Windows installer and links to distribution packages at http://rednotebook.sourceforge.net/downloads.html What is RedNotebook? RedNotebook is a **graphical journal** and diary helping you keep track of notes and thoughts. It includes a calendar navigation, customizable templates, export functionality and word clouds. You can also format, tag and search your entries. RedNotebook is available in the repositories of most common Linux distributions and a Windows installer is available. It is written in Python and uses GTK+ for its interface. What's new in this version? --- * Add option for automatically switching between edit and preview mode to preferences. * Since debian doesn't have a python2 symlink, try to run python2.7 and python2.6 in the run script. * Use PNG image in about dialog (SVG support is broken in Windows version). Cheers, Jendrik -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: Python Interview Questions
On 11/19/2012 1:01 AM, Ian Kelly wrote: than tuple access. Tuples are as fast as or faster than lists, pretty much universally. They seem to have closed the gap a bit in Python 3.3, though, as the following timings show. For one-shot construction, tuples seem to be more efficient for short sequences, but then lists win for longer sequences, although not by much. Of course, lists are always going to be much slower if you build them up with appends and extends. Interesting results. But what system (hardware, os). These sorts of times tend to vary with the system. C:\python -m timeit -s x = range(10) tuple(x) 100 loops, best of 3: 0.773 usec per loop C:\python -m timeit -s x = range(10) list(x) 100 loops, best of 3: 0.879 usec per loop C:\python -m timeit -s x = range(100) tuple(x) 10 loops, best of 3: 2.88 usec per loop C:\python -m timeit -s x = range(100) list(x) 10 loops, best of 3: 2.63 usec per loop C:\python -m timeit -s x = range(1000) tuple(x) 1 loops, best of 3: 37.4 usec per loop C:\python -m timeit -s x = range(1000) list(x) 1 loops, best of 3: 36.2 usec per loop C:\python -m timeit -s x = range(1) tuple(x) 1000 loops, best of 3: 418 usec per loop C:\python -m timeit -s x = range(1) list(x) 1000 loops, best of 3: 410 usec per loop For iteration, tuples are consistently 7-8% faster. C:\python -m timeit -s x = tuple(range(10)) for i in x: pass 100 loops, best of 3: 0.467 usec per loop C:\python -m timeit -s x = list(range(10)) for i in x: pass 100 loops, best of 3: 0.498 usec per loop C:\python -m timeit -s x = tuple(range(100)) for i in x: pass 10 loops, best of 3: 3.31 usec per loop C:\python -m timeit -s x = list(range(100)) for i in x: pass 10 loops, best of 3: 3.56 usec per loop C:\python -m timeit -s x = tuple(range(1000)) for i in x: pass 1 loops, best of 3: 31.6 usec per loop C:\python -m timeit -s x = list(range(1000)) for i in x: pass 1 loops, best of 3: 34.3 usec per loop C:\python -m timeit -s x = tuple(range(1)) for i in x: pass 1000 loops, best of 3: 318 usec per loop C:\python -m timeit -s x = list(range(1)) for i in x: pass 1000 loops, best of 3: 341 usec per loop For direct item access, tuples seem to be about 2-3% faster. C:\python -m timeit -s import operator as o; x = tuple(range(10)); g = o.itemgetter(*range(len(x))) g(x) 100 loops, best of 3: 0.67 usec per loop C:\python -m timeit -s import operator as o; x = list(range(10)); g = o.itemgetter(*range(len(x))) g(x) 100 loops, best of 3: 0.674 usec per loop C:\python -m timeit -s import operator as o; x = tuple(range(100)); g = o.itemgetter(*range(len(x))) g(x) 10 loops, best of 3: 4.52 usec per loop C:\python -m timeit -s import operator as o; x = list(range(100)); g = o.itemgetter(*range(len(x))) g(x) 10 loops, best of 3: 4.65 usec per loop C:\python -m timeit -s import operator as o; x = tuple(range(1000)); g = o.itemgetter(*range(len(x))) g(x) 1 loops, best of 3: 43.2 usec per loop C:\python -m timeit -s import operator as o; x = list(range(1000)); g = o.itemgetter(*range(len(x))) g(x) 1 loops, best of 3: 43.7 usec per loop C:\python -m timeit -s import operator as o; x = tuple(range(1)); g = o.itemgetter(*range(len(x))) g(x) 1000 loops, best of 3: 422 usec per loop C:\python -m timeit -s import operator as o; x = list(range(1)); g = o.itemgetter(*range(len(x))) g(x) 1000 loops, best of 3: 447 usec per loop -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Point of idle curiosity
Am 18.11.2012 12:45, schrieb Chris Angelico: (if you'll forgive the pun) Nevarr! Is IDLE named after Eric of that name, or is it pure coincidence? Maybe. Interestingly, there is also http://eric-ide.python-projects.org/, just to add some more unfounded conspiracy theories to this discussion. :P Uli -- http://mail.python.org/mailman/listinfo/python-list
Premature end of script headers: wsgihandler.py on usage of BytesIO()
Hi all, I am generating graphs using cairo plot in web2py project. Here I am using BytesIO() stream for generating graphs. Everything runs fine when I run on localhost but when I deploy it on apache server and then run from different machines OR from different browsers in same machine then the server becomes halt and in apache error log, I found this error message: Premature end of script headers: wsgihandler.py, Furthermore, it occurs only when I use BytesIO() stream for generating graphs. In all other cases, it run smoothly. Please guide me that how I should resolve this issue. Furthermore, please also guide, if I can use any stream other BytesIO() -- http://mail.python.org/mailman/listinfo/python-list
Re: error importing smtplib
I can do this in stand alone programs because my code does the import and calls the login function so I can control the order of things. Unfortunately stand alone programs are not the only ways in which I am using these Python bindings. You can customize and extend this 3rd party application at various extension points all of which are invoked after login. We have a lot of extensions written in Python. I guess I will have to back to the BAR vendor and ask if it is okay to remove their old .so file. Perhaps their code will just work with the newer 0.9.8e or perhaps they'll have to relink or recompile. On Fri, Nov 16, 2012 at 5:00 PM, Terry Reedy tjre...@udel.edu wrote: [easy] Do the import before the function call, which is the proper order and the one that works. -- Terry Jan Reedy -- http://mail.python.org/**mailman/listinfo/python-listhttp://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Interview Questions
In article 50a9e5cf$0$21863$c3e8da3$76491...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I see. It wasn't clear from your earlier description that the items had been post-processed from collections of raw log lines to fixed records. Well, I did provide the code that does this. But it doesn't actually change my analysis any. See below. By the way, based on the sample data you show, your script is possibly broken. You don't record either the line number that raises, or the exception raised, so your script doesn't differentiate between different errors that happen to occur with similar stack traces. You really might want to read the code I provided. Here's the reference again: https://bitbucket.org/roysmith/python-tools/src/4f8118d175ed/logs/traceba ck_helper.py The header referred to does indeed contain the exception raised. And the line numbers are included. Here's a typical output stanza: 2012-11-19T00:00:15+00:00 web5 ËË2012-11-19 00:00:15,831 [2712]: songza-api IGPhwNU2SJ691cx8 4C0ABFA9-50A974E7-384995 W6D-HSO 173.145.137.54 songza.django.middleware ERROR process_exception() Path = u'/api/1/station/1459775/next', Exception = ValueError(uSequentialSongPicker: Station 1459775: u'Old School 105.3': no song ids for mp3,) /home/songza/env/python/local/lib/python2.7/site-packages/django/core/han dlers/base.py:111:get_response() /home/songza/deploy/current/pyza/djapi/decorators.py:11:_wrapped_view_fun c() /home/songza/env/python/local/lib/python2.7/site-packages/django/views/de corators/http.py:45:inner() /home/songza/deploy/current/pyza/djapi/views.py:1659:station_next() /home/songza/deploy/current/pyza/models/station.py:660:next_song() /home/songza/deploy/current/pyza/lib/song_picker.py:327:pick() I say possibly broken because I don't know what your requirements are. Our requirements are to scan the logs of a production site and filter down the gobs and gobs of output (we produced 70 GB of log files yesterday) into something small enough that a human can see what the most common failures were. The tool I wrote does that. The rest of this conversation is just silly. It's turning into getting hit on the head lessons. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python questions help
On 2012-11-16, Chris Angelico ros...@gmail.com wrote: On Sat, Nov 17, 2012 at 5:00 AM, rh richard_hubb...@lavabit.com wrote: How many people think programming skills are inherent? i.e. that some people are just born with the gift to be good programmers Result: very few hands raised maybe a couple (possibly non-progammers??) Maybe, but there's definitely something that happens close to birth. If your parents give you the name Chris, you're more likely to become a geek and a programmer. There are people with rare talent who can program in a way that most others can't, .e.g, Chris Sawyer. But, as Louis Moyse, a great musician remarked: Without hard work, talent means nothing. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Interview Questions
OK, I've just read back over the whole thread. I'm really struggling to understand what point you're trying to make. I started out by saying: Use a list when you need an ordered collection which is mutable (i.e. can be altered after being created). Use a tuple when you need an immutable list (such as for a dictionary key). To which you obviously objected. So now you write: I think a tuple is an immutable sequence of items, and a list is a mutable sequence of items. So how is that different from what I said? Is this whole argument boiling down to your use of immutable sequence vs. my use of immutable list? -- http://mail.python.org/mailman/listinfo/python-list
Re: Premature end of script headers: wsgihandler.py on usage of BytesIO()
On 19/11/12 14:29:13, Yasir Saleem wrote: Hi all, I am generating graphs using cairo plot in web2py project. Here I am using BytesIO() stream for generating graphs. Everything runs fine when I run on localhost but when I deploy it on apache server and then run from different machines OR from different browsers in same machine then the server becomes halt and in apache error log, I found this error message: Premature end of script headers: wsgihandler.py, Furthermore, it occurs only when I use BytesIO() stream for generating graphs. In all other cases, it run smoothly. Please guide me that how I should resolve this issue. One technique is to put at the very top of the script, even above the import statements: print Content-Type: text/plain\n\n This will cause all text output by your script to be displayed in your browser as plain text [1]. If you inspect it, you'll probably find some kind of warning displayed above the HTML headers. You'll need to find a way to not receive that warning. It's usually best if you can actually solve the issue Python is warning about. it that's not possible, suppressing the warning may be your only alternative. If you can't figure out what the message means, and Google doesn't know either, you can post it in this forum and ask for further guidance. [1] Except if you use Internet Explorer, which will ask you whether you want to save the document. You can either do that and view the content with another application, or use another browser, or change the content-type to text/html. If you do the latter, IE will notice that the content is really plain text, and that it is actually quite capable of displaying that. Hope this helps, -- HansM -- http://mail.python.org/mailman/listinfo/python-list
Paid Python work for 30mins - 1 hour
I have three scripts that I would like written, they are designed to do the following: Backup.py – Zip a folder and store it on amazon S3 using BOTO with the date and time as the folder name. Restore.py – Grab a file from S3 and download it and then unzip it in the right location with two commandline parameters (1 = Get most recent, 2 = Get specific file) Import.py – Check that I have done this correctly and add command line parameter for changing the command This code is probably 50% completed already and if someone knows what they are doing, could be completed in a very short time. It is really basic Python code, I just dont know python myself. If you are interested get in touch! -- http://mail.python.org/mailman/listinfo/python-list
Re: Paid Python work for 30mins - 1 hour
Forgot to say, my email is blockedu...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Interview Questions
On Mon, Nov 19, 2012 at 7:30 AM, Roy Smith r...@panix.com wrote: In article 50a9e5cf$0$21863$c3e8da3$76491...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: By the way, based on the sample data you show, your script is possibly broken. You don't record either the line number that raises, or the exception raised, so your script doesn't differentiate between different errors that happen to occur with similar stack traces. You really might want to read the code I provided. Here's the reference again: https://bitbucket.org/roysmith/python-tools/src/4f8118d175ed/logs/traceba ck_helper.py The header referred to does indeed contain the exception raised. And the line numbers are included. Here's a typical output stanza: Yes, but the dict is still keyed on the traceback alone, and only the first header for a particular traceback is stored. If two different exceptions occur at the same line of code and sharing the same traceback, the second exception would be counted as a second occurrence of the first, effectively squashing any reporting of the second exception. -- http://mail.python.org/mailman/listinfo/python-list
Linux compatibility
Hi All, I would like know if Python 2.4.3 will be compatible with Linux RHEL 5.5 or 6.1? Thanks Tony -- http://mail.python.org/mailman/listinfo/python-list
Re: Yet another Python textbook
On Mon, Nov 19, 2012 at 6:30 AM, Pavel Solin solin.pa...@gmail.com wrote: I would like to introduce a new Python textbook aimed at high school students: http://femhub.com/textbook-python/. The textbook is open source and its public Git repository is located at Github: g...@github.com:femhub/nclab-textbook-python.git URL for humans: https://github.com/femhub/nclab-textbook-python Feedback and contributions are very much welcome, every contributor becomes automatically a co-author. Best regards, Pavel You are writing it for something called “NCLab”, not for the general public, and that sucks. 1. please use math-compatible fonts in LaTeX, like Computer Modern, Latin Modern, Lucida Bright or MathTime (I suggest one of the first two). This way, stuff in the math environment won’t look differently than the text. Currently, your text is in a fancy font and maths are in Computer Modern. 2. IMO, you should be doing a bit more general usage programming, not science-specific. 3. Code highlighting for inline code and other languages, please. This are just my basic thoughts from looking through it. -- Kwpolska http://kwpolska.tk stop html mail | always bottom-post www.asciiribbon.org | www.netmeister.org/news/learn2quote.html GPG KEY: 5EAAEA16 -- http://mail.python.org/mailman/listinfo/python-list
Re: Paid Python work for 30mins - 1 hour
blockedu...@gmail.com writes: I have three scripts that I would like written, they are designed to do the following: Backup.py – Zip a folder and store it on amazon S3 ... If you are interested get in touch! You could just type python s3 upload into web search and see if you can use the stuff that turns up. More realistically I'm not sure it makes sense to set up a 30 minute / 1 hour development gig, especially without a completely precise specification up front. There will have to be some back-and-forth about the user interface, the script will have to be tested, the developer will need access to an S3 account if s/he doesn't have it already, etc. So it's likely to end up taking longer than 1 hour even though the task is pretty simple. But, maybe someone will take you up on it, and if it turns out to be more trouble than it was worth, at least they learned something. If you already have 50% of the code written, what's preventing you from doing the other 50% yourself? If you're hitting snags, maybe you could post what you have so far, and ask for advice. -- http://mail.python.org/mailman/listinfo/python-list
Re: Paid Python work for 30mins - 1 hour
On Mon, Nov 19, 2012 at 10:14 AM, blockedu...@gmail.com wrote: I have three scripts that I would like written, they are designed to do the following: Backup.py – Zip a folder and store it on amazon S3 using BOTO with the date and time as the folder name. Restore.py – Grab a file from S3 and download it and then unzip it in the right location with two commandline parameters (1 = Get most recent, 2 = Get specific file) Import.py – Check that I have done this correctly and add command line parameter for changing the command This code is probably 50% completed already and if someone knows what they are doing, could be completed in a very short time. It is really basic Python code, I just dont know python myself. If you are interested get in touch! You might consider putting your request on elance.com or guru.com where you can hire programmers for small projects like this. Good luck, mark -- http://mail.python.org/mailman/listinfo/python-list
Re: Paid Python work for 30mins - 1 hour
Mark Adam dreamingforw...@gmail.com writes: You might consider putting your request on elance.com or guru.com where you can hire programmers for small projects like this. Even though the coding task is very small, I think it's unrealistic to scope it at less than 2-4 hours, given communication overhead etc. It would be quicker if it were done in person. -- http://mail.python.org/mailman/listinfo/python-list
Robust regex
Trying to robustly parse a string that will have key/value pairs separated by three pipes, where each additional key/value (if more than one exists) will be delineated by four more pipes. string = 'key_1|||value_1key_2|||value_2' regex = '((?:(?!\|\|\|).)+)(?:\|\|\|)((?:(?!\|\|\|).)+)(?:\|\|\|\|)?' I am not convinced this is the most effective or safest, any opinions would be greatly appreciated! jlc -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Interview Questions
On 11/19/2012 9:30 AM, Roy Smith wrote: Our requirements are to scan the logs of a production site and filter down the gobs and gobs of output (we produced 70 GB of log files yesterday) into something small enough that a human can see what the most common failures were. The tool I wrote does that. The rest of this conversation is just silly. It's turning into getting hit on the head lessons. I agree. In early Python, tuples were more different from lists than they are today. They did not have any (public) methods. Today, they have .index and .count methods, which make little sense from the 'tuple is a record' viewpoint. The addition of those methods redefined tuples as read-only (and therefore hashable) sequences. From the collections.abc doc ''' Sequence | Sized, Iterable, Container | __getitem__ __contains__, __iter__, __reversed__, index, and count ... class collections.abc.Sequence class collections.abc.MutableSequence ABCs for read-only and mutable sequences. ''' from collections.abc import Sequence issubclass(tuple, Sequence) True -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Robust regex
On Tue, Nov 20, 2012 at 7:32 AM, Joseph L. Casale jcas...@activenetwerx.com wrote: Trying to robustly parse a string that will have key/value pairs separated by three pipes, where each additional key/value (if more than one exists) will be delineated by four more pipes. string = 'key_1|||value_1key_2|||value_2' regex = '((?:(?!\|\|\|).)+)(?:\|\|\|)((?:(?!\|\|\|).)+)(?:\|\|\|\|)?' I am not convinced this is the most effective or safest, any opinions would be greatly appreciated! Is regex a requirement? Since you posted this on python-list, I'm going to assume you're working in Python. string = 'key_1|||value_1key_2|||value_2' content = dict(map(lambda x: x.split(|||),string.split())) -- {'key_1': 'value_1', 'key_2': 'value_2'} ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Robust regex
On Nov 19, 2012 12:37 PM, Joseph L. Casale jcas...@activenetwerx.com wrote: Trying to robustly parse a string that will have key/value pairs separated by three pipes, where each additional key/value (if more than one exists) will be delineated by four more pipes. string = 'key_1|||value_1key_2|||value_2' regex = '((?:(?!\|\|\|).)+)(?:\|\|\|)((?:(?!\|\|\|).)+)(?:\|\|\|\|)?' I am not convinced this is the most effective or safest, any opinions would be greatly appreciated! jlc -- http://mail.python.org/mailman/listinfo/python-list Do you even need a regular expression for this? Just split on and then split those on |||. -- http://mail.python.org/mailman/listinfo/python-list
Re: Point of idle curiosity
On Sun, 18 Nov 2012 16:08:34 +, Mark Lawrence wrote: On 18/11/2012 15:59, Steven D'Aprano wrote: On Sun, 18 Nov 2012 22:45:43 +1100, Chris Angelico wrote: (if you'll forgive the pun) Is IDLE named after Eric of that name, or is it pure coincidence? Well, IDLE is an IDE. The L doesn't seem to mean anything, so it's plausible that it is named after Eric Idle. https://en.wikipedia.org/wiki/IDLE_%28Python%29 i think it is fairly safe to assume that for most (if not all) good sounding acronyms the acronym was chosen before the meaning or at least chosen from short list of possible meanings because it looked good. -- I THINK MAN INVENTED THE CAR by instinct. -- Jack Handley, The New Mexican, 1988. -- http://mail.python.org/mailman/listinfo/python-list
Re: Robust regex
On 2012-11-19 20:32, Joseph L. Casale wrote: Trying to robustly parse a string that will have key/value pairs separated by three pipes, where each additional key/value (if more than one exists) will be delineated by four more pipes. string = 'key_1|||value_1key_2|||value_2' regex = '((?:(?!\|\|\|).)+)(?:\|\|\|)((?:(?!\|\|\|).)+)(?:\|\|\|\|)?' I am not convinced this is the most effective or safest, any opinions would be greatly appreciated! Do you need to use regex? It would be simpler to use the .split method: for pair in string.split(): key, value = pair.split(|||) print(key is {!r}, value is {!r}.format(key, value)) -- http://mail.python.org/mailman/listinfo/python-list
Re: Robust regex
In mailman.7.1353357285.29569.python-l...@python.org Joseph L. Casale jcas...@activenetwerx.com writes: Trying to robustly parse a string that will have key/value pairs separated by three pipes, where each additional key/value (if more than one exists) will be delineated by four more pipes. string = 'key_1|||value_1key_2|||value_2' regex = '((?:(?!\|\|\|).)+)(?:\|\|\|)((?:(?!\|\|\|).)+)(?:\|\|\|\|)?' I am not convinced this is the most effective or safest, any opinions would be greatly appreciated! Regexes may be overkill here. A simple string split might be better: string = 'key_1|||value_1key_2|||value_2' pairs = string.split('') for pair in pairs: keyval = pair.split('|||') print '%s=%s' % (keyval[0], keyval[1]) -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies -- http://mail.python.org/mailman/listinfo/python-list
Re: Point of idle curiosity
On Mon, Nov 19, 2012 at 11:38 PM, Ulrich Eckhardt ulrich.eckha...@dominolaser.com wrote: Am 18.11.2012 12:45, schrieb Chris Angelico: Is IDLE named after Eric of that name, or is it pure coincidence? Maybe. Interestingly, there is also http://eric-ide.python-projects.org/, just to add some more unfounded conspiracy theories to this discussion. :P Wait, that's completely separate. I don't think Eric Idle was ever a member of the Eric Conspiracy. http://www.catb.org/~esr/ecsl/ ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Python questions help
On Tue, Nov 20, 2012 at 1:57 AM, Neil Cerutti ne...@norwich.edu wrote: On 2012-11-16, Chris Angelico ros...@gmail.com wrote: On Sat, Nov 17, 2012 at 5:00 AM, rh richard_hubb...@lavabit.com wrote: How many people think programming skills are inherent? i.e. that some people are just born with the gift to be good programmers Result: very few hands raised maybe a couple (possibly non-progammers??) Maybe, but there's definitely something that happens close to birth. If your parents give you the name Chris, you're more likely to become a geek and a programmer. There are people with rare talent who can program in a way that most others can't, .e.g, Chris Sawyer. But, as Louis Moyse, a great musician remarked: Without hard work, talent means nothing. Sure, it definitely takes work. You still have to put in your ten thousand hours. I don't know what the connection is, but there do seem to be a LOT of geeky Chrises; in fact, in any mid-length thread here on python-list, you could probably conclude with a Thanks for the tip, Chris, it works now! without even bothering to read it. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
RE: xml data or other?
Artie Ziff wrote: On 11/9/12 5:50 AM, rusi wrote: On Nov 9, 5:54 pm, Artie Ziff artie.z...@gmail.com wrote: # submit correctedinput to etree I was very grateful to get the leg up on getting started down that right path with my coding. Many thanks to you, rusi. I took your excellent advices and have this working. class Converter(): PREFIX = ?xml version=1.0? data POSTFIX = /data def __init__(self, data): self.data = data self.writeXML() def writeXML(self): pattern = re.compile('testname=(.*)') replaceStr = r'testname name=\1' xmlData = re.sub(pattern, replaceStr, self.data) self.dataXML = self.PREFIX + xmlData.replace(\\, /) + self.POSTFIX ### main # input to script is directory: # sanitize trailing slash testPkgDir = sys.argv[1].rstrip('/') # Within each test package directory is doc/testcase tcDocDir = doc/testcases # set input dir, containing broken files tcTxtDir = os.path.join(testPkgDir, tcDocDir) # set output dir, to write proper XML files tcXmlDir = os.path.join(testPkgDir, tcDocDir + _XML) if not os.path.exists(tcXmlDir): os.makedirs(tcXmlDir) # iterate through files in input dir for filename in os.listdir(tcTxtDir): # set filepaths filepathTXT = os.path.join(tcTxtDir, filename) base = os.path.splitext(filename)[0] fileXML = base + .xml filepathXML = os.path.join(tcXmlDir, fileXML) # read broken file, convert to proper XML with open(filepathTXT) as f: c = Converter(f.read()) xmlFO = open(filepathXML, 'w') # xmlFileObject xmlFO.write(c.dataXML) xmlFO.close() ### Writing XML files so to see whats happening. My plan is to keep xml data in memory and parse with xml.etree.ElementTree. Unfortunately, xml parsing fails due to angle brackets inside description tags. In particular, xml.etree.ElementTree.parse() aborts on '' inside xml data such as the following: testname name=cron_test.sh description This testcase tests if crontab filename installs the cronjob and cron schedules the job correctly. \description ## What is right way to handle the extra angle brackets? Substitute on line-by-line basis, if that works? Or learn to write a simple stack-style parser, or recursive descent, it may be called? I think your description text should be in a CDATA section. http://en.wikipedia.org/wiki/CDATA#CDATA_sections_in_XML ~Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
RE: Robust regex
Regexes may be overkill here. A simple string split might be better: Yup, and much more robust as I was looking for. Thanks everyone! jlc -- http://mail.python.org/mailman/listinfo/python-list
re.search when used within an if/else fails
python version 2.4.3, yes i know that it is old. getting the sysadmin to update the OS requires a first born. with the following code.. for signal in register['signals'] : 351 sigName = signal['functionName'] 352 if re.search( rsrvd, sigName ) == None : 353 print sigName 354 newVal = %s%s % ( '1'*signal['bits'] , newVal ) #prepend 0's 355 if re.search( rsrvd, sigName ) != None : 356 print sigName 357 newVal = %s%s % ( '0'*signal['bits'], newVal ) regardless of how i code line 352, i can not EVER use an else clause with it. if i use an else clause, the else will NEVER get executed... has any one experienced anything like this behavior? any suggestions? the above code works but... why should i have to code it like this? kevin -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Interview Questions
On Mon, 19 Nov 2012 09:30:54 -0500, Roy Smith wrote: In article 50a9e5cf$0$21863$c3e8da3$76491...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I see. It wasn't clear from your earlier description that the items had been post-processed from collections of raw log lines to fixed records. Well, I did provide the code that does this. You did? When? [goes back and looks] Oh, so you did. Oops. By the way, your news client seems to be mangling long URLs, by splitting them when they exceed the maximum line length. I didn't follow the link you gave because it was mangled, and then forgot it even existed. Sorry about that. [...] You really might want to read the code I provided. Here's the reference again: https://bitbucket.org/roysmith/python-tools/src/4f8118d175ed/logs/ traceba ck_helper.py And mangled again :) The header referred to does indeed contain the exception raised. And the line numbers are included. Here's a typical output stanza: [snip] Ian Kelly has picked up on what I'm trying to say. You might collect the traceback in the header, but it doesn't get used in the key, and each time you find a repeated stack trace, you toss away whatever header you just saw and keep the header you saw the first time. [quote] header, stack = traceback_helper.extract_stack(lines) signature = tuple(stack) if signature in crashes: count, header = crashes[signature] crashes[signature] = (count + 1, header) else: crashes[signature] = (1, header) [end quote] In general, it is an unsafe assumption that the actual exception raised will be the same just because the stack trace is the same. So as I said, if you have two *distinct* failures occurring in the same function (not even necessarily on the same line), your code appears to treat them as the same error. That seems odd to me, but if you have a good reason for doing it that way, so be it. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Interview Questions
On Mon, 19 Nov 2012 09:59:19 -0500, Roy Smith wrote: OK, I've just read back over the whole thread. I'm really struggling to understand what point you're trying to make. I started out by saying: Use a list when you need an ordered collection which is mutable (i.e. can be altered after being created). Use a tuple when you need an immutable list (such as for a dictionary key). To which you obviously objected. So now you write: I think a tuple is an immutable sequence of items, and a list is a mutable sequence of items. So how is that different from what I said? Is this whole argument boiling down to your use of immutable sequence vs. my use of immutable list? Sheesh, of course not. Give me some credit. I gave some examples of when somebody might use lists, tuples, sets and dicts. Apparently I forgot a couple, and you responded with a sarcastic comment about the One True Church Of Pythonic Orthodoxy And Theoretical Correctness and gave a couple of additional examples. Although I didn't come out and *explicitly* say I agree to your examples, I actually did, with one proviso: your example of using an immutable list as dict key. So I asked a question about that *specific* use-case: [quote] Under what sort of circumstances would somebody want to take a mutable list of data, say a list of email addresses, freeze it into a known state, and use that frozen state as a key in a dict? What would be the point? Even if there was some meaningful reason to look up this list of 12000 email addresses as a single key, it is going to get out of sync with the actual mutable list. [end quote] Your reply was to give your stack trace script as an example. That's a fine example as a use-case for a temporary list, and I've done similar things dozens, hundreds of times myself. As I said: [quote] Sure, I have built a collection of items as a list, because lists are mutable, then frozen it into a tuple, and *thrown the list away*, then used the tuple as a key. But that's not the same thing, the intent is different. In my case, the data was never intended to be a list, it was always intended to be a fixed record-like collection, the use of list was as a temporary data structure used for construction. A bit like the idiom of ''.join(some_list). [end quote] To me, this sounds *exactly* like your use-case: your data, stack traces, represent a little chunk of immutable data that you build up a line at a time using a temporary list first, just like I wrote. And I said so. There's no sign in either your code or your description that the stack traces get treated as mutable objects in any way once you have finished building them a line at a time. So your real world, practical, in the trenches example matches my experience: you build a *fixed data record* using a *temporary list*, throw the list away, and then never mutate that data record again. So why are we disagreeing? Like many such discussions on the Internet, this one has rambled a bit, and I've misunderstood some of your code (sorry), and you seem to have misunderstood the question I am asking. Maybe my explanation was not clear enough, in which case, sorry again. I'm asking about the case where one might want the key to remain mutable even after it is used as a key, but can't because Python won't let you. There's no sign that your stack trace example is such an example. As I earlier said: [quote] But I can't think of any meaningful, non-contrived example where I might want an actual mutable list of values as a dict key. [end quote] and I still can't. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
RE: Python Interview Questions
Roy Smith wrote: OK, I've just read back over the whole thread. I'm really struggling to understand what point you're trying to make. I started out by saying: Use a list when you need an ordered collection which is mutable (i.e. can be altered after being created). Use a tuple when you need an immutable list (such as for a dictionary key). To which you obviously objected. So now you write: I think a tuple is an immutable sequence of items, and a list is a mutable sequence of items. So how is that different from what I said? Is this whole argument boiling down to your use of immutable sequence vs. my use of immutable list? ''' Roy: Use a list when you need an ordered collection which is mutable (i.e. can be altered after being created). Use a tuple when you need an immutable list (such as for a dictionary key). Steven: I keep hearing about this last one, but I wonder... who *actually* does this? I've created many, many lists over the years -- lists of names, lists of phone numbers, lists of directory search paths, all sorts of things. I've never needed to use one as a dictionary key. ''' To me this is more of a question than an argument. Now moving on to your specific example. ''' def extract_stack(lines): in traceback_helper module header = lines[0] stack = [] for line in lines: m = frame_pattern.match(line) if not m: continue frame = (m.group('path'), m.group('function')) stack.append(frame) # [Convert to tuple and return after finished building stack.] return (header, stack) [...] def main(args): crashes = {} [...] for line in open(log_file): if does_not_look_like_a_stack_dump(line): continue lines = traceback_helper.unfold(line) header, stack = traceback_helper.extract_stack(lines) signature = tuple(stack) if signature in crashes: count, header = crashes[signature] crashes[signature] = (count + 1, header) else: crashes[signature] = (1, header) ''' Seems to me that Steven is suggesting that stack (after being built) should converted to a tuple before being returned, because a stack for any unique exception should be unique and immutable. You do this anyway; you just do it before putting it into a dictionary rather than before returning it. Same net effect (as long as you do not modify `stack` later), so no real argument. ~Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
Splitting a line while keeping quoted items together
I am working on a cmd.Cmd-based program, and normally could just split the string and get the right parts. Now I have a case where I could have two or three words in the string that need to be grouped into the same thing. Then I realized that I'm not the only person who has had to deal with this, and I'm wondering if my solution is the best one out there or if this is as ugly at it feels? Code below ... #x('Seattle 456') - ('Seattle', '456') #x('Portland Alpha 123') - ('Portland Alpha', '123') #x('Portland Beta' 789') - ('Portland Beta', '789') def x(line): res = [] append = False appended = None quote = None for item in line.split(): if append: if item.endswith(quote): appended.append(item[:-1]) res.append(' '.join(appended)) quote = None appended = None append = False else: appended.append(item) else: if item[0] in [','']: append = True appended = [item[1:]] quote = item[0] else: res.append(item) return res .. This seem really ugly. Is there a cleaner way to do this? Is there a keyword I could search by to find something nicer? Thanks, Josh -- http://mail.python.org/mailman/listinfo/python-list
Re: Splitting a line while keeping quoted items together
On Monday, November 19, 2012, wrote: I am working on a cmd.Cmd-based program, and normally could just split the string and get the right parts. Now I have a case where I could have two or three words in the string that need to be grouped into the same thing. Then I realized that I'm not the only person who has had to deal with this, and I'm wondering if my solution is the best one out there or if this is as ugly at it feels? Code below ... #x('Seattle 456') - ('Seattle', '456') #x('Portland Alpha 123') - ('Portland Alpha', '123') #x('Portland Beta' 789') - ('Portland Beta', '789') snipped code defining function x() This seem really ugly. Is there a cleaner way to do this? Is there a keyword I could search by to find something nicer? Use the shlex module in the std lib? Cheers, Chris -- Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
re[2]: Splitting a line while keeping quoted items together
Well color me ignorant. Works cleanly. I shouldn't have reinvented the wheel. Thanks. This seem really ugly. Is there a cleaner way to do this? Is there a keyword I could search by to find something nicer? Use the "shlex" module in the std lib? Cheers, Chris-- Cheers,Chris--http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Linux compatibility
On Mon, 19 Nov 2012 08:44:37 -0800 (PST), EDI Support | nicoletti...@gmail.com declaimed the following in | gmane.comp.python.general: | I would like know if Python 2.4.3 will be compatible with Linux RHEL 5.5 or 6.1? It would help if you could qualify what you imagine compatible with to mean... On 19Nov2012 18:38, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: | Uhm... | 1)Python 2.4.x is practically an antique. (I just updated my Windows | machines to 2.7 from 2.5 -- and 2.7 will be the last 2.x version) RHEL 5.x ships with python 2.4; a up to date RHEL 5.x box here has 2.4.3. I would not surprise me if that was what shipped with 5.0. One feature if the RHEL distro is that it is _stable_. (See Dennis' point (3)). They backport bugfixes and security fixes, but otherwise the base OS doesn't change API. This produces reliable, predictable behaviour for stuff you have deployed to such a platform. The price for that is that pretty soon the versions of things supplied are quite dated. Anyway, qualify what compatible is supposed to mean for you. -- Cameron Simpson c...@zip.com.au in rec.moto, jsh wrote: Dan Nitschke wrote: Ged Martin wrote: On Sat, 17 May 1997 16:53:33 +, Dan Nitschke scribbled: (And you stay *out* of my dreams, you deviant little weirdo.) Yeah, yeah, that's what you're saying in _public_ Feh. You know nothing of my dreams. I dream entirely in text (New Century Schoolbook bold oblique 14 point), and never in color. I once dreamed I was walking down a flowchart of my own code, and a waterfall of semicolons was chasing me. (I hid behind a global variable until they went by.) You write code in a proportional serif? No wonder you got extra semicolons falling all over the place. No, I *dream* about writing code in a proportional serif font. It's much more exciting than my real life. /* dan: THE Anti-Ged -- Ignorant Yank (tm) #1, none-%er #7 */ Dan Nitschke pedan...@best.com nitsc...@redbrick.com -- http://mail.python.org/mailman/listinfo/python-list
Stack_overflow error
I'm having Stack_overflow exception in _ctypes_callproc (callproc.c). The error actually come from the: cleanup: for (i = 0; i argcount; ++i) Py_XDECREF(args[i].keep); when args[i].keep-ob_refCnt == 1 Aung. -- http://mail.python.org/mailman/listinfo/python-list
Re: Splitting a line while keeping quoted items together
On Mon, 19 Nov 2012 16:05:30 -0800, josh wrote: I am working on a cmd.Cmd-based program, and normally could just split the string and get the right parts. Now I have a case where I could have two or three words in the string that need to be grouped into the same thing. Try shlex.split. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Stack_overflow error
On Tue, Nov 20, 2012 at 11:49 AM, Aung Thet Naing aung.thetna...@gmail.com wrote: I'm having Stack_overflow exception in _ctypes_callproc (callproc.c). The error actually come from the: cleanup: for (i = 0; i argcount; ++i) Py_XDECREF(args[i].keep); when args[i].keep-ob_refCnt == 1 Can you offer more details? I'm guessing you're using ctypes from a Python script; can you share the script with us? What Python version are you using? What procedure are you calling? ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Splitting a line while keeping quoted items together
Use the shlex module in the std lib? Well color me ignorant. Works cleanly. I shouldn't have reinvented the wheel. I've experienced this enough: the csv module, option parsing, config-file parsing, logging, timeit, and pwd all come to mind as code I've written before realizing the stdlib already has it. Now, if my task sounds remotely like something that somebody else might have implemented already, my first stop is always to browse through the stdlib docs. Then try http://pypi.python.org/pypi to see if somebody else has already solved the problem without the solution getting into the stdlib. Only then do I proceed to trying to code up something of my own. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: re.search when used within an if/else fails
On 2012-11-19 23:43, Kevin T wrote: python version 2.4.3, yes i know that it is old. getting the sysadmin to update the OS requires a first born. with the following code.. for signal in register['signals'] : 351 sigName = signal['functionName'] 352 if re.search( rsrvd, sigName ) == None : 353 print sigName 354 newVal = %s%s % ( '1'*signal['bits'] , newVal ) #prepend 0's 355 if re.search( rsrvd, sigName ) != None : 356 print sigName 357 newVal = %s%s % ( '0'*signal['bits'], newVal ) regardless of how i code line 352, i can not EVER use an else clause with it. if i use an else clause, the else will NEVER get executed... has any one experienced anything like this behavior? any suggestions? the above code works but... why should i have to code it like this? Have you checked the indentation? There may be a mixture of tabs and spaces. A couple of points: 1. You should be using is None and is not None instead of == None and != None. 2. You don't need to use regex. Use rsrvd in sigName and rsrvd not in sigName. -- http://mail.python.org/mailman/listinfo/python-list
Re: re.search when used within an if/else fails
On Tue, 20 Nov 2012 01:24:54 +, Steven D'Aprano wrote: Your code is mangled to the point of unreadability. Ah, never mind, that's *my* fault, not yours. Or rather, my news reader software. Sorry about the noise. The rest of my post still stands: - simplify your example to the simplest example that we can run http://sscce.org/ - don't put line numbers at the start of lines - your code doesn't have an else clause - use if something is None, not == None. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: re.search when used within an if/else fails
On Mon, 19 Nov 2012 15:43:10 -0800, Kevin T wrote: python version 2.4.3, yes i know that it is old. getting the sysadmin to update the OS requires a first born. with the following code.. for signal in register['signals'] : 351 sigName = signal['functionName'] 352 if re.search( rsrvd, sigName ) == None : 353 print sigName 354 newVal = %s%s % ( '1'*signal['bits'] , newVal ) #prepend 0's 355 if re.search( rsrvd, sigName ) != None : 356 print sigName 357 newVal = %s%s % ( '0'*signal['bits'], newVal ) Your code is mangled to the point of unreadability. Please resend, and make sure you send it as PLAIN TEXT and not as HTML (rich text), since many mail programs feel that they are allowed to arbitrarily rewrap HTML text however they like. Preferably simplify your example to the simplest example that we can run: http://sscce.org/ Being able to run it means you shouldn't put line numbers on the left. If you must draw our attention to a specific line, use a comment. This isn't 1975 and we're not programming in BASIC. # BAD don't do this: 350 do_this(x) 351 do_that(y, z) 352 if something: 353 do_something_else(x, y, z) # GOOD do this: do_this(x) do_that(y, z) if something: # LINE 352 do_something_else(x, y, z) regardless of how i code line 352, i can not EVER use an else clause with it. if i use an else clause, the else will NEVER get executed... The code you show doesn't actually have an `else` clause, which might explain why it doesn't get executed. By the way, you should not write if something == None, always use if something is None or is not None. Technically, there are some exceptions but if you have to ask what they are, you don't need to know *wink* -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Linux compatibility
On Mon, 19 Nov 2012 08:44:37 -0800, EDI Support wrote: Hi All, I would like know if Python 2.4.3 will be compatible with Linux RHEL 5.5 or 6.1? I don't see any reason why it wouldn't be, but why would you want to use Python 2.4 in production if you don't have to? RHEL will come with Python already installed, I believe it is Python 2.6. It is *much* better to use Python 2.6 if you can: it is faster, has fewer bugs, and more modern features. But if you must use Python 2.4, make sure that you do NOT replace the system Python already installed. If installing from source, use make altinstall instead of make install to ensure that it doesn't overwrite the system Python. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems on these two questions
On 11/19/2012 06:16 PM, Dennis Lee Bieber wrote: On Sun, 18 Nov 2012 21:18:19 -0500, Dave Angel d...@davea.name declaimed the following in gmane.comp.python.general: if is_a_prime(n): is_prime = True Now all you have to do is write is_a_prime(). if you get stuck, please show us what you've got, and what the problem is with it. And as usual, tell us what version of Python you're writing in, if any. Since is_a_prime is returning a Boolean, this condenses to: is_prime = is_a_prime(n) Nope, the original problem statement didn't say what should should happen if n does have such factors. Clearly, it's only describing a program fragment. 1.Given a positive integer n , assign True to is_prime if n has no factors other than 1 and itself. (Remember, m is a factor of n if m divides n evenly.) -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
[OT]Two-tonne Witch computer gets a reboot
You may find this interesting http://www.bbc.co.uk/news/technology-20395212 -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Interview Questions
In article 50aac3d8$0$29983$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: By the way, your news client seems to be mangling long URLs, by splitting them when they exceed the maximum line length. Hmmm. So it did. My bad. -- http://mail.python.org/mailman/listinfo/python-list
Re: Yet another Python textbook
On Nov 20, 2:58 am, Kwpolska kwpol...@gmail.com wrote: You are writing it for something called “NCLab”, not for the general public, and that sucks. And making it available to the general public to consume. What's wrong with writing for one audience and providing for a broader? If you're that concerned with the NCLab-ness of it, fork it. 2. IMO, you should be doing a bit more general usage programming, not science-specific. It's produced by the Network Computing Laboratory for Science, Technology, Engineering and Mathematics, of course their focus will be on science. It's not like there's a lack of more generalised programming guides for Python. Some nice bikeshedding there, btw. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Interview Questions
In article 50aac66c$0$29983$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I'm asking about the case where one might want the key to remain mutable even after it is used as a key, but can't because Python won't let you. Ah. Now I see what you're getting at. Thank you. Well, I will admit that it probably doesn't make sense to mutate an object after it's put into a dict (or at least mutate it in a way which changes it's hash value and/or whether it compares equal to the original object). If you did (assuming lists were allowed as keys): l = [1, 2, 3] d = {l: spam} l.append(4) print d[l] I'm not sure what I would expect to print. It's not too hard to experiment, though. All you need do is: class HashableList(list): def __hash__(self): return hash(tuple(self)) and python is then happy to let you use a list as a key. I just played around with this a bit off-line. I think I got the results I was expecting, but since I'm not sure what I was expecting, that's hard to say. However, you didn't ask if it made sense to mutate an object after using it as a key. You asked if it made sense to let the object remain mutable after using it as a key. That's a harder question. Let's say I had lots of of lists I wanted to use a dictionary keys. As it stands now, I have to convert them to tuples, which means copying all the data. For a lot of data, that's inefficient. Wouldn't it be nice (or at least, more efficient) if I could just use the original lists as keys directly, without the extra copy? I would have to understand that even though they are mutable, interesting (and perhaps, unwanted) things if I actually mutated them. But, we're all consenting adults here. If I'm willing to accept responsibility for the consequences of my actions in return for the efficiency gain, why shouldn't I be allowed to? I guess the answer is, that I am allowed to. I just need to do the HashableList deal, shown above (no broken URL required to read the code). -- http://mail.python.org/mailman/listinfo/python-list
Re: changing process name
andrea crotti andrea.crott...@gmail.com wrote: I have very long processes to spawn which I want to lauch as separate processes (and communicate with ZeroMQ), but now the problem is that the forked process appears in ps with the same name as the launcher process. http://code.google.com/p/py-setproctitle/ -- Tim Roberts, t...@probo.com Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting a seeded value from a list
Are you generating the entire level on entry, or as each room is opened (if, as opened, you have the complication that going down a level and back up will result in different random numbers vs going straight to the room). Generating on entry only needs the seed for the initial generation point (as mentioned, first time you could use the system clock and save the value). I'm generating the room on entry -- the 'stairs' object calls 'make_map()' which creates the floor and lays out monsters and treasure. What I'm trying to do is set a persistent state for the levels generated by make_map(), so the player can move between floors without generating a totally new randomized floor each time. But for a dungeon -- you may be best served by generating the entire level (all rooms, doors, static encounters [traps, treasure]) when entering the level, and saving the entire dungeon (after all, after a treasure is collected, it shouldn't re-appear the next time you start that same level -- if you only save the starting seed, then all encounters will also be regenerated). In this scenario, where you save the entire dungeon, you don't even need to worry about the seed -- you'll never really want to recreate the same dungeon for another party [unless running a competition in which case you seed every computer the same so every participant is running the identical dungeon]. That actually sounds close to what I'd like to ?do. How would I go about saving the dungeon? I'm guessing I'd need to define how many levels to generate, first of all -- http://mail.python.org/mailman/listinfo/python-list
Re: xml data or other?
Prasad, Ramit, 19.11.2012 22:42: Artie Ziff wrote: Writing XML files so to see whats happening. My plan is to keep xml data in memory and parse with xml.etree.ElementTree. Unfortunately, xml parsing fails due to angle brackets inside description tags. In particular, xml.etree.ElementTree.parse() aborts on '' inside xml data such as the following: testname name=cron_test.sh description This testcase tests if crontab filename installs the cronjob and cron schedules the job correctly. \description ## What is right way to handle the extra angle brackets? Substitute on line-by-line basis, if that works? Or learn to write a simple stack-style parser, or recursive descent, it may be called? I think your description text should be in a CDATA section. http://en.wikipedia.org/wiki/CDATA#CDATA_sections_in_XML Ah, don't bother with CDATA. Just make sure the data gets properly escaped, any XML serialiser will do that for you. Just generate the XML using ElementTree and you'll be fine. Generating XML as literal text is not a good idea. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems on these two questions
On Mon, Nov 19, 2012 at 4:15 PM, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Sun, 18 Nov 2012 17:52:35 -0800 (PST), su29090 129k...@gmail.com declaimed the following in gmane.comp.python.general: I all of the other problems but I have issues with these: 1.Given a positive integer n , assign True to is_prime if n has no factors other than 1 and itself. (Remember, m is a factor of n if m divides n evenly.) Google: Sieve of Eratosthenes (might be mis-spelled) No, the Sieve is nifty, but it's meant for generating sequences of primes, not for testing individual primality. It's also more complex than is necessary. A better starting place for a programming novice is with trial division, which is a somewhat simpler algorithm and all that is needed here. -- http://mail.python.org/mailman/listinfo/python-list
Re: Yet another Python textbook
On Sun, Nov 18, 2012 at 10:30 PM, Pavel Solin solin.pa...@gmail.com wrote: I would like to introduce a new Python textbook aimed at high school students: http://femhub.com/textbook-python/. The textbook is open source and its public Git repository is located at Github: g...@github.com:femhub/nclab-textbook-python.git Feedback and contributions are very much welcome, every contributor becomes automatically a co-author. First impression: I'm opening up the book and reading the introduction, and I get to section 1.6, and the very first code example given is: print Hello, World! A fine tradition to be sure, but I have to say that I'm a little disappointed that a new textbook on Python being written in 2012 is focused squarely on Python 2, especially when I just read on the previous page that Python 3 was released in 2008. Is there any work underway get Python 3 into NCLab? The issue comes up again four pages later in section 2.4, when division is being demoed, and the text takes a page-and-a-half detour to caution about the use of floor division for expressions like: 33 / 6 If the book were teaching Python 3, then this warning would be unnecessary, since division in Python 3 is *automatically* true division, unless you go out of your way to invoke floor division by using the special // operator. I think that the earliness and frequency that these differences arise underscore the point that it would be best if the book could simply be teaching Python 3 to start with. Getting off that soapbox and moving along, I notice that on pages 20-22 there are some examples by way of comparison that are written in C, which makes me wonder what audience this textbook is really intended for. The previous pages and references to Karel have given me the impression that this is geared toward beginning programmers, who most likely are not familiar with C. The most troublesome is the last of these examples, which is led up to with this text: The asterisks in the code below are pointers, an additional programming concept that one needs to learn and utilize here: This seems to suggest that the reader should stop reading here and do a Google search on pointers, in order to understand the example. Since this is not a textbook on C, and Python has no concept of pointers at all, doing this would be a complete waste of the reader's time. Skimming through a few more chapters, I don't see anything else that sets my spidey sense tingling. I hope that what I've written above gives you some things to consider, though. Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list
[issue16507] Patch selectmodule.c to support WSAPoll on Windows
Trent Nelson added the comment: On Sun, Nov 18, 2012 at 03:19:19PM -0800, Antoine Pitrou wrote: Antoine Pitrou added the comment: Related post: http://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/ Yeah, came across that yesterday. Few other relevant links, for the records: http://social.msdn.microsoft.com/Forums/en/wsk/thread/18769abd-fca0-4d3c-9884-1a38ce27ae90 (has a code example of what doesn't work) http://www.codeproject.com/Articles/140533/The-Differences-Between-Network-Calls-in-Windows-a http://blogs.msdn.com/b/wndp/archive/2006/10/26/wsapoll.aspx http://curl.haxx.se/mail/lib-2012-10/0038.html -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16507 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16499] CLI option for isolated mode
Marc-Andre Lemburg added the comment: On 18.11.2012 15:30, Christian Heimes wrote: Christian Heimes added the comment: The first patch implements the arg parsing, sys.flags, PySys_SetArgv() modification that doesn't include the current directory as sys.path[0] and some doc updates. Open issue: - MAL has addressed concerns that '-I' is too similar to GCC's -I (include path) option - Is 'isolated mode' a good term to describe the feature? IMO 'restricted mode' is also a good name but it sounds too similar to PyPy's restricted python. Some other possible names: - unmodified mode (-U) - encapsulated mode (-e) - installation only mode (-I) - non-local mode (-l) Since this mode will often be used for testing Python installation and setup issues, perhaps emphasizing on the testing nature would be good... - test installation mode (-T) FWIW: Isolated and -I works for me as well. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Nov 19 2012) Python Projects, Consulting and Support ... http://www.egenix.com/ mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ ::: Try our new mxODBC.Connect Python Database Interface for free ! eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16499 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13538] Improve doc for str(bytesobject)
Chris Jerdonek added the comment: Updating patch after Ezio's review on Rietveld. -- Added file: http://bugs.python.org/file28040/issue-13538-6-default.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13538 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16493] Document the 'optimize' argument to compile()
Kushal Das added the comment: I guess somebody already did the work http://docs.python.org/3.4/library/functions.html?highlight=compile#compile ? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16493 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16493] Document the 'optimize' argument to compile()
Ezio Melotti added the comment: Looks like Georg did: 713c6b6ca5ce. The documentation is missing on 2.7, but AFAICT that's because the arg is only in 3.2+. Brett, if you meant that this should be documented somewhere else, feel free to reopen the issue. -- resolution: - out of date stage: needs patch - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16493 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16510] Using appropriate checks in tests
New submission from Serhiy Storchaka: The proposed patch upgrades tests to use specialized checks added in 3.1 and 3.2 (assertIsNone(x) instead assertTrue(x is None), assertLess(a, b) instead assertTrue(a b), etc). This modern checks provide a more useful error message in case of a fail. Replaced only those checks that are not related to the tested operators. For example, assertTrue(a b) preserved if the operator is tested. -- components: Tests files: tests_asserts.patch keywords: patch messages: 175953 nosy: ezio.melotti, michael.foord, pitrou, serhiy.storchaka priority: normal severity: normal stage: patch review status: open title: Using appropriate checks in tests type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file28041/tests_asserts.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16510 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11679] readline interferes with characters beginning with byte \xe9
Thomas Kluyver added the comment: OK, thanks, and sorry for the noise. I've closed this issue. Looking at the readline manual, it looks like this is tied up with the options input-meta, output-meta and convert-meta. Fiddling around with .inputrc hasn't clarified exactly what they do, but it seems that the terminal can either handle unicode, or shortcuts involving meta (alt), but not both. -- resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11679 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16475] Support object instancing and recursion in marshal
Kristján Valur Jónsson added the comment: If you have string sharing, adding support for general sharing falls automatically out without any effort. There is no reason _not_ to support it, in other words. Marshal may be primarily used for .pyc files but it is not the only usage. It is a very fast and powerful serializer for data that is not subject to the overhead or safety concerns of the general pickle protocol. This is illustrated by the following code (2.7): case TYPE_CODE: if (PyEval_GetRestricted()) { PyErr_SetString(PyExc_RuntimeError, cannot unmarshal code objects in restricted execution mode); Obviously, this shows that marshal is still expected to work and be useful even if not for pickling code objects. It is good to know that you care about the size of the .pyc files, Martin. But we should bear in mind that this size difference is directly reflected in the memory use of the loaded data. A reduction by 25% of the .pyc size is roughly equivalent to a 25% memory use reduction by the loaded code object. I haven't produced data about the savings of general object reuse because it relies on my recode code optimizer module which is still work in progress. However, I will do some tests and let you know. Suffice to say that it is enormously frustrating to re-generate code objects with an optimization tool, sharing common or identical sub-objects and so on, and then finding that the marshal module undoes all of that. I'll report back with additional figures. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16475 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16510] Using appropriate checks in tests
R. David Murray added the comment: Thanks for the work, but we don't generally make bulk changes like this. It generates churn in the codebase, and has the risk of inadvertently changing the meaning of the tests, to little actual benefit. Instead we modernize tests when we touch them for other reasons and are in a position to confirm that the changes do not change the meaning of the tests. (I realize that for most of your changes the meaning is trivially preserved...but when you make a lot of changes you are almost certain to make some mistakes...thus the resistance to doing bulk updates.) -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16510 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16506] devguide should have table of contents
Chris Jerdonek added the comment: Attaching patch. Out-of-the-box at least, Sphinx seems to have the constraint that the home page (what the link in the upper-left corner points to) needs to be the same as the table of contents (what the table of contents link in the left column points to). Retaining the same home page seems to be the most important, so for now at least, I'm proposing putting the table of contents at the bottom of the home page (with the home page itself not part of the contents). I also re-did the header formatting for a few pages to make the nesting levels match the page list. -- keywords: +needs review, patch stage: - patch review Added file: http://bugs.python.org/file28042/issue-16506-1.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16506 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16506] devguide should have table of contents
Nick Coghlan added the comment: Sounds good to me - I was looking for a link to the maintainer list the other day, and there doesn't appear to be one at the moment. Having a reasonably complete ToC/site map deals with that kind of problem, and putting it at the bottom helps avoid overwhelming newcomers. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16506 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16475] Support object instancing and recursion in marshal
Changes by Christian Heimes li...@cheimes.de: -- nosy: +christian.heimes ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16475 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16475] Support object instancing and recursion in marshal
Serhiy Storchaka added the comment: There is no many sense to use references for TYPE_INT whose representation size not greater then a reference representation size. I doubt about references to mutable objects. -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16475 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16510] Using appropriate checks in tests
Serhiy Storchaka added the comment: I understand this. I checked the patch few times, with long (more than a month) intervals between inspections. If someone wants to modernize some tests, he can turn to this patch for reference. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16510 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9613] Python considers pid longs under 64-bit Windows
Changes by Serhiy Storchaka storch...@gmail.com: -- status: open - pending ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9613 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3580] failures in test_os
Serhiy Storchaka added the comment: Is this reproduced on modern Python versions? -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3580 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16491] try-except-raise-bug
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti status: open - pending ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16491 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16475] Support object instancing and recursion in marshal
Kristján Valur Jónsson added the comment: Ok, I did some tests with my recode module. The following are the sizes of the marshal data: test2To3 ... 24748 24748 212430 212430 test3To3 ... 18420 17848 178969 174806 test4To3 ... 18425 18411 178969 178550 The columns: a) test_marshal.py without transform b) test_marshal.py with recode.intern() (folding common objects) c) and d): decimal.py module (the largest one in lib) The lines: 1) Version 2 of the protocol. 2) Version 3 of the protocol (object instancing and the works) 3) Version 4, an dummy version that only instances strings) As expected, there is no difference between version 3 and 4 unless I employ the recode module to fold common subobjects. This brings an additional saving of some 3% bringing the total reduction up to 28% and 18% respectively. Note that the transform is a simple recursive folding of objects. common argument lists, such as (self) are subject to this. No renaming of local variables or other stripping is performed. So, although the recode module is work in progress, and not the subject of this defect, its use shows how it is important to be able to support proper instancing in serialization protocols. Implementation note: The trick of using a bit flag on the type to indicate a slot reservation in the instance list is one that has been in use in CCP´s own Marshal format, a proprietary serialization format based on marshal back in 2002 (adding many more special opcodes and other stuff) Serhiy: There is no reason _not_ to reuse INT objects if we are doing it for other immutables to. As you note, the size of the data is the same. This will ensure that integers that are not cached can be folded into the same object, e.g. the value 123, if used in two functions, can be the same int object. I should also point out that the marshal protocol takes care to be able to serialize lists, sets and frozensets correctly, the latter being added in version 2.4. This despite the fact that code objects don't make use of these. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16475 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16475] Support object instancing and recursion in marshal
Serhiy Storchaka added the comment: The following are the sizes of the marshal data: Can you please measure the time of unmarshalling? It would be interesting. If you can count the statistics about marshalled types (what percent of shared and non shared integers, strings, etc), it would also be very interesting. There is no reason _not_ to reuse INT objects if we are doing it for other immutables to. There is at least one reason. This increases size of the refs table. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16475 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16475] Support object instancing and recursion in marshal
Antoine Pitrou added the comment: I should also point out that the marshal protocol takes care to be able to serialize lists, sets and frozensets correctly, the latter being added in version 2.4. This despite the fact that code objects don't make use of these. Code objects do use frozensets: def f(x): ... return x in {1,2,3,4,5,6} ... dis.dis(f) 2 0 LOAD_FAST0 (x) 3 LOAD_CONST 7 (frozenset({1, 2, 3, 4, 5, 6})) 6 COMPARE_OP 6 (in) 9 RETURN_VALUE I don't think marshal supports any type that isn't (or hasn't been) used in code objects. Obviously, this shows that marshal is still expected to work and be useful even if not for pickling code objects. The module officially intended for general-purpose serialization is pickle; if you use marshal for such a purpose, you're on your own. If you think pickle is not good enough, your improvements are welcome. As expected, there is no difference between version 3 and 4 unless I employ the recode module to fold common subobjects. This brings an additional saving of some 3% bringing the total reduction up to 28% and 18% respectively. 3% doesn't sound like a worthwhile improvement at all. The trick of using a bit flag on the type to indicate a slot reservation in the instance list is one that has been in use in CCP´s own Marshal format, a proprietary serialization format based on marshal back in 2002 (adding many more special opcodes and other stuff) Why don't you release your proprietary marshal on pypi? You would get feedback and a sense of whether people are interested in your approach. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16475 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16496] Simplify and optimize random_seed()
Changes by Mark Dickinson dicki...@gmail.com: -- assignee: - mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16496 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16499] CLI option for isolated mode
Changes by Christian Heimes li...@cheimes.de: Removed file: http://bugs.python.org/file28024/isolatemode.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16499 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16499] CLI option for isolated mode
Changes by Christian Heimes li...@cheimes.de: Removed file: http://bugs.python.org/file28036/isolatemode2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16499 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16499] CLI option for isolated mode
Christian Heimes added the comment: New patch with typo fixes and update for recent modification in the make_flags() function. Marc: The patch was motivated by use cases like Barry's issue with 3rd party software that accidentally messes with Python scripts like lsb_release. Your use case (testing) is valid but not the main focus here. Unmodified mode doesn't fit the bill either, Python can still import system wide packages or modifications from a venv. Apropos venv, I need to check how the option is affected by venv. -- Added file: http://bugs.python.org/file28043/isolatemode3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16499 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16506] devguide should have table of contents
Roundup Robot added the comment: New changeset 996b72dd1e31 by Chris Jerdonek in branch 'default': Unhide and move table of contents to bottom of home page (issue #16506). http://hg.python.org/devguide/rev/996b72dd1e31 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16506 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16506] devguide should have table of contents
Changes by Chris Jerdonek chris.jerdo...@gmail.com: -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16506 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16500] Add an 'afterfork' module
Christian Heimes added the comment: Thanks Richard! My first reaction was YAGNI but after I read the two tickets I now understand the need for three different hooks. I suggest that we implement our own hooks like the http://linux.die.net/man/3/pthread_atfork function, especially the order of function calls: The parent and child fork handlers shall be called in the order in which they were established by calls to pthread_atfork(). The prepare fork handlers shall be called in the opposite order. I like to focus on three hooks + the Python API and leave the usage of the hooks to other developers. Proposal: * Introduce a new module called atfork (Modules/atforkmodule.c) that is build into the core. * Move PyOS_AfterFork to Modules/atforkmodule.c. * Add PyOS_BeforeFork() (or PyOS_PrepareFork() ?) and PyOS_AfterForkParent() * call the two new methods around the calls to fork() in the stdlib. I'm not yet sure how to implement the Python API. I could either implement six methods: atfork.register_before_fork(callable, *args, **kwargs) atfork.register_after_fork_child(callable, *args, **kwargs) atfork.register_after_fork_parent(callable, *args, **kwargs) atfork.unregister_before_fork(callable) atfork.unregister_after_fork_child(callable) atfork.unregister_after_fork_parent(callable) or two: atfork.register(prepare=None, parent=None, child=None, *args, **kwargs) atfork.unregister(prepare=None, parent=None, child=None) -- nosy: +gregory.p.smith, twouters ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16500 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16482] pdb.set_trace() clobbering traceback on error
Xavier de Gaye added the comment: The top level frame line number is not updated because it has a local trace function while the global trace function is None. This is related to issue 7238. The following patch fixes the issue. The patch removes the local trace at the top level frame and makes sure it is not reinstalled when returning from the current trace function. diff --git a/Lib/bdb.py b/Lib/bdb.py --- a/Lib/bdb.py +++ b/Lib/bdb.py @@ -64,6 +64,10 @@ if self.stop_here(frame) or self.break_here(frame): self.user_line(frame) if self.quitting: raise BdbQuit +# Do not re-install the local trace when we are finished debugging, +# see issues 16482 and 7238. +if not sys.gettrace(): +return None return self.trace_dispatch def dispatch_call(self, frame, arg): @@ -231,8 +235,10 @@ # no breakpoints; run without debugger overhead sys.settrace(None) frame = sys._getframe().f_back -while frame and frame is not self.botframe: +while frame: del frame.f_trace +if frame is self.botframe: +break frame = frame.f_back def set_quit(self): The following code is a minimum implementation of pdb with the patch applied and the associated code to test it. class Bdb: def trace_dispatch(self, frame, event, arg): self.set_continue() if sys.gettrace(): return self.trace_dispatch def set_trace(self, frame): self.botframe = frame frame.f_trace = self.trace_dispatch sys.settrace(self.trace_dispatch) def set_continue(self): sys.settrace(None) del self.botframe.f_trace frame = sys._getframe() d = Bdb() d.set_trace(frame) y = line of code not triggering an error x = 1 assert x != 1 -- nosy: +xdegaye ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16482 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7238] frame.f_lineno doesn't get updated after local trace function assigned to it
Xavier de Gaye added the comment: See also the related issue 16482. -- nosy: +xdegaye ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7238 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16180] cannot quit pdb when there is a syntax error in the debuggee (must kill it)
rurpy the second added the comment: This continues to be a problem on Python-3.3.0 -- nosy: +rurpy2 versions: +Python 3.3 -Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16180 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3580] failures in test_os
Antoine Pitrou added the comment: I don't know. Anyway, it is not really a Python bug, so I suggest we close it. -- resolution: - invalid status: open - pending ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3580 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1284316] Win32: Security problem with default installation directory
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +tim.golden ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1284316 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16500] Add an 'afterfork' module
Richard Oudkerk added the comment: Note that Gregory P. Smith has written http://code.google.com/p/python-atfork/ I also started a pure python patch but did not get round it posting it. (It also implements the fork lock idea.) I'll attach it here. How do you intend to handle the propagation of exceptions? I decided that after atfork.atfork(prepare1, parent1, child1) atfork.atfork(prepare2, parent2, child2) ... atfork.atfork(prepareN, parentN, childN) calling pid = os.fork() should be equivalent to pid = None prepareN() try: ... prepare2() try: prepare1() try: pid = posix.fork() finally: parent1() if pid != 0 else child1() finally: parent2() if pid != 0 else child2() ... finally: parentN() if pid != 0 else childN() -- keywords: +patch Added file: http://bugs.python.org/file28044/pure-python-atfork.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16500 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16500] Add an 'afterfork' module
Gregory P. Smith added the comment: I would not allow exceptions to propagate. No caller is expecting them. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16500 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16500] Add an 'afterfork' module
Gregory P. Smith added the comment: pthread_atfork() cannot be used to implement this. Another non-python thread started by a C extension module or the C application that is embedding Python within it is always free to call fork() on its own with zero knowledge that Python even exists at all. It's guaranteed that fork will be called while the Python GIL is held in this situation which would cause any pre-fork thing registered by Python to deadlock. At best, this can be implemented manually as we do with some of the before and after fork stuff today but it must come with the caveat warning that it cannot guarantee that these things are actually called before and after fork() other than direct os.fork() calls from Python code or extremely Python aware C extension modules that may call fork() (very rare, most C C++ libraries an extension module may be using assume that they've got the run of the house). ie: this problem is unsolvable unless you control 100% of the code being used by your entire user application. On Mon, Nov 19, 2012 at 3:59 PM, Gregory P. Smith rep...@bugs.python.orgwrote: Gregory P. Smith added the comment: I would not allow exceptions to propagate. No caller is expecting them. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16500 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16500 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16500] Add an 'afterfork' module
Christian Heimes added the comment: Meh! Exception handling takes all the fun of the API and is going to make it MUCH more complicated. pthread_atfork() ignores error handling for a good reason. It's going to be hard to get it right. :/ IFF we are going to walk the hard and rocky road of exception handling, then we are going to need at least four hooks and a register function that takres four callables as arguments: register(prepare, error, parent, child). Each prepare() call pushes an error handling onto a stack. In case of an exception in a prepare handler, the error stack is popped until all error handlers are called. This approach allows a prepare handler to actually prevent a fork() call from succeeding. The parent and child hooks are always called no matter what. Exception are recorded and a warning is emitted when at least one hook fails. We might raise an exception but it has to be a special exception that ships information if fork() has succeeded, if the code runs in child or parent and about the child's PID. I fear it's going to be *really* hard to get everything right. Gregory made a good point, too. We can rely on pthread_atfork() as we are unable to predict how third party code is using fork(): Take cover, dead locks ahead! :) A cooperative design of the C API with three function is my preferred way, too. PyOS_AfterForkParent() should take an argument to signal a failed fork() call. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16500 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13538] Improve doc for str(bytesobject)
Chris Jerdonek added the comment: Attaching new patch to address Ezio's further comments (for the convenience of comparing in Rietveld). I will be committing this. -- Added file: http://bugs.python.org/file28045/issue-13538-7-default.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13538 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13538] Improve doc for str(bytesobject)
Éric Araujo added the comment: I left a few remarks. The patch is very nice, thanks! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13538 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13538] Improve doc for str(bytesobject)
Chris Jerdonek added the comment: Thanks, Éric! (And thanks also to Ezio who helped quite a bit with the improvements.) I replied to your comments on Rietveld. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13538 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16508] include the object type in the lists of documented types
Changes by Chris Jerdonek chris.jerdo...@gmail.com: -- assignee: docs@python - chris.jerdonek ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16508 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com