[RELEASED] Python 3.2.2
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On behalf of the Python development team, I'm happy to announce the Python 3.2.2 maintenance release. Python 3.2.2 mainly fixes `a regression http://bugs.python.org/12576`_ in the ``urllib.request`` module that prevented opening many HTTP resources correctly with Python 3.2.1. Python 3.2 is a continuation of the efforts to improve and stabilize the Python 3.x line. Since the final release of Python 2.7, the 2.x line will only receive bugfixes, and new features are developed for 3.x only. Since PEP 3003, the Moratorium on Language Changes, is in effect, there are no changes in Python's syntax and built-in types in Python 3.2. Development efforts concentrated on the standard library and support for porting code to Python 3. Highlights are: * numerous improvements to the unittest module * PEP 3147, support for .pyc repository directories * PEP 3149, support for version tagged dynamic libraries * PEP 3148, a new futures library for concurrent programming * PEP 384, a stable ABI for extension modules * PEP 391, dictionary-based logging configuration * an overhauled GIL implementation that reduces contention * an extended email package that handles bytes messages * a much improved ssl module with support for SSL contexts and certificate hostname matching * a sysconfig module to access configuration information * additions to the shutil module, among them archive file support * many enhancements to configparser, among them mapping protocol support * improvements to pdb, the Python debugger * countless fixes regarding bytes/string issues; among them full support for a bytes environment (filenames, environment variables) * many consistency and behavior fixes for numeric operations For a more extensive list of changes in 3.2, see http://docs.python.org/3.2/whatsnew/3.2.html To download Python 3.2 visit: http://www.python.org/download/releases/3.2/ Please consider trying Python 3.2 with your code and reporting any bugs you may notice to: http://bugs.python.org/ Enjoy! - -- Georg Brandl, Release Manager georg at python.org (on behalf of the entire python-dev team and 3.2's contributors) -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.18 (GNU/Linux) iEYEARECAAYFAk5j3d4ACgkQN9GcIYhpnLA2BACeLZ8nSdVOoxlJw4DnbM42neeA fwAAoKTHetXsVxrEfvCWSorUhoJ083kZ =5Wm1 -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Hello, and request for help with 'dynamic grids'
Hi, I am a applications developer - originally from Windows using primarily Visual Foxpro, although I am familiar with a variety of other xbase derivatives. I now use Linux / Ubuntu, and have been actively teaching myself Python with the view to migrate most of my applications to sqlite-based database. I am looking for the ability to create dynamic grids in a window but can't for the life of me find how to do this. Here is the functionality that I desire... 1. Have a dialog appear that allows me to select a database, e.g. sqlite3 database. 2. Select table in the database and have all the records appear in a grid. Fields represented as column, width and order adjustable, rows representing records. Each cell can be edited directly. 3. I would like to create filters on this grid based on attributes in the table. So if the table is a list of names, filter and show only those people with a particular first name. For people familiar with xbase languages it equivalent to browsing a table and applying a filter. 4. Once the record is identified I would like to select the record or hit enter to have the data sent to the keyboard buffer or put into the clipboard. I have found most of these elements available. I can create dialogs, I can connect to a database, I can extract data from the tables using SQL but I can't find how to easily get these lists into a grid -- it appears to me you need to allocate list record 1 to grid row 1, list record 2 to grid row 2, etc and manage how many rows are displayed and 'page' through the table. Am I missing something? I presume that you could just supply a list or array selected using SQL from a table and just pass this data to a grid and have it manage all the basics like if the window is resized the number of rows and columns are adjusted accordingly, buffering records, etc. My investigations have generally found that windows/forms/data entry screen can be created for a specific table or view, but these are hard-wired during development. Is there anyway of rapidly defining the grid during runtime so any table can be viewed? -- Cheers Simon Simon Cropper - Open Content Creator / Website Administrator Free and Open Source Software Workflow Guides Introduction http://www.fossworkflowguides.com GIS Packages http://gis.fossworkflowguides.com bash / Pythonhttp://scripting.fossworkflowguides.com -- http://mail.python.org/mailman/listinfo/python-list
Need help with simple OOP Python question
Hi, I'm having trouble creating objects that in turn can have custom objects as variables. The code looks like this: - class A: sub = dict() def sub_add(self, cls): obj = cls() self.sub[obj.id] = obj class B(A): id = 'inst' base = A() base.sub_add(B) base.sub['inst'].sub_add(B) print # prints a blank line print base.sub['inst'] print base.sub['inst'].sub['inst'] -- Now, what I get from this is the following: __main__.B instance at 0x01FC20A8 __main__.B instance at 0x01FC20A8 Why is this? What I want is for them to be two separate objects, but it seems like they are the same one. I've tried very hard to get this to work, but as I've been unsuccessful I would really appreciate some comments on this. I'm sure it's something really easy that I just haven't thought of. Python version is 2.6.5 (I'm using Panda3D to create a 2½D game). -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with simple OOP Python question
On 9/4/11 11:47 PM, Kristofer Tengström wrote: Hi, I'm having trouble creating objects that in turn can have custom objects as variables. The code looks like this: - class A: sub = dict() You are sharing this single sub dictionary with all instances of your A class. If you want to define instance-specific attributes, define them in the __init__ method, like so: class A: def __init__(self): self.sub = dict() def sub_add(self, cls): obj = cls() self.sub[obj.id] = obj -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with simple OOP Python question
Kristofer Tengström wrote: Hi, I'm having trouble creating objects that in turn can have custom objects as variables. The code looks like this: - class A: sub = dict() Putting it into the class like this means sub is shared by all instances. def sub_add(self, cls): obj = cls() self.sub[obj.id] = obj class B(A): id = 'inst' base = A() base.sub_add(B) base.sub['inst'].sub_add(B) print # prints a blank line print base.sub['inst'] print base.sub['inst'].sub['inst'] -- Now, what I get from this is the following: __main__.B instance at 0x01FC20A8 __main__.B instance at 0x01FC20A8 Why is this? What I want is for them to be two separate objects, but it seems like they are the same one. I've tried very hard to get this to work, but as I've been unsuccessful I would really appreciate some comments on this. I'm sure it's something really easy that I just haven't thought of. Your class A needs an initialiser: class A: def __init__(self): self.sub = {} # one dict per instance # ... -- http://mail.python.org/mailman/listinfo/python-list
Re: Hello, and request for help with 'dynamic grids'
On Mon, 5 Sep 2011 03:18 pm Simon Cropper wrote: I am looking for the ability to create dynamic grids in a window but can't for the life of me find how to do this. What GUI toolkit are you using? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with simple OOP Python question
Kristofer Tengström krille...@gmail.com writes: Hi, I'm having trouble creating objects that in turn can have custom objects as variables. That terminology is rather confused. I think what you want is to have instances with their own attributes. class A: sub = dict() This binds a single object (a new empty dict) to the class attribute ‘sub’. Every instance of class ‘A’ will share the same attribute, and hence that same dict. def sub_add(self, cls): This defines a function which will be bound to the class attribute ‘sub_add’. It will, when later called as a method, receive the instance as the first parameter, bound to the local name ‘self’. obj = cls() self.sub[obj.id] = obj Here, ‘self’ will be an instance of the ‘A’ class. Each instance has no ‘sub’ attribute, so Python will find the class attribute ‘A.sub’, shared by all ‘A’ instances. You're then modifying that class attribute ‘A.sub’. […] Now, what I get from this is the following: __main__.B instance at 0x01FC20A8 __main__.B instance at 0x01FC20A8 Why is this? I hope the above explains it. What I want is for them to be two separate objects, but it seems like they are the same one. Yes. Anything you talk about in the class definition scope cannot know about any instance of that class, since the instances don't exist yet. Instead, instance attributes need to be bound to a particular instance, which means you need to have a reference to the instance; that's what ‘self’ is for. The class initialiser is a method named ‘__init__’, and is called on each newly-created instance before that instance is returned from the constructor. I advise you to work through the Python tutorial, beginning to end, which will give you a good grounding in these and other fundamental Python topics URL:http://docs.python.org/tutorial/. Work through each example, understand it by experimenting, and then proceed to the next, until you've done the lot. -- \ “If history and science have taught us anything, it is that | `\ passion and desire are not the same as truth.” —E. O. Wilson, | _o__) _Consilience_, 1998 | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing WebDAV server
Possibly. I tried this: server.py -n -c config.ini Once again, the server is up and running and when I am logging in with my browser (10.0.0.140:8081) I can see information showing up at the command prompt, showing somebody is logging is, but the same error: fshandler:get_data: \Webdav not found. During starting up the server mentioned: pywebdav:Serving data from \Webdav. In the config file it says: # main directory directory = \Webdav Perhaps my Python configuration is at fault. Fokke Is the path supposed to be absolute? In which case you'd need to have: directory=C:\path\to\Webdav instead of just directory=\Webdav I tried: directory=D:\Webdav directory=D:/Webdav To no avail. It didn.t make any difference. I surely believe my WebDAV installation is at fault. Fokke Interestingly, looking at the code that returns the fshandler:get_data: \Webdav not found message, it looks like it tests that the path given exists and then tries an os.path.isfile, then an os.path.isdir. If both fail you get the message that you see. This might be a bit of a shot in the dark but could you try the path with and without a trailing '/' or '\'? I don't currently have a windows box available to test on and figure out why it would be detected as existing but not test true for either a file or directory. Becky Lewis -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with simple OOP Python question
Hi, You are getting same object because you are overriding the dictionary update. Its printing the proper value with the last updated instance of B. If you want to see the two different instances of class B give print self.sub inside the sub_add method in class A. CHEERS CNA 9986229891 On Mon, Sep 5, 2011 at 12:17 PM, Kristofer Tengström krille...@gmail.comwrote: Hi, I'm having trouble creating objects that in turn can have custom objects as variables. The code looks like this: - class A: sub = dict() def sub_add(self, cls): obj = cls() self.sub[obj.id] = obj class B(A): id = 'inst' base = A() base.sub_add(B) base.sub['inst'].sub_add(B) print # prints a blank line print base.sub['inst'] print base.sub['inst'].sub['inst'] -- Now, what I get from this is the following: __main__.B instance at 0x01FC20A8 __main__.B instance at 0x01FC20A8 Why is this? What I want is for them to be two separate objects, but it seems like they are the same one. I've tried very hard to get this to work, but as I've been unsuccessful I would really appreciate some comments on this. I'm sure it's something really easy that I just haven't thought of. Python version is 2.6.5 (I'm using Panda3D to create a 2½D game). -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Hello, and request for help with 'dynamic grids'
On 05/09/11 17:19, Steven D'Aprano wrote: On Mon, 5 Sep 2011 03:18 pm Simon Cropper wrote: I am looking for the ability to create dynamic grids in a window but can't for the life of me find how to do this. What GUI toolkit are you using? I have looked at wxGlade, Boa Constructor, wxFormBuilder, tkinder, I have also looked through the Python website many times looking for commands that would allow me to create a GUI from scratch. -- Cheers Simon Simon Cropper - Open Content Creator / Website Administrator Free and Open Source Software Workflow Guides Introduction http://www.fossworkflowguides.com GIS Packages http://gis.fossworkflowguides.com bash / Pythonhttp://scripting.fossworkflowguides.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Hello, and request for help with 'dynamic grids'
On 05/09/11 07:18, Simon Cropper wrote: I am looking for the ability to create dynamic grids in a window but can't for the life of me find how to do this. It depends on which windowing toolkit you're planning to use. If you use PyGTK, you'd want a TreeView widget to display the list. Fill a ListStore instance with your data and give that to the TreeView. You can implement filtering and sorting on top of that using TreeModelFilter and TreeModelSort. LibreOffice and OpenOffice have database management components (I haven't used them, I assume they're somewhat similar to MS Access) - and they can be scripted using Python. Depending on what you're doing, and what you're planning to do in the future (re learning investment), that might be worth looking into. Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: Hello, and request for help with 'dynamic grids'
On 05/09/11 20:40, Thomas Jollans wrote: It depends on which windowing toolkit you're planning to use. If you use PyGTK, you'd want a TreeView widget to display the list. Fill a ListStore instance with your data and give that to the TreeView. You can implement filtering and sorting on top of that using TreeModelFilter and TreeModelSort. I have look at most. I have no preference. Are you able to point me to some resource material explaining how this can be done - e.g. a tutorial or manual? LibreOffice and OpenOffice have database management components (I haven't used them, I assume they're somewhat similar to MS Access) - and they can be scripted using Python. Depending on what you're doing, and what you're planning to do in the future (re learning investment), that might be worth looking into. 'Base' is of no value in this regard. It is not really designed for this and there is a raging debate at the moment whether it will be maintained in the future. It also fails in that it requires predefined connections and forms to be established. It would not be possible to dynamically link to a table in a database (I have established ODBC links to a SQLite database, but the driver is an un-maintained draft). I also believe that the 'base' component in libreoffice/openoffice is a java implementation not python. -- Cheers Simon Simon Cropper - Open Content Creator / Website Administrator Free and Open Source Software Workflow Guides Introduction http://www.fossworkflowguides.com GIS Packages http://gis.fossworkflowguides.com bash / Pythonhttp://scripting.fossworkflowguides.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Hello, and request for help with 'dynamic grids'
Hi Simon, I am a applications developer - originally from Windows using primarily Visual Foxpro, although I am familiar with a variety of other xbase derivatives. Check out dabodev.com. Dabo is a Python framework created by former VFP developers. Highly recommended. Malcolm -- http://mail.python.org/mailman/listinfo/python-list
Re: Hello, and request for help with 'dynamic grids'
On 05/09/11 23:23, pyt...@bdurham.com wrote: Check out dabodev.com. Dabo is a Python framework created by former VFP developers. Dabo is a great product. Spoke extensively with Ed Leafe and Paul McNett. Unfortunately the framework is not 'dynamic'. If you have an fixed database and tables it can quite quickly create a basic data entry setup and menu. Looks great when it runs. The problem is creating the window and grid on the fly. I want a program that can be used to open any database and 'data mine' and extract table content. Dabo allows RAD for an established relational databases not unknown ones. -- Cheers Simon Simon Cropper - Open Content Creator / Website Administrator Free and Open Source Software Workflow Guides Introduction http://www.fossworkflowguides.com GIS Packages http://gis.fossworkflowguides.com bash / Pythonhttp://scripting.fossworkflowguides.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with simple OOP Python question
Kristofer Tengström wrote: Thanks everyone, moving the declaration to the class's __init__ method did the trick. Now there's just one little problem left. I'm trying to create a list that holds the parents for each instance in the hierarchy. This is what my code looks like now: - class A: def __init__(self, parents=None): self.sub = dict() if parents: You should explicitly test for None here; otherwise in a call like ancestors = [] a = A(anchestors) the list passed as an argument will not be used, which makes fore confusing behaviour. self.parents = parents else: self.parents = [] def sub_add(self, cls): hierarchy = self.parents hierarchy.append(self) Here you are adding self to the parents (that should be called ancestors) and pass it on to cls(...). Then -- because it's non-empty -- it will be used by the child, too, and you end up with a single parents list. obj = cls(hierarchy) self.sub[obj.id] = obj While the minimal fix is to pass a copy def sub_add(self, cls): obj = cls(self.parents + [self]) self.sub[obj.id] = obj I suggest that you modify your node class to keep track only of the direct parent instead of all ancestors. That makes the implementation more robust when you move a node to another parent. -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with simple OOP Python question
Thanks everyone, moving the declaration to the class's __init__ method did the trick. Now there's just one little problem left. I'm trying to create a list that holds the parents for each instance in the hierarchy. This is what my code looks like now: - class A: def __init__(self, parents=None): self.sub = dict() if parents: self.parents = parents else: self.parents = [] def sub_add(self, cls): hierarchy = self.parents hierarchy.append(self) obj = cls(hierarchy) self.sub[obj.id] = obj class B(A): id = 'inst' base = A() base.sub_add(B) base.sub['inst'].sub_add(B) print print vars(base) print print vars(base.sub['inst']) print print vars(base.sub['inst'].sub['inst']) - The output from this program is the following: {'parents': [__main__.A instance at 0x02179468, __main__.B instance at 0x021794B8], 'sub': {'inst': __main__.B instance at 0x021794B8}} {'parents': [__main__.A instance at 0x02179468, __main__.B instance at 0x021794B8], 'sub': {'inst': __main__.B instance at 0x021794E0}} {'parents': [__main__.A instance at 0x02179468, __main__.B instance at 0x021794B8], 'sub': {}} As you can see, the problem looks similar to the one before: All the instances have an identical parent list. However, I don't understand why as self.parents is declared in the __init__ method. Any ideas? What I want is for the first instance to have an empty list, the second to have one element in the list and the third to have two parent elements. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why do class methods always need 'self' as the first parameter?
Chris Torek nos...@torek.net writes: [snip] Instead, we have a syntax where you, the programmer, write out the name of the local variable that binds to the first parameter. This means the first parameter is visible. Except, it is only visible at the function definition -- when you have the instance and call the instance or class method: black_knight = K() black_knight.meth1('a', 1) black_knight.meth2(2) the first parameters (black_knight, and black_knight.__class__, respectively) are magic, and invisible. Thus, Python is using the explicit is better than implicit rule in the definition, but not at the call site. I have no problem with this. Sometimes I think implicit is better than explicit. In this case, there is no need to distinguish, at the calls to meth1() and meth2(), as to whether they are class or instance methods. At the *calls* they would just be distractions. It *is* explicit also at the call site. It only is written at the left of the dot rather than at the right of the parenthesis. And that is necessary to locate which definition of the method applies. It would be silly to repeat this information after the parenthesis. Not only silly, it would be stupid as it would be a source of errors, and an example of DRY. -- Piet van Oostrum p...@vanoostrum.org WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: Hello, and request for help with 'dynamic grids'
On Sep 5, 3:18 pm, Simon Cropper simoncrop...@fossworkflowguides.com wrote: My investigations have generally found that windows/forms/data entry screen can be created for a specific table or view, but these are hard-wired during development. Is there anyway of rapidly defining the grid during runtime so any table can be viewed? The commercial product Resolver One provides a grid/spreadsheet style interface with Python scripting capabilities. I'm not sure of its current licensing status but I believe it used to be free if used on open source projects. http://www.resolversystems.com/products/resolver-one/ Each spreadsheet itself is Python code; I think it should be quite do- able to take something with introspective SQL capabilities like SQLAlchemy and have it title columns and fill them with the correct fields accordingly. Hope this helps. -- http://mail.python.org/mailman/listinfo/python-list
Re: Closures and Partial Function Application
Travis Parks jehugalea...@gmail.com writes: I also like partial function application. What is the easiest way of achieving this in Python? Would it look something like this: def foo(x, y): return x + y xFoo = lambda y: foo(10, y) from functools import partial xfoo = partial(foo, 10) -- Piet van Oostrum p...@vanoostrum.org WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing WebDAV server
becky_lewis bex.le...@gmail.com wrote in message news:a7cd34d7-ed2b-4449-8edc-a6a45b59e...@hb5g2000vbb.googlegroups.com... Possibly. I tried this: server.py -n -c config.ini Once again, the server is up and running and when I am logging in with my browser (10.0.0.140:8081) I can see information showing up at the command prompt, showing somebody is logging is, but the same error: fshandler:get_data: \Webdav not found. During starting up the server mentioned: pywebdav:Serving data from \Webdav. In the config file it says: # main directory directory = \Webdav Perhaps my Python configuration is at fault. Fokke Is the path supposed to be absolute? In which case you'd need to have: directory=C:\path\to\Webdav instead of just directory=\Webdav I tried: directory=D:\Webdav directory=D:/Webdav To no avail. It didn.t make any difference. I surely believe my WebDAV installation is at fault. Fokke Interestingly, looking at the code that returns the fshandler:get_data: \Webdav not found message, it looks like it tests that the path given exists and then tries an os.path.isfile, then an os.path.isdir. If both fail you get the message that you see. This might be a bit of a shot in the dark but could you try the path with and without a trailing '/' or '\'? I don't currently have a windows box available to test on and figure out why it would be detected as existing but not test true for either a file or directory. Hi Becky, I tried it straight away: directory=D:\Webdav\ directory=D:/Webdav/ Didn't work, in both cases the same error fshandler:get_data: \Webdav not found. I have the opinion that my WebDAV installation is at fault. The database is not created either. To have set up Python, I used python-2.7.2.msi. To install WebDAV, I used PyWebDAV-0.9.4.1 and PyXML-0.8.4 packages, both Unix/Linux. To install the, I used You dont install from Python GUI, use normal cmd, navigate to the folder you downloaded PyXML and PyWebDAV and run python setup.py install (python.exe has to be in your PATH). Then you have to find the startup-script davserver. Find your python installation directory and look intoInstall dir/Tools/Scripts, in my computer this is E:\python27\Tools\Scripts. PyXML and PyWebDAV get installed in the site-packages folder i.e. E:\python27\Lib/site-packages. You might have to look for davserver there... Shall I reïnstall the whole lot? Would it make a difference if in that case I would use ActivePython-2.7.2.5-win32-x86.msi instead of python-2.7.2.msi? Fokke -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with simple OOP Python question
On Sep 5, 3:43 pm, Peter Otten __pete...@web.de wrote: Kristofer Tengström wrote: Thanks everyone, moving the declaration to the class's __init__ method did the trick. Now there's just one little problem left. I'm trying to create a list that holds the parents for each instance in the hierarchy. This is what my code looks like now: - class A: def __init__(self, parents=None): self.sub = dict() if parents: You should explicitly test for None here; otherwise in a call like ancestors = [] a = A(anchestors) the list passed as an argument will not be used, which makes fore confusing behaviour. self.parents = parents else: self.parents = [] def sub_add(self, cls): hierarchy = self.parents hierarchy.append(self) Here you are adding self to the parents (that should be called ancestors) and pass it on to cls(...). Then -- because it's non-empty -- it will be used by the child, too, and you end up with a single parents list. obj = cls(hierarchy) self.sub[obj.id] = obj While the minimal fix is to pass a copy def sub_add(self, cls): obj = cls(self.parents + [self]) self.sub[obj.id] = obj I suggest that you modify your node class to keep track only of the direct parent instead of all ancestors. That makes the implementation more robust when you move a node to another parent. I may not be understanding the OP correctly, but going by what you've put here, I might be tempted to take this kind of stuff out of the class's and using a graph library (such as networkx) - that way if traversal is necessary, it might be a lot easier. But once again, I must say I'm not 100% sure what the OP wants to achieve... Jon. -- http://mail.python.org/mailman/listinfo/python-list
[OT] Anyone here familiar with installing Open Watcom F77?
See Subject. -- http://mail.python.org/mailman/listinfo/python-list
Best way to print a module?
Hi, If I wanted to print an entire module, skipping the attributes starting with __ is there an *optimal* way? Currently I am doing something like this. Note I am just using sys here to make the point import sys data = [] for attr in sys.__dict__.keys(): if not attr.startswith('__') and not attr.endswith('__'): attr_val = getattr(sys, attr) data.append((attr, attr_val)) data.sort() for i in data: print %s = %s % (i[0], i[1]) Clearly this would be quicker if I didn't store it and sort the output, i.e. for attr in sys.__dict__.keys(): if not attr.startswith('__') and not attr.endswith('__'): attr_val = getattr(sys, attr) print %s = %s % (attr, attr_val) Anyway if there is a better way it would be useful to hear it... Many thanks, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Anyone here familiar with installing Open Watcom F77?
On Tue, Sep 6, 2011 at 1:15 AM, W. eWatson wolftra...@invalid.com wrote: See Subject. -- http://mail.python.org/mailman/listinfo/python-list To what extent familiar? I have it installed on several computers, but only because it comes with Open Wat C/C++. With something off-topic like this, it might be better to have a real email address, so the responses can be off-list. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with simple OOP Python question
Jon Clements wrote: I must say I'm not 100% sure what the OP wants to achieve... Learn Python? ;) -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Anyone here familiar with installing Open Watcom F77?
On 9/5/2011 8:24 AM, Chris Angelico wrote: On Tue, Sep 6, 2011 at 1:15 AM, W. eWatsonwolftra...@invalid.com wrote: See Subject. -- http://mail.python.org/mailman/listinfo/python-list To what extent familiar? I have it installed on several computers, but only because it comes with Open Wat C/C++. With something off-topic like this, it might be better to have a real email address, so the responses can be off-list. ChrisA sierra_mtnview @ sbcglobal.net Here's the story. As far as I can tell F77 1.8 is not available. I've Googled quite a bit for it. My source for 1.9 is http://www.openwatcom.org/index.php/Download. It gives me: open-watcom-f77-win32-1.9.exe. When I install, there are only choices: Custom, which presumably will ask a lot of questions, and some one shot do-it without any intervention. I took the latter. ..., XP, and no Win7? I use Win7. Trouble?? Something is amiss with my install. I downloaded 1.9. I did not use any customization. I can bring up the IDE easily. Using it is a different matter. The only Getting Started in F77 manual I can find is shown as v1.8. If 1.9 is needed, I can't find it. If I use the 1.8 manual, then the contents don't match up with what I find in the F77 IDE. For example, the manual talks about a Kitchen project on page 15. Not found anywhere in the install folder. -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Anyone here familiar with installing Open Watcom F77?
Hello, On 2011-09-05 16:15:20 +, W. eWatson said: On 9/5/2011 8:24 AM, Chris Angelico wrote: On Tue, Sep 6, 2011 at 1:15 AM, W. eWatsonwolftra...@invalid.com wrote: See Subject. snip To what extent familiar? I have it installed on several computers, but only because it comes with Open Wat C/C++. With something off-topic like this, snip sierra_mtnview @ sbcglobal.net Here's the story. As far as I can tell F77 1.8 is not available. I've Googled quite a bit for it. My source for 1.9 is http://www.openwatcom.org/index.php/Download. It gives me: open-watcom-f77-win32-1.9.exe. On Usenet, comp.lang.fortran might be the best source of help for this. There's a good chance one of the regulars there can answer you within one or two posts. (I'll not cross-post, you can choose for yourself.) HTH -- Cheers! Dan Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Anyone here familiar with installing Open Watcom F77?
On 05-Sep-11 12:22 PM, Dan Nagle wrote: Hello, On 2011-09-05 16:15:20 +, W. eWatson said: On 9/5/2011 8:24 AM, Chris Angelico wrote: On Tue, Sep 6, 2011 at 1:15 AM, W. eWatsonwolftra...@invalid.com wrote: See Subject. snip To what extent familiar? I have it installed on several computers, but only because it comes with Open Wat C/C++. With something off-topic like this, snip sierra_mtnview @ sbcglobal.net Here's the story. As far as I can tell F77 1.8 is not available. I've Googled quite a bit for it. My source for 1.9 is http://www.openwatcom.org/index.php/Download. It gives me: open-watcom-f77-win32-1.9.exe. On Usenet, comp.lang.fortran might be the best source of help for this. There's a good chance one of the regulars there can answer you within one or two posts. (I'll not cross-post, you can choose for yourself.) HTH You might get in touch with someone at Waterloo University, which is located in Kitchener/Waterloo. This could have come from the 60's or 70's. Good luck. Colin W. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to print a module?
On Sep 5, 10:06 am, Martin De Kauwe mdeka...@gmail.com wrote: Hi, If I wanted to print an entire module, skipping the attributes starting with __ is there an *optimal* way? Currently I am doing something like this. Note I am just using sys here to make the point import sys data = [] for attr in sys.__dict__.keys(): if not attr.startswith('__') and not attr.endswith('__'): attr_val = getattr(sys, attr) data.append((attr, attr_val)) data.sort() for i in data: print %s = %s % (i[0], i[1]) Clearly this would be quicker if I didn't store it and sort the output, i.e. for attr in sys.__dict__.keys(): if not attr.startswith('__') and not attr.endswith('__'): attr_val = getattr(sys, attr) print %s = %s % (attr, attr_val) Anyway if there is a better way it would be useful to hear it... Many thanks, Martin Martin, have you considered that your custom function is just re- inventing the built-in dir() function? I would suggest using a list comprehension against the dir() function with a predicate to remove anything that startswith '_'. Here's some Ruby code to solve the problem. I'll let you figure out the Python equivalent. rb ['_hello', '__goodbye__', 'whatsup'].select{|x| x[0].chr != '_'} [whatsup] -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with simple OOP Python question
On 9/5/2011 9:15 AM, Kristofer Tengström wrote: Thanks everyone, moving the declaration to the class's __init__ method did the trick. Now there's just one little problem left. I'm trying to create a list that holds the parents for each instance in the hierarchy. This is what my code looks like now: - class A: def __init__(self, parents=None): self.sub = dict() if parents: self.parents = parents else: self.parents = [] def sub_add(self, cls): hierarchy = self.parents hierarchy.append(self) obj = cls(hierarchy) self.sub[obj.id] = obj Indexing objects by their internal id is usually useless. Considier whether you should be using sets rather than dicts. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Functions vs OOP
On 9/4/2011 9:13 AM, rusi wrote: On Sep 3, 9:15 pm, William Gillnore...@domain.invalid wrote: During some recent research, and re-familiarization with Python, I came across documentation that suggests that programming using functions, and programming using objects were somehow opposing techniques. Staying with (for the moment) the suggestion that OO-P and F-P are complementary, I believe it is worthwhile to distinguish syntactic OO- P vs F-P from semantic OO-P vs F-P. Syntactically: f(x) is functional x.f() is object oriented. Semantically if f's return value depends only on x ie does not depend on state it is functional (in the math sense) -- the jargon is that f is referentially transparent. Not to split hairs, but syntactically f(x) is a function in many programming paradigms. As I understand it functional programming places specific requirements on functions, i.e.referential transparency. So f(x) may or may not be functional. x.f() is also a function, but it is a member of the object x, is referred to as a 'method' of x, and uses the syntactical dot notation objectdotfunction for identification. Referential opaqueness is usually such a source of problems that it turns out good to contain the problem somewhat -- hence the wish for encapsulation. One can find in the python library itself all 4 combinations: syntactically and semantically OO : sort syntactically and semantically FP: sorted syntactically OO semantically FP: join -- http://mail.python.org/mailman/listinfo/python-list
Re: Functions vs OOP
On 9/3/2011 12:25 PM, Steven D'Aprano wrote: William Gill wrote: Are they suggesting that any function that takes an object as an argument should always be a method of that object? Yes. I can think of times when a special application, such as a converter, would take an object as an argument, but the somewhat unique nature of the application wouldn't justify changing the class to make the behavior into a method. I could extend the underlying class to include the new behavior (method), but that would mean existing instances of the base class would need conversion to the new class, requiring yet another method. Seems to me, that would be POOP (Puristic Object Oriented Programming) ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Functions vs OOP
William Gill wrote: Not to split hairs, but syntactically f(x) is a function in many programming paradigms. As I understand it functional programming places specific requirements on functions, i.e.referential transparency. So f(x) may or may not be functional. x.f() is also a function, but it is a member of the object x, is referred to as a 'method' of x, and uses the syntactical dot notation objectdotfunction for identification. Functional programming is not about writing a programm with functions (google it for more info). This may cause some confusion. Your original post was about functions vs methods, which are identical except some syntax detail. FYI, in python x.f() is equivalent to f(x). In an OOP world one will prefer the x.f() form. JM -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to print a module?
Martin De Kauwe mdeka...@gmail.com wrote: If I wanted to print an entire module, skipping the attributes starting with __ is there an *optimal* way? Your question is somewhat ambiguous. When I read print an entire module, I assumed you were asking for a way to print the source code, perhaps with syntax coloring. Surely there is no reason to have an optimal method of doing this -- this is never going to be in an inner loop. If you have a method that works, there is little justification to optimize... -- Tim Roberts, t...@probo.com Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
One line command line filter
It seems unreasonably hard to write simple one-line unix command line filters in python: eg: ls | python -c something print x.upper() to get at sys.stdin or similar needs an import, which makes a subsequent for-loop illegal. python -c import sys; for x in sys.stdin(): print x - SyntaxError Am I missing something obvious? The best I've come up with is to use sitecustomize.py to add to __builtin__ def stdin(): import sys for x in sys.stdin(): if not x: return yield x.strip() import __builtin__ __builtin__.stdin = stdin This allows ls | python -c for x in stdin(): print x.upper() Is there a better solution - if not is this worth a PEP? -- http://mail.python.org/mailman/listinfo/python-list
Re: One line command line filter
On 05/09/11 22:38, Jon Redgrave wrote: It seems unreasonably hard to write simple one-line unix command line filters in python: eg: ls | python -c something print x.upper() to get at sys.stdin or similar needs an import, which makes a subsequent for-loop illegal. python -c import sys; for x in sys.stdin(): print x - SyntaxError Am I missing something obvious? ls | python -c for line in __import__('sys').stdin: print (line.upper()) -- http://mail.python.org/mailman/listinfo/python-list
Re: One line command line filter
Am I missing something obvious? ls | python -c for line in __import__('sys').stdin: print (line.upper()) Ah, so I am missing something - it is possible - but 'obvious'? Do people think it should be more accessible -- http://mail.python.org/mailman/listinfo/python-list
Running Python Demo on the Web?
Python has been ported to the web browser at pythonfiddle.com. Python Fiddle can import snippets of code that you are reading on a web page and run them in the browser. It supports a few popular libraries. Another common usage is to post code on the site to allow other people to play around with it. Also, it can be used to demonstrate a working program. -- http://mail.python.org/mailman/listinfo/python-list
Re: One line command line filter
On 9/5/2011 4:38 PM, Jon Redgrave wrote: It seems unreasonably hard to write simple one-line unix command line filters in python: eg: ls | python -c something print x.upper() to get at sys.stdin or similar needs an import, which makes a subsequent for-loop illegal. python -c import sys; for x in sys.stdin(): print x- SyntaxError Am I missing something obvious? The doc says -c command Execute the Python code in command. command can be one or more statements separated by newlines, However, I have no idea how to put newlines into a command-line string. Changing '; ' to '\n' does not work, at least not in Windows. The '\n' is passed on to Python as 2 chars, and the '\' is seen as the line-continuation char and the 'n' as illegal following it. Will a *nix shell 'cook' the string and convert '\n' to a literal newline before passing it to Python? For *nix, I would expect the EOF mechanism to work. Have you tried that? That said, Python is designed for named multiple-statement programs, just as it is designed for named multiple-statement functions. Or it is designed for interactive work. The following works: dir | python -c while True: print(input()) except that it finishes with an error traceback: Traceback (most recent call last): File string, line 1, in module EOFError: EOF when reading a line Perhaps tolerable if Python is at the end of the pipe, not otherwise. Is there a better solution - if not is this worth a PEP? PEPs have to propose a concrete solution, preferably with some previous discussion. I take is that your proposal would be to add another builtin means to access stdin. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Functions vs OOP
On 9/5/2011 1:45 PM, William Gill wrote: On 9/4/2011 9:13 AM, rusi wrote: On Sep 3, 9:15 pm, William Gillnore...@domain.invalid wrote: During some recent research, and re-familiarization with Python, I came across documentation that suggests that programming using functions, and programming using objects were somehow opposing techniques. Staying with (for the moment) the suggestion that OO-P and F-P are complementary, I believe it is worthwhile to distinguish syntactic OO- P vs F-P from semantic OO-P vs F-P. Syntactically: f(x) is functional x.f() is object oriented. Semantically if f's return value depends only on x ie does not depend on state it is functional (in the math sense) -- the jargon is that f is referentially transparent. Not to split hairs, but syntactically f(x) is a function in many programming paradigms. As I understand it functional programming places specific requirements on functions, i.e.referential transparency. So f(x) may or may not be functional. In Python, it may be a parameterized procedure. Some languages separate functions and procedures (also called subroutines). Python does not. (Or you could say that it makes procedures into functions with side-effects by returning None by default). x.f() is also a function, but it is a member of the object x, is referred to as a 'method' of x, and uses the syntactical dot notation objectdotfunction for identification. Referential opaqueness is usually such a source of problems that it turns out good to contain the problem somewhat -- hence the wish for encapsulation. One can find in the python library itself all 4 combinations: syntactically and semantically OO : sort syntactically and semantically FP: sorted syntactically OO semantically FP: join -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: One line command line filter
On 9/5/2011 5:32 PM, Jon Redgrave wrote: Am I missing something obvious? ls | python -c for line in __import__('sys').stdin: print (line.upper()) Ah, so I am missing something - it is possible - but 'obvious'? Do people think it should be more accessible __import__ is well-documented and is listed in the index of the builtin functions chapter. Direct use of __import__() is rare, except in cases where you want to import a module whose name is only known at runtime. could be explanded to include or where you want to import as part of an expression Every Python programmer should peruse that chapter to learn what is available for possible future use. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to print a module?
Hi, Tim yes I had a feeling my posting might be read as ambiguous! Sorry I was trying to quickly think of a good example. Essentially I have a set of .ini parameter files which I read into my program using configobj, I then replace the default module parameters if the user file is different (in my program). When it comes to writing the data back out I need to potentially loop over 5 module files and I need to ignore the superfluous information. My guess is that the way I am doing it might be a little on the slow side, hence the posting. Like you said it might be that the way I am doing it is fine, I just wanted to see if there was a better way that is all. Rantingrick I did actually try the dir() to start with, I can't remember why I changed back. I will try your suggestion and see (thanks) So instead of sys as per my example my module more realistically looks like this: params.py apples = 12.0 cats = 14.0 dogs = 1.3 so my fuller example then import sys sys.path.append(/Users/mdekauwe/Desktop/) import params #params.py contains #apples = 12.0 #cats = 14.0 #dogs = 1.3 fname = test.asc try: ofile = open(fname, 'w') except IOError: raise IOError(Can't open %s file for write % fname) data = [] for attr in params.__dict__.keys(): if not attr.startswith('__') and not attr.endswith('__'): attr_val = getattr(params, attr) data.append((attr, attr_val)) data.sort() try: ofile.write([params]\n) for i in data: ofile.write(%s = %s\n % (i[0], i[1])) except IOError: raise IOError(Error writing params files, params section) etc, etc thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Hello, and request for help with 'dynamic grids'
On 06/09/11 00:40, alex23 wrote: On Sep 5, 3:18 pm, Simon Croppersimoncrop...@fossworkflowguides.com wrote: My investigations have generally found that windows/forms/data entry screen can be created for a specific table or view, but these are hard-wired during development. Is there anyway of rapidly defining the grid during runtime so any table can be viewed? The commercial product Resolver One provides a grid/spreadsheet style interface with Python scripting capabilities. I'm not sure of its current licensing status but I believe it used to be free if used on open source projects. http://www.resolversystems.com/products/resolver-one/ Each spreadsheet itself is Python code; I think it should be quite do- able to take something with introspective SQL capabilities like SQLAlchemy and have it title columns and fill them with the correct fields accordingly. Hope this helps. Alex, The Resolver Package looks good. Not exactly open source though. I equate it to a proprietary package that can at times be used for free by select groups. The product creates spreadsheets with python code in the background (instead of say VBA in Excel or Basic in Calc). Access to a database still needs to be hard-wired, so it does not act as a 'dynamic' viewer. The product works pretty much like Excel and Calc in this manner. Sheets can be shared, although the Resolver Exchange website does not clarify the licence under which samples are released (GPL, CC, etc), so it is debatable how any of this could reliably be used in creation of derivatives. From what I can glean from this page... http://www.resolversystems.com/opensource/ ... Resolver will allow you to use the package if you are an open source project to create spreadsheets that can be redistributed. For people to use these sheets they need to download the viewer or purchase the package. -- Cheers Simon Simon Cropper - Open Content Creator / Website Administrator Free and Open Source Software Workflow Guides Introduction http://www.fossworkflowguides.com GIS Packages http://gis.fossworkflowguides.com bash / Pythonhttp://scripting.fossworkflowguides.com -- http://mail.python.org/mailman/listinfo/python-list
Re: One line command line filter
Terry Reedy wrote: The doc says -c command Execute the Python code in command. command can be one or more statements separated by newlines, However, I have no idea how to put newlines into a command-line string. I imagine that it depends on the shell you are using, but bash on Linux makes it simple: double quotes ... are like Python's triple-quoted strings in that they can include newlines. [steve@sylar python]$ ls f*.py | python -c import sys print sys.stdin.read() factorial.py fetchqm.py fib.py fileutils.py findsingle.py fixascii.py fix.py frange.py frequencies.py Other shells may be different. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to print a module?
Trying to follow the suggestion this would be the alternate implementation. import sys sys.path.append(/Users/mdekauwe/Desktop/) import params #params.py contains #apples = 12.0 #cats = 14.0 #dogs = 1.3 fname = test.asc try: ofile = open(fname, 'w') except IOError: raise IOError(Can't open %s file for write % fname) attributes = [attr for attr in dir(params) if not attr.startswith('__')] attributes.sort() try: ofile.write([params]\n) for i in attributes: ofile.write(%s = %s\n % (i, getattr(params, i))) except IOError: raise IOError(Error writing params files, params section) Is that a better version? I honestly don't know. thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: One line command line filter
Jon Redgrave wrote: It seems unreasonably hard to write simple one-line unix command line filters in python: eg: ls | python -c something print x.upper() Python is neither bash nor Perl. It is not intended to compete in the quick and dirty one-liner commands stakes. However, you might like to consider ipython, which is intended as a complete Python shell, not just an interactive interpreter. http://ipython.org/ [...] The best I've come up with is to use sitecustomize.py to add to __builtin__ If you're a system administrator who wants to replace bash one-liners at the command line with Python one-liners, sure, why not? If you build up a useful collection of sys admin tools or recipes, you might like to consider sharing them. Perhaps if Python was used more by sys admins, there might be less resistance to making it easier to compete with bash one-liners. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to print a module?
Tim Roberts wrote: Martin De Kauwe mdeka...@gmail.com wrote: If I wanted to print an entire module, skipping the attributes starting with __ is there an *optimal* way? Your question is somewhat ambiguous. When I read print an entire module, I assumed you were asking for a way to print the source code, perhaps with syntax coloring. Surely there is no reason to have an optimal method of doing this -- this is never going to be in an inner loop. Regardless of an inner loop or not, the time required for IO (reading the file from disk, writing it to a printer) will be much larger than the time required to skip dunder (double-underscore) objects. If you have a method that works, there is little justification to optimize... Pretty much. HOWEVER, having agreed with you in general, in this specific case it is obvious to me from context that the OP doesn't want to print the source code of the module, but the module's names and their values. I'd try a couple of approaches: - use dir() or vars() to get the module's names, then loop and print each one; - make a shallow copy of the module __dict__, less dunder names, and pass it to the prettyprint module for printing. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Functions vs OOP
On 9/5/2011 3:04 PM, Jean-Michel Pichavant wrote: William Gill wrote: Not to split hairs, but syntactically f(x) is a function in many programming paradigms. As I understand it functional programming places specific requirements on functions, i.e.referential transparency. So f(x) may or may not be functional. x.f() is also a function, but it is a member of the object x, is referred to as a 'method' of x, and uses the syntactical dot notation objectdotfunction for identification. Functional programming is not about writing a programm with functions snip. This may cause some confusion. It can, and it did. That was the impression I (incorrectly) got from the documentation. Which didn't make sense to me. (google it for more info). I can, and I did. That, and the answers I got in this ng are how I corrected my misconception. Your original post was about functions vs methods, which are identical except some syntax detail. FYI, in python x.f() is equivalent to f(x). In an OOP world one will prefer the x.f() form. No, my original post was about how (based on the aforementioned misconception) the documentation seemed to suggest that OOP should never have free standing functions, only methods. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why do class methods always need 'self' as the first parameter?
Chris Torek nos...@torek.net writes: [snip] when you have [an] instance and call [an] instance or class method: [note: I have changed the names very slightly here, and removed additional arguments, on purpose] black_knight = K() black_knight.spam() black_knight.eggs() the first parameters ... are magic, and invisible. Thus, Python is using the explicit is better than implicit rule in the definition, but not at the call site. ... In article m2wrdnf53u@cochabamba.vanoostrum.org Piet van Oostrum p...@vanoostrum.org wrote: It *is* explicit also at the call site. It only is written at the left of the dot rather than at the right of the parenthesis. It cannot possibly be explicit. The first parameter to one of the method functions is black_knight, but the first parameter to the other method is black_knight.__class__. Which one is which? Is spam() the instance method and eggs() the class method, or is spam() the class method and eggs the instance method? (One does not, and should not, have to *care*, which is kind of the point here. :-) ) And that is necessary to locate which definition of the method applies. By that I assume you mean the name black_knight here. But the name is not required to make the call; see the last line of the following code fragment: funclist = [] ... black_knight = K() funclist.append(black_knight.spam) funclist.append(black_knight.eggs) ... # At this point, let's say len(funclist) 2, # and some number of funclist[i] entries are ordinary # functions that have no special first parameter. random.choice(funclist)() It would be silly to repeat this information after the parenthesis. Not only silly, it would be stupid as it would be a source of errors, and an example of DRY. Indeed. But I believe the above is a demonstration of how the self or cls parameter is in fact implicit, not explicit. (I am using python 2.x, and doing this in the interpreter: random.choice(funclist) -- without the parentheses to call the function -- produces: bound method K.[name omitted] of __main__.K object at 0x249f50 bound method type.[name omitted] of class '__main__.K' function ordinary at 0x682b0 The first is the instance method, whose name I am still keeping secret; the second is the class method; and the third is the ordinary function I added to the list. The actual functions print their own name and their parameters if any, and one can see that the class and instance methods get one parameter, and the ordinary function gets none.) -- In-Real-Life: Chris Torek, Wind River Systems Intel require I note that my opinions are not those of WRS or Intel Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603 email: gmail (figure it out) http://web.torek.net/torek/index.html -- http://mail.python.org/mailman/listinfo/python-list
Re: One line command line filter
On 9/5/2011 7:18 PM, Steven D'Aprano wrote: Terry Reedy wrote: The doc says -ccommand Execute the Python code in command. command can be one or more statements separated by newlines, However, I have no idea how to put newlines into a command-line string. I imagine that it depends on the shell you are using, but bash on Linux makes it simple: double quotes ... are like Python's triple-quoted strings in that they can include newlines. [steve@sylar python]$ ls f*.py | python -c import sys print sys.stdin.read() factorial.py fetchqm.py I was guessing that whoever wrote the doc could do something like that. As far as I know, there is no way to escape a newline with Windows cmd.exe. (Someone please tell me if I am wrong!) An unmatched quote is either ignored or matched by the newline! C:\Programs\Python32 python -c print('haha') haha -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Why do class methods always need 'self' as the first parameter?
On Aug 31, 9:35 am, T. Goodchild tgoodch...@gmail.com wrote: I’m new to Python, and I love it. The philosophy of the language (and of the community as a whole) is beautiful to me. Welcome aboard mate! But one of the things that bugs me Oh here we go! :-) is the requirement that all class methods have 'self' as their first parameter. On a gut level, to me this seems to be at odds with Python’s dedication to simplicity. It will will seem odd at first. I too hated typing all those selfs all the time. But believe me my new friend in no time those selfs will roll of your fingers with great ease. You'll forget how much you hate them and find much more to complain about. Like for instance: I really lament the missing redundancy of Explicit Lexical Scoping in python. For me global variables should have to be qualified. For example, consider Python’s indent-sensitive syntax. [...] and the result was a significantly improved signal-to-noise ratio in the readability of Python code. Yes, forced indention is my favorite aspect of Python! So why is 'self' necessary on class methods? It could be that Guido has a exaggerated self importance and just liked the sound of all those selfs whist reading source code. However i believe the real reason is really readability! It takes a while to understand this aspect because the natural human response is to be lazy (for instance i could have used used to in the previous sentence if i was slothful). We are all inherently lazy beings who need structure to keep us from spiraling out of control into the abyss of selfishness. GvR: Computer Scientist and Behavioral psychologist. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why do class methods always need 'self' as the first parameter?
On Tue, 6 Sep 2011 11:10 am Chris Torek wrote: black_knight = K() black_knight.spam() black_knight.eggs() the first parameters ... are magic, and invisible. Thus, Python is using the explicit is better than implicit rule in the definition, but not at the call site. ... In article m2wrdnf53u@cochabamba.vanoostrum.org Piet van Oostrum p...@vanoostrum.org wrote: It *is* explicit also at the call site. It only is written at the left of the dot rather than at the right of the parenthesis. It cannot possibly be explicit. The first parameter to one of the method functions is black_knight, but the first parameter to the other method is black_knight.__class__. I think you are expecting more explicitness than actually required. There are degrees of explicitness: - The current President of the United States is a black man. - On 6th September 2011, the duly constituted President of the United States of America is a black man. - On 6th September 2011, the duly constituted government official with the title of President of the nation known as the United States of America is an individual member of the species Homo sapiens with XY chromosomes and of recent African ancestry. As opposed to implicit: - He is a black guy. There is no requirement for every last gory detail to be overtly specified in full. I quote from WordNet: explicit adj 1: precisely and clearly expressed or readily observable; leaving nothing to implication; explicit instructions; she made her wishes explicit; explicit sexual scenes [syn: expressed] [ant: implicit] 2: in accordance with fact or the primary meaning of a term [syn: denotative] Note the second definition in particular: in accordance with the primary meaning of a term: the primary meaning of class method is that it receives the class rather than the instance as first argument. The explicit is better than implicit Zen should, in my opinion, be best understood as a recommendation that code should, in general, avoid getting input from context. In general, functions should avoid trying to decide which behaviour is wanted according to context or the environment: def func(x): if running_in_a_terminal(): print The answer is, (x+1)/2 else: printer = find_a_printer() if printer is not None: printer.send((x+1)/2, header=func(%r)%x, footer=Page 1) else: # Try sending email to the current user, the default user, # postmaster or root in that order. msg = make_email(The answer is, (x+1)/2) for user in [get_current_user(), DEFAULT_USER, root@localhost.localdomain, ...]: result = send_mail(msg, to=user) if result == 0: break else: # Fall back on beeping the speakers in Morse code ... (what if I want to beep the speakers from the terminal?), but not as a prohibition against code like this: def factorial(x): # Return the factorial of the integer part of x. n = int(x) if n = 1: return 1 return n*factorial(n-1) There's no need to require the user to explicitly call int(x) before calling factorial just to satisfy the Zen. A function is free to process arguments as required, even to throw out information (e.g. float - int, instance - class). What it shouldn't do is *add* information implied by context (or at least, it should be very cautious in doing so, and document it carefully, and preferably allow the caller to easily override such implied data). Which one is which? Is spam() the instance method and eggs() the class method, or is spam() the class method and eggs the instance method? (One does not, and should not, have to *care*, which is kind of the point here. :-) ) You can't tell just from the syntax used to call them: function(arg) bound_method(arg) builtin_function_or_method(arg) callable_instance(arg) type(arg) all use the same syntax. There is no requirement that you should be able to tell *everything* about a line of code just from the syntax used. If you want to know whether black_knight.spam is an instance method or a class method, or something else, use introspection to find out. By that I assume you mean the name black_knight here. But the name is not required to make the call; see the last line of the following code fragment: funclist = [] ... black_knight = K() funclist.append(black_knight.spam) funclist.append(black_knight.eggs) ... # At this point, let's say len(funclist) 2, # and some number of funclist[i] entries are ordinary # functions that have no special first parameter. random.choice(funclist)() Irrelevant. The instance used for the bound method is explicitly specified when you create it. But there's no requirement that you need to explicitly specify the instance every single time you
[issue3132] implement PEP 3118 struct changes
Stefan Krah stefan-use...@bytereef.org added the comment: Yes, definitely. I'm going to push a new memoryview implementation (complete for all 1D/native format cases) in a couple of days. Once that is done, perhaps we could create a memoryview-struct branch on top of that. -- nosy: +skrah ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3132 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11682] PEP 380 reference implementation for 3.3
Zbyszek Szmek zbys...@in.waw.pl added the comment: I've created some documentation... The patches are the bitbucket repo. Nothing is added to the tutorial, because I think that this isn't material for a newcomer to python. The tutorial doesn't mention generator.throw() and send() either, just talks a little about writing simple generator functions. -- hgrepos: +66 nosy: +zbysz ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11682 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1172711] long long support for array module
Changes by Armin Rigo ar...@users.sourceforge.net: -- nosy: -arigo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1172711 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12897] Support for iterators in multiprocessing map
New submission from andrew cooke and...@acooke.org: http://stackoverflow.com/questions/7306522/combining-itertools-and-multiprocessing/7307078 suggests (and the idea itself seems reasonable) that it would sometimes be useful for multiprocessing to operate correctly (ie lazily) with lazy input (iterables). for example, if the input is large, or perhaps generated by some other process on demand. obviously this complicates matters, given the asynchronous nature of a worker pool, and would mean re-allocating the results list as required. but in principle i suspect it would be possible and might be a useful extension. -- components: Library (Lib) messages: 143511 nosy: acooke priority: normal severity: normal status: open title: Support for iterators in multiprocessing map type: feature request versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12897 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12888] html.parser.HTMLParser.unescape works only with the first 128 entities
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 9896fc2a8167 by Ezio Melotti in branch '3.2': #12888: Fix a bug in HTMLParser.unescape that prevented it to escape more than 128 entities. Patch by Peter Otten. http://hg.python.org/cpython/rev/9896fc2a8167 New changeset 7b6096852665 by Ezio Melotti in branch 'default': #12888: merge with 3.2. http://hg.python.org/cpython/rev/7b6096852665 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12888 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12888] html.parser.HTMLParser.unescape works only with the first 128 entities
Ezio Melotti ezio.melo...@gmail.com added the comment: Fixed, thanks for the report and the patch! -- components: +Library (Lib) -None resolution: - fixed stage: commit review - committed/rejected status: open - closed versions: +Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12888 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12117] Failures with PYTHONDONTWRITEBYTECODE: test_importlib, test_imp, test_distutils, test_packaging, test_runpy, test_import
Éric Araujo mer...@netwok.org added the comment: Alright, closing. -- resolution: - fixed stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12117 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12886] datetime.strptime parses input wrong
Heiðar Rafn Harðarson heidar.r...@hrolfsskali.net added the comment: My understanding of the python documentation and the ISO 8601 standard is that the digits in a timestamp representing hours, minutes and seconds shall always be in pairs of 2 digits (hh, mm, ss), i.e. when a number is less than 10 it should be preceded by 0. In the example I give, the minute figure is split between minutes and seconds by the python library function which I consider a bug: datetime.datetime.strptime('20110817T1234','%Y%m%dT%H%M%S') gives datetime.datetime(2011, 8, 17, 12, 3, 4) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12886 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12659] Add tests for packaging.tests.support
Éric Araujo mer...@netwok.org added the comment: Follow the link titled “review” on the right of your patch in the list of files above the messages. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12659 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12886] datetime.strptime parses input wrong
Heiðar Rafn Harðarson heidar.r...@hrolfsskali.net added the comment: This issue is also discussed here: http://bugs.python.org/issue5979 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12886 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10914] Python sub-interpreter test
Éric Araujo mer...@netwok.org added the comment: Except that it didn't work under Windows... Ah. If it was an extension module, I’d have a clue (the debug thing), but I know nothing about embedding. An alternative would be to install the file with the msi system and use a project file to have it compiled (sounds like much hassle). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10914 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10914] Python sub-interpreter test
Antoine Pitrou pit...@free.fr added the comment: Ah. If it was an extension module, I’d have a clue (the debug thing), but I know nothing about embedding. An alternative would be to install the file with the msi system and use a project file to have it compiled (sounds like much hassle). Agreed, but it's not something that I know how to do :) (and yet, of course, it would be good to test that embedding works under Windows too, as well as under Unix installs) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10914 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11957] re.sub confusion between count and flags args
Ezio Melotti ezio.melo...@gmail.com added the comment: See also #12888 for an error in the stdlib caused by this. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11957 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12841] Incorrect tarfile.py extraction
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 2bc122347351 by Lars Gustäbel in branch '3.2': Issue #12841: Fix tarfile extraction of non-existent uids/gids. http://hg.python.org/cpython/rev/2bc122347351 New changeset da59abc0ce3b by Lars Gustäbel in branch 'default': Merge with 3.2: Issue #12841: Fix tarfile extraction of non-existent uids/gids. http://hg.python.org/cpython/rev/da59abc0ce3b New changeset b64ef2951093 by Lars Gustäbel in branch '2.7': Issue #12841: Fix tarfile extraction of non-existent uids/gids. http://hg.python.org/cpython/rev/b64ef2951093 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12841 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7219] Unhelpful error message when a distutils package install fails due to a permissions error
higery shoulderhig...@gmail.com added the comment: I have run the 'test_install_lib' on cpython3.3(windows version), the 'test_install_error' failed. The detail is: *FAIL: test_install_error (__main__.InstallLibTestCase) -- Traceback (most recent call last): File D:\add-develop-command\Lib\distutils\tests\test_install_lib.py, line 112, in test_install_error cmd.run() AssertionError: DistutilsFileError not raised* The corresponding lines are: * with self.assertRaises(DistutilsFileError) as cm: cmd.run()* -- Added file: http://bugs.python.org/file23101/unnamed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7219 ___I have run the #39;test_install_lib#39; on cpython3.3(windows version), the #39;test_install_error#39; failed.brbrThe detail is: brbrbFAIL: test_install_error (__main__.InstallLibTestCase)br--br Traceback (most recent call last):br File quot;D:\add-develop-command\Lib\distutils\tests\test_install_lib.pyquot;, line 112, in test_install_errorbr   cmd.run()brAssertionError: DistutilsFileError not raised/bbr brThe corresponding lines are:brbbrwith self.assertRaises(DistutilsFileError) as cm:br       cmd.run()/bbr ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12898] add opendir() for POSIX platforms
Ross Lagerwall rosslagerw...@gmail.com added the comment: Also see fdopendir(3) which allows you to pass an open file descriptor to get a C dirent struct. This is implemented in the os module too but instead of returning a struct, it returns a list. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12898 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12841] Incorrect tarfile.py extraction
Lars Gustäbel l...@gustaebel.de added the comment: Close as fixed. Thanks all! -- resolution: - fixed stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12841 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12898] add opendir() for POSIX platforms
New submission from Larry Hastings la...@hastings.org: With the recent spate of POSIX *at() functions added to os, we now have a bunch of places in the API that take directory fds. But afaict there's no way to get a directory fd in Python! The only calls to opendir() in the tree are internal, in os.listdir() and in the import machinery. (Though in practice most people will use AT_FDCWD anyway.) I propose adding a new function, os.opendir(), the implementation to be much the same as (aka a hacked-up copy and paste of) os.unlink() in Modules/posixmodule.c. I'd be happy to contribute the patch. -- components: Extension Modules messages: 143522 nosy: larry priority: normal severity: normal status: open title: add opendir() for POSIX platforms type: feature request versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12898 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7219] Unhelpful error message when a distutils package install fails due to a permissions error
Éric Araujo mer...@netwok.org added the comment: I really don't think C error messages are portable, so you shouldn't test for them :) Too bad. I’ll have to be satisfied with a manual test from Michael then. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7219 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12898] add opendir() for POSIX platforms
Ross Lagerwall rosslagerw...@gmail.com added the comment: opendir opens a C dirent structure with an underlying file descriptor. However, to open a directory file descriptor, simple use: os.open(/tmp, os.O_RDONLY) This can then be used as the fd to the functions which require a directory fd like os.openat() Cheers Ross -- nosy: +rosslagerwall ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12898 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12899] Change os.utimensat() and os.futimens() to use float for atime mtime
New submission from Larry Hastings la...@hastings.org: The new functions os.futimens() and os.utimensat() update the timestamps of a file with nanosecond precision. However, both functions take atime and mtime as a tuple: (seconds since epoch, nanoseconds). Contrast this with os.utime(), which produces atime and mtime as a floating point number of seconds since epoch. Why the mismatch between the APIs? It simply forces the user to do the conversion themselves. You can see this in the regression tests for these two functions--there's a lot of multiplying by 1e9 going on. The only justification I can contrive is that the conversion of (secs+(1e-9*nsecs)) can be inaccurate; a double would need roughly one more byte of mantissa to be able to accurately preserve all possible nanosecond values. But that ship has sailed--os.utime() produces inaccurate results, and afaik there's no other way to do it in the Python library. os.futimens() and os.utimensat() should take atime and mtime in the floating-point format as produced by os.utime(). I'm happy to contribute the patch. -- components: Extension Modules messages: 143529 nosy: larry priority: normal severity: normal status: open title: Change os.utimensat() and os.futimens() to use float for atime mtime type: behavior versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12899 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8286] distutils: path '[...]' cannot end with '/' -- need better error message
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 6cd8c1582dff by Éric Araujo in branch '3.2': Warn instead of crashing because of invalid path in MANIFEST.in (#8286). http://hg.python.org/cpython/rev/6cd8c1582dff New changeset b42661daa5cc by Éric Araujo in branch 'default': Merge fix for #8286 from 3.2 http://hg.python.org/cpython/rev/b42661daa5cc -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8286 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8286] distutils: path '[...]' cannot end with '/' -- need better error message
Éric Araujo mer...@netwok.org added the comment: This should now be fixed. -- resolution: - fixed stage: test needed - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8286 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11155] multiprocessing.Queue's put() signature differs from docs
Senthil Kumaran sent...@uthcode.com added the comment: anikom15's first patch seems correct. In the multiprocessing.py, the the arg 'obj' can be safely replaced with 'item' to be consistent with the docs. As this is not a keyword arg, it does not stand any chance of breaking any backwards compatibility. It looks me to that when multiprocessing' Queue.put was coding the first arg was wrongly mentioned as 'obj' instead of 'item'. I shall commit the first patch unless someone objects to the above reasoning. -- assignee: docs@python - orsenthil nosy: +orsenthil ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11155 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12897] Support for iterators in multiprocessing map
Antoine Pitrou pit...@free.fr added the comment: Since it's a feature request, I would suggest to look whether it can apply to concurrent.futures instead. -- nosy: +pitrou versions: +Python 3.3 -Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12897 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12885] distutils.filelist.findall() fails on broken symlink in Py2.x
Éric Araujo mer...@netwok.org added the comment: I've come across it as I'm creating a Debian package of the Python package in the same tree I think a lot of people are doing this. The broken symlinks are relative and in debian/tmp, and will point to locations provided by other Debian packages once my package is installed in the right location. It’s too bad that filelist goes into the debian subdirectory :( The Ubuntu-originated python-distutils-extra project had a similar problem and they switched from FileList.findall to os.walk to avoid it. What happens if you ignore the debian dir in MANIFEST.in? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12885 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8286] distutils: path '[...]' cannot end with '/' -- need better error message
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 9cdc845d5f2e by Éric Araujo in branch '2.7': Warn instead of crashing because of invalid path in MANIFEST.in (#8286). http://hg.python.org/cpython/rev/9cdc845d5f2e -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8286 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12898] add opendir() for POSIX platforms
Larry Hastings la...@hastings.org added the comment: Well, there's no os.fdopendir(); I think you're referring to fdlistdir(), which uses the C function fdopendir() internally. The DIR structure is not exposed to the Python caller at any point. I did miss the whole opendir-returns-a-DIR-not-a-fd thing, hopefully that's my dumb thing of the day. This suggests opendir() would have to call dirfd() on your behalf. Would it be safe to call close() on the fd returned from dirfd(opendir())? If not, I guess we'd need a special closedir() function, which would use the C functions fdopendir() then closedir() internally. ... or we could forget the whole thing, I guess. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12898 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12898] add opendir() for POSIX platforms
Antoine Pitrou pit...@free.fr added the comment: Well, is there any case where fdlistdir() is not sufficient? -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12898 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12898] add opendir() for POSIX platforms
Larry Hastings la...@hastings.org added the comment: fdlistdir() is largely irrelevant to the discussion. I was proposing adding a function to open directory fds, because there isn't one; fdlistdir(), like many other POSIX functions available in Python, consumes directory fds. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12898 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12900] Use universal newlines mode for setup.cfg
New submission from Éric Araujo mer...@netwok.org: We need tests to make sure that setup.cfg files using CRLF or CR as newline character work. We could require that people use LF in the spec, but I don’t think it’s worth it, as it’s simple enough to support all newlines whereas Windows users can’t always use LF easily. For packaging in 3.3, opening the file in text mode gives us universal newlines for free, so the code is good but we need tests. For distutils2 in 2.x, we need to pass 'rU' as open flags. -- assignee: tarek components: Distutils2 keywords: easy messages: 143539 nosy: alexis, eric.araujo, tarek priority: normal severity: normal stage: needs patch status: open title: Use universal newlines mode for setup.cfg type: behavior versions: 3rd party, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12900 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12899] Change os.utimensat() and os.futimens() to use float for atime mtime
Ross Lagerwall rosslagerw...@gmail.com added the comment: See #11457 for a long discussion about the API and whether to use decimal or not to get the full precision. -- nosy: +rosslagerwall ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12899 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5876] __repr__ returning unicode doesn't work when called implicitly
Éric Araujo mer...@netwok.org added the comment: I think it’s not an implicit vs. explicit call problem, rather repr vs. str. IIRC, in 2.x it is allowed that __str__ returns a unicode object, and str will convert it to a str. To do that, it will use the default encoding, which is ASCII in 2.5+, so your example cannot work. Ideas for work-arounds: - write a displayhook (http://docs.python.org/dev/library/sys#sys.displayhook) that converts unicode objects using sys.stout.encoding - for 2.6+, test if setting PYTHONIOENCODING changes soemthing -- nosy: +eric.araujo, lemburg versions: -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5876 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7425] Improve the robustness of pydoc -k in the face of broken modules
Éric Araujo mer...@netwok.org added the comment: Does this patch solves only pydoc -k, not all “invalid spam module makes pydoc crash”? (I wanted to consolidate the handful of reports we have into one but did not get the time.) -- nosy: +eric.araujo title: [PATCH] Improve the robustness of pydoc -k in the face of broken modules - Improve the robustness of pydoc -k in the face of broken modules ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7425 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11155] multiprocessing.Queue's put() signature differs from docs
Senthil Kumaran sent...@uthcode.com added the comment: Well, I should take back my previous comment. I realized that the positional arg in this case can be called as keyword arg. It would be wrong to change multiprocessing.py and it is correct to change the docs. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11155 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11473] upload command no longer accepts repository by section name
Éric Araujo mer...@netwok.org added the comment: I started working on a test for this in packaging and it’s worse than I expected: it does not support multiple repositories at all. The config parser has bogus tests and the upload command has no test for this. I will work on fixing this in packaging and backport. -- assignee: tarek - eric.araujo components: +Distutils2 nosy: +alexis versions: +3rd party, Python 2.7, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11473 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12898] add opendir() for POSIX platforms
Antoine Pitrou pit...@free.fr added the comment: I was proposing adding a function to open directory fds, because there isn't one; fdlistdir(), like many other POSIX functions available in Python, consumes directory fds. I don't think I understand. This already works: fd = os.open(Misc, os.O_RDONLY) os.fdlistdir(fd) ['python.pc', 'README.coverity', 'ACKS.orig', 'NEWS.orig', 'HISTORY', 'python.man', 'valgrind-python.supp', 'TextMate', 'python-config.in', 'NEWS', 'RPM', 'vgrindefs', 'svnmap.txt', 'python-wing4.wpr', 'gdbinit', 'build.sh', 'README.AIX', 'Vim', 'SpecialBuilds.txt', 'indent.pro', 'python-wing3.wpr', 'ACKS', 'README', 'README.valgrind', 'Porting', 'python.pc.in'] Is there anything you want to do on a directory fd except listing its contents? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12898 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12898] add opendir() for POSIX platforms
Larry Hastings la...@hastings.org added the comment: Is there anything you want to do on a directory fd except listing its contents? In the first message in this bug, I wrote: With the recent spate of POSIX *at() functions added to os, we now have a bunch of places in the API that take directory fds. To be specific: faccessat, fchmodat, fchownat, fstatat, futimesat, linkat, mkdirat, mknodat, openat, readlinkat, renameat, symlinkat, unlinkat, utimensat, mkfifoat. At the time I created this ticket I didn't realize you could just call open() on a directory. It seem that works fine and is supported everywhere that these *at functions exist, so perhaps it's best if we just close this ticket. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12898 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11155] multiprocessing.Queue's put() signature differs from docs
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset c6d4d4d64405 by Senthil Kumaran in branch '3.2': Fix closes Issue11155 - Correct the multiprocessing.Queue.put's arg (replace 'item' with 'obj') in the docs. Patch by Westley Martínez. http://hg.python.org/cpython/rev/c6d4d4d64405 New changeset 8f1187288fac by Senthil Kumaran in branch 'default': merge from 3.2. Fix closes Issue11155 - Correct the multiprocessing.Queue.put's arg (replace 'item' with 'obj') in the docs. Patch by Westley Martínez. http://hg.python.org/cpython/rev/8f1187288fac New changeset d29c9006d770 by Senthil Kumaran in branch '2.7': merge from 3.2. Fix closes Issue11155 - Correct the multiprocessing.Queue.put's arg (replace 'item' with 'obj') in the docs. Patch by Westley Martínez. http://hg.python.org/cpython/rev/d29c9006d770 -- nosy: +python-dev resolution: - fixed stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11155 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12898] add opendir() for POSIX platforms
Changes by STINNER Victor victor.stin...@haypocalc.com: -- resolution: - works for me status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12898 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5845] rlcompleter should be enabled automatically
Éric Araujo mer...@netwok.org added the comment: We can’t just decide to enable completion by checking “'readline' in sys.modules” in site, because it always returns False. site is imported in Python/pythonrun.c, and I guess that Modules/main.c is run afterwards. More importantly, I think the import of readline in Modules/main.c is a CPython implementation detail, and I’d prefer to have code in site that is directly useful for other VMs. (I’d go as far as proposing to remove the import readline from main.c, when my patch makes it obsolete.) I re-read the docs for sys.argv and the -m switch and decided to translate to C checks (“command == NULL filename == NULL module == NULL”) to “if not sys.argv[0]”. Unfortunately, sys.argv is not available when site is imported, so this is a dead end :( So, I could try your _setupinteractive module idea, even though I think it’s a bit unclean, or drink the cool aid and set up completion in main.c. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5845 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12898] add opendir() for POSIX platforms
STINNER Victor victor.stin...@haypocalc.com added the comment: At the time I created this ticket I didn't realize you could just call open() on a directory. Yes, os.open or os.openat. -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12898 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5876] __repr__ returning unicode doesn't work when called implicitly
STINNER Victor victor.stin...@haypocalc.com added the comment: I think that this issue is a duplicate of #4947 which has been fixed in Python 2.7.1. Can you retry with Python 2.7.2 (or 2.7.1)? -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5876 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12779] Update packaging documentation
Éric Araujo mer...@netwok.org added the comment: To make commit review possible, I thought I’d make two patches for this: the first would be only markup fixes and minimal updates to match the reality of the code (i.e. convert setup.py examples to setup.cfg or pysetup, remove obsolete parts, etc.) and a second one with more rephrasing and reorganization (i.e. file deletions, moving chunks of docs, etc.). I’m not finished on the first patch and the diff already contains 1026 insertions and 921 deletions. So, as potential commit reviewers, do you think I should - 1) go ahead with my initial plan of a huge boring commit and a more interesting commit - 2) just make one commit - 3) one commit per file (with boring markup changes + non-boring changes) -- nosy: +ezio.melotti, sandro.tosi ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12779 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12901] Nest class/methods directives in documentation
New submission from Éric Araujo mer...@netwok.org: I picked up a few files in Doc/library and updated their markup to use directives nesting. The attached patch is the result; it’s a lot of changes for small benefit. If we think it’s a good change anyway, I have two questions - Do you think it would be a good idea to have the -checkins emails ignore whitespace changes in some cases? (I’m thinking a magic string in the commit message) - A number of files have a class directive near the top of the file, in the list of all public names, and a later section “XX objects” with the methods and attributes. When this is changed to nested class/methods directives, sometimes the first class directive gets a noindex flag, but I think it should jsut be removed: the index in the sidebar is enough to let people jump to the doc. Do you agree? -- assignee: docs@python components: Documentation messages: 143552 nosy: benjamin.peterson, docs@python, eric.araujo, georg.brandl priority: normal severity: normal status: open title: Nest class/methods directives in documentation versions: Python 2.7, Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12901 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12901] Nest class/methods directives in documentation
Changes by Éric Araujo mer...@netwok.org: -- keywords: +patch Added file: http://bugs.python.org/file23102/doc-nest-methods-3.2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12901 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5876] __repr__ returning unicode doesn't work when called implicitly
Tomasz Melcer li...@o2.pl added the comment: Debian SID. No, it wasn't. Python 2.7.2+ (default, Aug 16 2011, 09:23:59) [GCC 4.6.1] on linux2 Type help, copyright, credits or license for more information. class T(object): ... def __repr__(self): return u'あみご' ... T().__repr__() u'\u3042\u307f\u3054' print T().__repr__() あみご T() Traceback (most recent call last): File stdin, line 1, in module UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128) print T() Traceback (most recent call last): File stdin, line 1, in module UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128) import sys sys.stdin.encoding 'UTF-8' sys.stdout.encoding 'UTF-8' -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5876 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5845] rlcompleter should be enabled automatically
Cherniavsky Beni b...@google.com added the comment: Easily detecting interactive mode is of general interest for customization. 1. What if C also set sys.flags.interactive in python mode, or exposed sys.flags.implicit_interactive (but with better name)? 2. It's more useful to have a hook called when entering interactive mode, rather than a flag that's set from the beginning: $ python -i -c 'import sys; print sys.flags.interactive' 1 For this, importing _setupinteractive is a step forward; calling e.g. sys.__interactivehook__ sounds even better. (site.py would set it by default to a function that enables rlcompleter, user can always override...) BTW, drawback of doing any such setup in site.py: python -S would be unfriendly! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5845 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com