signed vs unsigned int
i'm reading bytes from a serial port, and storing it into an array. each byte represents a signed 8-bit int. currently, the code i'm looking at converts them to an unsigned int by doing ord(array[i]). however, what i'd like is to get the _signed_ integer value. whats the easiest way to do this? thanks in advance. johnty -- http://mail.python.org/mailman/listinfo/python-list
Re: signed vs unsigned int
johnty, 02.06.2010 08:43: i'm reading bytes from a serial port, and storing it into an array. each byte represents a signed 8-bit int. currently, the code i'm looking at converts them to an unsigned int by doing ord(array[i]). however, what i'd like is to get the _signed_ integer value. whats the easiest way to do this? See the struct module, it supports various different C types. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: expat parsing error
On 2 Ιούν, 03:47, John Machin sjmac...@lexicon.net wrote: On Jun 2, 1:57 am, kak...@gmail.com kak...@gmail.com wrote: On Jun 1, 11:12 am, kak...@gmail.com kak...@gmail.com wrote: On Jun 1, 11:09 am, John Bokma j...@castleamber.com wrote: kak...@gmail.com kak...@gmail.com writes: On Jun 1, 10:34 am, Stefan Behnel stefan...@behnel.de wrote: kak...@gmail.com, 01.06.2010 16:00: how can i fix it, how to ignore the headers and parse only the XML? Consider reading the answers you got in the last thread that you opened with exactly this question. Stefan That's exactly, what i did but something seems to not working with the solutions i had, when i changed my implementation from pure Python's sockets to twisted library! That's the reason i have created a new post! Any ideas why this happened? As I already explained: if you send your headers as well to any XML parser it will choke on those, because the headers are /not/ valid / well-formed XML. The solution is to remove the headers from your data. As I explained before: headers are followed by one empty line. Just remove lines up and until including the empty line, and pass the data to any XML parser. -- John Bokma j3b Hacking Hiking in Mexico - http://johnbokma.com/http://castleamber.com/-PerlPython Development Thank you so much i'll try it! Antonis Dear John can you provide me a simple working solution? I don't seem to get it You're not wrong. Trysomething like this: rubbish1, rubbish2, xml = your_guff.partition('\n\n') Ok thanks a lot! Antonis -- http://mail.python.org/mailman/listinfo/python-list
Re: signed vs unsigned int
On Tue, 01 Jun 2010 23:43:33 -0700, johnty wrote: i'm reading bytes from a serial port, and storing it into an array. An array or a list? each byte represents a signed 8-bit int. currently, the code i'm looking at converts them to an unsigned int by doing ord(array[i]). however, what i'd like is to get the _signed_ integer value. whats the easiest way to do this? import array s = 'Some unsigned bytes \xc3\x80\xc3\xa0\xc3\xa6\xc3\x9f\xc2\xb5' array.array('b', s) array('b', [83, 111, 109, 101, 32, 117, 110, 115, 105, 103, 110, 101, 100, 32, 98, 121, 116, 101, 115, 32, -61, -128, -61, -96, -61, -90, -61, -97, -62, -75]) See also the fromstring method of array objects. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: signed vs unsigned int
i'm reading bytes from a serial port, and storing it into an array. each byte represents a signed 8-bit int. currently, the code i'm looking at converts them to an unsigned int by doing ord(array[i]). however, what i'd like is to get the _signed_ integer value. whats the easiest way to do this? http://docs.python.org/library/struct.html -- http://mail.python.org/mailman/listinfo/python-list
Re: signed vs unsigned int
On Jun 2, 12:04 am, Christian Heimes li...@cheimes.de wrote: i'm reading bytes from a serial port, and storing it into an array. each byte represents a signed 8-bit int. currently, the code i'm looking at converts them to an unsigned int by doing ord(array[i]). however, what i'd like is to get the _signed_ integer value. whats the easiest way to do this? http://docs.python.org/library/struct.html the struct docs is exactly what i needed to read. unpacking it as a signed char did the trick. thanks guys! -- http://mail.python.org/mailman/listinfo/python-list
Python Forum
Hello, I would like to let the community know that there is a new web-based forum for Python enthusiasts over at PythonForum.org (http:// pythonforum.org). Web-based forums is a preferred method by Python newcomers to get help in exploring the world of Python and programming overall. The main goal of PythonForum.org is to popularize Python by welcoming all newcomers. Recently the forum got attacked with questions by users just starting out with Python. I hope here will be someone ready to welcome and help newcomers to enter the beautiful world of Python. Thank you, Einars -- http://mail.python.org/mailman/listinfo/python-list
Mixing Decimal and float
Hi, In order to solve some issues due to operations between Decimal and float, we wanted to implement a class that inherits from both float and Decimal. Typically, we wrote: class Float(Decimal, float): ... This can not be achieved because of a TypeError exception (with message multiple bases have instance lay-out conflict). With a class that inherits from Decimal, with overridden __add__, __mul__, , we succeed to solve operations issues. But we also need to do: isinstance(Float('1'), float) == True isinstance(Float('1'), Decimal) == True which is, AFAIK, only possible with Float(Decimal, float). Is there a workaround ? We are developping with python version 2.5 and 2.6. Thanks for your help. B. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Forum
On 2 June 2010 09:04:56 UTC+1, pyDev einars.stra...@gmail.com wrote: I hope here will be someone ready to welcome and help newcomers to enter the beautiful world of Python. Just send them here, or to http://mail.python.org/mailman/listinfo/tutor. We'll be happy to help. -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list
Re: plac, the easiest command line arguments parser in the world
On 02/06/2010 05:37, Michele Simionato wrote: I would like to announce to the world the first public release of plac: http://pypi.python.org/pypi/plac Plac is a wrapper over argparse and works in all versions of Python starting from Python 2.3 up to Python 3.1. I like it. I'm a constant user of the def main (a, b=1, c=2): # ... if __name__ == '__main__': main (*sys.argv[1:]) pattern, which provides a minimally semi-self-documenting approach for positional args, but I've always found the existing offerings just a little too much work to bother with. I'll give plac a run and see how it behaves. Thanks TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Forum
pyDev, 02.06.2010 10:04: I would like to let the community know that there is a new web-based forum for Python enthusiasts over at PythonForum.org (http:// pythonforum.org). Web-based forums is a preferred method by Python newcomers to get help in exploring the world of Python and programming overall. It's not how the English speaking community works, though. There are two main mailing lists (mirrored as/from newsgroups) around which the larger community gathers: python-list (c.l.py) and python-tutor. I doubt (or rather put my hope against it) that a forum will attract a critical mass of Python cracks to make it attractive to newbees, and I would certainly prefer an effort to get them into joining python-tutor instead. There is not much to gain from splitting the community. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: plac, the easiest command line arguments parser in the world
Tim Golden m...@timgolden.me.uk writes: pattern, which provides a minimally semi-self-documenting approach for positional args, but I've always found the existing offerings just a little too much work to bother with. I'll give plac a run and see how it behaves. After using optparse a couple of times I got the hang of it. Maybe its docs could be organized a bit better, but it does the obvious things conveniently once you've figured it out a bit. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Forum
pyDev a écrit : Hello, I would like to let the community know that there is a new web-based forum for Python enthusiasts over at PythonForum.org (http:// pythonforum.org). YetAnotherUselessWebForum :( Web-based forums is a preferred method by Python newcomers to get help Oh yeah ? Chapter and verse, please ? Do the world a favour : replace your whole forum with a static page explaining how to join the official MLs and/or c.l.py. in exploring the world of Python and programming overall. The main goal of PythonForum.org is to popularize Python by welcoming all newcomers. Newcomers have always been welcomed here. And yet another forum *where the helpful experts won't post nor correct wrong posts* is certainly not the best way to popularize Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: Vote to Add Python Package pubsub to the Python Standard Library
Daniel Fetchinson fetchin...@googlemail.com writes: A good example for the first couple of stages of this process is PEP 3143 concerning adding a daemon package to the stdlib: http://www.python.org/dev/peps/pep-3143/ Thanks for the shout-out for PEP 3143. I can certainly say that the process Daniel describes was a very healthy one for the development of the API in that specification. Trimming the fat from the implementation, and delegating concerns outside the specification, was a major benefit of going through that public discussion process. The PEP 3143 reference implementation has a lot of happy users, who are making use of the API to perform the tasks they need. Once I complete the extraction of dependencies, I'll be submitting the resulting code for inclusion in the standard library. I haven't found the beginning of the thread discussing this For the process you outline, the thread where I began soliciting feedback of the “what's the best way to do this?” kind begins at URL:http://mail.python.org/pipermail/python-list/2008-September/560437.html. Some later threads gave me a better idea what was required and what was possible. While making a reference implementation, I drafted a PEP to describe the interface I wanted the standard library to provide. Once I had it in good shape, and had a reference implementation ready, I submitted it and it was registered as PEP 3143. The first PEP 3143 discussion thread starts at URL:http://mail.python.org/pipermail/python-ideas/2009-January/002529.html. Once I had incorporated a lot of the feedback, I fished again with URL:http://mail.python.org/pipermail/python-list/2009-March/1197730.html. It's annoying that many threads get broken because of poor transmission of message references. You'll need to browse manually to get more complete versions of some of the thread. -- http://mail.python.org/mailman/listinfo/python-list
Re: plac, the easiest command line arguments parser in the world
On Jun 2, 10:43 am, Paul Rubin no.em...@nospam.invalid wrote: Tim Golden m...@timgolden.me.uk writes: pattern, which provides a minimally semi-self-documenting approach for positional args, but I've always found the existing offerings just a little too much work to bother with. I'll give plac a run and see how it behaves. After using optparse a couple of times I got the hang of it. Maybe its docs could be organized a bit better, but it does the obvious things conveniently once you've figured it out a bit. Notice that optparse is basically useless in the use case Tim is considering (positional arguments) since it only manages options. -- http://mail.python.org/mailman/listinfo/python-list
Re: plac, the easiest command line arguments parser in the world
Michele Simionato wrote: I would like to announce to the world the first public release of plac: http://pypi.python.org/pypi/plac Plac is a wrapper over argparse and works in all versions of Python starting from Python 2.3 up to Python 3.1. With blatant immodesty, plac claims to be the easiest to use command line arguments parser module in the Python world. Its goal is to reduce the learning curve of argparse from hours to minutes. It does so by removing the need to build a command line arguments parser by hand: actually it is smart enough to infer the parser from function annotations. Here is a simple example (in Python 3) to wet your appetite: $ cat example.py def main(arg: required argument): do something with arg print('Got %s' % arg) if __name__ == '__main__': import plac; plac.call(main) # passes sys.argv[1:] to main $ python example.py -h usage: example.py [-h] arg do something with arg positional arguments: arg required argument optional arguments: -h, --help show this help message and exit $ python example.py usage: example.py [-h] arg example.py: error: too few arguments $ python example.py arg Got arg $ python example.py arg1 arg2 usage: example.py [-h] arg example.py: error: unrecognized arguments: arg2 You can find in the documentation a lot of other simple and not so simple examples: http://micheles.googlecode.com/hg/plac/doc/plac.html Enjoy! Michele Simionato P.S. answering an unspoken question: yes, we really needed yet another command line arguments parser! ;) Thanks for participating. JM -- http://mail.python.org/mailman/listinfo/python-list
Re: Drawing Multigraphs
geremy condra debat...@gmail.com wrote in message news:mailman.825.1275414239.32709.python-l...@python.org... On Tue, Jun 1, 2010 at 9:42 AM, Nima nima@gmail.com wrote: Hi there, Is it possible to draw an (undirected) multigraph using a python library? I need to write a program that finds an Eulerian circuit in a graph (which might obviously be a multigraph). As the output of the program, I should draw the graph and print out the solution. We use Dot in Graphine, and it works well. It's also very easy to output to. NetworkX apparently has dot bindings built-in, although I've not used it, so I think one should just be able to export to it. -- http://mail.python.org/mailman/listinfo/python-list
Re: plac, the easiest command line arguments parser in the world
Paul Rubin, 02.06.2010 10:43: Tim Golden writes: pattern, which provides a minimally semi-self-documenting approach for positional args, but I've always found the existing offerings just a little too much work to bother with. I'll give plac a run and see how it behaves. After using optparse a couple of times I got the hang of it. Maybe its docs could be organized a bit better, but it does the obvious things conveniently once you've figured it out a bit. Same from here. I managed to talk a Java-drilled collegue of mine into writing a Python script for a little command line utility, but he needed a way to organise his argument extraction code when the number of arguments started to grow beyond two. I told him that there were two ways to do it: do it by hand or do it right. He took the right choice and I took him to the optparse docs, copied the first example into his code and we adapted it a little. He just loved the beauty of it. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: plac, the easiest command line arguments parser in the world
On Jun 2, 11:01 am, Stefan Behnel stefan...@behnel.de wrote: I managed to talk a Java-drilled collegue of mine into writing a Python script for a little command line utility, but he needed a way to organise his argument extraction code when the number of arguments started to grow beyond two. I told him that there were two ways to do it: do it by hand or do it right. He took the right choice and I took him to the optparse docs, copied the first example into his code and we adapted it a little. He just loved the beauty of it. Could you show plac to your friend? I would be curious to know what he think. Perhaps he would call out his judgment on optparse ;) -- http://mail.python.org/mailman/listinfo/python-list
Re: Vote to Add Python Package pubsub to the Python Standard Library
I definitvely vote for adding such a package to the stdlib (or at least a symilar publish/subscrive and observer implementation). It's useful in a wide range of programs. 2010/6/2 Carl Banks pavlovevide...@gmail.com On May 26, 4:26 am, Tom tom.brow...@gmail.com wrote: I vote for adding the Python package pubsub to the Python standard library. It has recently been added to wxpython (replacing the old wx.lib.pubsub package), but it has application to non-gui programs as well. Well, I can definitely see a case for adding something like this to the standard library. If there is a standard publish-subscribe implementation, then different third-party packages can use it in a consistent way together. It can open whole paradigms of package integration. However, I'm not sure this particular library is the one to use, and I would not be in favor of throwing the first publish-subscribe implentation that comes by into the standard library, at least not without a whole lot of vetting first. (They did that with optparse and the Python community has been paying for it ever since.) I think it has a pretty good chance of being accepted, too. The publish-subscribe pattern, if you will, seems to have been implemented separately in many places. The logging module in the standard library uses something like this. Qt's signal/slot mechanism is another variation. I'm sure there's lots more. I've noticed that pointing out lots of independetnly crafted examples in the wild, and especially in the standard library, works quite well. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Forum
On Wed, 2010-06-02 at 10:44 +0200, Bruno Desthuilliers wrote: pyDev a écrit : Hello, I would like to let the community know that there is a new web-based forum for Python enthusiasts over at PythonForum.org (http:// pythonforum.org). YetAnotherUselessWebForum :( +1 Yuck; no better way to make new users hate your product than have a web forum - where they post questions and never get answers... because the people with the answers are over on the much-easier-to-use mailist [what an awesome feature: the questions just show up in my INBOX! Sweet.]. Web-based forums is a preferred method by Python newcomers to get help Oh yeah ? Chapter and verse, please Do the world a favour : replace your whole forum with a static page explaining how to join the official MLs and/or c.l.py. in exploring the world of Python and programming overall. The main goal of PythonForum.org is to popularize Python by welcoming all newcomers. Newcomers have always been welcomed here. And yet another forum *where the helpful experts won't post nor correct wrong posts* is certainly not the best way to popularize Python. +1 -- Adam Tauno Williams awill...@whitemice.org LPIC-1, Novell CLA http://www.whitemiceconsulting.com OpenGroupware, Cyrus IMAPd, Postfix, OpenLDAP, Samba -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixing Decimal and float
On Jun 2, 9:24 am, B.V. bv.try...@gmail.com wrote: Hi, In order to solve some issues due to operations between Decimal and float, we wanted to implement a class that inherits from both float and Decimal. Typically, we wrote: class Float(Decimal, float): Can you explain exactly what issues you want to solve, and how you want your Float class to behave? Do I understand correctly that you want your Float class to be able to represent both floats and Decimals? But we also need to do: isinstance(Float('1'), float) == True isinstance(Float('1'), Decimal) == True Can you explain why you need this? Should isinstance(Float('1.1'), float) and isinstance(Float('1.1'), Decimal) also both be true, or would only one of those be true? (And by the way, what value would Float('1.1') have? float('1.1') and Decimal('1.1') are different values.) I don't think your approach can succeed; I'd suggest just subclassing 'object' and abandoning the 'isinstance' requirements. Or perhaps creating a subclass of Decimal that interacts nicely with floats. You might also want to investigate the numbers ABC, though that's new in Python 2.6. -- Mark -- http://mail.python.org/mailman/listinfo/python-list
optional optional args vs optional positional options
On Wed, 2 Jun 2010 01:49:18 -0700 (PDT) Michele Simionato michele.simion...@gmail.com wrote: Notice that optparse is basically useless in the use case Tim is considering (positional arguments) since it only manages options. By the way, could you stop naming these optional arguments, since positional arguments can be optional as well? It is confusing :) Thanks Antoine. -- http://mail.python.org/mailman/listinfo/python-list
Re: optional optional args vs optional positional options
On 02/06/2010 11:42, Antoine Pitrou wrote: On Wed, 2 Jun 2010 01:49:18 -0700 (PDT) Michele Simionatomichele.simion...@gmail.com wrote: Notice that optparse is basically useless in the use case Tim is considering (positional arguments) since it only manages options. By the way, could you stop naming these optional arguments, since positional arguments can be optional as well? It is confusing :) The great thing with English is that you can use nouns as adjectives without changing them, so you can say option arguments and position arguments quite happily here :) But then you run into the fact that you're having semantic arguments about argument semantics :( TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: signed vs unsigned int
On Jun 2, 4:43 pm, johnty johntyw...@gmail.com wrote: i'm reading bytes from a serial port, and storing it into an array. each byte represents a signed 8-bit int. currently, the code i'm looking at converts them to an unsigned int by doing ord(array[i]). however, what i'd like is to get the _signed_ integer value. whats the easiest way to do this? signed = unsigned if unsigned = 127 else unsigned - 256 -- http://mail.python.org/mailman/listinfo/python-list
Opinion On Best Way...
Hi; I have a script in which I currently pass a number of variables to another script through the url in a meta http-equiv tag. This seems both awkward and hackable. I think it would be best to create a temporary mysql table, insert them there, and pull them from the following script. The situation is where a purchaser places an item in my shopping cart. A script is called that simply pushes the data to the cart script. The reason for this step is to ensure that when the cart script calls itself (in the form tag) through an update to either update or delete items, the last cached items aren't re-added to the shopping cart. What are your thoughts on the best way to preserve the data from script to script? TIA. beno -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixing Decimal and float
On Jun 2, 12:22 pm, Mark Dickinson dicki...@gmail.com wrote: On Jun 2, 9:24 am, B.V. bv.try...@gmail.com wrote: Hi, In order to solve some issues due to operations between Decimal and float, we wanted to implement a class that inherits from both float and Decimal. Typically, we wrote: class Float(Decimal, float): Can you explain exactly what issues you want to solve, and how you want your Float class to behave? Do I understand correctly that you want your Float class to be able to represent both floats and Decimals? Let me give you the whole story. We work on Tryton, an client/server application framework written in Python (http://www.tryton.org). The framework defines several types of fields within its own ORM (http://doc.tryton.org/1.6/trytond/doc/ref/models/fields.html#ref- models-fields); among those types, there's a fields.Float type -- not to be confused with the class Float we are talking about -- (with underlying python type float) and fields.Numeric (with underlying python type Decimal). fields.Numeric(Decimal) where implemented at the beginning of the fork (Tryton is a fork of OpenERP, formerly known as TinyERP), because the use of floats in OpenERP leads many problems in module handling financial data. The client is written in pygtk. The client connects the server through a specific (but simple) protocol called pysocket (roughly pickled data over sockets). In an application, you may define objects with both Numeric or Float attributes, and when you need to make them interact, you have to cast. And everything is fine. But trying to be open to other languages, the server implements also an XMLRPC interface (and also a JSONRPC-like interface). That's the key point: Decimal is python specific. So in an application, you can't rely on the value received from a client, because depending on the protocol, the type of the value is different. So the idea was to create a class that can behave like a Decimal or a float depending on the context, and set xmlrpclib.Unmarshaller.dispatch[double] to a function that return a Float instance. A contributor filed an issue on the bug tracker (https:// bugs.tryton.org/roundup/issue1575) and because he's a nice guy (ok it's a friend of mine), he made a patch proposal (http:// codereview.appspot.com/1387041). The end of the story is in the comments of the proposal. But we also need to do: isinstance(Float('1'), float) == True isinstance(Float('1'), Decimal) == True Can you explain why you need this? It's a requirement of the project leader. Should isinstance(Float('1.1'), float) and isinstance(Float('1.1'), Decimal) also both be true, or would only one of those be true? (And by the way, what value would Float('1.1') have? float('1.1') and Decimal('1.1') are different values.) I think they both should be True, for '1', '1.1', '0', '0.1', ... For the value, I would say that it depends of the definition of the field (fields.Float or fields.Numeric). I don't think your approach can succeed; I'd suggest just subclassing 'object' and abandoning the 'isinstance' requirements. Or perhaps creating a subclass of Decimal that interacts nicely with floats. You might also want to investigate the numbers ABC, though that's new in Python 2.6. First, Float implementation was a subclass of Decimal that works with floats, and solves many (maybe all) problems. But as you may read in the comments of the patch proposal, it seems to be not enough. B. -- http://mail.python.org/mailman/listinfo/python-list
functools.wraps and help()
Hi! When I use help() on a function, it displays the arguments of the function, along with the docstring. However, when wrapping the function using functools.wraps it only displays the arguments that the (internal) wrapper function takes, which is typically *args, **kwargs, which isn't very useful. Any suggestions how to fix that? Is that even a bug or a systematic limitation? In case of the latter, should the documentation for functools.wraps mention it? Cheers! Uli -- Sator Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 -- http://mail.python.org/mailman/listinfo/python-list
Re: functools.wraps and help()
On Jun 2, 2:20 pm, Ulrich Eckhardt eckha...@satorlaser.com wrote: Hi! When I use help() on a function, it displays the arguments of the function, along with the docstring. However, when wrapping the function using functools.wraps it only displays the arguments that the (internal) wrapper function takes, which is typically *args, **kwargs, which isn't very useful. Any suggestions how to fix that? Is that even a bug or a systematic limitation? In case of the latter, should the documentation for functools.wraps mention it? See http://pypi.python.org/pypi/decorator -- http://mail.python.org/mailman/listinfo/python-list
Re: optional optional args vs optional positional options
+1 Options are options, arguments are arguments. An optional argument is not an option. It is an argument that can be left out. On Wed, 2010-06-02 at 12:42 +0200, Antoine Pitrou wrote: On Wed, 2 Jun 2010 01:49:18 -0700 (PDT) Michele Simionato michele.simion...@gmail.com wrote: Notice that optparse is basically useless in the use case Tim is considering (positional arguments) since it only manages options. By the way, could you stop naming these optional arguments, since positional arguments can be optional as well? It is confusing :) Thanks Antoine. -- http://mail.python.org/mailman/listinfo/python-list
Re: plac, the easiest command line arguments parser in the world
On Jun 2, 6:37 am, Michele Simionato michele.simion...@gmail.com wrote: With blatant immodesty, plac claims to be the easiest to use command line arguments parser module in the Python world It seems I have to take that claim back. A few hours after the announce I was pointed out to http://pypi.python.org/pypi/CLIArgs which, I must concede, is even easier to use than plac. It seems everybody has written its own command line arguments parser! -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixing Decimal and float
On 6/2/2010 8:17 AM, B.V. wrote: A contributor filed an issue on the bug tracker (https:// bugs.tryton.org/roundup/issue1575) and because he's a nice guy (ok it's a friend of mine), he made a patch proposal (http:// codereview.appspot.com/1387041). The end of the story is in the comments of the proposal. I have no idea how to do what you want. But for future reference, links put in running email/newsgroup text as above are not very usable for most readers. They are best put on a line *by themselves*. Then they can be clicked on in at least some mail/newsgroup readers, or at worst, copied and pasted to a browser. Reformatted to be more usable: A contributor filed an issue on the bug tracker https://bugs.tryton.org/roundup/issue1575 and because he's a nice guy (ok it's a friend of mine), he made a patch proposal http://codereview.appspot.com/1387041 The end of the story is in the comments of the proposal. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: python and filter design: calculating s optimal transform
On Jun 1, 2:58 pm, Terry Reedy tjre...@udel.edu wrote: On 6/1/2010 2:18 PM, robert somerville wrote: Hi; this is an airy question. does anybody have some code or ideas on how to calculate the optimal S transform of user specified order (wanting the coefficients) for a published filter response curve, ie. f(s) = 1.0/(a1*S^2 + a2*S + a3) If you do not get an answer here, try the scipy list. Say what There are tables of coefficients for Butterworth, Bessel, and other standard filter forms. Could you be a little clearer on what you're trying to do? -- http://mail.python.org/mailman/listinfo/python-list
Properly posting links (was Re: Python Forum)
On 6/2/2010 4:04 AM, pyDev wrote: forum for Python enthusiasts over at PythonForum.org (http:// pythonforum.org). Web-based forums is a preferred method by Python This is the second time today I have read a post with a useless link wrapped over two lines. Email lists and newsgroups (this is both) are text, not html based. Put a link on one line by itself, with no punctuation. The above, if posted at all, should have been forum for Python enthusiasts over at PythonForum.org. http://pythonforum.org Web-based forums is a preferred method by Python -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixing Decimal and float
On 2 juin, 17:08, Terry Reedy tjre...@udel.edu wrote: On 6/2/2010 8:17 AM, B.V. wrote: A contributor filed an issue on the bug tracker (https:// bugs.tryton.org/roundup/issue1575) and because he's a nice guy (ok it's a friend of mine), he made a patch proposal (http:// codereview.appspot.com/1387041). The end of the story is in the comments of the proposal. I have no idea how to do what you want. But for future reference, links put in running email/newsgroup text as above are not very usable for most readers. They are best put on a line *by themselves*. Then they can be clicked on in at least some mail/newsgroup readers, or at worst, copied and pasted to a browser. Reformatted to be more usable: A contributor filed an issue on the bug trackerhttps://bugs.tryton.org/roundup/issue1575 and because he's a nice guy (ok it's a friend of mine), he made a patch proposalhttp://codereview.appspot.com/1387041 The end of the story is in the comments of the proposal. Terry Jan Reedy Thank you for your remarks, my next posts will in accordance. B. -- http://mail.python.org/mailman/listinfo/python-list
decorating a memberfunction
Hi! I have a class that maintains a network connection, which can be used to query and trigger Things(tm). Apart from normal errors, a broken network connection and a protocol violation from the peer are something we can't recover from without creating a new connection, so those errors should stick. The code looks roughly like this: class Client(object): def __init__(self, ...): self._error = None def _check(fn): def do_check(self, *args, **kwargs): # check for sticky error if self._error: raise self._error try: fn(self, *args, **kwargs) except NetworkError, e: self._error = e raise except ProtocolError, e: self._error = e raise return do_check @_check def frobnicate(self, foo): # format and send request, read and parse answer So, any function like frobnicate() that does things is decorated with _check() so that unrecoverable errors stick. I hope I didn't shorten the code too much to understand the principle, in particular I'm using functools.wraps() in order to retain function names and docstrings. Is this sound? Would you have done it differently? Any other suggestions? What I'm mostly unsure about is whether the definition of _check() and do_check() are correct or could be improved. Thanks! Uli -- Sator Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 -- http://mail.python.org/mailman/listinfo/python-list
Re: decorating a memberfunction
Ulrich Eckhardt wrote: Hi! I have a class that maintains a network connection, which can be used to query and trigger Things(tm). Apart from normal errors, a broken network connection and a protocol violation from the peer are something we can't recover from without creating a new connection, so those errors should stick. The code looks roughly like this: class Client(object): def __init__(self, ...): self._error = None def _check(fn): def do_check(self, *args, **kwargs): # check for sticky error if self._error: raise self._error try: fn(self, *args, **kwargs) except NetworkError, e: self._error = e raise except ProtocolError, e: self._error = e raise return do_check @_check def frobnicate(self, foo): # format and send request, read and parse answer So, any function like frobnicate() that does things is decorated with _check() so that unrecoverable errors stick. I hope I didn't shorten the code too much to understand the principle, in particular I'm using functools.wraps() in order to retain function names and docstrings. Is this sound? Would you have done it differently? Any other suggestions? What I'm mostly unsure about is whether the definition of _check() and do_check() are correct or could be improved. You could merge the two excepts: try: fn(self, *args, **kwargs) except (NetworkError, ProtocolError), e: self._error = e raise You could also choose a better name for the decorator, eg _check_sticky_error. :-) -- http://mail.python.org/mailman/listinfo/python-list
Simple hack to get $500 to your home.
Simple hack to get $500 to your home at http://dailyupdatesonly.tk Due to high security risks,i have hidden the cheque link in an image. in that website on left side below search box, click on image and enter your name and address where you want to receive your cheque.please dont tell to anyone. -- http://mail.python.org/mailman/listinfo/python-list
Syntax question
Dear Group, It's really rookie question, but I'm currently helping my wife in some python-cases, where I'm non-python developer and some of syntax-diffs make me a bit confused. Could anyone give some light on line, as following: ds = d[:] ### where 'd' is an array Let me guess, is it a declaration of two-dimension array? Thanks a lot for help and all the best, Przemek M. Zawada -- http://mail.python.org/mailman/listinfo/python-list
Re: Syntax question
On Wed, Jun 2, 2010 at 10:40 AM, pmz przemek.zaw...@gmail.com wrote: Dear Group, It's really rookie question, but I'm currently helping my wife in some python-cases, where I'm non-python developer and some of syntax-diffs make me a bit confused. Could anyone give some light on line, as following: ds = d[:] ### where 'd' is an array Let me guess, is it a declaration of two-dimension array? Nope; Python doesn't really have variable declarations.* That line of code copies the list `d` ( `[]` is the slicing operator, and the colon indicates the bounds are the entire list; this is a Python idiom) and assigns the copy to the variable `ds`. Note that the copying is shallow (i.e. not recursive, only 1 level deep). *Well, almost: There are `global` and `nonlocal`, but they're only needed to specify a variable's scope in certain circumstances when you want to be able to assign to said variable. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Syntax question
On Wed, Jun 2, 2010 at 10:40 AM, pmz przemek.zaw...@gmail.com wrote: Dear Group, It's really rookie question, but I'm currently helping my wife in some python-cases, where I'm non-python developer and some of syntax-diffs make me a bit confused. Could anyone give some light on line, as following: ds = d[:] ### where 'd' is an array I'm guessing you mean that d is a list. The square braces with the colon is python's slicing notation, so if I say [1,2,3,4][0] I get a 1 back, and if I say [1,2,3,4][1:4] I get [2,3,4]. Python also allows a shorthand in slicing, which is that if the first index is not provided, then it assumes 0, and that if the second index is not provided, it assumes the end of the list. Thus, [1,2,3,4][:2] would give me [1,2] and [1,2,3,4][2:] would give me [3, 4]. Here, neither has been provided, so the slice simply takes the items in the list from beginning to end and returns them- [1,2,3,4][:] gives [1,2,3,4]. The reason someone would want to do this is because lists are mutable data structures. If you fire up your terminal you can try the following example: a = [1,2,3,4] b = a c = [:] b[0] = 5 b [5,2,3,4] # here's the issue a [5,2,3,4] # and the resolution c [1,2,3,4] Hope this helps. Geremy Condra -- http://mail.python.org/mailman/listinfo/python-list
Re: Syntax question
On 2 Cze, 19:56, geremy condra debat...@gmail.com wrote: On Wed, Jun 2, 2010 at 10:40 AM, pmz przemek.zaw...@gmail.com wrote: Dear Group, It's really rookie question, but I'm currently helping my wife in some python-cases, where I'm non-python developer and some of syntax-diffs make me a bit confused. Could anyone give some light on line, as following: ds = d[:] ### where 'd' is an array I'm guessing you mean that d is a list. The square braces with the colon is python's slicing notation, so if I say [1,2,3,4][0] I get a 1 back, and if I say [1,2,3,4][1:4] I get [2,3,4]. Python also allows a shorthand in slicing, which is that if the first index is not provided, then it assumes 0, and that if the second index is not provided, it assumes the end of the list. Thus, [1,2,3,4][:2] would give me [1,2] and [1,2,3,4][2:] would give me [3, 4]. Here, neither has been provided, so the slice simply takes the items in the list from beginning to end and returns them- [1,2,3,4][:] gives [1,2,3,4]. The reason someone would want to do this is because lists are mutable data structures. If you fire up your terminal you can try the following example: a = [1,2,3,4] b = a c = [:] b[0] = 5 b [5,2,3,4] # here's the issue a [5,2,3,4] # and the resolution c [1,2,3,4] Hope this helps. Geremy Condra Thank you for such fast answer! I quite catch, but: As I see, the d[:] is equal to sentence get the d array from the first to the last element? :) P. -- http://mail.python.org/mailman/listinfo/python-list
Re: Syntax question
Anyway I suggest you to use a syntax like: b = list(a) in order to copy a list, it should be better than slicing. On Wed, Jun 2, 2010 at 7:56 PM, geremy condra debat...@gmail.com wrote: On Wed, Jun 2, 2010 at 10:40 AM, pmz przemek.zaw...@gmail.com wrote: Dear Group, It's really rookie question, but I'm currently helping my wife in some python-cases, where I'm non-python developer and some of syntax-diffs make me a bit confused. Could anyone give some light on line, as following: ds = d[:] ### where 'd' is an array I'm guessing you mean that d is a list. The square braces with the colon is python's slicing notation, so if I say [1,2,3,4][0] I get a 1 back, and if I say [1,2,3,4][1:4] I get [2,3,4]. Python also allows a shorthand in slicing, which is that if the first index is not provided, then it assumes 0, and that if the second index is not provided, it assumes the end of the list. Thus, [1,2,3,4][:2] would give me [1,2] and [1,2,3,4][2:] would give me [3, 4]. Here, neither has been provided, so the slice simply takes the items in the list from beginning to end and returns them- [1,2,3,4][:] gives [1,2,3,4]. The reason someone would want to do this is because lists are mutable data structures. If you fire up your terminal you can try the following example: a = [1,2,3,4] b = a c = [:] b[0] = 5 b [5,2,3,4] # here's the issue a [5,2,3,4] # and the resolution c [1,2,3,4] Hope this helps. Geremy Condra -- http://mail.python.org/mailman/listinfo/python-list -- Matteo Landi http://www.matteolandi.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Syntax question
Yes it is; d[i:j] is equal to give me the array from the d[i] to d[j - 1], and if you omit i and j then the i and j are respectively assumed as 0 and len(d) - 1. On Wed, Jun 2, 2010 at 8:01 PM, pmz przemek.zaw...@gmail.com wrote: On 2 Cze, 19:56, geremy condra debat...@gmail.com wrote: On Wed, Jun 2, 2010 at 10:40 AM, pmz przemek.zaw...@gmail.com wrote: Dear Group, It's really rookie question, but I'm currently helping my wife in some python-cases, where I'm non-python developer and some of syntax-diffs make me a bit confused. Could anyone give some light on line, as following: ds = d[:] ### where 'd' is an array I'm guessing you mean that d is a list. The square braces with the colon is python's slicing notation, so if I say [1,2,3,4][0] I get a 1 back, and if I say [1,2,3,4][1:4] I get [2,3,4]. Python also allows a shorthand in slicing, which is that if the first index is not provided, then it assumes 0, and that if the second index is not provided, it assumes the end of the list. Thus, [1,2,3,4][:2] would give me [1,2] and [1,2,3,4][2:] would give me [3, 4]. Here, neither has been provided, so the slice simply takes the items in the list from beginning to end and returns them- [1,2,3,4][:] gives [1,2,3,4]. The reason someone would want to do this is because lists are mutable data structures. If you fire up your terminal you can try the following example: a = [1,2,3,4] b = a c = [:] b[0] = 5 b [5,2,3,4] # here's the issue a [5,2,3,4] # and the resolution c [1,2,3,4] Hope this helps. Geremy Condra Thank you for such fast answer! I quite catch, but: As I see, the d[:] is equal to sentence get the d array from the first to the last element? :) P. -- http://mail.python.org/mailman/listinfo/python-list -- Matteo Landi http://www.matteolandi.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Syntax question
On 2 Cze, 20:07, Matteo Landi landima...@gmail.com wrote: Anyway I suggest you to use a syntax like: b = list(a) in order to copy a list, it should be better than slicing. On Wed, Jun 2, 2010 at 7:56 PM, geremy condra debat...@gmail.com wrote: On Wed, Jun 2, 2010 at 10:40 AM, pmz przemek.zaw...@gmail.com wrote: Dear Group, It's really rookie question, but I'm currently helping my wife in some python-cases, where I'm non-python developer and some of syntax-diffs make me a bit confused. Could anyone give some light on line, as following: ds = d[:] ### where 'd' is an array I'm guessing you mean that d is a list. The square braces with the colon is python's slicing notation, so if I say [1,2,3,4][0] I get a 1 back, and if I say [1,2,3,4][1:4] I get [2,3,4]. Python also allows a shorthand in slicing, which is that if the first index is not provided, then it assumes 0, and that if the second index is not provided, it assumes the end of the list. Thus, [1,2,3,4][:2] would give me [1,2] and [1,2,3,4][2:] would give me [3, 4]. Here, neither has been provided, so the slice simply takes the items in the list from beginning to end and returns them- [1,2,3,4][:] gives [1,2,3,4]. The reason someone would want to do this is because lists are mutable data structures. If you fire up your terminal you can try the following example: a = [1,2,3,4] b = a c = [:] b[0] = 5 b [5,2,3,4] # here's the issue a [5,2,3,4] # and the resolution c [1,2,3,4] Hope this helps. Geremy Condra -- http://mail.python.org/mailman/listinfo/python-list -- Matteo Landihttp://www.matteolandi.net/ In fact, that ain't my syntax, I'd rather use C++ for that project, because that's my world is not Python, but thank you anyway for help - I see that Python also has many fans and friends online :) I'll try help her using your explanations. THANK you again and all the best, Przemek M. Zawada -- http://mail.python.org/mailman/listinfo/python-list
See and Enjoy Indian Girls Gallery.
http://www.teluguscope.com/allfiles/galleryfiles/actressfiles/kajole/1.html http://www.teluguscope.com/allfiles/galleryfiles/actressfiles/aishwaryarai/33.html http://www.teluguscope.com/allfiles/galleryfiles/actressfiles/mallikasherawat/2.html http://www.teluguscope.com/allfiles/galleryfiles/actressindexfiles/katrinakaifindex.html http://www.teluguscope.com/allfiles/galleryfiles/actressindexfiles/ilianaindex.html http://www.teluguscope.com/allfiles/galleryfiles/actressindexfiles/kajoleindex.html http://www.teluguscope.com/allfiles/galleryfiles/actressindexfiles/deepikapadukoneindex.html -- http://mail.python.org/mailman/listinfo/python-list
Re: multiprocessing and accessing server's stdout
Tim Arnold wrote: Hi, This is the setup I was asking about. I've got users using a python-written command line client. They're requesting services from a remote server that fires a LaTeX process. I want them to see the stdout from the LaTeX process. So what you really need is to capture the output of a command, in this case LaTeX, so you can copy it back to the client. You can do that with the subprocess module in the Python standard library. If the command generated so much output so fast that you felt the need to avoid the extra copy, I suppose you could fork() then hook stdout directly to socket connected to the client with dup2(), then exec() the command. But no need for that just to capture LaTeX's output. -- --Bryan Olson -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQLDB - server has gone on blob insertion...
On Tuesday 01 June 2010 12:46:40 John Nagle wrote: durumdara wrote: When I tried to start this, I got error: _mysql_exceptions.OperationalError: (2006, 'MySQL server has gone away') Are you by any chance trying to do this on a HostGator account? HostGator servers run a program which kills long MySQL transactions by executing MySQL KILL transactions. This is reported to the user as 'MySQL server has gone away' I don't think HostGator is alone in this -- AFAIK several web hosts (including mine) do it too. Rami Chowdhury As an online discussion grows longer, the probability of a comparison involving Nazis or Hitler approaches one. -- Godwin's Law 408-597-7068 (US) / 07875-841-046 (UK) / 01819-245544 (BD) -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixing Decimal and float
On Wed, 02 Jun 2010 05:17:11 -0700, B.V. wrote: But trying to be open to other languages, the server implements also an XMLRPC interface (and also a JSONRPC-like interface). That's the key point: Decimal is python specific. So in an application, you can't rely on the value received from a client, because depending on the protocol, the type of the value is different. So the idea was to create a class that can behave like a Decimal or a float depending on the context, and set xmlrpclib.Unmarshaller.dispatch[double] to a function that return a Float instance. Looking at the Tryton docs, it seems that it already supports field types that can't be directly represented in XMLRPC or JSON, like BigInteger or Selection. How are these serialized over the non-python RPC mechanisms? Could you not do the same for Decimals? A contributor filed an issue on the bug tracker (https:// bugs.tryton.org/roundup/issue1575) and because he's a nice guy (ok it's a friend of mine), he made a patch proposal (http:// codereview.appspot.com/1387041). The end of the story is in the comments of the proposal. But we also need to do: isinstance(Float('1'), float) == True isinstance(Float('1'), Decimal) == True Can you explain why you need this? It's a requirement of the project leader. Should isinstance(Float('1.1'), float) and isinstance(Float('1.1'), Decimal) also both be true, or would only one of those be true? (And by the way, what value would Float('1.1') have? float('1.1') and Decimal('1.1') are different values.) I think they both should be True, for '1', '1.1', '0', '0.1', ... For the value, I would say that it depends of the definition of the field (fields.Float or fields.Numeric). I don't think your approach can succeed; I'd suggest just subclassing 'object' and abandoning the 'isinstance' requirements. Or perhaps creating a subclass of Decimal that interacts nicely with floats. You might also want to investigate the numbers ABC, though that's new in Python 2.6. First, Float implementation was a subclass of Decimal that works with floats, and solves many (maybe all) problems. But as you may read in the comments of the patch proposal, it seems to be not enough. B. -- http://mail.python.org/mailman/listinfo/python-list
Embedding Python in a C extension
I have a problem with embedding Python into a C extension in Windows Vista. I have implemented a timer routine in C as an extension, which I can import into Python 2.6.5 and run. Each timer interval, the extension calls a C CALLBACK function. I want to be able to have this CALLBACK function call a Python function, so that I can write the timer handler in Python. I can write Python functions and call them from a C extension function with no trouble in all cases EXCEPT when the function that calls the Python code is the timer's CALLBACK function. That is, if I call PyRun_SimpleString or PyRun_SimpleFile, or PyImport_ImportModule, or basically any Python-y function in the CALLBACK function, Python crashes and I get a window saying Python has stopped working. Windows is searching for a solution to the problem. The Python code runs fine if I call it from a function in the extension that is not the CALLBACK function. And regular C code runs in the CALLBACK function properly. It only crashes if I try to run the Python code from the timer CALLBACK function (or any C function I call from the CALLBACK function). Does anybody know how to fix this? Is there a workaround of some sort? -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixing Decimal and float
My apologies if someone already mentioned this and I missed it but... class.__instancecheck__(self, instance) - Return true if instance should be considered a (direct or indirect) instance of class. If defined, called to implement isinstance(instance, class). class.__subclasscheck__(self, subclass) - Return true if subclass should be considered a (direct or indirect) subclass of class. If defined, called to implement issubclass(subclass, class). Nathan On Wed, Jun 2, 2010 at 4:24 AM, B.V. bv.try...@gmail.com wrote: Hi, In order to solve some issues due to operations between Decimal and float, we wanted to implement a class that inherits from both float and Decimal. Typically, we wrote: class Float(Decimal, float): ... This can not be achieved because of a TypeError exception (with message multiple bases have instance lay-out conflict). With a class that inherits from Decimal, with overridden __add__, __mul__, , we succeed to solve operations issues. But we also need to do: isinstance(Float('1'), float) == True isinstance(Float('1'), Decimal) == True which is, AFAIK, only possible with Float(Decimal, float). Is there a workaround ? We are developping with python version 2.5 and 2.6. Thanks for your help. B. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Converting a pickle to python3
Em 02-06-2010 04:48, Paulo da Silva escreveu: Hi! I have a big data structure cpickled into a datafile, by python2. I tried to unpickle it using python3 but got the followin message: File /usr/lib64/python3.1/pickle.py, line 1372, in loads encoding=encoding, errors=errors).load() _pickle.UnpicklingError: invalid load key, 'x'. ... Please ignore this question. The problem is not the pickle thing but a compress function I have that has problems related with the new str/bytes stuff. Sorry. -- http://mail.python.org/mailman/listinfo/python-list
Re: multiprocessing and accessing server's stdout
I wrote: So what you really need is to capture the output of a command, in this case LaTeX, so you can copy it back to the client. You can do that with the subprocess module in the Python standard library. If the command generated so much output so fast that you felt the need to avoid the extra copy, I suppose you could fork() then hook stdout directly to socket connected to the client with dup2(), then exec() the command. But no need for that just to capture LaTeX's output. Upon further reading, I see that the subprocess module makes the direct-hookup method easy, at least on 'nix systems. Just tell subprocess.Popen to use the client-connected socket as the subprocess's stdout. The question here turns out to make more sense than I had though upon reading the first post. The server runs a command at the client's request, and we want to deliver the output of that command back to the client. A brilliantly efficient method is to direct the command's stdout to the client's connection. Below is a demo server that sends the host's words file to any client that connects. It assumes Unix. --Bryan Olson #!/usr/bin/python from thread import start_new_thread from subprocess import Popen def demo(sock): subp = Popen(['cat', '/usr/share/dict/words'], stdout=sock) subp.wait() sock.close() if __name__ == '__main__': listener_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) listener_sock.bind(('', 54321)) listener_sock.listen(5) while True: sock, remote_address = listener_sock.accept() start_new_thread(demo, (sock,)) -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixing Decimal and float
On Wed, 02 Jun 2010 17:17:11 -0400, Nathan Rice wrote: My apologies if someone already mentioned this and I missed it but... class.__instancecheck__(self, instance) - Return true if instance should be considered a (direct or indirect) instance of class. If defined, called to implement isinstance(instance, class). class.__subclasscheck__(self, subclass) - Return true if subclass should be considered a (direct or indirect) subclass of class. If defined, called to implement issubclass(subclass, class). The original poster needs to support Python 2.5 and 2.6, but __instancecheck__ and __subclasscheck__ are only supported in 2.6 or higher, so this doesn't help. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Properly posting links
Terry Reedy tjre...@udel.edu writes: On 6/2/2010 4:04 AM, pyDev wrote: forum for Python enthusiasts over at PythonForum.org (http:// pythonforum.org). Web-based forums is a preferred method by Python This is the second time today I have read a post with a useless link wrapped over two lines. Email lists and newsgroups (this is both) are text, not html based. Put a link on one line by itself, with no punctuation. Or better, follow appendix “E. Recommendations for Delimiting URI in Context” of RFC 2396 URL:http://www.ietf.org/rfc/rfc2396.txt. This allows the text to flow more naturally than breaking every URL onto a separate line, while still delimiting URLs within the text in a standard manner that most text processing tools will recognise. -- \ “We can't depend for the long run on distinguishing one | `\ bitstream from another in order to figure out which rules | _o__) apply.” —Eben Moglen, _Anarchism Triumphant_, 1999 | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixing Decimal and float
On Wed, Jun 2, 2010 at 4:11 PM, Steven D'Aprano steve-remove-t...@cybersource.com.au wrote: On Wed, 02 Jun 2010 17:17:11 -0400, Nathan Rice wrote: My apologies if someone already mentioned this and I missed it but... class.__instancecheck__(self, instance) - Return true if instance should be considered a (direct or indirect) instance of class. If defined, called to implement isinstance(instance, class). class.__subclasscheck__(self, subclass) - Return true if subclass should be considered a (direct or indirect) subclass of class. If defined, called to implement issubclass(subclass, class). The original poster needs to support Python 2.5 and 2.6, but __instancecheck__ and __subclasscheck__ are only supported in 2.6 or higher, so this doesn't help. Even in 2.6+, good luck trying to define new methods on class `type` (the metaclass of float and Decimal). Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding Python in a C extension
p...@mail.python.org wrote: I have a problem with embedding Python into a C extension in Windows Vista. I have implemented a timer routine in C as an extension, which I can import into Python 2.6.5 and run. Each timer interval, the extension calls a C CALLBACK function. I want to be able to have this CALLBACK function call a Python function, so that I can write the timer handler in Python. I can write Python functions and call them from a C extension function with no trouble in all cases EXCEPT when the function that calls the Python code is the timer's CALLBACK function. That is, if I call PyRun_SimpleString or PyRun_SimpleFile, or PyImport_ImportModule, or basically any Python-y function in the CALLBACK function, Python crashes and I get a window saying Python has stopped working. Windows is searching for a solution to the problem. The Python code runs fine if I call it from a function in the extension that is not the CALLBACK function. And regular C code runs in the CALLBACK function properly. It only crashes if I try to run the Python code from the timer CALLBACK function (or any C function I call from the CALLBACK function). Does anybody know how to fix this? Is there a workaround of some sort? Here's a quote from the Python docs at: http://docs.python.org/c-api/init.html The Python interpreter is not fully thread safe. In order to support multi-threaded Python programs, there's a global lock, called the global interpreter lock or GIL, that must be held by the current thread before it can safely access Python objects. Without the lock, even the simplest operations could cause problems in a multi-threaded program: for example, when two threads simultaneously increment the reference count of the same object, the reference count could end up being incremented only once instead of twice. That's probably what's happening to you. -- http://mail.python.org/mailman/listinfo/python-list
Re: plac, the easiest command line arguments parser in the world
Michele Simionato michele.simion...@gmail.com wrote: It seems I have to take that claim back. A few hours after the announce I was pointed out tohttp://pypi.python.org/pypi/CLIArgs which, I must concede, is even easier to use than plac. It seems everybody has written its own command line arguments parser! I think I still find opterator[1] to be simpler and clearer. No magic global variables, no spooky behaviour with the main function, just a decorator and docstring. 1: http://github.com/buchuki/opterator -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding Python in a C extension
On Jun 2, 1:46 pm, Paul Grunau wrote: I have a problem with embedding Python into a C extension in Windows Vista. I have implemented a timer routine in C as an extension, which I can import into Python 2.6.5 and run. Each timer interval, the extension calls a C CALLBACK function. I want to be able to have this CALLBACK function call a Python function, so that I can write the timer handler in Python. I can write Python functions and call them from a C extension function with no trouble in all cases EXCEPT when the function that calls the Python code is the timer's CALLBACK function. That is, if I call PyRun_SimpleString or PyRun_SimpleFile, or PyImport_ImportModule, or basically any Python-y function in the CALLBACK function, Python crashes and I get a window saying Python has stopped working. Windows is searching for a solution to the problem. The Python code runs fine if I call it from a function in the extension that is not the CALLBACK function. And regular C code runs in the CALLBACK function properly. It only crashes if I try to run the Python code from the timer CALLBACK function (or any C function I call from the CALLBACK function). Does anybody know how to fix this? Is there a workaround of some sort? See PEP 311. When an external/uncertain thread calls into Python, it has to be sure a Python thread state exists for that thread, and that the thread holds the global interpreter lock. This is done by surrounding all Python code with the following calls: PyGILState_STATE state = PyGILState_Ensure(); and PyGILState_Release(state); Normally, code in extension modules can rely on the current thread having the global lock at all entry points, so it doesn't have worry about the thread state. But a callback from a timer can't assume that. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
[issue8873] Popen uses 333 times as much CPU as a shell pipe on Mac OS X
Antoine Pitrou pit...@free.fr added the comment: Have you tried specifying a value for the bufsize argument to Popen? Either 1 for line buffering or e.g. 4096 for a decent size block buffering. -- nosy: +gregory.p.smith, pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8873 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1038909] pydoc method documentation lookup enhancement
Changes by Éric Araujo mer...@netwok.org: -- nosy: +merwok ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1038909 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1185124] pydoc doesn't find all module doc strings
Changes by Éric Araujo mer...@netwok.org: -- nosy: +merwok ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1185124 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8848] Deprecate or remove U and U# formats of Py_BuildValue()
Walter Dörwald wal...@livinglogic.de added the comment: The code for case 's'/'z' in py3k is indeed the same as for case 'U'. The patch looks good to me. IMHO removing 'U' should only be done once Py2 is dead. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8848 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8876] distutils should not assume that hardlinks will work
New submission from samtygier samtyg...@yahoo.co.uk: distutils will currently try to use hardlinks if os has a 'link' attribute, however sometimes os.link() will fail, for example the filesystem may not support it (see attached traceback). in commands/sdist.py in make_release_tree() there is the test: if hasattr(os, 'link'):# can make hard links on this system link = 'hard' msg = making hard links in %s... % base_dir 'link' is then passed to copy_file() in file_util.py, which trusts that if link == 'hard', then hardlinking will work. there has been discussion in the past, but i dont think it has been fixed http://thread.gmane.org/gmane.comp.python.distutils.devel/2076 -- assignee: tarek components: Distutils files: hardlink-traceback.txt messages: 106881 nosy: samtygier, tarek priority: normal severity: normal status: open title: distutils should not assume that hardlinks will work versions: Python 2.6 Added file: http://bugs.python.org/file17521/hardlink-traceback.txt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8876 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8876] distutils should not assume that hardlinks will work
Changes by Éric Araujo mer...@netwok.org: -- components: +Distutils2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8876 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8877] 2to3 fixes stdlib import wrongly
New submission from Dirkjan Ochtman dirk...@ochtman.nl: d...@enrai src $ ls -l test/* -rw-r--r-- 1 djc users 34 Jun 2 16:00 test/http.py -rw-r--r-- 1 djc users 0 Jun 2 16:00 test/__init__.py d...@enrai src $ cat test/http.py from httplib import BadStatusLine d...@enrai src $ 2to3 test/* RefactoringTool: Skipping implicit fixer: buffer RefactoringTool: Skipping implicit fixer: idioms RefactoringTool: Skipping implicit fixer: set_literal RefactoringTool: Skipping implicit fixer: ws_comma --- test/http.py (original) +++ test/http.py (refactored) @@ -1,1 +1,1 @@ -from httplib import BadStatusLine +from .http.client import BadStatusLine RefactoringTool: Files that need to be modified: RefactoringTool: test/http.py ... which doesn't work, of course. On the other hand, http.py is not in a package, it works correctly. If test/http.py is moved to test/blah.py instead, it also works correctly. 2to3 should be able to conclude that the httplib it was before did not refer to .http, but refered to http.client. -- components: 2to3 (2.x to 3.0 conversion tool) messages: 106882 nosy: djc priority: normal severity: normal status: open title: 2to3 fixes stdlib import wrongly versions: Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8877 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2459] speedup for / while / if with better bytecode
Dirkjan Ochtman dirk...@ochtman.nl added the comment: Is this still relevant / will it get some love in the future? -- nosy: +djc ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2459 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1766304] improve xrange.__contains__
Tal Einat talei...@users.sourceforge.net added the comment: I'd like to implement this for 2.x, if there's any chance of this being accepted. Is there still a chance of getting this into 2.7? This will be my first patch for the Python core, so please tell me if I'm missing something. Currently I'm thinking of: 1. starting with the original patch 2. applying the required changes as mentioned Mark Dickinson, looking at the the accepted 3.x patch for guidance 3. back-porting the tests 4. checking for later additional changes in the source history, and back-porting any such relevant changes -- nosy: +taleinat ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1766304 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8876] distutils should not assume that hardlinks will work
samtygier samtyg...@yahoo.co.uk added the comment: here is a patch against http://svn.python.org/projects/python/trunk it moves the return statements into the individual file copying sections, and takes the final call to _copy_file_contents() out of the else. this allows an error in hardlinking to fall through by passing the exception. i have only tested on Linux. when running it still prints out hard linking CHANGES - pyzgoubi-0.4dev because of how the message is generated in line 130. do you think this needs to be changed. do we need a hardlinking failed, falling back to copy message? it might cause unnecessary worry (distutils already suppresses tracebacks to avoid scaring non-python-programmers). i have a patch that applies to 2.6 as well, is there much chance of that being accepted? -- keywords: +patch Added file: http://bugs.python.org/file17522/distutil-hardlink-trunk.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8876 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8876] distutils should not assume that hardlinks will work
Éric Araujo mer...@netwok.org added the comment: Distutils is a special case: Many third-party code relies on its undocumented quirks and bugs, so it’s basically frozen. Some non-disruptive bugfixes are accepted, in which case the normal Python rules apply (e.g., no new features in 2.7 which is in beta). Work has been moved to Distutils2, which breaks compatibility in order to fix things and add needed features. If Tarek (maintainer of both packages) agrees this can go into Distutils, Benjamin Peterson (release manager) will say whether he agrees or not. Patient a while for Tarek to see this bug report, and thanks for your work :) -- nosy: +merwok ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8876 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8878] IDLE - str(integer) - TypeError: 'str' object is not callable
New submission from Neil Crouch neil.cro...@tradingtechnologies.com: Unable to convert int to str in idle but from the cmd python prompt it work sfine. -- components: IDLE files: IDLE_err.txt messages: 106887 nosy: Stranger381 priority: normal severity: normal status: open title: IDLE - str(integer) - TypeError: 'str' object is not callable type: behavior versions: Python 2.6 Added file: http://bugs.python.org/file17523/IDLE_err.txt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8878 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8878] IDLE - str(integer) - TypeError: 'str' object is not callable
Ezio Melotti ezio.melo...@gmail.com added the comment: You probably did str = '4bf3e914' at some point and overridden str. -- nosy: +ezio.melotti resolution: - invalid stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8878 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8878] IDLE - str(integer) - TypeError: 'str' object is not callable
Mark Dickinson dicki...@gmail.com added the comment: The code you show works fine for me. The error you're seeing is almost certainly the result of inadvertently using 'str' as a variable name earlier in the IDLE session: Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin Type help, copyright, credits or license for more information. str = '4bf3e914' hell = str(123) Traceback (most recent call last): File stdin, line 1, in module TypeError: 'str' object is not callable help(str) no Python documentation found for '4bf3e914' -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8878 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1766304] improve xrange.__contains__
Mark Dickinson dicki...@gmail.com added the comment: A rapidly diminishing chance for 2.7, IMO. I wouldn't want to try to add this after the first release candidate, which is scheduled for June 5 (and I'm not sure I'll have time to review a patch between now and then). On the other hand, since this is pure optimization it might be acceptable for 2.7.1. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1766304 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1766304] improve xrange.__contains__
Tal Einat talei...@users.sourceforge.net added the comment: I'd really like to have this in 2.7. Is there no chance of getting it into 2.7 after rc1 is released? If so, I can have the patch ready by Friday 14:00 GMT, but if nobody will have time to review (and possibly commit) in time for RC1 I guess I'll take my time with this. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1766304 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8873] Popen uses 333 times as much CPU as a shell pipe on Mac OS X
Hugh Secker-Walker hug...@users.sourceforge.net added the comment: OK. Using bufsize=4096 or bufsize=-1 eliminates the CPU-hogging problem on Mac OS X. Thank you. I have to say that the Popen() doc could be better. It says: bufsize, if given, has the same meaning as the corresponding argument to the built-in open() function! which implies behavior like open(), which is to use the system's default buffering, generally a good thing. I think the default of 0, meaning unbuffered, is a poor choice. I'm guessing many many Mac users are getting a big slowdown from this default behavior (as I've now discovered elsewhere in our project!). I request that you change the default to be the same as open(), i.e. use the system default. Barring that semantic change, please add a note to the doc: Most users will want to set bufsize=4096 for pipe-like buffering, or bufsize=1 for line-based buffering. Thanks again for the quick response and resolution. -Hugh -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8873 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1766304] improve xrange.__contains__
Mark Dickinson dicki...@gmail.com added the comment: Benjamin? I'd really like to have this in 2.7. Is there no chance of getting it into 2.7 after rc1 is released? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1766304 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8873] Popen uses 333 times as much CPU as a shell pipe on Mac OS X
Antoine Pitrou pit...@free.fr added the comment: I think the default of 0, meaning unbuffered, is a poor choice. So do I, but I'm not sure whether it's acceptable to change behaviour in a potentially incompatible way. Barring that semantic change, please add a note to the doc: Most users will want to set bufsize=4096 for pipe-like buffering, or bufsize=1 for line-based buffering. Yes, it deserves a documentation note indeed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8873 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8870] --user-access-control=force produces invalid installer on Vista
anatoly techtonik techto...@gmail.com added the comment: Thanks for thorough explanation. Can somebody close it with some resolution like Can't fix. OS level problem? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8870 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8873] Popen uses 333 times as much CPU as a shell pipe on Mac OS X
Skip Montanaro s...@pobox.com added the comment: This problem has come up before. It was a bug introduced I think when the subprocess module was first incorporated into Python. I don't recall if the default was changed in 2.7 or 3.x. Can you demonstrate the problem with Python 2.7 or 3.1? If not, I'd recommend this ticket just be closed. -- nosy: +skip.montanaro ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8873 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8877] 2to3 fixes stdlib import wrongly
Martin v. Löwis mar...@v.loewis.de added the comment: Just in case it isn't clear: this is because of the order of fixes. The first fixer replaces httplib with http.client, then the next fixer thinks this is a relative import. -- nosy: +loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8877 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8873] Popen uses 333 times as much CPU as a shell pipe on Mac OS X
Antoine Pitrou pit...@free.fr added the comment: This problem has come up before. It was a bug introduced I think when the subprocess module was first incorporated into Python. I don't recall if the default was changed in 2.7 or 3.x. According to the docs it is still unbuffered by default. I've added a documentation note about performance issues in r81652. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8873 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1766304] improve xrange.__contains__
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: On Wed, Jun 2, 2010 at 11:17 AM, Tal Einat rep...@bugs.python.org wrote: .. If so, I can have the patch ready by Friday 14:00 GMT, but if nobody will have time to review (and possibly commit) in time for RC1 I guess I'll take my time with this. I'll review your patch, but why are you so eager to get this into 2.7? You realize that for integer x, x in xrange(a, b) is just another way to spell a = x b. What is your use case? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1766304 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1766304] improve xrange.__contains__
Changes by Alexander Belopolsky belopol...@users.sourceforge.net: -- assignee: - belopolsky ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1766304 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8877] 2to3 fixes stdlib import wrongly
Benjamin Peterson benja...@python.org added the comment: And this has been fixed in the lastest versions of 2to3. -- nosy: +benjamin.peterson resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8877 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1766304] improve xrange.__contains__
Antoine Pitrou pit...@free.fr added the comment: If so, I can have the patch ready by Friday 14:00 GMT, but if nobody will have time to review (and possibly commit) in time for RC1 I guess I'll take my time with this. I'll review your patch, but why are you so eager to get this into 2.7? You realize that for integer x, x in xrange(a, b) is just another way to spell a = x b. What is your use case? I really think this shouldn't go into 2.7. We certainly have better things to do than potentially break something for an almost useless non-feature. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1766304 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1766304] improve xrange.__contains__
Antoine Pitrou pit...@free.fr added the comment: Rescheduling to 3.2, if applicable (otherwise I suggest closing). -- versions: +Python 3.2 -Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1766304 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1766304] improve xrange.__contains__
Benjamin Peterson benja...@python.org added the comment: I don't really see the point. I would be more inclined towards it if there was a patch already, but patching this doesn't strike me as a key feature. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1766304 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1766304] improve xrange.__contains__
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: This is already in 3.x. The only reason I can think of to get this in 2.7 is to have fewer performance surprises between 2.x and 3.x. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1766304 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8874] py3k documentation mentions deprecated opcode LOAD_LOCALS
Benjamin Peterson benja...@python.org added the comment: Thanks. Removed in r81656. -- nosy: +benjamin.peterson resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8874 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5434] datetime.monthdelta
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: Rejecting this for stdlib. A 3rd party package is available at http://pypi.python.org/pypi?name=MonthDelta:action=display . -- stage: - committed/rejected status: pending - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5434 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1766304] improve xrange.__contains__
Antoine Pitrou pit...@free.fr added the comment: Le mercredi 02 juin 2010 à 18:10 +, Alexander Belopolsky a écrit : This is already in 3.x. The only reason I can think of to get this in 2.7 is to have fewer performance surprises between 2.x and 3.x. Since you are supposed to forward-port from 2.x and 3.x, the surprise will be a good one anyway. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1766304 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8879] Implement os.link on Windows
New submission from Brian Curtin cur...@acm.org: Add os.link support for Windows (mostly a reminder to myself to finish the patch I have) -- assignee: brian.curtin components: Extension Modules, Windows messages: 106908 nosy: brian.curtin priority: normal severity: normal stage: needs patch status: open title: Implement os.link on Windows type: feature request versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8879 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8870] --user-access-control=force produces invalid installer on Vista
Changes by Éric Araujo mer...@netwok.org: -- resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8870 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8866] socket.getaddrinfo() should support keyword arguments
Giampaolo Rodola' g.rod...@gmail.com added the comment: The patch in attachment implements keyword arguments. -- keywords: +patch Added file: http://bugs.python.org/file17524/kwargs.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8866 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8870] --user-access-control=force produces invalid installer on Vista
anatoly techtonik techto...@gmail.com added the comment: Is it possible to detect this situation and display more user-friendly error message with a reference to this issue? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8870 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5094] datetime lacks concrete tzinfo impl. for UTC
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: Here is my first attempt to implement fixed offset timezone type. The patch is based on Brett's next-patch.txt and while I changed the type name from datetime.UTC to datetime.timezone, I did not change the name of the related C structures. I would like to ask for comments on the following questions: 1. How to call the new type? I like timezone because it is likely to be the only concrete tzinfo subclass in datetime module, so we don't really need to call it fixedoffsetfromutctimezone. 2. Do we want to add a dst indicator and altname attributes? I would say: no. I would rather treat DST as a different fixed offset timezone. 3. I am not quite happy about having to specify offset in minutes. I think timezone(hours[, minutes]) may be clearer. Alternatively we may just take offset as a timedelta. Note issue5288. There is some interest in supporting sub-minute timezones. 4. I have fixed a reference leak in utcnow, but I am still against giving it tz_aware argument. -- Added file: http://bugs.python.org/file17525/issue5094.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5094 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8880] ConfigParser.set does not convert non-string values
New submission from Edwin Pozharski pozhar...@gmail.com: set() method of ConfigParser accepts boolean True/False as values at runtime without converting them to strings internally. As a result, getboolean() method reports the following error File /usr/lib/python2.6/ConfigParser.py, line 350, in getboolean if v.lower() not in self._boolean_states: AttributeError: 'bool' object has no attribute 'lower' since it expects get() method to return strings. (Same problem occurs if other types are used, int/float, etc) Altering set() behavior may be not the best thing to do, I'd rather suggest that getboolean() converts the get() output to string. Of course, the way to avoid this problem is always convert values submitted to set() to strings, but it's a hard-to-catch bug. In my case, I was stuck with problematic configuration when assigning values to wx.CheckBox.GetValue(), which returns boolean. -- messages: 106912 nosy: Edwin.Pozharski priority: normal severity: normal status: open title: ConfigParser.set does not convert non-string values type: behavior versions: Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8880 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8880] ConfigParser.set does not convert non-string values
Éric Araujo mer...@netwok.org added the comment: Would that mean that booleans would be converted to strings on set and converted back on get? Seems wasteful. (I’ve changed the version field for this bug. Its meaning is not “versions this applies to” but “versions that will get a fix”, and 3.2 is the only active branch now. Some bugfixes may still go into 2.7.) -- components: +Library (Lib) nosy: +merwok versions: +Python 3.2 -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8880 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5094] datetime lacks concrete tzinfo impl. for UTC
Brett Cannon br...@python.org added the comment: My thoughts on Alexander's questions: 1. Call it FixedTimezone or something (remember it has to be CapWords). Calling it simply Timezone does not convey the fact that DST is not supported and people might naively think it will. Its limited abilities should be portrayed in the name. 2. Keep the class dead-simple. The primary motivator is to support UTC, maybe the %z directive for strptime. Otherwise everything else should be left out of the stdlib and let third-parties manage it as they will be the ones that need to manage the bazillion timezone instances they need. We don't need to dictate an interface to them. 3. Taking a timedelta makes sense since the class represents the fixed time offset from UTC. As for the tz_aware argument to utcnow and friends, I am fine with letting go of them if we have a utc attribute on datetime and we simply document that to get a UTC-aware value do ``now(datetime.utc)`` and consider deprecating utcnow. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5094 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com