Re: Is there a better way to code variable number of return arguments?
On Thursday, 8 October 2009 18:41:31 Dr. Phillip M. Feldman wrote: I currently have a function that uses a list internally but then returns the list items as separate return values as follows: if len(result)==1: return result[0] if len(result)==2: return result[0], result[1] (and so on). Is there a cleaner way to accomplish the same thing? Why do you not change the list into a tuple and return the tuple, and let automatic unpacking handle it? As I see it, the problem is not in the return, but in the call - how do you know now, which of the following to write: answer = thing(params) answer0,answer1 = thing(params) answer0,answer1,answer2 = thing(params) answer0,answer1,answer2,answer3 = thing(params) and so on... probably best to write: answers = thing(params) for answer in answers: do something with answer - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading hex to int from a binary string
On Oct 9, 3:12 am, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Thu, 8 Oct 2009 14:52:33 -0700 (PDT), Luc luc.traonmi...@gmail.com declaimed the following in gmane.comp.python.general: On Oct 8, 11:13 pm, Diez B. Roggisch de...@nospam.web.de wrote: Luc schrieb: Hi all, I read data from a binary stream, so I get hex values as characters (in a string) with escaped x, like \x05\x88, instead of 0x05. I am looking for a clean way to add these two values and turn them into an integer, knowing that calling int() with base 16 throws an invalid literal exception. Any help appreciated, thanks. Consider this (in the python interpreter): chr(255) '\xff' chr(255) == r\xff False int(rff, 16) 255 In other words: no, you *don't* get hex values. You get bytes from the stream as is, with python resorting to printing these out (in the interpreter!!!) as \xXX. Python does that so that binary data will always have a pretty output when being inspected on the REPL. But they are bytes, and to convert them to an integer, you call ord on them. So assuming your string is read bytewise into two variables a b, this is your desired code: a = \xff b = \xa0 ord(a) + ord(b) 415 HTH, Diez Sorry I was not clear enough. When I said add, I meant concatenate because I want to read 0x0588 as one value and ord() does not allow that. However you pointed me in the right direction and I found that int (binascii.hexlify(a + b, 16)) does the job. Yeesh... This is what struct is designed for... import struct something = \x05\x88and more\r\n print something ˆand more (h1, st, h2) = struct.unpack(H8sh, something) h1 34821 st 'and more' h2 2573 print %4x, %4x % (h1, h2) 8805, a0d You may need to adjust for expected endian mode... (h1, st, h2) = struct.unpack(H8sh, something) print %4.4x, %4.4x % (h1, h2) 0588, 0d0a h1 1416 h2 3338 -- Wulfraed Dennis Lee Bieber KD6MOG wlfr...@ix.netcom.com HTTP://wlfraed.home.netcom.com/ Nice, thanks! -- http://mail.python.org/mailman/listinfo/python-list
Google, Bing search api wrappers for python
Does any one know of a good wrappers for both of these search engines? There seem to a few but, wondering what people experience with them. Vitaly Babiy -- http://mail.python.org/mailman/listinfo/python-list
Reading hex to int from a binary string
Hi all, I read data from a binary stream, so I get hex values as characters (in a string) with escaped x, like \x05\x88, instead of 0x05. I am looking for a clean way to add these two values and turn them into an integer, knowing that calling int() with base 16 throws an invalid literal exception. Any help appreciated, thanks. -- http://mail.python.org/mailman/listinfo/python-list
Help configuring Lamson. Multiple domains on one box
Is there anybody here that can help me out with some configuration issues concerning using the Lamson mail server(http:// lamsonproject.org/)? 1. I would like to use it as my main MTA 2. I would like it to mange 3 domains on one box Thanks -- http://mail.python.org/mailman/listinfo/python-list
save windows clipboard content temporarily and restore later
Is there a way to: 1. save windows clipboard content temporarily in a variable 2. (the clipboard content is then overwritten by some other applications) 3. restore the saved data back into the clipboard. ? I've tried win32clipboard's GetClipboardData, SetClipboardData. The GetClipboardData method is able to retrieve clipboard content only after a format is specified. Restoring the data with that format could result in information loss, for example when HTML text is saved in ordinary text format. There is no format that could preserve 100% of any kind of clipboard content. Does anyone has a brilliant solution? -- http://mail.python.org/mailman/listinfo/python-list
Re: mktime, how to handle dates before 01-01-1970 ?
John Yeung gallium.arsen...@gmail.com writes: I think the choice of epoch is not a big deal, once you pick one far enough back. Ben Finney's suggestion to use 4004 BCE is not appreciably different (computationally) from JDN. (Though I will say that the Wikipedia link he provided doesn't mention 4004 BCE, and if anything suggests using 1 CE as the epoch.) My apologies, I gave the wrong year. I was intending to refer to the URL:http://en.wikipedia.org/wiki/Julian_date system, which begins at the year −4712 (4713 BCE). This has the advantages of: * clearly covering spans of human history more recent than ancient civilisations * having a long-recognised standard specification * being commonly used in computing (for astronomy and other scientific computing applications) * making arithmetic on dates simple (it uses a year zero, making the time line an uninterrupted number line) -- \ “When we talk to God, we're praying. When God talks to us, | `\ we're schizophrenic.” —Jane Wagner, via Lily Tomlin, 1985 | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: save windows clipboard content temporarily and restore later
kakarukeys: Restoring the data with that format could result in information loss, for example when HTML text is saved in ordinary text format. There is no format that could preserve 100% of any kind of clipboard content. Does anyone has a brilliant solution? Enumerate all the clipboard formats with EnumClipboardFormats and grab the contents in each format then put them all back when finished. Neil -- http://mail.python.org/mailman/listinfo/python-list
Re: web sound recording with python
Hi! On windows, you can record sound who play on the local sound-card. It is not really Python scripting, but Python can launch it. @+ -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter -- the best way to make a realtime loop
On Oct 8, 7:15 pm, J Wolfe vorticitywo...@gmail.com wrote: Thank you both for your replies. I had something similar to this: def incr(): var.set(1 + var.get()) root.after(1000, incr) except I had an extra set of parenthesis... def incr(): var.set(1 + var.get()) root.after(1000, incr()) on the function which was screwing it up. Also needed to have a root.update() to refresh the GUI. M, no? The root.update() should not be necessary: the triggering of the action specified in after(...) is done by the tk mainloop when it's idle, and if it's idle, it means that it already has updated the display. So no update() should be needed. What happens if you remove it? -- http://mail.python.org/mailman/listinfo/python-list
Re: Most active coroutine library project?
On Sep 23, 10:58 pm, Brian Hammond or.else.it.gets.the.h...@gmail.com wrote: On Aug 25, 12:51 am, Denis denis.bile...@gmail.com wrote: You can also atgevent http://pypi.python.org/pypi/gevent Please, please document this! There are a lot of people who would love to use this but give up when they don't find a guide or something similar. I've actually started doing that recently, check out http://gevent.org Feedback is appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading hex to int from a binary string
Luc schrieb: On Oct 8, 11:13 pm, Diez B. Roggisch de...@nospam.web.de wrote: Luc schrieb: Hi all, I read data from a binary stream, so I get hex values as characters (in a string) with escaped x, like \x05\x88, instead of 0x05. I am looking for a clean way to add these two values and turn them into an integer, knowing that calling int() with base 16 throws an invalid literal exception. Any help appreciated, thanks. Consider this (in the python interpreter): chr(255) '\xff' chr(255) == r\xff False int(rff, 16) 255 In other words: no, you *don't* get hex values. You get bytes from the stream as is, with python resorting to printing these out (in the interpreter!!!) as \xXX. Python does that so that binary data will always have a pretty output when being inspected on the REPL. But they are bytes, and to convert them to an integer, you call ord on them. So assuming your string is read bytewise into two variables a b, this is your desired code: a = \xff b = \xa0 ord(a) + ord(b) 415 HTH, Diez Sorry I was not clear enough. When I said add, I meant concatenate because I want to read 0x0588 as one value and ord() does not allow that. (ord(a) 8) + ord(b) Diez -- http://mail.python.org/mailman/listinfo/python-list
Plotting multiple datasets with gnuplot
Hi, I'm trying to get gnuplot to display multiple data series on a single plot using gnuplot in python. I've searched around and haven't found a solution to how to do this when I have a variable-length list of plots to add. For example, the following code will work: plotData1 = Gnuplot.PlotItems.Data(data1, title=title1) plotData2 = Gnuplot.PlotItems.Data(data2, title=title2) g.plot( plotData1, plotData2 ) [I've removed the rest of the code for clarity] But how can I do the following instead: data = [] ... # Populate data ... plots = [] for dataSet in data: plots.append(dataSet) g.plot(plots) I don't know how many plots I'll be wanting to plot, but the number will be roughly 15-20 and it seems ridiculous to have to hand-write individual setup for each plot when I should be able to just loop through the datasets and add them to gnuplot automatically. Any help would be much appreciated! Thanks, Rob PS mulitplot isn't the solution - this places plots literally on top of each other, it doesn't plot different sets of data on the same axes. -- http://mail.python.org/mailman/listinfo/python-list
Tree Structure
Hello, Is there any python class to display the drive and folder structure as a tree(As you see in the windows explorer window)?? Thanks, Girish.. -- http://mail.python.org/mailman/listinfo/python-list
mxDateTime history (Re: mktime, how to handle dates before 01-01-1970 ?)
John Yeung wrote: On Oct 6, 4:10 pm, Stef Mientki stef.mien...@gmail.com wrote: thanks guys, mx works a bit better Another popular Python date library is dateutil: http://labix.org/python-dateutil It gives a certain amount of credit to mxDateTime (praising it but not being very clear how they are related; there is some mention of using the specification of mxDateTime). History goes a bit like this: mxDateTime was the first Python library to implement native date/time types for Python. I started the project in 1997. Back then I had a good look around at the various date/time libs and then decided to take a little more academic approach to the whole thing. The result was that you only need two basic types in mxDateTime: the DateTime object, which refers to a point in time, and the DateTimeDelta object, which allows measuring the time span between two such points. Note the absence of a Date object. These would be date/time range objects since they apply to the timespan of a full day with a time reference point at midnight. I decided to leave such ranges for a later stage in development - and have so far, never needed them :-) A bit later in 1998, I also added the RelativeDateTime object, which allows doing date/time calculations based on relative terms, e.g. x minus one year (which could mean 356 or 366 days depending on the year), first of next month (which could mean anything from 1-31 days), last of next month, Tuesday in 3 weeks, last Monday next month, etc. And again a bit later in 2000, I added the RelativeDateTimeDiff object which works a bit like an age function in that it tries to determine the RelativeDateTime value which has to be applied to a DateTime object in order to reach another one, say from your birthday to today. The result reads is more user- friendly than a bare DateTimeDelta, e.g. you get 40 years, 6 months, 3 days instead of 14796 days. In 2002 Zope Corp initiated the development of the datetime module, which borrowed a lot of design and API ideas from mxDateTime. However, it did not provide a date/time string parser and also misses out on lots of the other good stuff you can find in mxDateTime. Gustavo Niemeyer started to work on a date/time parser based on the datetime module - that's the python-dateutil library. He also added a relative date/time object which was one of the bits Zope Corp left out in the datetime module from mxDateTime and added some other things that are not currently part of mxDateTime: recurring events and time zones. mxDateTime continues to be actively developed - mostly driven by eGenix' own needs and experience we find in projects. Whenever we need something new, we can just add it to mxDateTime and since its release cycle is not bound to Python's, such enhancement are more readily available to others as well. Overall, my impression is that the datetime module was designed on the drawing board without actually touching real life usage scenarios. We've just done a project that used the datetime module for date/time related things instead of mxDateTime and found that while the implementation is similar to mxDateTime (naturally, see above), many useful features you find in mxDateTime are not available on the datetime objects. For future releases, we'll make the interaction between the two implementations more user friendly, e.g. it should be possible to pass a datetime object to mx.DateTime.DateTimeFrom() and call a method on DateTime objects to get a datetime module object with the same values. I would say mxDateTime and dateutil are the two heavyweights in this arena. As you would expect, they have a lot of overlapping functionality and which one is used is often just a matter of taste, or whichever one you happened to find first. One thing that dateutil provides that mxDateTime doesn't is support for lay person month operations. That is, as far as I can tell, mxDateTime tries not to dirty itself with the messy business of month arithmetic, whereas dateutil rolls up its sleeves and takes an honest stab at it. If you are writing a calendar/appointment application, or other end-user-facing program, I would expect dateutil to be a little more helpful. Month arithmetic is a bit of a mess, since it's not clear how to map e.g. Jan 31 + one month. mxDateTime does support month arithmetic via the RelativeDateTime object, but I'm not all that happy with the solution to the above problem. The alternatives are basically deciding between loosing data or raising an exception - both aren't really all that nice. Perhaps I'll just add a parameter to allow customization of the behavior depending on application needs. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Oct 09 2009) Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...
Re: Plotting multiple datasets with gnuplot
En Fri, 09 Oct 2009 06:36:45 -0300, Rob Garrett rgagarr...@gmail.com escribió: I'm trying to get gnuplot to display multiple data series on a single plot using gnuplot in python. I've searched around and haven't found a solution to how to do this when I have a variable-length list of plots to add. For example, the following code will work: plotData1 = Gnuplot.PlotItems.Data(data1, title=title1) plotData2 = Gnuplot.PlotItems.Data(data2, title=title2) g.plot( plotData1, plotData2 ) [I've removed the rest of the code for clarity] But how can I do the following instead: data = [] ... # Populate data ... plots = [] for dataSet in data: plots.append(dataSet) g.plot(plots) g.plot(*plots) should work; it's like calling g.plot(plots[0], plots[1], plots[2]...) See http://docs.python.org/reference/expressions.html#calls for the gory details. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Tree Structure
On Oct 9, 5:02 am, Girish girish@gmail.com wrote: Is there any python class to display the drive and folder structure as a tree(As you see in the windows explorer window)?? You could use a recursive function to print it out of course or you will need to use a GUI kit. wxPython has a tree widget, i think TIX has a simplistic tree widget? TIX is included in the stdlib -- http://mail.python.org/mailman/listinfo/python-list
Re: mxDateTime history (Re: mktime, how to handle dates before 01-01-1970 ?)
Month arithmetic is a bit of a mess, since it's not clear how to map e.g. Jan 31 + one month. Jan 31 + one month usually means add one to the month value and then keep backing off the day if you get an exception making the date, so you'd get Feb 31, exception, Feb 30, exception, Feb 29, possibly an exception, and possibly/finally Feb 28th. This makes pretty intuitive sense to most folks and is usually what's meant. I've found that issues and confusion stem more from the non-commutative reality that Jan 31 + (1 month) + (-1 month) != Jan 31 + (-1 month) + (1 month) or the non-associative Jan 31 + (1 month + 1 month) != (Jan 31 + 1 month) + 1 month :-/ So yes, messy it is! -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: save windows clipboard content temporarily and restore later
On Oct 9, 11:30 am, Neil Hodgson nyamatongwe+thun...@gmail.com wrote: kakarukeys: Restoring the data with that format could result in information loss, for example when HTML text is saved in ordinary text format. There is no format that could preserve 100% of any kind of clipboard content. Does anyone has a brilliant solution? Enumerate all the clipboard formats with EnumClipboardFormats and grab the contents in each format then put them all back when finished. Neil Hi Neil, I followed your hints, and wrote the following code. It works for most clipboard formats except files. Selecting and copying a file, followed by backup() and restore() throw an exception: Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. from test12 import * backup() restore() Traceback (most recent call last): File stdin, line 1, in module File test12.py, line 40, in restore win32clipboard.SetClipboardData(format, cb[format]) TypeError: expected a readable buffer object If I try to skip the error, pasting into a folder creates a file named 'scrap' with more or less the same content as the copied file. Is there any solution? import win32clipboard storage = [] def backup(): cb = {} win32clipboard.OpenClipboard() format = 0 try: while True: format = win32clipboard.EnumClipboardFormats(format) if format == 0: break else: try: RawData = win32clipboard.GetClipboardData(format) except: continue else: cb[format] = RawData finally: win32clipboard.CloseClipboard() storage.append(cb) def restore(): if storage != []: win32clipboard.OpenClipboard() try: win32clipboard.EmptyClipboard() cb = storage.pop() for format in cb: win32clipboard.SetClipboardData(format, cb[format]) finally: win32clipboard.CloseClipboard() -- http://mail.python.org/mailman/listinfo/python-list
Re: Nested Menus
Hmm. I didn't bother to look at the comparison post. The indenting looks right to me. I reread my post and I believe my question is straight-forward. The crux of the issue is my sentence at the bottom. I believe that details what my objective is. Not sure what I should do here. I hope you can clarify what it is you want me to clarify. V On Fri, Oct 9, 2009 at 2:04 AM, r rt8...@gmail.com wrote: On Oct 8, 5:58 pm, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: (snip: atrocious post formatting!) Dear Dennis, This is not a personal attack on you but your writing style is so horrendous i must at least notify you of it. Go to this link and view your post in GG's and let me know what you think of it. http://groups.google.com/group/comp.lang.python/browse_thread/thread/6301372f8e581a74?hl=en# As you can see the post is virtually impossible to read from the large and seemingly random indenting and tabbing going on.(notwitstanding the bombastic verbosity and unbridled quoting). I have seen many posts like this in the past so maybe you are just oblivious...? Are you writing like this on purpose or is your newsreader bugging out? Sincerely, concerned Pythonista -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Python CherryPy TurboGears 2 project support needed [in Belgium]
b...@creue-consulting schrieb: Dear comp.lang.python users, Firstly, this a is a Job post for a on-site Freelance Python Job in Belgium, I know this is frowned upon by some, so I am very sorry if it is not well received, but as it is such a great job, I have been encouraged to post this to the list. So, apology done, and hopefully accepted, I need a Python *guru*, ideally with CherryPy TurboGears 2/AJAX experience. Out of curiosity: TG1 is based upon CherryPy - TG2 on Pylons. So in my opinion, this is somewhat mutual exclusive (not the know how, but using this in one project). So where comes CherryPy into the game? Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: cx_Freeze.freezer.ConfigError: no initscript named Console
On Oct 1, 2:19 pm, John j...@nospam.net wrote: cx_freeze v4.01 Python 2.6 Ubuntu Jaunty Following the example of 'cx-freeze hello.py', I'm getting the error message below. I put all of the error keywords into google and found no hits. Some people in various posts have said to use Python 2.5 but a lot of my code is using Python 2.6 features. Can you telling what I'm doing wrong? ./cxfreeze hello.py Traceback (most recent call last): File ./cxfreeze, line 5, in module main() File /root/cx_Freeze-4.1/cx_Freeze/main.py, line 178, in main silent = options.silent) File /root/cx_Freeze-4.1/cx_Freeze/freezer.py, line 85, in __init__ self._VerifyConfiguration() File /root/cx_Freeze-4.1/cx_Freeze/freezer.py, line 325, in _VerifyConfiguration self._GetInitScriptFileName() File /root/cx_Freeze-4.1/cx_Freeze/freezer.py, line 246, in _GetInitScriptFileName raise ConfigError(no initscript named %s, name) cx_Freeze.freezer.ConfigError: no initscript named Console Hi, I found the same problem when used to install cx_freeze via easy_install. Download the cx_freeze sorce, than: sudo setup.py install Now all is fine. Ubuntu 9.04, Python 2.6 -- http://mail.python.org/mailman/listinfo/python-list
Re: Nested Menus
On Fri, Oct 9, 2009 at 7:13 AM, Victor Subervi victorsube...@gmail.comwrote: Hmm. I didn't bother to look at the comparison post. The indenting looks right to me. I reread my post and I believe my question is straight-forward. The crux of the issue is my sentence at the bottom. I believe that details what my objective is. Not sure what I should do here. I hope you can clarify what it is you want me to clarify. He was complaining not about your post but a rather extended response Dennis made to you while trying to help. Which is a particularly asshatish thing to do, but hey. Dennis's response isn't really my style of using SQL in Python, but its perfectly legible and understandable -- both in GMail where I usually read, and via the link r provided to prove his point, which it doesn't at all. It looks fine in both. Either way, I basically do it just the same way Dennis did-- so did that solve your question? A little bit of table redesign and then recursive calls between the items and relationships tables. --S -- http://mail.python.org/mailman/listinfo/python-list
Re: Python CherryPy TurboGears 2 project support needed [in Belgium]
Diez, Thanks for pointing this out. It maybe that we are talking about TG 1.1 in that case. I will double check with the TA. Sorry for any confusion! - I'll let you know. Thanks again. Cheers, Ben On Oct 9, 3:36 pm, Diez B. Roggisch de...@nospam.web.de wrote: b...@creue-consulting schrieb: Dear comp.lang.python users, Firstly, this a is a Job post for a on-site Freelance Python Job in Belgium, I know this is frowned upon by some, so I am very sorry if it is not well received, but as it is such a great job, I have been encouraged to post this to the list. So, apology done, and hopefully accepted, I need a Python *guru*, ideally with CherryPy TurboGears 2/AJAX experience. Out of curiosity: TG1 is based upon CherryPy - TG2 on Pylons. So in my opinion, this is somewhat mutual exclusive (not the know how, but using this in one project). So where comes CherryPy into the game? Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading hex to int from a binary string
On Oct 9, 10:45 am, Diez B. Roggisch de...@nospam.web.de wrote: Luc schrieb: On Oct 8, 11:13 pm, Diez B. Roggisch de...@nospam.web.de wrote: Luc schrieb: Hi all, I read data from a binary stream, so I get hex values as characters (in a string) with escaped x, like \x05\x88, instead of 0x05. I am looking for a clean way to add these two values and turn them into an integer, knowing that calling int() with base 16 throws an invalid literal exception. Any help appreciated, thanks. Consider this (in the python interpreter): chr(255) '\xff' chr(255) == r\xff False int(rff, 16) 255 In other words: no, you *don't* get hex values. You get bytes from the stream as is, with python resorting to printing these out (in the interpreter!!!) as \xXX. Python does that so that binary data will always have a pretty output when being inspected on the REPL. But they are bytes, and to convert them to an integer, you call ord on them. So assuming your string is read bytewise into two variables a b, this is your desired code: a = \xff b = \xa0 ord(a) + ord(b) 415 HTH, Diez Sorry I was not clear enough. When I said add, I meant concatenate because I want to read 0x0588 as one value and ord() does not allow that. (ord(a) 8) + ord(b) Diez Yes that too. But I have four bytes fields and single bit fields to deal with as well so I'll stick with struct. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Nested Menus
Well, as sometimes happens, the response to Dennis' response caught my attention (out of context) and I didn't notice Dennis' response! Thanks for bringing it to my attention. I will look at it tonight, and follow-up tomorrow after I've had a chance to digest it and work with it. (And thank you Dennis!) V On Fri, Oct 9, 2009 at 11:13 AM, Stephen Hansen apt.shan...@gmail.comwrote: On Fri, Oct 9, 2009 at 7:13 AM, Victor Subervi victorsube...@gmail.comwrote: Hmm. I didn't bother to look at the comparison post. The indenting looks right to me. I reread my post and I believe my question is straight-forward. The crux of the issue is my sentence at the bottom. I believe that details what my objective is. Not sure what I should do here. I hope you can clarify what it is you want me to clarify. He was complaining not about your post but a rather extended response Dennis made to you while trying to help. Which is a particularly asshatish thing to do, but hey. Dennis's response isn't really my style of using SQL in Python, but its perfectly legible and understandable -- both in GMail where I usually read, and via the link r provided to prove his point, which it doesn't at all. It looks fine in both. Either way, I basically do it just the same way Dennis did-- so did that solve your question? A little bit of table redesign and then recursive calls between the items and relationships tables. --S -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Zip Question
Hi; I have the following code: elif table[0] == 't': # This is a store subtype table bits = string.split(table, '0') sst.append(bits[2]) sstp.append(bits[1]) subtypes = dict(zip(sstp, sst)) When I print these out to screen, I get this: sst: ['doctors', 'patient'] sstp: ['prescriptions', 'prescriptions'] subtypes: {'prescriptions': 'patient'} Why do I only get one item from sst and sstp zipped? Why not both?? TIA, V -- http://mail.python.org/mailman/listinfo/python-list
Re: Zip Question
On Fri, Oct 9, 2009 at 10:02 AM, Victor Subervi victorsube...@gmail.comwrote: Hi; I have the following code: elif table[0] == 't': # This is a store subtype table bits = string.split(table, '0') sst.append(bits[2]) sstp.append(bits[1]) subtypes = dict(zip(sstp, sst)) When I print these out to screen, I get this: sst: ['doctors', 'patient'] sstp: ['prescriptions', 'prescriptions'] subtypes: {'prescriptions': 'patient'} Why do I only get one item from sst and sstp zipped? Why not both?? I think you have a logic problem that's not shown in that code sample: sst = ['doctors', 'patient'] sstp = ['prescriptions', 'prescriptions'] zip(sst,sstp) [('doctors', 'prescriptions'), ('patient', 'prescriptions')] dict(zip(sst,sstp)) {'patient': 'prescriptions', 'doctors': 'prescriptions'} --S -- http://mail.python.org/mailman/listinfo/python-list
Re: Zip Question
On Fri, Oct 9, 2009 at 10:10 AM, Stephen Hansen apt.shan...@gmail.comwrote: On Fri, Oct 9, 2009 at 10:02 AM, Victor Subervi victorsube...@gmail.comwrote: Hi; I have the following code: elif table[0] == 't': # This is a store subtype table bits = string.split(table, '0') sst.append(bits[2]) sstp.append(bits[1]) subtypes = dict(zip(sstp, sst)) When I print these out to screen, I get this: sst: ['doctors', 'patient'] sstp: ['prescriptions', 'prescriptions'] subtypes: {'prescriptions': 'patient'} Why do I only get one item from sst and sstp zipped? Why not both?? I think you have a logic problem that's not shown in that code sample: sst = ['doctors', 'patient'] sstp = ['prescriptions', 'prescriptions'] zip(sst,sstp) [('doctors', 'prescriptions'), ('patient', 'prescriptions')] dict(zip(sst,sstp)) {'patient': 'prescriptions', 'doctors': 'prescriptions'} --S -- http://mail.python.org/mailman/listinfo/python-list The issue is: subtypes = dict(zip(sstp, sst)) If you remove the dict, you'll see the following: [('prescriptions', 'doctors'), ('prescriptions', 'patient')] When this is converted to a dict, the first element of each tuple is placed as the dict's key, and the second as the value. This means that you have two keys of prescriptions, and so the final one happens to be chosen as the value. Changing the line: subtypes = dict(zip(sstp, sst)) to: subtypes = dict(zip(sst, sstp)) as I believe Stephen misread it to be causes the zip operation to return: [('doctors', 'prescriptions'), ('patient', 'prescriptions')] and thus the dict will contain: {'patient': 'prescriptions', 'doctors': 'prescriptions'} Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Zip Question
You're right...how strange. Here's the whole code: tables = [] bst = [] bdt = [] spt = [] sst = [] sstp = [] cursor.execute('show tables;') all = cursor.fetchall() for a in all: tables.append(a[0]) for table in tables: if table[0] == 'b': # This is a basic table if table[1] == '0': # This is a basic static table bst.append(table) # elif table[1] == '1': # This is a basic dynamic table #bdt.append(table) # Basic dynamic tables, like pic below, have to be manually created. elif table[0] == 's': # This is a store table if table[1] == '0': # This is a store primary table spt.append(table) elif table[0] == 't': # This is a store subtype table bits = string.split(table, '0') sst.append(bits[2]) sstp.append(bits[1]) subtypes = dict(zip(sstp, sst)) print sst print 'br /' print sstp print 'br /' print subtypes print 'br /' This is what prints out: ['doctors', 'patient'] ['prescriptions', 'prescriptions'] {'prescriptions': 'patient'} TIA, V On Fri, Oct 9, 2009 at 12:10 PM, Stephen Hansen apt.shan...@gmail.comwrote: On Fri, Oct 9, 2009 at 10:02 AM, Victor Subervi victorsube...@gmail.comwrote: Hi; I have the following code: elif table[0] == 't': # This is a store subtype table bits = string.split(table, '0') sst.append(bits[2]) sstp.append(bits[1]) subtypes = dict(zip(sstp, sst)) When I print these out to screen, I get this: sst: ['doctors', 'patient'] sstp: ['prescriptions', 'prescriptions'] subtypes: {'prescriptions': 'patient'} Why do I only get one item from sst and sstp zipped? Why not both?? I think you have a logic problem that's not shown in that code sample: sst = ['doctors', 'patient'] sstp = ['prescriptions', 'prescriptions'] zip(sst,sstp) [('doctors', 'prescriptions'), ('patient', 'prescriptions')] dict(zip(sst,sstp)) {'patient': 'prescriptions', 'doctors': 'prescriptions'} --S -- http://mail.python.org/mailman/listinfo/python-list
Re: Zip Question
Changing the line: subtypes = dict(zip(sstp, sst)) to: subtypes = dict(zip(sst, sstp)) as I believe Stephen misread it to be causes the zip operation to return: [('doctors', 'prescriptions'), ('patient', 'prescriptions')] and thus the dict will contain: {'patient': 'prescriptions', 'doctors': 'prescriptions'} Whoops! You're absolutely right. I totally flipped the options to zip in my head when eyeing it. I suppose I'm suffering from late-onset dyslexia. Ahem. Yeah, I think the arguments to zip() were probably just flipped in Victor's code. Unless he wants a result different then what I assume is expected. I assume he's expecting {doctors: prescriptions, patient: prescriptions}. If instead its something more like {prescriptions: [doctors, patient]} then zip() isn't how to accomplish it. --S -- http://mail.python.org/mailman/listinfo/python-list
Re: Is pythonic version of scanf() or sscanf() planned?
ryniek90 wrote: So maybe someone, someday decide to put in Python an alternative, really great implementation of scanf() ? My idea of a great scanf() function would be a clever combination of re.match(), int(), and float(). j -- http://mail.python.org/mailman/listinfo/python-list
Re: Zip Question
So, because the results in sstp were duplicates ( ['prescriptions', 'prescriptions'] ) it only returned one result in the dict(zip()) statement. Weird. Bug or feature? ;) Thanks, V On Fri, Oct 9, 2009 at 12:37 PM, Stephen Hansen apt.shan...@gmail.comwrote: Changing the line: subtypes = dict(zip(sstp, sst)) to: subtypes = dict(zip(sst, sstp)) as I believe Stephen misread it to be causes the zip operation to return: [('doctors', 'prescriptions'), ('patient', 'prescriptions')] and thus the dict will contain: {'patient': 'prescriptions', 'doctors': 'prescriptions'} Whoops! You're absolutely right. I totally flipped the options to zip in my head when eyeing it. I suppose I'm suffering from late-onset dyslexia. Ahem. Yeah, I think the arguments to zip() were probably just flipped in Victor's code. Unless he wants a result different then what I assume is expected. I assume he's expecting {doctors: prescriptions, patient: prescriptions}. If instead its something more like {prescriptions: [doctors, patient]} then zip() isn't how to accomplish it. --S -- http://mail.python.org/mailman/listinfo/python-list
Re: Zip Question
On Fri, Oct 9, 2009 at 11:04 AM, Victor Subervi victorsube...@gmail.comwrote: So, because the results in sstp were duplicates ( ['prescriptions', 'prescriptions'] ) it only returned one result in the dict(zip()) statement. Weird. Bug or feature? ;) Thanks, V Feature. zip() returned two results, but dictionaries are mappings of keys to values. If you duplicate a key, you don't get multiple values for that key -- you replace the value. If you want something dictionary like which has multiple values, try something like: http://code.activestate.com/recipes/52219/ Or even this dict subclass: http://code.activestate.com/recipes/440502/ HTH, --S -- http://mail.python.org/mailman/listinfo/python-list
Python 2.5 execfile() works only once, why ?
hello, I'm working on a kind of IDE, to build and distribute Python programs. One of the parts is editing a build file for py2exe and running the modified script. In the script editor I've an accelerator key, to launch these tasks: - save modified script file - run modified script file - catch log and error information from py2exe - launch the distro executable self.Edit.SaveFile ( self.Edit.Filename ) Globalsx = {} #Globalsx [ 'stdout' ] = self.Log execfile ( self.Edit.Filename, Globalsx ) The above code (with or without the stdout redirection), works perfect, ... the first time ... but does (almost?) nothing (doesn't crash, try / except around execfile), although the source file self.Edit.Filename has changed. Could someone give me an explanation, why this happens ? It would be great to have a work around. I've currently switched to Popen, but can't get output / error piping working fluently. thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: No threading.start_new_thread(), useful addition?
I personally find it much cleaner this way. Also, why should any code care in which thread it is executed? Why should I have to derive a class from some other only because I want to run one of its functions in a separate thread? I think you are right! Especially that you can (and probably will) call other methods from your thread. For example, functions from the standard library. Or use methods of objects that where created in a different thread. I think we can say, you must call methods of other (not Thread) objects if you ever want to do something useful in your thread. Now I'm beginnig to agree with you, Ulrich. We have threading.enumerate() - it can be used to list active threads. So if you only want to start a function in a separate thread, then you do not really need the Thread object. Then we do you HAVE TO create a Thread object explicitely? Of course you can easily create a nice decorator like this: import threading def threadlaunch(func): def launcher(*args,**kwargs): thr = threading.Thread(target=func,args=args,kwargs=kwargs) thr.start() return thr return launcher And then do something like: import time @threadlaunch def print_something(w,s): print please wait... time.sleep(w) print s thr = print_something(3,Test) print started print_something in,thr How about that? (Or was it your concern that it is not part of the standard library?) Best, Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: Persistent Distributed Objects
I've seen evidence about this being done wrt what looks like insanely complex stuff on this list but I'm wondering if there is something to do this with any number of nodes and just farm out random classes/objects to them? Designing and opreating distributed systems is a complex thing. Especially if you do not want to specify an exact problem domain that you needed to solve - then you need to design a distributed system that is able to solve general problems. It is very complex, and - at least to my knowledge - there is no efficient solution out of the box. This is not Python specific. It would be a hard task just to design how that system should work, regardless of the computer language it is implemented in. L -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.5 execfile() works only once, why ?
On Oct 9, 11:15 am, Stef Mientki stef.mien...@gmail.com wrote: hello, I'm working on a kind of IDE, to build and distribute Python programs. One of the parts is editing a build file for py2exe and running the modified script. In the script editor I've an accelerator key, to launch these tasks: - save modified script file - run modified script file - catch log and error information from py2exe - launch the distro executable self.Edit.SaveFile ( self.Edit.Filename ) Globalsx = {} #Globalsx [ 'stdout' ] = self.Log execfile ( self.Edit.Filename, Globalsx ) The above code (with or without the stdout redirection), works perfect, ... the first time ... but does (almost?) nothing (doesn't crash, try / except around execfile), although the source file self.Edit.Filename has changed. Could someone give me an explanation, why this happens ? I'm guessing you have references to objects from the first time you ran execfile that don't get updated. It's kind of hard to tell. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: No threading.start_new_thread(), useful addition?
On Oct 8, 5:03 am, Ulrich Eckhardt eckha...@satorlaser.com wrote: sturlamolden wrote: On 8 Okt, 09:17, Ulrich Eckhardt eckha...@satorlaser.com wrote: I'm looking at the 'threading' module and see that other than the 'thread' module it doesn't have a simple function to start a new thread. Instead, you first have to instantiate a threading object and then start the new thread on it: t = threading.Thread(target=my_function) t.start() One usually want to subclass threading.Thread instead of specifying a target function. No. You also don't derive from a file class in order to read a file. The point is that the Thread instance is not a thread but it is an object that can be used to access a thread, similar to a File instance which file which is not the file but just an object to access one. I personally find it much cleaner this way. Also, why should any code care in which thread it is executed? Why should I have to derive a class from some other only because I want to run one of its functions in a separate thread? I have to agree. I've been trying to understand some other entity's Java code lately, and it's mondo-confusing because there is a subclass of Thread that has methods that are called from other threads. To make matters worse the variable this method is assigned to is called, simply, thread. As far as I can discern doing that way (as opposed to using a Runnable object) didn't have any effect except to make the logic harder to understand. So (getting back to Python) count me among those who say one usally want to specify a target function instead of subclassing threading.Thread. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: No threading.start_new_thread(), useful addition?
Laszlo Nagy wrote: IMHO it is much cleaner to implement this as a decorator. Pro: transparent passing of positional and keyword arguments, keeps function documentation. You are entitled to your opinion but I STRONGLY recommend against your decorator. You MUST NOT start threads a a side effect of a module import. It can lead to severe bugs and dead lock the entire interpreter. I'm speaking as an experienced Python developer and a CPython core developer. Please trust me in this. The interaction between the import system, its global import lock and threads can and will lead to surprising and hard to debug bugs. A well designed application loads its modules first and then initializes its components explicitly. You don't want to fire up threads randomly! Christian -- http://mail.python.org/mailman/listinfo/python-list
easy install
A puzzlement: I used easy_install the other day to get xlutils on my system. It automatically installed xlrd and xlwt as well. This is cool. What's not so cool are my tracebacks. E.g. Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. -- import xlwt -- xlwt.__name__ 'xlwt' -- xlwt.__file__ 'C:\\Python25\\lib\\site-packages\\xlwt-0.7.2-py2.5-win32.egg\\xlwt\\__init__.pyc' -- xlwt.Workbook().save('non-file') Traceback (most recent call last): File stdin, line 1, in module File c:\docume~1\ethanf\locals~1\temp\easy_install-q1s1rb\xlwt-0.7.2-py2.5-win32.egg.tmp\xlwt\Workbook.py, line 634, in save File c:\docume~1\ethanf\locals~1\temp\easy_install-q1s1rb\xlwt-0.7.2-py2.5-win32.egg.tmp\xlwt\Workbook.py, line 615, in get_biff_data IndexError: list index out of range -- Anyone know why that is? ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: easy install
On Fri, Oct 9, 2009 at 5:02 PM, Ethan Furman et...@stoneleaf.us wrote: A puzzlement: I used easy_install the other day to get xlutils on my system. It automatically installed xlrd and xlwt as well. This is cool. What's not so cool are my tracebacks. E.g. Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. -- import xlwt -- xlwt.__name__ 'xlwt' -- xlwt.__file__ 'C:\\Python25\\lib\\site-packages\\xlwt-0.7.2-py2.5-win32.egg\\xlwt\\__init__.pyc' -- xlwt.Workbook().save('non-file') Traceback (most recent call last): File stdin, line 1, in module File c:\docume~1\ethanf\locals~1\temp\easy_install-q1s1rb\xlwt-0.7.2-py2.5-win32.egg.tmp\xlwt\Workbook.py, line 634, in save File c:\docume~1\ethanf\locals~1\temp\easy_install-q1s1rb\xlwt-0.7.2-py2.5-win32.egg.tmp\xlwt\Workbook.py, line 615, in get_biff_data IndexError: list index out of range -- Anyone know why that is? ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list You can't save a workbook with no worksheets. Try: W = xlwt.Workbook() W.add_sheet('no-sheet') W.save('non-file') -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading hex to int from a binary string
Luc schrieb: On Oct 9, 10:45 am, Diez B. Roggisch de...@nospam.web.de wrote: Luc schrieb: On Oct 8, 11:13 pm, Diez B. Roggisch de...@nospam.web.de wrote: Luc schrieb: Hi all, I read data from a binary stream, so I get hex values as characters (in a string) with escaped x, like \x05\x88, instead of 0x05. I am looking for a clean way to add these two values and turn them into an integer, knowing that calling int() with base 16 throws an invalid literal exception. Any help appreciated, thanks. Consider this (in the python interpreter): chr(255) '\xff' chr(255) == r\xff False int(rff, 16) 255 In other words: no, you *don't* get hex values. You get bytes from the stream as is, with python resorting to printing these out (in the interpreter!!!) as \xXX. Python does that so that binary data will always have a pretty output when being inspected on the REPL. But they are bytes, and to convert them to an integer, you call ord on them. So assuming your string is read bytewise into two variables a b, this is your desired code: a = \xff b = \xa0 ord(a) + ord(b) 415 HTH, Diez Sorry I was not clear enough. When I said add, I meant concatenate because I want to read 0x0588 as one value and ord() does not allow that. (ord(a) 8) + ord(b) Diez Yes that too. But I have four bytes fields and single bit fields to deal with as well so I'll stick with struct. For the future: it helps describing the actual problem, not something vaguely similar - this will get you better answers, and spare those who try to help you the effort to come up with solutions that aren't ones. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: smtplib.SMTPServerDisconnected: please run connect() first
In mailman.1096.1255129309.2807.python-l...@python.org Ethan Furman et...@stoneleaf.us writes: The line preceeding it, s = smtplib.SMTP() needs to have an e-mail server specified. E.g. s = smtplib.SMTP('localhost') # from the 2.5 docs Perfect. Thanks! kynn -- http://mail.python.org/mailman/listinfo/python-list
Re: No threading.start_new_thread(), useful addition?
Christian Heimes wrote: Laszlo Nagy wrote: IMHO it is much cleaner to implement this as a decorator. Pro: transparent passing of positional and keyword arguments, keeps function documentation. You are entitled to your opinion but I STRONGLY recommend against your decorator. You MUST NOT start threads a a side effect of a module import. It can lead to severe bugs and dead lock the entire interpreter. I'm speaking as an experienced Python developer and a CPython core developer. Please trust me in this. The interaction between the import system, its global import lock and threads can and will lead to surprising and hard to debug bugs. A well designed application loads its modules first and then initializes its components explicitly. You don't want to fire up threads randomly! Christian Okay, I for one will never start threads as a side-effect of module import. Other than that, are there other inherent problems with using that decorator at non-import times? ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: Need feedback on subprocess-using function
In pan.2009.10.07.03.27.32.844...@nowhere.com Nobody nob...@nowhere.com writes: You could always lift the code from Popen._communicate(), which uses threads for Windows and select() for POSIX. Thanks. A lot of useful advice in your replies. G. -- http://mail.python.org/mailman/listinfo/python-list
Poll on Eval in Python
I am Lisp programmer and I write an article on issues as macros, fexprs and eval. I want to compare opinions of programmers of various programming languages on eval. If you want to contribute your opinion on eval in Python (or you want to look at result), the adress is: http://kazimirmajorinc.blogspot.com Thank you, -- Kazimir Majorinc -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading hex to int from a binary string
Luc wrote: Hi all, I read data from a binary stream, so I get hex values as characters (in a string) with escaped x, like \x05\x88, instead of 0x05. I am looking for a clean way to add these two values and turn them into an integer, knowing that calling int() with base 16 throws an invalid literal exception. Any help appreciated, thanks. Hi, Check out the ord() function. Example: x = '\x34' print ord(x) output: 52 Also, if you, lets say read(4), and end up with `x = '\x05\x41\x24\x00' you can use x[i] to address each character. So if you print x[1] output: 'A' That should be enough to get you started in the right direction. -Jack -- http://mail.python.org/mailman/listinfo/python-list
Re: Persistent Distributed Objects
Sorry about being interpreted as being vague. `et me try to narrow it down. program a creates objects b c d which each need to use 1 disk space 2 ram 3 processor time. I would like to create a heckpoint which would save the work of the object to be later used and then delete it from memory [which I assume from reading about them implimented elsewhere is more or less how they work]. The other part would be to assign the objects via a network depending on the number of network machines. I.e. suppose b c and d see machines e f g on a network they can send those machines objects b c and d and have any work saved on the main machine or local ones. What I was wondering is how would I do that in python. The arbitrary part could be no more complicated than a program where b is calculating a list of prime numbers from x to infinity c is just a notepad program and d is a program that prints say the size of the file as youi type it and says I like writing a poem of [bytes big] while m y computer foun ou that [new prime] is the biggest on [machines #] computers. Rmi supposedly does this for the distribuited part. Object persistence does this for saving to the best of what I`ve seen nothing distributes and saved at the same time. Does that help? The death of one man is a tragedy. The death of ten million is a statistic--- Joseph Stalin --Original Message-- From: Laszlo Nagy gand...@shopzeus.com To: John Haggerty bouncy...@gmail.com,python-list (General) python-list@python.org Date: Fri, 9 Oct 2009 09:18:12 PM +0430 Subject: Re: Persistent Distributed Objects I've seen evidence about this being done wrt what looks like insanely complex stuff on this list but I'm wondering if there is something to do this with any number of nodes and just farm out random classes/objects to them? Designing and opreating distributed systems is a complex thing. Especially if you do not want to specify an exact problem domain that you needed to solve - then you need to design a distributed system that is able to solve general problems. It is very complex, and - at least to my knowledge - there is no efficient solution out of the box. This is not Python specific. It would be a hard task just to design how that system should work, regardless of the computer language it is implemented in. L -- http://mail.python.org/mailman/listinfo/python-list
How to find number of line that is currently executing?
I would like to put a statement on line N of my program that prints the line number that is currently executing. This may sound fairly trivial, but I don't want to hard code the line number because N will change if lines are inserted or deleted above that point. Any advice will be appreciated. -- View this message in context: http://www.nabble.com/How-to-find-number-of-line-that-is-currently-executing--tp25830766p25830766.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to find number of line that is currently executing?
On Fri, Oct 9, 2009 at 8:46 PM, Dr. Phillip M. Feldman pfeld...@verizon.net wrote: I would like to put a statement on line N of my program that prints the line number that is currently executing. This may sound fairly trivial, but I don't want to hard code the line number because N will change if lines are inserted or deleted above that point. Any advice will be appreciated. If you're doing this for debugging, it's often more convenient to just come up with a unique string you can grep for, but anyway: import traceback print traceback.extract_stack()[-1][1] Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Are there any modules for IRC, that work with Python 3.1?
Does anyone know of any modules for dealing with the IRC protocol, that will work with Python 3.1? It doens't have to be super great, just less time consuming then playing with sockets directly (and obv. stable). The only module in my systems package manager is irclib for Python 2.6. I can live with writing code for Python 2.4+ easily but, ahem, I think it would be wise to write new code around Python 3.1 instead... so yeah, here we are. Searching Google doesn't offer much encouragement - just irclib and oyoyo. Has anyone here tried using oyoyo with Python 3.1, and is there anything else I might have missed? # circumstances Having recently been put into search for a new IRC client, and everything I've thrown in the cauldron having become a disappointment... let's just say, I've come to a conclusion -- either I'm going to install ircII and live with whatever it has to offer(!), or hash out something quickly in Python that fits my needs. If I'm considering writing an IRC client, it makes sense to check for modules implementing the protocol before I have to roll something myself, but nothing seems to fit the bill. (For those that don't know it, ircII is a really freaking old Internet Rely Chat client ;) -- TerryP -- http://mail.python.org/mailman/listinfo/python-list
[issue7089] shlex behaves unexpected if newlines are not whitespace
New submission from Jan David Mol jjd...@gmail.com: The shlex module does not function as expected in the presence of comments when newlines are not whitespace. An example (attached): from shlex import shlex lexer = shlex(a \n b) print ,.join(lexer) a,b lexer = shlex(a # comment \n b) print ,.join(lexer) a,b lexer = shlex(a \n b) lexer.whitespace= print ,.join(lexer) a, ,b lexer = shlex(a # comment \n b) lexer.whitespace= print ,.join(lexer) a,b Now where did my newline go? The comment ate it! Even though the docs seem to indicate the newline is not part of the comment itself: shlex.commenters: The string of characters that are recognized as comment beginners. All characters from the comment beginner to end of line are ignored. Includes just '#' by default. -- files: lexertest.py messages: 93776 nosy: jjdmol2 severity: normal status: open title: shlex behaves unexpected if newlines are not whitespace type: behavior versions: Python 2.4, Python 2.5, Python 2.6, Python 2.7, Python 3.0, Python 3.1, Python 3.2 Added file: http://bugs.python.org/file15087/lexertest.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7089 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6676] expat parser throws Memory Error when parsing multiple files
Andy Balaam m...@artificialworlds.net added the comment: I am also seeing this with Python 2.5.2 on Ubuntu. -- nosy: +andybalaam ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7089] shlex behaves unexpected if newlines are not whitespace
Jan David Mol jjd...@gmail.com added the comment: Attached is a patch which fixes this for me. It basically does a fall-through using '\n' when encountering a comment. So that may be a bit of a hack (who says '\n' is the only newline char in there, and not '\r'?) but I'll leave the more intricate stuff to you experts. -- keywords: +patch Added file: http://bugs.python.org/file15088/lexer-newline-tokens.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7089 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6676] expat parser throws Memory Error when parsing multiple files
Andy Balaam m...@artificialworlds.net added the comment: Just in case it wasn't obvious - the workaround is to create a new parser (with xml.parsers.expat.ParserCreate()) for every XML file you want to parse. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7090] encoding uncode objects greater than FFFF
New submission from Mahmoud sagh...@med.mui.ac.ir: Odd behaviour with str.encode or codecs.Codec.encode or simailar functions, when dealing with uncode objects above with 2.6 u'\u10380'.encode('utf') '\xe1\x80\xb80' with 3.x '\u10380'.encode('utf') '\xe1\x80\xb80' correct output must be: \xf0\x90\x8e\x80 -- components: Unicode messages: 93780 nosy: msaghaei severity: normal status: open title: encoding uncode objects greater than type: behavior versions: Python 2.6, Python 2.7, Python 3.0, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7090 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7090] encoding uncode objects greater than FFFF
Ezio Melotti ezio.melo...@gmail.com added the comment: If you want to specify codepoints greater than U+ you have to use u'\U': x = u'\u10380' x.encode('utf-8') '\xe1\x80\xb80' x[0] u'\u1038' x[1] u'0' y = u'\U00010380' y.encode('utf-8') '\xf0\x90\x8e\x80' -- nosy: +ezio.melotti resolution: - invalid stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7090 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7089] shlex behaves unexpected if newlines are not whitespace
Changes by Jan David Mol jjd...@gmail.com: -- components: +Library (Lib) ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7089 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6676] expat parser throws Memory Error when parsing multiple files
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment: I'm not familiar with expat, but we can see what is happening more clearly with attached adhok patch. Traceback (most recent call last): File expat-error.py, line 14, in module p.ParseFile(file) xml.parsers.expat.ExpatError: parsing finished: line 2, column 482 It seems ParseFile() doesn't support second call. I'm not sure this is intended behavior or not. -- keywords: +patch nosy: +ocean-city versions: +Python 2.7 Added file: http://bugs.python.org/file15089/pyexpat_addhok.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7082] Patch for get_filename in email.message when content-disposition is missing
Darren Worrall d...@darrenworrall.co.uk added the comment: Indeed, I'm certainly not constructing messages like that, but occasionally have to process them :) RE: the python versions, I'll remember that in future, thanks. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7082 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7086] logging.handlers.SysLogHandler with TCP support
Vinay Sajip vinay_sa...@yahoo.co.uk added the comment: Which syslog daemon are you using? There are some issues pending with syslog-ng and Python logging (see issue6444) and in general syslog over TCP is not necessarily all that reliable, see http://blog.gerhards.net/2008/04/on-unreliability-of-plain-tcp-syslog.html The requested change is not difficult to make, but it will be difficult for me to test because in general end-to-end testing for network APIs is not there in the standard regression test suite, and I don't have a setup where I can test it independently. So I'm sorry to say I will not be able to give this a very high priority at the moment (unless another committer can test this). Just curious (as no one has asked for this before) why you're using TCP, given that it doesn't eliminate message loss and it is slower and has less support than UDP? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7086 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6676] expat parser throws Memory Error when parsing multiple files
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: The patch is good; a test would be appreciated. The difference now is that in case of true low-memory conditions, ExpatError(no memory) is raised instead of MemoryError. This is acceptable IMO. It seems ParseFile() doesn't support second call This is correct; the C expat library has a function XML_ParserReset() which could be called before calling ParseFile() again, but pyexpat does not expose it yet (see issue1208730). -- nosy: +amaury.forgeotdarc ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1208730] expat binding for XML_ParserReset
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: This (old) patch needs some work: - unit tests are neeeded. - it it not enough to return NULL when XML_ParserReset() returns an error; a python exception must be raised. - This function may not be used on a parser created using XML_ExternalEntityParserCreate: if XML_ParserReset() does not check it properly, we should ensure that an exception is properly raised. - How many of the struct elements do I need to reset?: this should be worked out. And I'm not convinced that self-intern should be reset. -- nosy: +amaury.forgeotdarc ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1208730 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3210] subprocess.Popen does not release process handles if process cannot be started
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment: No, this is not duplicate of issue5179. That issue described handle was leaked when exception occurred. But this issue is not *leak*. See following code. import subprocess, os, sys file = open(filename, w) try: proc = subprocess.Popen(nosuchprogram, stdout=file) except OSError: file.close() sys.exc_clear() # here we go os.remove(filename) # now we can delete file! subprocess is implemented using sp_handle_type in PC/_subprocess.c (windows). This object is in exception stack frame(?), so handle lives until another exception occurs or explicitly sys.exc_clear() is called. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3210 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3210] subprocess.Popen does not release process handles if process cannot be started
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment: Probably we can fix this issue by calling Close() of sp_handle_type somewhere in Lib/subprocess.py, but I have no patch now. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3210 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5672] Implement a way to change the python process name
Changes by Martin Marcher mar...@marcher.name: -- nosy: +martin.marcher ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5672 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7091] Distutils build ignores the --compiler command line option
New submission from jmb jeber...@free.fr: I tried building an extension on windows with the following command: python setup.py build --compiler=mingw32 and got an error: Unable to find vcvarsall.bat. The way I understand it, that error shows that it tried to use the MSVC compiler instead of obeying the --compiler=mingw32 command line option. I then tried to give a bogus compiler value and got the same error message (iirc python 2.5 used to say that it didn't know the 'bogus' compiler). Finally, I modified _default_compilers in distutils/ccompiler.py and put 'mingw32' in the 'nt' key. Afterward, my extension compiled and works properly. Python version: 2.6.3 on WinXP 32 bits. -- assignee: tarek components: Distutils messages: 93789 nosy: jmb, tarek severity: normal status: open title: Distutils build ignores the --compiler command line option type: behavior versions: Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7091 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6676] expat parser throws Memory Error when parsing multiple files
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment: Well, I tried to write test like this. 1. Check if xml.parsers.expat.error is raised. 2. Compare *code* attribute of error object with xml.parsers.expat.errors.XML_ERROR_FINISHED But I noticed XML_ERROR_FINISHED is not integer but string. (!) According to http://docs.python.org/library/pyexpat.html#expaterror-objects ExpatError.code Expat’s internal error number for the specific error. This will match one of the constants defined in the errors object from this module. Is this document bug or implementation bug? Personally, I think string 'parsing finished' as error constant might be useless... -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6676] expat parser throws Memory Error when parsing multiple files
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: Looks like an implementation bug to me; far too late to change it, though. In your test, you could use pyexpat.ErrorString(e.code) == pyexpat.errors.XML_ERROR_FINISHED And the docs could mention this trick. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4428] make io.BufferedWriter observe max_buffer_size limits
Antoine Pitrou pit...@free.fr added the comment: max_buffer_size is no longer used, so this issue is obsolete ;) -- resolution: - out of date status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4428 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4555] Smelly exports
Antoine Pitrou pit...@free.fr added the comment: In trunk: _add_one_to_index_C _add_one_to_index_F asdl_int_seq_new asdl_seq_new init_ast init_codecs initerrno initgc initimp initposix initpwd initsignal init_sre init_symtable initthread initxxsubtype initzipimport In py3k: _add_one_to_index_C _add_one_to_index_F asdl_int_seq_new asdl_seq_new -- versions: +Python 3.2 -Python 3.0 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4555 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6676] expat parser throws Memory Error when parsing multiple files
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment: Here is the patch. I'm not confident with my English comment though. -- Added file: http://bugs.python.org/file15090/pyexpat.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6676] expat parser throws Memory Error when parsing multiple files
Changes by Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp: Removed file: http://bugs.python.org/file15089/pyexpat_addhok.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7092] Test suite emits many DeprecationWarnings when -3 is enabled
New submission from Jean-Paul Calderone exar...@divmod.com: If the test suite is run with -3, many deprecation warnings are reported. Quite a few are generated by code in the tests themselves, but many are from constructs in the stdlib which are different or no longer supported in 3.x. Even aside from the fact that many of these warnings being caused by code which I think many people would agree is not ideal, I think it is important for these warnings to be fixed for Python 2.7. Since the 3.x porting guidelines recommend that projects first run their test suite with -3, these warnings are going to be generating extra noise for developers to filter through when they try porting their code to 3.x. They shouldn't need to wade through stdlib warnings to find warnings about their own code. Attached is a log of a complete test run with -3. -- components: Library (Lib) files: test.log messages: 93795 nosy: exarkun severity: normal status: open title: Test suite emits many DeprecationWarnings when -3 is enabled type: behavior versions: Python 2.7 Added file: http://bugs.python.org/file15091/test.log ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7092 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7029] Improve pybench
Kristján Valur Jónsson krist...@ccpgames.com added the comment: Fixed the bug with timer = timer in trunk in revision 75293 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7029 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6280] calendar.timegm() belongs in time module, next to time.gmtime()
Simon Cross hodges...@gmail.com added the comment: The attached patch adds a simple implementation of time.timegm that calls calendar.timegm. It includes a short test to show that time.timegm(time.gmtime(ts)) == ts for various timestamps. I implemented a pure C version by pulling in the various functions needed from datetime, but it was a bit messy and a lot more invasive. Documentation updates are still needed -- I will do those if there is support for the patch. -- keywords: +patch Added file: http://bugs.python.org/file15092/add-timegm-to-time.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6280 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7093] xmlrpclib.ServerProxy() doesn't support unicode uri
New submission from STINNER Victor victor.stin...@haypocalc.com: I backported xmlrpclib from Python trunk to Python 2.5 to get connected socket (HTTP/1.1), which implies to backport also httplib, ssl and socket. It works well. It's *much* faster, eg. 960 ms = 70 ms with HTTPS over a VPN. I just have a little issue: if ServerProxy() URI is an unicode string and an argument is an unicode string (with at least one non-ASCII character), the request fails with: File .../SVN/python-trunk/Lib/httplib.py, line 784, in _send_output msg += message_body UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 320: ordinal not in range(128) Attached patch includes a test. Can uri contains a login and/or pasword? If yes, should it be encoded to UTF-8 (instead of ASCII)? -- components: Library (Lib) files: xmlrpclib_unicode_host.patch keywords: patch messages: 93798 nosy: haypo severity: normal status: open title: xmlrpclib.ServerProxy() doesn't support unicode uri versions: Python 2.6, Python 2.7 Added file: http://bugs.python.org/file15093/xmlrpclib_unicode_host.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7093 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7093] xmlrpclib.ServerProxy() doesn't support unicode uri
STINNER Victor victor.stin...@haypocalc.com added the comment: Hum, it looks that the issue is not on ServerProxy.__host, but on ServerProxy.__handler. That's why my test uses http://host:port/RPC2; instead of http://host:port;. In the second case, the handler is set to the default value: /RPC2 which is str (and not unicode). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7093 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7092] Test suite emits many DeprecationWarnings when -3 is enabled
Benjamin Peterson benja...@python.org added the comment: I don't think it's so important that tests not raises -3 warnings, but that the stdlib doesn't. -- nosy: +benjamin.peterson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7092 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7086] logging.handlers.SysLogHandler with TCP support
Jr Aquino jr.aqu...@citrixonline.com added the comment: Thank you for responding so quickly Vinay. I am using a multitude of syslog daemons, from syslog, syslog-ng, rsyslog, and several different proprietary SIEM/SEM Log archiving appliances. I work in the security sector. (Yes I have read Rainer before, its actually a big reason I am writing the tool that I am working on. Gaps in logs are a real world problem!) Regarding issue 6444, these users are attempting to use SysLogHandler to write to the local system's syslog sockets. A way of piggy backing on the configuration of the local systems logging daemon. What I am actually doing is ignoring the local systems syslog, and sending the syslog packets directly to a remote syslog server. This is to replay syslog data that may have been previously lost due to connectivity outages. My tool can also be used to send the data to an external server for forensic reasons. I believe the answer to your last question also sheds light on your first question! The reason that I am looking to add TCP is because a lot of new data center architectures are heavily utilizing tcp syslog in a chained / centralized environment. I am also seeing a lot of preferential treatment of tcp syslog on logging appliances such as Loglogic. I am sorry to hear that your test environment is lacking the regression suites that you need. I do hope that another commiter can test for us. Syslog is an old technology and I hope that more efforts like mine and Rainer's can help to identify and correct deficiencies in the design. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7086 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6676] expat parser throws Memory Error when parsing multiple files
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: Do you know the new context manager feature of assertRaises? it makes it easier to check for exceptions. I join a new patch that uses it. -- Added file: http://bugs.python.org/file15094/pyexpat-2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6676] expat parser throws Memory Error when parsing multiple files
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment: I knew existence of that new feature, but didn't know how to use it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6676] expat parser throws Memory Error when parsing multiple files
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment: Hmm, looks useful. I think your patch is good. Only one problem is that we cannot use this new feature in python2.6. If we use my patch in that branch, I think there is no problem. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7092] Test suite emits many DeprecationWarnings when -3 is enabled
Brett Cannon br...@python.org added the comment: I agree with Benjamin. We shouldn't release 2.7 w/ any of the standard library itself generating a Py3kWarning, but that should not apply to the test suite. I have made this a release blocker until we can create separate issues for the modules that are emitting the warning. -- nosy: +brett.cannon priority: - release blocker ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7092 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7092] Test suite emits many DeprecationWarnings when -3 is enabled
Antoine Pitrou pit...@free.fr added the comment: FWIW I tried to filter out the test-related warnings using the following command line, but it didn't work (nothing was filtered out): $ ./python -3 -W 'ignore::DeprecationWarning:test:0' -m test.regrtest -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7092 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7094] Add alternate float formatting styles to new-style formatting.
New submission from Mark Dickinson dicki...@gmail.com: Python's old-style formatting supports the use of an alternative form (specified by including a '#' in the format) for 'e', 'f' and 'g' formatting: Python 3.2a0 (py3k:75275:75276, Oct 7 2009, 20:26:36) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type help, copyright, credits or license for more information. '%.17g' % 1.2 '1.2' '%#.17g' % 1.2 '1.2000' New-style formatting doesn't currently support this: format(1.2, '#.17g') Traceback (most recent call last): File stdin, line 1, in module ValueError: Alternate form (#) not allowed in float format specifier To aid migration from old-style to new-style formatting, it might be worth adding the alternate forms. At least the float, complex and Decimal types would be affected. -- components: Interpreter Core messages: 93807 nosy: eric.smith, mark.dickinson severity: normal stage: test needed status: open title: Add alternate float formatting styles to new-style formatting. type: feature request versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7094 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7094] Add alternate float formatting styles to new-style formatting.
Eric Smith e...@trueblade.com added the comment: I'm adding 2.7. Since 2.7 and 3.2 share the same code base, I'd rather add it to both if we're going to do it at all. -- assignee: - eric.smith versions: +Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7094 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7094] Add alternate float formatting styles to new-style formatting.
Mark Dickinson dicki...@gmail.com added the comment: Just for reference, the effect of the alternative style is explained succinctly in the C99 standard (well, the N1256 draft, anyway): For a, A, e, E, f, F, g, and G conversions, the result of converting a floating-point number always contains a decimal-point character, even if no digits follow it. (Normally, a decimal-point character appears in the result of these conversions only if a digit follows it.) For g and G conversions, trailing zeros are not removed from the result. For other conversions, the behavior is undefined. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7094 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7086] logging.handlers.SysLogHandler with TCP support
Vinay Sajip vinay_sa...@yahoo.co.uk added the comment: @Jr Aquino: can you please test the attached alternative patch with all the various syslog daemons in Unix domain, UDP and TCP socket combinations, and post your results here? Thanks. P.S. Also available colourised at http://gist.github.com/206380 -- assignee: - vinay.sajip status: open - pending Added file: http://bugs.python.org/file15095/sockhand.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7086 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7077] SysLogHandler can't handle Unicode
Changes by Vinay Sajip vinay_sa...@yahoo.co.uk: -- assignee: - vinay.sajip ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7077 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7082] Patch for get_filename in email.message when content-disposition is missing
Changes by R. David Murray rdmur...@bitdance.com: -- assignee: - r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7082 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7086] logging.handlers.SysLogHandler with TCP support
Jr Aquino jr.aqu...@citrixonline.com added the comment: Vinay, tested on all syslog daemons/servers. Works perfectly. Thank you very much. I appreciate your time greatly. -- status: pending - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7086 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7095] Multiprocessing.Array(lock=False) fails
New submission from schlesin schle...@cshl.edu: The documentation for the Multiprocessing.Array says: multiprocessing.Array(typecode_or_type, size_or_initializer, *, lock=True)¶ ... If lock is False then access to the returned object will not be automatically protected by a lock, so it will not necessarily be “process-safe”. ... However: In [48]: mp.Array('i',1,lock=False) --- AssertionErrorTraceback (most recent call last) /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ multiprocessing/__init__.pyc in Array(typecode_or_type, size_or_initializer, **kwds) 252 ''' 253 from multiprocessing.sharedctypes import Array -- 254 return Array(typecode_or_type, size_or_initializer, **kwds) 255 256 # /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ multiprocessing/sharedctypes.pyc in Array(typecode_or_type, size_or_initializer, **kwds) 85 if lock is None: 86 lock = RLock() --- 87 assert hasattr(lock, 'acquire') 88 return synchronized(obj, lock) 89 AssertionError: --- I.e. it looks like lock=False is not actually supported. -- components: Extension Modules messages: 93812 nosy: schlesin severity: normal status: open title: Multiprocessing.Array(lock=False) fails type: behavior versions: Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7095 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7095] Multiprocessing.Array(lock=False) fails
Changes by Benjamin Peterson benja...@python.org: -- assignee: - jnoller nosy: +jnoller ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7095 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7095] Multiprocessing.Array(lock=False) fails
Jesse Noller jnol...@gmail.com added the comment: schlesin - what platform are you on, and what version of 2.6? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7095 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7095] Multiprocessing.Array(lock=False) fails
schlesin schle...@cshl.edu added the comment: Happens both on Python 2.6 (r26:66714, Jul 25 2009, 11:30:23) [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2 and Python 2.6.1 (r261:67515, Dec 6 2008, 16:42:21) [GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7095 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7060] test_multiprocessing dictionary changed size errors and hang
R. David Murray rdmur...@bitdance.com added the comment: Benjamin tried reverting the weakref patch, but that didn't fix it. Turns out the problem is the other patch in that merge, that adds saving of the exception to AssertRaises. Adding Kristjan as that was his patch. (The tests pass with the weakref patch applied and the unittest patch reverted, by the way.) -- nosy: +krisvale ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7060 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7082] Patch for get_filename in email.message when content-disposition is missing
R. David Murray rdmur...@bitdance.com added the comment: Applied to trunk in r75301, py3k in r75307, and 3.1 in r75308. Leaving open until I can backport it to 2.6. Thanks, Darren. -- resolution: - fixed stage: commit review - committed/rejected ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7082 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7095] Multiprocessing.Array(lock=False) fails
Gabriel Genellina gagsl-...@yahoo.com.ar added the comment: Fixed in r68708 - upgrading to 2.6.2 should solve this. -- nosy: +gagenellina ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7095 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com