[issue24067] Weakproxy is an instance of collections.Iterator
Gareth Rees added the comment: The documentation says that weakref.Proxy objects are not hashable because this avoids a number of problems related to their fundamentally mutable nature, and prevent their use as dictionary keys. Hashable objects must be immutable, otherwise the hash might change, invalidating the invariants that make dictionaries work, but Proxy objects are fundamentally mutable: when there are no more strong references to the proxied object, the object gets destroyed and the Proxy object now refers to None. If the Proxy object were hashable then its hash would change at this point. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24067 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24067] Weakproxy is an instance of collections.Iterator
Antoine Pitrou added the comment: Still, weakref.ref objects are hashable, so I don't understand why weakref.proxy would be different. Hashability of weakref.ref has been added in 29aa832b8787, to support weak dictionaries. See issue403985. It simply wasn't discussed whether to also add hashability to proxy objects. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24067 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24056] Expose closure generator status in function repr()
Mark Dickinson added the comment: I can see that the `generator` information would be useful. What's the use-case for reporting that a function is a closure? I'm having trouble thinking of a case where it's useful to know that a function is a closure without also knowing which locals refer to cells. -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24056 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24067] Weakproxy is an instance of collections.Iterator
Antoine Pitrou added the comment: So consider what happens if you forward the __hash__ method to the proxied object: the hash will change when the object dies. ref objects behave differently: they inherit their referent's hash value when alive, and remember it. proxy objects could be made to behave the same way. The hash support for ref objects is definitely a very special case, only intended to support WeakKeyDictionary I've relied several times on the hashability of ref objects, in third-party code. (OTOH, I never use weakref proxies) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24067 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24067] Weakproxy is an instance of collections.Iterator
Antoine Pitrou added the comment: weakref.Proxy objects are not hashable regardless of the referent Interesting. @fdrake, do you remember why that is? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24067 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11205] Evaluation order of dictionary display is different from reference manual.
Steve Dougherty added the comment: I've added a change to the bytecode magic number as well. I don't see a magic tag anymore, either in the code or for recent versions. There are autogenerated changes to Python/importlibs.h. Is my understanding correct that these are not to be committed? -- Added file: http://bugs.python.org/file39225/issue11205-v2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11205 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24067] Weakproxy is an instance of collections.Iterator
Fred L. Drake, Jr. added the comment: Clearly I've been away from this code for a long time. The hash support for ref objects is definitely a very special case, only intended to support WeakKeyDictionary. We that class implemented in C, we'd probably want the hash support for refs not to be exposed. You've convinced me hashability for proxies isn't desirable. Let's stick with the status quo on this. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24067 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23749] asyncio missing wrap_socket
Changes by Andrew Svetlov andrew.svet...@gmail.com: -- nosy: +asvetlov stage: - needs patch versions: +Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23749 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24071] Python 2.7.8, 2.7.9 re.MULTILINE failure
Changes by Serhiy Storchaka storch...@gmail.com: -- resolution: - not a bug stage: - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24071 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Tit for tat
On 2015-04-28 07:58, Steven D'Aprano wrote: On Tuesday 28 April 2015 13:18, Seymore4Head wrote: In the past, I have had some measure of success with the Toot for Tail strategy. I don't believe that is a standard name for an Iterated Prisoner's Dilemma strategy. I've googled for it, using two different search engines, and neither come up with any references for Toot For Tail strategies. I do believe he is trying to make a crude joke. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- https://mail.python.org/mailman/listinfo/python-list
[issue24072] xml.etree.ElementTree.Element does not catch text
Raymond Hettinger added the comment: What would you have it do in the general case, should it concatenate all the text in: root4 = ET.fromstring('aabcbdef/bghi/a') root4.text 'abc' If I'm interpreting the XML spec correctly ( http://www.w3.org/TR/2006/REC-xml-20060816/#sec-starttags section [43]), the optional character data must be a the beginning of the element before any other elements, comments, or processing instructions: content::= CharData? ((element | Reference | CDSect | PI | Comment) CharData?)* In other words, I'm not sure your XML is considered well-formed. -- nosy: +rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24072 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Tit for tat
On Tue, 28 Apr 2015 15:16:05 -0700 (PDT), John Ladasky john_lada...@sbcglobal.net wrote: On Tuesday, April 28, 2015 at 1:10:14 PM UTC-7, Robert Kern wrote: On 2015-04-28 07:58, Steven D'Aprano wrote: I do believe he is trying to make a crude joke. I agree, that's what he's doing. And I find it ironic, since he started this thread, and seemed to invite a serious discussion of the topic. I did start out serious. I thought I was making a pretty funny joke too. I though both were allowed. I guess not. Sorry What I was fishing for were personal stories of programmers that had tried the tit for tat program challenge. I thought that Patrick Grim's analysis was very interesting, showing that the Spatialized Iterated Prisoner's Dilemma (SIPD) could emulate the Wireworld cellular automaton, which is a Turing-complete system. Thus, the SIPD, a seemingly simple system at first glance, includes configurations which are formally undecidable in the Gödelian sense. I'm not sure whether Grim proved that an SIPD which includes the Tit for Tat strategy could emulate Wireworld, but it seems likely that one could be built. -- https://mail.python.org/mailman/listinfo/python-list
[issue24072] xml.etree.ElementTree.Element does not catch text
New submission from Jérôme Laurens: text is not catcher in case 3 below INPUT import xml.etree.ElementTree as ET root1 = ET.fromstring('aTEXT/a') print(root1.text) root2 = ET.fromstring('aTEXTb//a') print(root2.text) root3 = ET.fromstring('ab/TEXT/a') print(root3.text) CURRENT OUTPUT TEXT TEXT None -- ERROR HERE EXPECTED OUTPUT TEXT TEXT TEXT -- messages: 242207 nosy: jlaurens priority: normal severity: normal status: open title: xml.etree.ElementTree.Element does not catch text type: behavior versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24072 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Tit for tat
On Wednesday, April 29, 2015 at 3:46:24 AM UTC+5:30, John Ladasky wrote: I thought that Patrick Grim's analysis was very interesting, showing that the Spatialized Iterated Prisoner's Dilemma (SIPD) could emulate the Wireworld cellular automaton, which is a Turing-complete system. Thus, the SIPD, a seemingly simple system at first glance, includes configurations which are formally undecidable in the Gödelian sense. I'm not sure whether Grim proved that an SIPD which includes the Tit for Tat strategy could emulate Wireworld, but it seems likely that one could be built. Thanks John for those pointers -- Ive been looking at it with interest. This area is of some interest to me -- as my last two blog posts would indicate http://blog.languager.org/2015/04/poverty-universality-structure-0.html http://blog.languager.org/2015/03/cs-history-0.html PS Google groups invites to writing longlines which causes trouble to some people out here (with historical machines?). -- https://mail.python.org/mailman/listinfo/python-list
Re: Clize 3.0b1: An argument parser that draws a CLI from your function sigature
On Wed, Apr 29, 2015 at 11:55 AM, Yann Kaiser kaiser.y...@gmail.com wrote: I'm aware of the pattern, and I don't really like it, especially because it gets weird when multiple modules are involved. You'd have to import modules because they have a side-effect of adding stuff to a list rather than import things so that you can put them in a list. In addition, if Clize manages that list, it will be a global mutable object to take care of in tests and so forth. That'll be rather yucky. I like the straightforwardness of names are imported or defined - names are passed to run (what is passed to run *is* what you get) rather than names are collected as side effect of this and that import then run looks at them (well, I could explore what all those imports are doing...). Okay. That's a philosophical difference that I can understand. There is some magic when the decorator hangs onto a reference, and personally, I think it's worth it, but if you don't, that's fine. All I'd need to do is have my own decorator that collects the functions up into a list. Can you put together a Clize equivalent? I'm pretty sure it's going to be remarkably close to what I want. https://gist.github.com/epsy/fba26300fccb7e672729 It is pretty much the same save for the result formatting (clize prints non-None results on its own then exits, although for your example I understand the extra format step is necessary) I already hacked the output a bit compared to the original. Exact details aren't a big deal. In the case of fore/database.py, the precise formatting hardly matters; this is basically the bootstrapping back end (when you have a completely empty database, the server won't start, so you need to create yourself an account first), so it's okay if it just prints out a tuple's repr. Annotated line numbers for put: (PEP8 double-spacing increased the numbers, sorry) 1-6: Boilerplate: imports 16: Function signature 17-22: Documentation (parameter descriptions need to be in their own paragraph in Clize's default helper) 37-39: Defining a wrapper just for reformatting the result 42-43: defining the execution point and adding the result format decorator The result formatting could be better. Maybe run could be made not to exit upon success (but still upon failure) and return the evaluated value rather than print it, or apply decorators en masse. I definitely see the appeal in either. Returning rather than printing would perhaps be nice in terms of reducing the magic, but there's already some magic around (eg exiting on failure; mine, since it chains through to argparse, exits on --help or failure), so it's not a big deal. So we're actually really REALLY close to each other here. This looks good! ChrisA -- https://mail.python.org/mailman/listinfo/python-list
[issue24072] xml.etree.ElementTree.Element does not catch text
Changes by Raymond Hettinger raymond.hettin...@gmail.com: -- Removed message: http://bugs.python.org/msg242208 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24072 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24072] xml.etree.ElementTree.Element does not catch text
Ned Deily added the comment: While a bit confusing, I don't think this is a bug. Note the definition of the tail attribute of an element: If the element is created from an XML file the attribute will contain any text found after the element’s end tag and before the next tag. Unlike in root1 and root2 where 'TEXT' is before the end of element a and the start of element b (in root2), 'TEXT' in root3 follows the end tag of element b and so is associated with it as its tail attribute. root3 Element 'a' at 0x1022ab188 root3[0] Element 'b' at 0x1022ab1d8 root3[0].tail 'TEXT' https://docs.python.org/3/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element.tail -- nosy: +ned.deily resolution: - not a bug stage: - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24072 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Question Installing latest Python
On Wed, 29 Apr 2015 05:26 am, Φώντας Λαδοπρακόπουλος wrote: Τη Τρίτη, 28 Απριλίου 2015 - 10:02:24 π.μ. UTC+3, ο χρήστης Φώντας Λαδοπρακόπουλος έγραψε: First of all Steven thank youvery much for your detailed help. Secondly prior of seeing your post i tried to folowe a guid and isntall python 3.3.2 for CentOS 7.1 x64 using yum. What command did you use to install with yum? The python ould have been installed in 3.3.2 there as yous ay, but instead look: [root@secure ~]# /usr/bin/python3 -V /usr/bin/python3: error while loading shared libraries: libpython3.3m.so.1.0: cannot open shared object file: No such file or directory [root@secure ~]# /opt/rh/python33/root/usr/bin/python -V /opt/rh/python33/root/usr/bin/python: error while loading shared libraries: libpython3.3m.so.1.0: cannot open shared object file: No such file or directory [root@secure ~]# Run these commands: cd /tmp python3 -c import sys; print(sys.executable) What output do you get? Should i remove the package with yum and try the build from scracth method you posted otr is there is a way to reloves this error Steven? No, do not remove the yum package yet. If you are satisfied with Python 3.3 the yum package is better than installing from source. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
[issue24067] Weakproxy is an instance of collections.Iterator
Fred L. Drake, Jr. added the comment: I don't see any reason for proxy objects to be less hashable than ref objects. As for the p == p case, where the referent has expired, returning True if p is p seems acceptable (along with False inequalities, and True for other comparisons allowing equality), but anything beyond that seems unwise. Not sure whether that would really be enough to help real use cases. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24067 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24067] Weakproxy is an instance of collections.Iterator
Gareth Rees added the comment: I don't see any reason for proxy objects to be less hashable than ref objects. The difference is that unlike a ref object, a proxy object is supposed to forward its method calls to the proxied object. So consider what happens if you forward the __hash__ method to the proxied object: the hash will change when the object dies. A proxy object could, of course, not forward the __hash__ method, instead computing its own hash. But I think this would do more harm than good: surely most attempts to store weakref.Proxy objects in sets or dictionaries are going to be mistakes -- the user should have used a WeakKeyDictionary or a WeakSet instead. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24067 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24067] Weakproxy is an instance of collections.Iterator
Gareth Rees added the comment: Hashable is particularly misleading, because weakref.Proxy objects are not hashable regardless of the referent. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24067 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24067] Weakproxy is an instance of collections.Iterator
Antoine Pitrou added the comment: Ok, PEP 205 explains it a bit more: the resulting proxy cannot be used as a dictionary key since it cannot be compared once the referent has expired, and comparability is necessary for dictionary keys. Operations on proxy objects after the referent dies cause weakref.ReferenceError to be raised in most cases. Perhaps this can be relaxed, and comparison simply made to return false. The following behaviour is a bit troubling :-) p weakproxy at 0x7f4054fe8cd8 to NoneType at 0x88a780 p == p Traceback (most recent call last): File stdin, line 1, in module ReferenceError: weakly-referenced object no longer exists -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24067 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24056] Expose closure generator status in function repr()
Berker Peksag added the comment: Here is a patch with a test. -- components: +Interpreter Core keywords: +patch nosy: +berker.peksag stage: needs patch - patch review Added file: http://bugs.python.org/file39224/issue24056.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24056 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
getting twisted to work in python - sending data from one protocol to another
I am a newbie in python. Right now I am working on this messaging app and I would like to pass data from one protocol to another. I have been referencing to other answers provided in other similar questions by trying to add a variable storing the data from one factory then initiate another factory and write the data to it. Unfortunately it is only writing back to itself now instead of writing to another factory, and I cannot figure out why. If anyone can provide any sort of help I will really appreciate it as I have been stuck in this point for quite a while. Here is the code # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. import kivy from kivy.app import App from kivy.uix.label import Label from kivy.uix.scatter import Scatter from kivy.uix.boxlayout import BoxLayout from kivy.uix.scrollview import ScrollView from kivy.uix.button import Button from kivy.graphics.vertex_instructions import Rectangle from kivy.graphics.context_instructions import Color from kivy.graphics.instructions import Instruction from kivy.base import runTouchApp from kivy.lang import Builder import socket from kivy.core.window import Window import pygame import random from kivy.support import install_twisted_reactor install_twisted_reactor() from twisted.internet import reactor, protocol Window.size = (550, 400) # monitoring wordlist with open(wordlist.txt) as word_file: wordlist = list(word.strip().lower() for word in word_file) # protocols for sender class EchoProtocol(protocol.Protocol): This is just about the simplest possible protocol def dataReceived(self, data): As soon as any data is received, write it back. sendermessage = data if sendermessage: self.transport.write(sendermessage) MultiEcho().dataReceived(self.transport.write(sender: %s %sendermessage)) class EchoFactory(protocol.Factory): protocol = EchoProtocol def __init__(self, app): self.app = app # protocols for receiver class MultiEcho(protocol.Protocol): def connectionMade(self): self.factory.echoers.append(self) def dataReceived(self, data): receivermessage = data # handlereceivermessage = self.factory.app.handle_message(data) if receivermessage: self.transport.write(receivermessage) EchoProtocol().dataReceived(self.transport.write(receiver: %s %receivermessage)) class MultiEchoFactory(protocol.Factory): protocol = MultiEcho def __init__(self, app): self.echoers = [] self.app = app class ServerApp(App): def build(self): self.layout = BoxLayout(orientation='vertical', spacing=10) self.label = Button(text='Censoring process begin\nBeware of keyword umbrella\n ', color=[1.0, 1.0, 1.0, 1.0]) self.label.color = [0.9, 0.2, 0.2, 1.0] self.upperscroll = Button(pos_hint={'x': 0, 'center_y': .5}, size_hint=(None, None)) self.scatter = Scatter() self.displaybox = Label() self.displaybox.color = [0.4, 0.9, 0.4, 1.0] reactor.listenTCP(8000, MultiEchoFactory(self)) # for sender reactor.listenTCP(8001, EchoFactory(self)) # for receiver self.layout.add_widget(self.label) self.layout.add_widget(self.scatter) self.scatter.add_widget(self.displaybox) return self.layout def handle_message(self, msg): if any(word in msg.lower() for word in wordlist): self.displaybox.color = [0.9, 0.4, 0.4, 1.0] self.displaybox.text = content blocked self.label.text += Alert! Sender posts %s \n % msg else: self.label.text += Safe - sender posts %s \n % msg self.displaybox.color = [0.4, 0.9, 0.4, 1.0] self.displaybox.text = %s % msg msg = msg return msg def handle_message2(self, msg): if any(word in msg.lower() for word in wordlist): self.label.color = [0.8, 0.8, 0.5, 1.0] self.label.text += Alert! Receiver got %s \n % msg else: self.label.color = [0.2, 0.2, 1.0, 1.0] self.label.text += Safe - receiver sends %s \n % msg msg = msg return msg if __name__ == '__main__': ServerApp().run() -- https://mail.python.org/mailman/listinfo/python-list
[issue24072] xml.etree.ElementTree.Element does not catch text
Changes by Raymond Hettinger raymond.hettin...@gmail.com: -- nosy: +eli.bendersky, scoder ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24072 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Neil Girdhar added the comment: All tests pass. All reviewer comments addressed. Please let me know if anything else needs to be done from my end. -- Added file: http://bugs.python.org/file39230/starunpack42.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Clize 3.0b1: An argument parser that draws a CLI from your function sigature
On Mon, 27 Apr 2015 at 17:04 Chris Angelico ros...@gmail.com wrote: On Mon, Apr 27, 2015 at 7:02 PM, Yann Kaiser kaiser.y...@gmail.com wrote: Hello everyone! After a few years in development, I am proud to say Clize is landing its feet again and is now in beta for an upcoming release. You can try it out usingpip install --user clize=3.0b1and you can browse the docs athttps://clize.readthedocs.org/ For those who'd like an explanation before clicking links, here's Clize's 5-bullet point explanation: * Command-line interfaces are created by passing functions to `clize.run`. * Parameter types are deduced from the functions' parameters. * A ``--help`` message is generated from your docstrings. (Why does this still need to be a bullet point?) * Decorators can be used to reuse functionality across functions. * Clize can be extended with new parameter behavior. Interesting. I've also been working on a simpler arg handling module; maybe we can work together. The goals for mine are: * Each function should be as independent as possible. In Clize, commands are also just regular functions which have the desired amount of keyword-only parameters and annotations. They can still be run individually, be tested, and so forth. * Minimize repetition (of names, descriptions, etc) I try to minimize repetition, but the reality of things is that a parameter name could be repeated up to 4 times in Clize: * In the function's parameter list * In the function's docstring * If named explicitly, in a @-kwoargs decorator (not needed with Py3) * In an annotate decorator (again, not needed with Py2 compatibility isn't desired) Two of these wouldn't be relevant in a Python 3-only world (if it's just a shell script replacement, you can probably pretend to be in one for a moment), the remainder being normal things in a function. So I'm not doing too badly there. Descriptions are of course only written in the description :-) In addition, I took up the goal of helping minimize repetition in client code behavior through better support for decorators (which is really cool, by the way!) * Keep everything in the function signature I started taking this at heart with 3.0, after seeing the rather disgusting constructs that had to be used in Clize 2.x for specifying aliases and value converters. Now everything is annotations. Nothing in the docstring specifies behavior, and it isn't even read at all until --help is triggered. I intend to keep docstrings behavior-free because, well, they're strictly for documentation IMO. One of the last remains of the old give parameters to Clize about what your function's parameters does stuff, a flag to pass the executable name to the function that's being run, was in fact changed in 3.0b1 to be an annotation instead, giving it more flexibility (you can annotate whichever parameter you want rather than being forced to use the first one). What I mean to say, is that I am definitely committed to keeping everything in the function signature. Probably even more than you :-) * Simplify the basic and obvious usages That's where Clize started and I intend to keep simple usages simple. One could say having to use @autokwoargs for turning parameters with default values into keyword-only parameters, but I feel it was necessary for consistency with the presence of actual keyword-only parameters. Overall we're agreed on all these goals. I will add that I'm taking up extensibility as a goal as of Clize 3.0. clize.parameters.argument_decorator[1] wasn't originally by idea and was first implemented by someone else using the public API. [1] http://clize.readthedocs.org/en/latest/compositing.html#using-a-composed-function-to-process-arguments-to-a-parameter What it's clearly lacking when compared to your parser is better docstrings, haha :-) The parser docs alleviate that a bit, but the parser can be hard to navigate at first. https://github.com/Rosuav/docstringargs https://pypi.python.org/pypi/docstringargs/ There's a demo file in the source repo, plus here are a couple of actual usage examples: https://github.com/Rosuav/LetMeKnow/blob/master/letmeknow.py https://github.com/MikeiLL/appension/blob/master/fore/database.py The latter is an existing module in an existing project, and it grew a command-line interface with minimal changes, eg: https://github.com/MikeiLL/appension/commit/566f195 Can we merge our plans and make a single module that's more likely to be maintained long-term? No point over-duplicating! Agreed. I'm open to have more maintainers and to take input, but I have to admit that at this stage of development, I'm quite attached to Clize's existing codebase and features (although I'm always open to refactoring, and the test suite helps with that). ChrisA -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Clize 3.0b1: An argument parser that draws a CLI from your function sigature
On Mon, 27 Apr 2015 at 22:30 Ethan Furman et...@stoneleaf.us wrote: On 04/28, Chris Angelico wrote: That's a lot of separate pieces. Here's the docstringargs equivalent: https://github.com/Rosuav/snippets/blob/dsa/snippets.py Just for grins, here's that using Scription: -- 8 Store and retrieve snippets of text from scription import * import logging # Set the log output file, and the log level logging.basicConfig(filename=snippets.log, level=logging.DEBUG) data = {} @Script() def main(): print('Result: {!r}'.format(script_command())) @Command( name=('the name of the snippet', ), snippet=('the snippet text', ), ) def put(name, snippet): Blargh, this is exactly what I didn't like about Clize 2.x Store a snippet with an associated name. logging.info(Storing({!r}, {!r}).format(name, snippet)) data[name] = snippet return name, snippet @Command( name=('the name of the snippet', ), ) def get(name): Retrieve the snippet with a given name. logging.error(Retrieving({!r}).format(name)) return data.get(name) Main() -- 8 and a sample run with nothing selected: -- 8 $ python snippet Store and retrieve snippets of text snippet get NAME Retrieve the snippet with a given name. NAME the name of the snippet snippet put NAME SNIPPET Store a snippet with an associated name. NAME the name of the snippet SNIPPET the snippet text -- 8 -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
[issue24073] sys.stdin.mode can not give the right mode and os.fdopen does not check argument
New submission from Xiang Zhang: The problem is what the title tells and can be produced by the snippet below. import sys import os sys.stdout.write(%s\n % sys.stdin.mode) sys.stdout.flush() f = os.fdopen(sys.stdin.fileno(), r) f.write() f.flush() f.read() f.close() When running this snippet with nohup, which changes the stdin's mode to O_WRONLY(which can also be shown below because the write operation will fail), this snippet will still give sys.stdin.mode as r, both in 2.7 and 3.4. In 2.7, the os.fdopen will fail with Invalid Argument error because the mode r given to fdopen conflicts with stdin's real mode w. In 3.4, os.fdopen won't give any error. Both in 2.7 and 3.4, if I change the mode given to os.fdopen to w: f = os.fdopen(sys.stdin.fileno(), w) The write operation will succeed and the read operation will fail. The output produced in nohup.out for 2.7 is: r Traceback (most recent call last): File test.py, line 9, in module f.read() IOError: File not open for reading For 3.4: r Traceback (most recent call last): File test.py, line 9, in module f.read() io.UnsupportedOperation: not readable I run the snippet with nohup on Gnome Terminal, bash, Ubuntu 15.04. The Python version is 2.7.9 and 3.4.3. -- components: Library (Lib) messages: 242211 nosy: angwer priority: normal severity: normal status: open title: sys.stdin.mode can not give the right mode and os.fdopen does not check argument type: behavior versions: Python 2.7, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24073 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Best GUI for Python
On Monday, April 27, 2015 at 12:52:48 PM UTC+5:30, Chris Angelico wrote: On Mon, Apr 27, 2015 at 4:55 PM, Christian Gollwitzer wrote: Am 27.04.15 um 01:06 schrieb Chris Angelico: On Mon, Apr 27, 2015 at 6:26 AM, Ben Finney wrote: It doesn't have to. By using the newer ‘tkinter.ttk’ library URL:https://docs.python.org/3/library/tkinter.ttk.html, the GUI will use native look-and-feel widgets. Does the new library also deal with the ongoing issues with Unicode support? AIUI there's some fundamental problem with Tkinter which means that (possibly only on Windows?) non-BMP characters simply can't be displayed. No. That is a fundamental limit in Tcl 8 (it uses UCS-2 to store strings), and will probably only addressed in Tcl 9. ttk addresses mostly the theming issue and is now 8 years new (Tk 8.5a6) with a precursor (Tile) from ten years ago. Right, so this is an ongoing issue (at least for now). To me, that's a pretty bad flaw - we should be aiming new projects at complete Unicode support, which means Python 3 and a good GUI toolkit. YMMV. Is non-BMP needed for any living non-esoteric language? I agree that it is a big flaw, but still is useful for very many projects. Maybe not for the language itself, but then, you can transliterate Chinese using nothing but Roman letters and Arabic numerals (all in ASCII), so merely proving that you can represent text doesn't necessarily mean everything. Mainly, SMP characters are used for things like musical notes, mathematical symbols, emoticons, and so on. (Also, I'm not sure of the current state of the art as regards Chinese and Japanese characters.) If you support only the BMP, then you're far better off than supporting only ASCII or only some eight-bit code page, to be sure, but it's still cutting out some characters. For a program that already exists, already works, and can't handle non-BMP characters, it's a small issue, and not one that I'd be recommending a complete GUI toolkit replacement for; but for a green-field project, I would strongly recommend using Python 3 and some toolkit which supports the full Unicode range. Everything else being equal this is likely fine advice. However everything is rarely equal; eg the one time I tried to use wxpython it segfaulted, probably the only time in 15 years of python-use that Ive got python to segfault. This is a problem that won't just go away. As more SMP blocks get assigned, more people will start using them, and get frustrated at your program for not letting them. (And why should an end user need to know the difference between and ⍥, that the second one works and the first doesn't?) Unless you're willing to wait for a Python that ships Tcl 9, Tkinter is a choice that restricts your end users. The issue is a bit subtle and nuanced Python is 2 (at least) things 1. A fine unicode supporting framework 2. A glue for putting together systems composed of various components Since some of those *other* components may break, it would be good for the 'glueness' of python to break more smoothly than it currently does. http://blog.languager.org/2015/03/whimsical-unicode.html#half-assed is a very non-exhaustive list – not just Tkinter – of - ostensibly unicode-supporting - actually SMP-borked software IOW it would be good if bugs (enhancements actually) like these be resolved: http://bugs.python.org/issue23672 http://bugs.python.org/issue18814 http://bugs.python.org/issue22264 -- https://mail.python.org/mailman/listinfo/python-list
[issue2292] Missing *-unpacking generalizations
Neil Girdhar added the comment: Hi Steve: I have limited expertise in most of these areas, but I looked at starunpack40.diff and have these comments: * tests look to have good coverage of the feature (can't speak to coverage of the parser/compiler code) * parsermodule.c changes comprehension handling, but I thought we pulled this out? There was some code taken common in various places, but there should be no code for unpacking comprehensions left in. Do you have a question about a specific line? * why was dictobject.c.h added? I don't understand clinic thoroughly, but it seems a lot of new code for what was changed in dictobject.c They weren't added. They were moved by someone else. The only changes are exposing a method. * can the BUILD_(TUPLE|LIST)_UNPACK code in ceval.c share most of the processing? Or is there an unwanted perf impact to that? Good idea. I'll make that change. * whoever applies the patch should regenerate importlib.h themselves - just a reminder Otherwise, I didn't see anything that particularly scared me. Since we apparently don't have anyone willing and with the expertise to thoroughly check the patch, I'd vote for checking it in asap so it has more releases to bake before 3.5 final. Thanks! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: mac os core dump from detached process
On 27 Apr 2015, at 10:21, Robin Becker ro...@reportlab.com wrote: I'm using the double fork exec model as exemplified in http://code.activestate.com/recipes/278731-creating-a-daemon-the-python-way/ to run a django management command detached from any view. A database object is used to store/update information about the process. The command does have a log file and appears to work well on linux. However, on my developer colleague's mac using the django development server the job ends suddenly without passing through the try except finally that's supposed to capture information. I believe the only way it can do this is os._exit or an interrupt eg SIGSEGV etc etc. Is it possible to get core dumps on the Mac for debugging purposes? Would the detached process inherit flags etc etc from the starting process? I know little about OS X/Mach. My first thought would be to run Applications - Utilities - Console and look for a crash report under ‘User Diagnostic Reports’ in the sidebar. I’m not entirely sure what my second thought would be if there wasn’t a report there. — CMcP -- https://mail.python.org/mailman/listinfo/python-list
Re: Clize 3.0b1: An argument parser that draws a CLI from your function sigature
On Mon, 27 Apr 2015 at 20:28 Chris Angelico ros...@gmail.com wrote: On Tue, Apr 28, 2015 at 12:45 PM, Yann Kaiser kaiser.y...@gmail.com wrote: On Mon, 27 Apr 2015 at 17:04 Chris Angelico ros...@gmail.com wrote: Interesting. I've also been working on a simpler arg handling module; maybe we can work together. The goals for mine are: * Each function should be as independent as possible. In Clize, commands are also just regular functions which have the desired amount of keyword-only parameters and annotations. They can still be run individually, be tested, and so forth. To implement something like the examples I gave, though, you'd need to enumerate the subcommand functions at the end. I'd like to be able to not do that. My inspiration came partly from Flask. I can build up a web site with several separate files, where one file might define routes for all the human-accessible content (the stuff that's designed for a web browser) and a separate file could define the API endpoints (emitting JSON or something). There's no need to have a single gathering point that lists every function that needs to be called - they get squirreled away by the decorator. I'm aware of the pattern, and I don't really like it, especially because it gets weird when multiple modules are involved. You'd have to import modules because they have a side-effect of adding stuff to a list rather than import things so that you can put them in a list. In addition, if Clize manages that list, it will be a global mutable object to take care of in tests and so forth. That'll be rather yucky. I like the straightforwardness of names are imported or defined - names are passed to run (what is passed to run *is* what you get) rather than names are collected as side effect of this and that import then run looks at them (well, I could explore what all those imports are doing...). * Minimize repetition (of names, descriptions, etc) I try to minimize repetition, but the reality of things is that a parameter name could be repeated up to 4 times in Clize: * In the function's parameter list * In the function's docstring * If named explicitly, in a @-kwoargs decorator (not needed with Py3) * In an annotate decorator (again, not needed with Py2 compatibility isn't desired) Two of these wouldn't be relevant in a Python 3-only world (if it's just a shell script replacement, you can probably pretend to be in one for a moment), the remainder being normal things in a function. So I'm not doing too badly there. Descriptions are of course only written in the description :-) A lot of my projects are Py3-only. I have no problem with that. * Keep everything in the function signature I started taking this at heart with 3.0, after seeing the rather disgusting constructs that had to be used in Clize 2.x for specifying aliases and value converters. Now everything is annotations. Nothing in the docstring specifies behavior, and it isn't even read at all until --help is triggered. I intend to keep docstrings behavior-free because, well, they're strictly for documentation IMO. What I mean to say, is that I am definitely committed to keeping everything in the function signature. Probably even more than you :-) :) There's a spectrum of convenience: 1) The actual function signature - information that already exists. Function and parameter names, basically. 2) Annotations, directly attached to the parameters. 3) Docstrings and decorators, adjacent to the 'def' statement. 4) Code elsewhere in the file. 5) Code or directives in a separate file. Some of Clize stretches as far as level 4, and that's what I'd like to pull up a bit. With docstringargs, the only things at level 4 are generic setup - importing the module (unavoidable) and if name is main, do stuff (also unavoidable unless you want to put in some major MAJOR magic). (I took this spectrum from the discussions surrounding PEP 484, incidentally. I'm sure you won't be even *considering* having crucial command-line parsing out in a separate file, but that's precisely what type-hint stub files are.) There's a demo file in the source repo, plus here are a couple of actual usage examples: https://github.com/Rosuav/LetMeKnow/blob/master/letmeknow.py https://github.com/MikeiLL/appension/blob/master/fore/database.py The latter is an existing module in an existing project, and it grew a command-line interface with minimal changes, eg: https://github.com/MikeiLL/appension/commit/566f195 Can we merge our plans and make a single module that's more likely to be maintained long-term? No point over-duplicating! Agreed. I'm open to have more maintainers and to take input, but I have to admit that at this stage of development, I'm quite attached to Clize's existing codebase and features (although I'm always open to refactoring, and the test suite helps with that). If Clize can
[issue24069] Option to delete obsolete bytecode files
New submission from Sworddragon: The library compileall has the option -f to force the rebuilding of the bytecode files so I thought maybe there could also be an option to delete all bytecode files which haven't a non-bytecode library anymore. -- components: Library (Lib) messages: 242189 nosy: Sworddragon priority: normal severity: normal status: open title: Option to delete obsolete bytecode files type: enhancement versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24069 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17908] Unittest runner needs an option to call gc.collect() after each test
Guido van Rossum added the comment: It's trivial to add to a single test or even a single TestCase subclass, yes. The use case is more that you have a ton of tests and you suspect there's a problem due to GC. Being able to call gc.collect() after each test through the flip of a flag would be useful. But I agree it's iffy whether this belongs in the unittest package; we could add it to the CPython run_tests.py script, or you could request this as a feature from py.test. If someone wants to add this to run_tests.py I think this issue would be the place to review the patch. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17908 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19543] Add -3 warnings for codec convenience method changes
Serhiy Storchaka added the comment: Here is a patch that backports issue19619 and issue20404 with changing an exception to Py3k warning, and makes necessary changes in other modules and tests. $ ./python -3 Python 2.7.10rc0 (2.7:4234b0dd2a54+, Apr 28 2015, 16:51:51) [GCC 4.8.2] on linux2 Type help, copyright, credits or license for more information. 'abcd'.decode('hex') __main__:1: DeprecationWarning: 'hex' is not a text encoding; use codecs.decode() to handle arbitrary codecs '\xab\xcd' -- Added file: http://bugs.python.org/file39226/issue19543_blacklist_transforms_py27.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19543 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Tit for tat
On Tuesday, April 28, 2015 at 1:10:14 PM UTC-7, Robert Kern wrote: On 2015-04-28 07:58, Steven D'Aprano wrote: I do believe he is trying to make a crude joke. I agree, that's what he's doing. And I find it ironic, since he started this thread, and seemed to invite a serious discussion of the topic. I thought that Patrick Grim's analysis was very interesting, showing that the Spatialized Iterated Prisoner's Dilemma (SIPD) could emulate the Wireworld cellular automaton, which is a Turing-complete system. Thus, the SIPD, a seemingly simple system at first glance, includes configurations which are formally undecidable in the Gödelian sense. I'm not sure whether Grim proved that an SIPD which includes the Tit for Tat strategy could emulate Wireworld, but it seems likely that one could be built. -- https://mail.python.org/mailman/listinfo/python-list
Re: Not possible to hide local variables
On Tuesday 28 April 2015 17:33, Cecil Westerhof wrote: If I remember correctly you can not hide variables of a class or make them read-only? In Python circles, the preferred terminology for class and instance members is attributes rather than variables. Variable is reserved for module- and function-level name bindings. But other than that, you are correct. Python practices attribute hiding by convention. Names beginning with a single underscore like _spam or obj._eggs are treated as private. Names beginning with two underscores, but not trailing with underscores, are also name-mangled: obj.__eggs will be mangled to obj._TheClass__eggs. You should avoid name-mangling unless you really need it, don't use it just in case. The convention is, if the caller messes with your private attributes or variables, and their code breaks, they have nobody to blame but themselves, and we are allowed to laugh at them. We're consenting adults here. (The only exception is C extension objects and built-ins, where messing with private data could cause a segfault.) I want to rewrite my moving average to python. The init is: def __init__(self, length): if type(length) != int: raise ParameterError, 'Parameter has to be an int' if n 0: raise ValueError, 'Parameter should be greater or equal 2' self.length = length self.old_values = [] self.current_total = 0 But when someone changes length, old_values, or current_total that would wreck havoc with my class instance. What is the best way to handle this? Don't use a class at all. Moving average is best handled as a generator. We can use a regular generator: import collections, itertools def moving_average(data, window=3): Iterate over data, yielding the simple moving average with a fixed window size. With a window size of N (defaulting to three), the simple moving average yields the average of items data[0:N], data[1:N+1], data[2:N+2], ... list(moving_average([40, 30, 50, 46, 39, 44])) [40.0, 42.0, 45.0, 43.0] it = iter(data) d = collections.deque(itertools.islice(it, window)) if len(d) != window: raise ValueError('too few data points for given window size') s = sum(d) yield s/window for x in it: s += x - d.popleft() d.append(x) yield s/window Being an iterator, it can consume data points one at a time and return results as needed, or here is an example of consuming all the data greedily: py data = [1, 2, 3, 2, 3, 5, 4, 7, 3] py list(moving_average(data)) [2.0, 2.3335, 2.6665, 3.3335, 4.0, 5.333, 4.667] If you must use a class, flag the internal attributes as private with a leading underscore. Your callers will respect that, and if they don't, all promises are null and void. -- Steve -- https://mail.python.org/mailman/listinfo/python-list
Re: Not possible to hide local variables
On Tue, Apr 28, 2015 at 6:37 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: The convention is, if the caller messes with your private attributes or variables, and their code breaks, they have nobody to blame but themselves, and we are allowed to laugh at them. We're consenting adults here. (The only exception is C extension objects and built-ins, where messing with private data could cause a segfault.) Hey. If you cause a segfault, we're still allowed to laugh at you. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
[issue24068] statistics module - incorrect results with boolean input
Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de: Removed file: http://bugs.python.org/file39220/statistics._sum.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24068 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24068] statistics module - incorrect results with boolean input
Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de: Added file: http://bugs.python.org/file39221/statistics._sum.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24068 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24068] statistics module - incorrect results with boolean input
New submission from Wolfgang Maier: the mean function in the statistics module gives nonsensical results with boolean values in the input, e.g.: mean([True, True, False, False]) 0.25 mean([True, 1027]) 0.5 This is an issue with the module's internal _sum function that mean relies on. Other functions relying on _sum are affected more subtly, e.g.: variance([1, 1027, 0]) 351234.33 variance([True, 1027, 0]) 351234.34 The problem with _sum is that it will try to coerce its result to any non-int type found in the input (so bool in the examples), but bool(1028) is just True so information gets lost. I've attached a patch preventing the type cast when it would be to bool. I don't have time to write a separate test though so if somebody wants to take over .. :) -- components: Library (Lib) files: statistics._sum.patch keywords: patch messages: 242169 nosy: steven.daprano, wolma priority: normal severity: normal status: open title: statistics module - incorrect results with boolean input type: behavior versions: Python 3.4, Python 3.5 Added file: http://bugs.python.org/file39220/statistics._sum.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24068 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17908] Unittest runner needs an option to call gc.collect() after each test
Antoine Pitrou added the comment: I still think that it's something that people can trivially implement and that has no place in the standard unittest package. -- versions: +Python 3.5 -Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17908 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Not possible to hide local variables
On 04/28, Cecil Westerhof wrote: If I remember correctly you can not hide variables of a class or make them read-only? I want to rewrite my moving average to python. The init is: def __init__(self, length): if type(length) != int: raise ParameterError, 'Parameter has to be an int' if n 0: raise ValueError, 'Parameter should be greater or equal 2' self.length = length self.old_values = [] self.current_total = 0 But when someone changes length, old_values, or current_total that would wreck havoc with my class instance. What is the best way to handle this? Prefix those names with a single leading underscore, which is the convention for private variables. This way, if some user (maybe you! ;) has a good reason to change those values in can be done, but it is quite clear that said user is mucking about with internals and they are on their own. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
Re: Best GUI for Python
Am 28.04.15 um 09:54 schrieb Steven D'Aprano: On Tuesday 28 April 2015 16:59, Chris Angelico wrote: On Tue, Apr 28, 2015 at 4:43 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I don't think that choosing UCS-2 only is any worse than any other application feature like support only jpegs, not every obscure image format GIMP supports or choose to use floating point maths instead of some numeric type with unlimited precision. You are free to make whatever trade- offs you like, and your users are free to use another application :-) True, although supporting only one image format can be worked around by converting your images. You can't just convert your UCS-4 data into UCS-2. Of course \u0079\x6f75; can :-) Lossy data compression ;) Christian -- https://mail.python.org/mailman/listinfo/python-list
Re: Best GUI for Python
On Tue, Apr 28, 2015 at 5:54 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Tuesday 28 April 2015 16:59, Chris Angelico wrote: On Tue, Apr 28, 2015 at 4:43 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I don't think that choosing UCS-2 only is any worse than any other application feature like support only jpegs, not every obscure image format GIMP supports or choose to use floating point maths instead of some numeric type with unlimited precision. You are free to make whatever trade- offs you like, and your users are free to use another application :-) True, although supporting only one image format can be worked around by converting your images. You can't just convert your UCS-4 data into UCS-2. Of course \u0079\x6f75; can :-) That's an encoding, not a conversion :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Question Installing latest Python
On Mon, Apr 27, 2015 4:55 PM CEST Steven D'Aprano wrote: On Mon, 27 Apr 2015 01:11 am, Φώντας Λαδοπρακόπουλος wrote: Τη Κυριακή, 26 Απριλίου 2015 - 6:05:50 μ.μ. UTC+3, ο χρήστης Steven D'Aprano έγραψε: On Mon, 27 Apr 2015 01:00 am, Φώντας Λαδοπρακόπουλος wrote: Hello, Can you please tell me how to install latest Python 3.4.x without disturbing the other default python v2.7.5 intallation that i currently have on my VPS server and access it as Python 3? Thank you. Not unless you tell us more about your setup. What operating system? Linux, OS X, Unix, Windows? 32-bit or 64-bit OS? Do you have root/Administrator access to the machine? If you are running Windows, do you have a C compiler? Have you read the instructions on the Python web site? -- Steven Yes, sure: CentOS 7.1 x64 bit Root Access to the VPS (1) Go here: https://www.python.org/downloads/release/python-342/ (2) Choose the source distribution you want. Save it to your hard drive on the server you will be working on. (3) Unpack the file. Do you need help with unpacking? (4) cd into the unpacked directory. Read the README file. Any questions? (5) Run these three commands from the unpacked directory as a regular user, not root: ./configure make make test (6) Take careful note of any errors from those commands. Some warnings and errors may be harmless. Feel free to ask about them here. You may prefer to ignore normal output and only see errors: ./configure /dev/null make /dev/null make test /dev/null If there are any errors you do not understand, STOP! Read the README file again. Does that tell you how to fix the problem? If not, ask for help before proceeding. (7) When you are satisfied that everything is okay run this: sudo make altinstall or if you prefer: su make altinstall (8) Test that everything works as expected by running these two commands: python -c import sys; print sys.executable python3.4 -c import sys; print(sys.executable) You should see something like this: /bin/python2.7 /usr/local/bin/python3.4 And also (if you did not read the 'make test' results carefully), e.g.: python3.4 -c import sqlite3 Useful link: https://github.com/yyuu/pyenv/wiki/Common-build-problems I always assume that failing win* (eg winsound) and startfile tests are no problem on linux. -- https://mail.python.org/mailman/listinfo/python-list
What means -?
Hi, in the Python Language Specification, I've found the delimiter - (cf. https://docs.python.org/3/reference/lexical_analysis.html#delimiters, last entry in the table´s second line). Could you please describe the effects of this delimiter? I read nothing about - by now. In addition, help(-) didn´t work. Many thanks in advance. -- https://mail.python.org/mailman/listinfo/python-list
[issue23749] asyncio missing wrap_socket
Elizabeth Myers added the comment: It seems pretty simple to just make a function that returns a new transport, something like transport = yield from loop.ssl_wrap_transport(transport). I'm not sure how to handle plaintext data left on the wire, though, unless that's not really a consideration (given most (all?) real-world protocols can (and usually do) wait for the SSL handshake before sending more data when STARTTLS has been requested). For the higher-level API, I'm thinking reader, writer = asyncio.ssl_wrap(reader, writer) maybe? You can't have half-closed SSL connections, so you would have to pass them both in. As for replacing the protocol but keeping the transport, what would be the semantics of that? I can't really think of how to do that one. I do know SMTP clears all state, but some protocols might not (IRC is a key example - this isn't usually a problem since you are supposed to negotiate it early on before you log onto the server), so this shouldn't be mandatory. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23749 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: What means -?
On Tue, Apr 28, 2015 at 1:18 PM, stehlam...@arcor.de wrote: in the Python Language Specification, I've found the delimiter - (cf. https://docs.python.org/3/reference/lexical_analysis.html#delimiters, last entry in the table´s second line). Could you please describe the effects of this delimiter? I read nothing about - by now. In addition, help(-) didn´t work. It's part of the syntax for function annotations. See here in the reference manual: https://docs.python.org/3/reference/compound_stmts.html#index-23 and/or refer to PEP 3107 for more background: https://www.python.org/dev/peps/pep-3107/ If you're interested, PEP 484 (https://www.python.org/dev/peps/pep-0484/) is attempting to chart out the future uses of function annotation for doing type checking in external tools (keep in mind that PEP 484 isn't final yet, nor has it been accepted, my impression is that it's still a work in progress). -- Jerry -- https://mail.python.org/mailman/listinfo/python-list
[issue17908] Unittest runner needs an option to call gc.collect() after each test
Serhiy Storchaka added the comment: See also issue23839 where proposed not only call gc.collect(), but clear all caches in test.regrtest. -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17908 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24070] Exceptions and arguments disappear when using argparse inside with statement
New submission from Roy Hyunjin Han: Exceptions and arguments disappear when using argparse inside a with statement. The behavior was confusing and frustrating because I could not pinpoint why certain arguments were missing or unrecognized. Unhandled exceptions inside the with statement typically trigger a traceback, unless __exit__ returns True, in which the exception is swallowed (https://www.python.org/dev/peps/pep-0343/). However, the NameError exception and tile_indices argument disappear because of a premature sys.exit (https://hg.python.org/cpython/file/default/Lib/argparse.py#l2385). ``` $ python exception-in-with.py EXPECTED Traceback (most recent call last): File exception-in-with.py, line 51, in module abc # !!! NameError: name 'abc' is not defined ACTUAL usage: exception-in-with.py [-h] --image_path PATH exception-in-with.py: error: argument --image_path is required $ python exception-in-with.py --image_path x EXPECTED == ACTUAL Traceback (most recent call last): File exception-in-with.py, line 51, in module abc # !!! NameError: name 'abc' is not defined $ python exception-in-with.py --image_path x --tile_indices 1 EXPECTED Traceback (most recent call last): File exception-in-with.py, line 51, in module abc # !!! NameError: name 'abc' is not defined ACTUAL usage: exception-in-with.py [-h] --image_path PATH exception-in-with.py: error: unrecognized arguments: --tile_indices 1 from argparse import ArgumentParser class Starter(object): def __init__(self): self.argument_parser = ArgumentParser() def __enter__(self): return self def __exit__(self, exception_type, exception_value, exception_traceback): self.argument_parser.parse_args() def add_argument(self, *args, **kw): self.argument_parser.add_argument(*args, **kw) with Starter() as starter: starter.add_argument('--image_path', metavar='PATH', required=True) abc # !!! starter.add_argument('--tile_indices', metavar='INTEGER') ``` -- components: Library (Lib) files: argparse-with-exception.py messages: 242192 nosy: invisibleroads priority: normal severity: normal status: open title: Exceptions and arguments disappear when using argparse inside with statement type: behavior versions: Python 2.7, Python 3.3 Added file: http://bugs.python.org/file39227/argparse-with-exception.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24070 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Best GUI for Python
On 2015-04-26, Cecil Westerhof ce...@decebal.nl wrote: I want to use a GUI for Python. When searching I found (beside some others) Tkinter and wxPython. From what I found it looks like Tkinter is slightly better. What would be the pros/cons of these two? Would there be a compelling reason to use another GUI? For cross-platform work, I think it comes down to wx or Qt. I've used them on Windows, Mac and Linux. Qt has the more polished and consistent API, and is more popular with the big scientific Python distros. wx has the most liberal license, and I think having to deal with only one Python binding is somewhat an advantage. I've gone back and forth between them, and could probably live with either one. Gtk is also worth looking at if you only care about Linux. Dave Cook -- https://mail.python.org/mailman/listinfo/python-list
[issue23749] asyncio missing wrap_socket
Antoine Pitrou added the comment: Reading the source now (just woke up, sorry!), the new protocol thing makes sense Good :-) I'm not sure what to do with the waiter argument or how to handle that. I'm not sure. Apparently it's used for create_connection(), so perhaps it's not necessary here? Perhaps Victor or Guido can give some insight... What I'm really trying to think of here is how to handle copying of state Well, there shouldn't be any copying necessary. The user just continues using the same protocol instance; it just calls a different transport. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23749 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11205] Evaluation order of dictionary display is different from reference manual.
Eric Snow added the comment: Changes to importlib.h should always be committed. It is the frozen importlib._bootstrap module, which is the implementation of the import system used by the interpreter. So failure to commit changes to importlib.h means your changes to importlib._bootstrap will not have any effect. -- nosy: +eric.snow ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11205 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23882] unittest discovery doesn't detect namespace packages when given no parameters
Robert Collins added the comment: Ah the user model? I think the following: If I run 'python -m unittest' in a directory, then I expect to run all of the tests contained within that directory tree, and no others. Does that definition help? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23882 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23749] asyncio missing wrap_socket
Elizabeth Myers added the comment: Reading the source now (just woke up, sorry!), the new protocol thing makes sense. I'm not sure what to do with the waiter argument or how to handle that. What I'm really trying to think of here is how to handle copying of state. I guess users will just have to do it by hand if they want to do that? I don't know if keeping the same protocol is practical and just wrapping the transport is a good idea :(. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23749 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24070] Exceptions and arguments disappear when using argparse inside with statement
Benjamin Peterson added the comment: I'm not sure why this is so surprising. parse_args in __exit__ raises a SystmExit, which the Python interpreter takes to mean the program is responsibly exiting. I don't think any other behavior would be reasonable. e.g. sys.exit() in an except clause shouldn't cause the exception to be printed. -- nosy: +benjamin.peterson resolution: - not a bug status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24070 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23058] argparse silently ignores arguments
Changes by Barry A. Warsaw ba...@python.org: -- nosy: +barry ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23058 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23058] argparse silently ignores arguments
Barry A. Warsaw added the comment: Wouldn't it be safer all around if the subparsers took different arguments, or at least different namespace 'dest', than the main parser? IMHO, yes. I agree that the semantics of what the original code is trying to do is quite ambiguous. Since the documentation says that parents= causes all the given parsers and adds their options to the parser being constructed, I'd take that to mean that the -v before the command, and the command's -v would point to the same dest. The admonition for add_help=False seems to reinforce that. The fact that this used to work should be considered an accident. I wouldn't call it a regression because the documentation does not make it clear that this should work. I think this is not a bug. Feel free to reopen this if you disagree and and cite a convincing argument for sharing dests. To be totally unambiguous, use different destinations. FWIW, I've never used parents myself. I've always done something like what honcho eventually landed. -- resolution: - not a bug status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23058 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23749] asyncio missing wrap_socket
Antoine Pitrou added the comment: As for replacing the protocol but keeping the transport, what would be the semantics of that? The protocol is not really replaced, it's wrapped. Before: SocketTransport - UserProtocol After: SocketTransport - (asyncio.sslproto.SSLProtocol - asyncio.sslproto._SSLProtocolTransport) - UserProtocol That way, the same SocketTransport (but it could be something else, e.g. a pipe transport) is always bound to the event loop; we simply insert a processing layer in the chain between the original transport and the final protocol. There are two distinct objects so that the SocketTransport sees a protocol and the UserProtocol sees a transport; but those two objects work hand in hand. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23749 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23749] asyncio missing wrap_socket
Guido van Rossum added the comment: That sounds like a good plan for the top-level APIs. But I think we may need to think about low-level APIs that handle Transports and Protocols as well. The design I had been thinking of does not do any socket-level manipulation (in fact it doesn't care if the Transport has a socket or some other way to connect to a networking peer) but it does require some cooperation of the Transport and Protocol. Let me draw some ASCII art. In the initial state (no ssl) we have an App embodied in a Protocol, talking to a Transport which abstracts away a network connection: data_received() [ --- ] App == Protocol [ ] Transport == Network [ --- ] write() (I.e., when the app wants to write to the network, it calls transport.write(); when the network has data for the app, it calls protocol.data_received().) In the final state (ssl established) I was thinking the picture would look like this (leaving the method names out): [ ][ ] App = Protocol [ ] HelperTransport = HelperProtocol [ ] Transport = Network [ ][ ] Here the Protocol at the far left and the Transport at the far right are the same objects as in the first diagram; however we've inserted a pair of helpers that handle SSL. Once the SSL connection is flowing, a write() by the app gives the data to the helper, which gives it to the SSL library. When the SSL library wants to send some (encrypted etc.) data to the network it calls write() on the rightmost Transport (the original one, which still owns the network connection). Conversely, when data arrives over the network, it is still given to the rightmost Transport via its data_received() method. This Transport then gives it to the SSL library, which eventually decrypts it (etc.) and gives it to the helper, which then calls data_received() with the decrypted plaintext on the leftmost Protocol (i.e. the App). The clever trick here is that the Protocol on the left still talks to a Transport, it's just a different Transport (owned by the helpr); similarly, the Transport on the right still talks to a Protocol, it's just a different one owned by the helper. People have proposed general stacks of Protocol/Transport pairs, but so far I haven't seen much of a use case for that. This might be that use case. In order to switch the arrangements, the helper code (which is ultimately invoked by your loop.ssl_wrap_transport() call) must first create the HelperTransport and HelperProtocol halves of the SSL helper layer, and then call set_transport()/set_protocol() on the existing App Protocol and Network Transport to change their respective associated transport and protocol. Note that the relationship between HelperTransport and HelperProtocol is not the same as that between associated Transport/Protocol pairs; the interface they use to talk to each other is completely internal to the implementation of the helper (and probably determined mostly by the needs of the underlying SSL BIO interface). Hope this helps (and hope others on the issue agree). --Guido -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23749 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23749] asyncio missing wrap_socket
Guido van Rossum added the comment: Looks like Antoine drew the same diagram but quicker. :-) Regarding the waiter arg, you can leave that None if you don't need it. It is intended to give the caller a way to block (using event loop machinery) until the connection is ready. But if your caller doesn't need it that's fine. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23749 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17908] Unittest runner needs an option to call gc.collect() after each test
Robert Collins added the comment: I'm going to disagree with michael and antoine here. The *internals* should be clean and pluggable for sure, but this is actually a pretty common thing to try, so there's no reason to force it to only be done by external plugins. Right now the way to plug this in has been complicated by the addition of module / class suites, which already perform extra work around individual tests, but in a non-introspectable / extensible fashion. So you could add this as a hook to the loader (decorate each test with some new thing) and a CLI option to use that hook for a gc collect call. Alternatively, we could face down the class/module stuff and rearrange it to be extensible (e.g. something along the lines of testresources internals - generic groups pre-post stuff) or via some interaction with TestResult but I really dislike using TestResult to control the run - I have a better layout mostly sketched in mind but haven't had time to formalise it. So I recommend the TestLoader hook point - its well within the current responsibilities for it to do this, and I don't see any long term maintenance issues. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17908 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11205] Evaluation order of dictionary display is different from reference manual.
Steve Dougherty added the comment: I've added the importlib.h changes and changed the name of the test to be more descriptive. -- Added file: http://bugs.python.org/file39228/issue11205-v3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11205 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24066] send_message should take all the addresses in the To: header into account
Changes by Ned Deily n...@acm.org: -- nosy: +barry, r.david.murray -ned.deily stage: - patch review versions: +Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24066 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Best GUI for Python
Christian Gollwitzer aurio...@gmx.de wrote: Yes, the default theme is terrible on Linux (Mac Windows uses native widgets). There are additional themes available, which are buried in some packages and a bit difficult to install, but give reasonable approximations to the QT look; I'm talking about plastik, for instance http://wiki.tcl.tk/24094 (1st picture - the layout of the test is terrible, but the widgets do look good). For some reason I've got no insights, these themes are very slow (they are based on displaying pre-rendered PNG images for the widget bits and pieces). Yet another possibility are the tileQT and tileGTK packages, which render the widgets using QT and GTK, but of course this introduces these dependencies and it might be simpler to just use QT or GTK natively. Yes, in the case of a more complex control-panel interface, it becomes worthwhile to design it with a GUI designer like Glade anyway, so that would give it the gi GTk3 widget set which looks fine. Tkinter is OK if you want to make something utilitarian like an oscilloscope interface and it does seem to be the easiest way to build an interface without a GUI builder. Kivy isn't bad, being fairly easy to use without a GUI designer, and having a modern flat smartphone-style widget set, if you like that sort of thing. You're expected to give the buttons logos and different colours. -- https://mail.python.org/mailman/listinfo/python-list
[issue24066] send_message should take all the addresses in the To: header into account
Kirill Elagin added the comment: x_x -- keywords: +patch Added file: http://bugs.python.org/file39219/multiple_to.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24066 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Best GUI for Python
On Tuesday 28 April 2015 15:32, Chris Angelico wrote: On Tue, Apr 28, 2015 at 3:10 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Monday 27 April 2015 17:22, Chris Angelico wrote: This is a problem that won't just go away. As more SMP blocks get assigned, more people will start using them, and get frustrated at your program for not letting them. (And why should an end user need to know the difference between and ⍥, that the second one works and the first doesn't?) Unless you're willing to wait for a Python that ships Tcl 9, Tkinter is a choice that restricts your end users. I'm not really arguing with you, just giving a slightly difference of emphasis... I don't think that failure to support the SMPs is a deal-breaker. Obviously, if you specifically need some subset of Unicode in the SMPs, say Phoenician, then it may be, but I'm just talking about general use. Given the generally poor support for non-ASCII characters many applications provide, any Unicode support is better than none. I agree that it isn't _in itself_ a deal-breaker; it's a choice, but most choices restrict you, the programmer. Choosing to use Python rather than C restricts what you can do easily (but so would the converse choice); choosing to use SQLite3 restricts your ability to alter tables; choosing to use PyGTK forces you to include an external dependency. But choosing to use Tkinter restricts *your users* to BMP-only. That's a consideration that takes a bit more thought to evaluate; how bad is it? You can decide on the cost of a UTF-8 string type by figuring out how often you need to know about character lengths, but how can you know the cost of a UCS-2 font renderer? On the other hand, you can use something like QT, except that judging from claims made by the KDE 4 developers, QT has a bunch of Unicode-related bugs which they refuse to fix (the one which keeps biting me is that the application will suddenly decide I am typing right-to-left, and everything I type shows up in redro gnorw eht. Only restarting the application fixes it. I don't think that choosing UCS-2 only is any worse than any other application feature like support only jpegs, not every obscure image format GIMP supports or choose to use floating point maths instead of some numeric type with unlimited precision. You are free to make whatever trade- offs you like, and your users are free to use another application :-) -- Steve -- https://mail.python.org/mailman/listinfo/python-list
[issue24067] Weakproxy is an instance of collections.Iterator
Antoine Pitrou added the comment: Those methods are defined precisely so that they can be delegated. Since virtually anything can be proxied, the weakref.proxy *class* cannot tell upfront whether the proxied object will be an Iterator or not. I don't really see how to get around that. -- nosy: +benjamin.peterson, gvanrossum versions: +Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24067 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23882] unittest discovery doesn't detect namespace packages when given no parameters
Changes by Alex Shkop a.v.sh...@gmail.com: Added file: http://bugs.python.org/file39223/issue23882_find_one_level.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23882 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23882] unittest discovery doesn't detect namespace packages when given no parameters
Alex Shkop added the comment: I'm still not sure which solution is the best. So I attach two simple patches. First one enables full recursive scan of start_dir for namespace packages. Second one loads tests only from top level namespace packages. -- keywords: +patch Added file: http://bugs.python.org/file39222/issue23882_find_all.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23882 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17620] Python interactive console doesn't use sys.stdin for input
Drekin added the comment: Note that under status quo PyOS_Readline is called from two places: the tokenizer during an interactive session and the builtin function input. The tokenizer passes promptstring encoded in sys.stdin.encoding while input() passes promtstring encoded in sys.stdout.encoding, so it is not possible to implement a readline hook correctly in the case the encodings are different. This might be considered a bug. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17620 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Not possible to hide local variables
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: The convention is, if the caller messes with your private attributes or variables, and their code breaks, they have nobody to blame but themselves, and we are allowed to laugh at them. We're consenting adults here. I would take it further: as a rule, user code should not think of modifying the contents of an object unless it is clearly documented as a supported operation. IOW, you should consider all attributes private, or at least read-only. BTW, the principle is actually enforced for some objects: hello.join = lambda *x: world Traceback (most recent call last): File stdin, line 1, in module AttributeError: 'str' object attribute 'join' is read-only hello.joinn = lambda *x: world Traceback (most recent call last): File stdin, line 1, in module AttributeError: 'str' object has no attribute 'joinn' hello.__setattr__ = lambda *x: None Traceback (most recent call last): File stdin, line 1, in module AttributeError: 'str' object attribute '__setattr__' is read-only A tougher issue is with encapsulation. A derived class might accidentally step on the toes of the base class by redefining an attribute: class Base: def __init__(self): self._secret = 17 def divulge_secret(self): return self._secret class Derived(Base): def __init__(self): self._secret = 1 print(Derived().divulge_secret()) which outputs 1. Marko -- https://mail.python.org/mailman/listinfo/python-list
[issue18383] test_warnings modifies warnings.filters when running with -W default
Alex Shkop added the comment: *ping* -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18383 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
http://garciniawowfacts.com/pure-body-elite-review/
Pure Body Elite very first thing you need to do is attempt to tell your family and friends to alter their diet plan. That is not likely going to work. So that you are probably Weight Loss Reviews likely to have to try and dismiss them. Keep healthful snacks readily available so that once you see someone eating a dessert or some other unhealthy thing you're able to go right ahead and grab one of the items of fruit or other healthful items to consume which will be beneficial for your diet.Additionally you might want to watch Television in another place than other people of the household if they're going to be doing a lot of snacking. You could also keep these things please not snack facing you, which will become a good support. http://garciniawowfacts.com/pure-body-elite-review/ -- View this message in context: http://python.6.x6.nabble.com/http-garciniawowfacts-com-pure-body-elite-review-tp5093556.html Sent from the Python - python-list mailing list archive at Nabble.com. -- https://mail.python.org/mailman/listinfo/python-list
[issue24067] Weakproxy is an instance of collections.Iterator
Gareth Rees added the comment: Not just Iterator, but Container, Hashable, Iterable, and Sized too! import weakref class C: pass o = C() w = weakref.proxy(o) from collections.abc import * isinstance(w, Container) True isinstance(w, Hashable) True isinstance(w, Iterable) True isinstance(w, Sized) True -- nosy: +Gareth.Rees ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24067 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24071] Python 2.7.8, 2.7.9 re.MULTILINE failure
New submission from Stephen Evans: A simple multiline regex fails when just the re.MULTILINE argument is used, but works when equivalent alternative methods are used. This was tested on Python2.7.8 on FreeBSD and Win32 Python2.7.9 data = re.sub(r'#.*', '', text, re.MULTILINE) # fails data = re.sub(r'(?m)#.*', '', text) # Ok data = re.sub(r'#.*', '', text, re.MULTILINE|re.DEBUG) # Ok All the expressions work correctly with Win64 Python3.4.3 The attached file has the code and with a sample of text that fails. -- components: Regular Expressions files: refail.py messages: 242205 nosy: Stephen.Evans, ezio.melotti, mrabarnett priority: normal severity: normal status: open title: Python 2.7.8, 2.7.9 re.MULTILINE failure type: behavior versions: Python 2.7 Added file: http://bugs.python.org/file39229/refail.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24071 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24071] Python 2.7.8, 2.7.9 re.MULTILINE failure
Matthew Barnett added the comment: The 4th argument of re.sub is the maximum count (0 means unlimited). help(re.sub) Help on function sub in module re: sub(pattern, repl, string, count=0, flags=0) Return the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in string by the replacement repl. repl can be either a string or a callable; if a string, backslash escapes in it are processed. If it is a callable, it's passed the match object and must return a replacement string to be used. The value of re.MULTILINE is 8: re.MULTILINE 8 therefore it'll perform a maximum of 8 substitutions. In summary: not a bug. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24071 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: A question on the creation of list of lists
On 23/04/2015 2:18 AM, subhabrata.bane...@gmail.com wrote: I have a list of file names of a directory, I want to read each one of them. After reading each one of them, I want to put the results of each file in a list. These lists would again be inserted to create a list of lists. While there's nothing wrong with for loops, Python does provide list comprehensions which can help simplify list creation. If you just want a list with each element being a list of the contents of a file: all_content = [ open(x, 'r').readlines() for x in list_of_files ] If you want a list containing a list of filenames and another list holding the content lists (which you seem to be wanting from your code): files_and_content = zip(list_of_files, all_content) Another useful way of storing data such as this is in a dictionary, using the filenames as keys: file_content = { x:open(x, 'r').readlines() for x in list_of_files } What structure is most important is, of course, dependent on what you want to do with it next. -- https://mail.python.org/mailman/listinfo/python-list
Re: Tit for tat
On Tuesday 28 April 2015 13:18, Seymore4Head wrote: In the past, I have had some measure of success with the Toot for Tail strategy. I don't believe that is a standard name for an Iterated Prisoner's Dilemma strategy. I've googled for it, using two different search engines, and neither come up with any references for Toot For Tail strategies. -- Steve -- https://mail.python.org/mailman/listinfo/python-list
Re: Best GUI for Python
On Tue, Apr 28, 2015 at 4:43 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I don't think that choosing UCS-2 only is any worse than any other application feature like support only jpegs, not every obscure image format GIMP supports or choose to use floating point maths instead of some numeric type with unlimited precision. You are free to make whatever trade- offs you like, and your users are free to use another application :-) True, although supporting only one image format can be worked around by converting your images. You can't just convert your UCS-4 data into UCS-2. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Not possible to hide local variables
If I remember correctly you can not hide variables of a class or make them read-only? I want to rewrite my moving average to python. The init is: def __init__(self, length): if type(length) != int: raise ParameterError, 'Parameter has to be an int' if n 0: raise ValueError, 'Parameter should be greater or equal 2' self.length = length self.old_values = [] self.current_total = 0 But when someone changes length, old_values, or current_total that would wreck havoc with my class instance. What is the best way to handle this? -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof -- https://mail.python.org/mailman/listinfo/python-list
Re: Best GUI for Python
On Tuesday 28 April 2015 16:59, Chris Angelico wrote: On Tue, Apr 28, 2015 at 4:43 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I don't think that choosing UCS-2 only is any worse than any other application feature like support only jpegs, not every obscure image format GIMP supports or choose to use floating point maths instead of some numeric type with unlimited precision. You are free to make whatever trade- offs you like, and your users are free to use another application :-) True, although supporting only one image format can be worked around by converting your images. You can't just convert your UCS-4 data into UCS-2. Of course \u0079\x6f75; can :-) -- Steve -- https://mail.python.org/mailman/listinfo/python-list
Re: Not possible to hide local variables
On Tue, Apr 28, 2015 at 5:33 PM, Cecil Westerhof ce...@decebal.nl wrote: If I remember correctly you can not hide variables of a class or make them read-only? I want to rewrite my moving average to python. The init is: def __init__(self, length): if type(length) != int: raise ParameterError, 'Parameter has to be an int' if n 0: raise ValueError, 'Parameter should be greater or equal 2' self.length = length self.old_values = [] self.current_total = 0 But when someone changes length, old_values, or current_total that would wreck havoc with my class instance. What is the best way to handle this? If you simply want them to never change them, but they may look at them, the best option is to do nothing. It's no different from anything else they might do; for instance, someone might inject a new 'type' into your namespace, and completely break your check. (More on that later.) If they aren't meant to look at _or_ change them, what you could do is name them _length and so on - a single leading underscore is a signal that this is a private implementation detail, not to be changed or viewed. But you can't stop people from messing you up. You can't stop people from playing around with ctypes and changing the value of 0 (and yes, that is possible - it'll probably crash Python sooner or later though!). None of that is your problem. In fact, it's not really your problem if someone gives you a length that isn't a simple integer. In the first place, they might give you a subclass of int, so a better check would be this: if not isinstance(length, int): raise ValueError(length should be integral) (note that I'm avoiding the multiple-argument syntax which doesn't work in Python 3; if ParameterError is a subclass of ValueError you could use that instead, but ValueError works) You don't even need to check that it's an integer. If you get something that can't be compared against 0, they'll get an instant exception; otherwise, the exception might come up later. But it's still not your problem. You could skip the nonnegativity check too, but that's good documentation. (I'm assuming that ought to be checking 'length', as there is no 'n' in your example.) So here's how I'd write that function: def __init__(self, length): if length 0: raise ValueError(Length should be non-negative) self.length = length self.old_values = [] self.current_total = 0 If someone changes them... not your problem. Life's so easy when you don't have to worry! ChrisA -- https://mail.python.org/mailman/listinfo/python-list
[issue23699] Add a macro to ease writing rich comparisons
Changes by Barry A. Warsaw ba...@python.org: -- nosy: +barry ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23699 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24067] Weakproxy is an instance of collections.Iterator
Fred L. Drake, Jr. added the comment: ref objects behave differently: they inherit their referent's hash value when alive, and remember it. proxy objects could be made to behave the same way. They could, yes, but that would break the proxy behavior, and the hash -- equality behavior for mutable objects. In particular, mutable objects can become equal; if the hashes were computed for the proxies before that happened, the hashes would be inappropriate later. That's pretty important. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24067 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com