Re: [Python-Dev] PEP 3101 Update
Steven Bethard steven.bethard at gmail.com writes: I'm still not a big fan of mixing together getitem-style access and getattribute-style access. That makes classes that support both ambiguous in this context. You either need to specify the order in which these are checked (e.g. attribute then item or item then attribute), or, preferably, you need to extend the syntax to allow getitem-style access too. Just to be clear, I'm not suggesting that you support anything more then items and attributes. So this is *not* a request to allow arbitrary expressions. In fact, the only use-case I see in the PEP needs only item access, not attribute access, so maybe you could drop attribute access? Can't you just extend the syntax for *only* item access? E.g. something like: My name is {0[name]} :-\{\}.format(dict(name='Fred')) I'm not opposed to the idea of adding item access, although I believe that attribute access is also useful. In either case, its not terribly hard to implement. I'd like to hear what other people have to say on this issue. -- Talin ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] PEP 3101 Update
Steven Bethard steven.bethard at gmail.com writes: I believe the proposal is taking advantage of the fact that '\{' is not interpreted as an escape sequence -- it is interpreted as a literal backslash followed by an open brace: This is exactly correct. -- Talin ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] PEP 3101 Update
Steven Bethard wrote: On 5/7/06, Edward Loper [EMAIL PROTECTED] wrote: Talin wrote: Braces can be escaped using a backslash: My name is {0} :-\{\}.format('Fred') Which would produce: My name is Fred :-{} Do backslashes also need to be backslashed then? If not, then what is the translation of this:? r'abc\{%s\}' % 'x' I believe the proposal is taking advantage of the fact that '\{' is not interpreted as an escape sequence -- it is interpreted as a literal backslash followed by an open brace: Yes, I knew that fact, but it's not related to my question. The basic issue is, that if you have a quote character ('\\'), then you usually need to be able to quote that quote character ('') in at least some contexts. So I'll try again with a different example. I'll avoid using raw strings, just because doing so seems to have confused a couple people about what my question is about. Let's say I have a program now that contains the following line: print 'Foo\\%s' % x And I'd like to translate that to use str.format. How do I do it? If I just replace %s with {0} then I get: print 'Foo\\{0}'.format(x) but this will presumably raise an exception, since the '\\{' (which is identical to '\{') gets treated as a quoted brace, and the '}' is unmatched. If it were possible to backslash backslashes, then I could do: print 'Foo{1}' % x (which can also be spelled r'Foo\\{1}' -- i.e., the string now contains two backslash characters). But I haven't seen any mention of backslashing backslashes so far. -Edward ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Visual studio 2005 express now free
Martin v. Löwis [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] - Paul Moore has contributed a Python build procedure for the free version of the 2003 compiler. This one is without IDE, but still, it should allow people without a VS 2003 license to work on Python itself; it should also be possible to develop extensions with that compiler (although I haven't verified that distutils would pick that up correctly). AFAIR Paul Moore was based on some other instructions posted previously somewhere on the net, which I followed at least a year back; it was a little hard to fix all variables etc, but I managed to build for 2.4 an extension of mine (haar transformation for image comparisons) successfully using just the setup.py of my module. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] rest2latex - pydoc writer - tables
On Fri, 28 Apr 2006, Thomas Heller wrote: I must work on the docs themselves, so I currently have only two things: - the table in the ctypes tutorial has a totally different look than the other tables in the docs. Compare http://docs.python.org/dev/lib/ctypes-simple-data-types.html with http://docs.python.org/dev/lib/module-struct.html could you try docutils.sf.net sandbox pydoc-writer checkout (svn or the snapshot or tomorrow http://docutils.sourceforge.net/sandbox/pydoc-writer/mkpydoc.py) - feature request: it would be very nice if it were possible to generate links into the index for functions and types from the rest sources. into the index means what ? into the module index ? cheers -- --- Engelbert Gruber ---+ SSG Fintl,Gruber,Lassnig / A6170 Zirl Innweg 5b / Tel. ++43-5238-93535 ---+ ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] PEP 3101 Update
One small comment: The conversion specifier consists of a sequence of zero or more characters, each of which can consist of any printable character except for a non-escaped '}'. Escaped? How are they escaped? (with '\'?) If so, how are backslashes escaped (with '\\'?) And does the mechanism un-escape these for you before passing them to __format__? Later... - Variable field width specifiers use a nested version of the {} syntax, allowing the width specifier to be either a positional or keyword argument: {0:{1}.{2}d}.format(a, b, c) This violates the specification given above... it has non-escaped '}' characters. Make up one rule and be consistant. -- Michael Chermside ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] PEP 3101 Update
Michael Chermside mcherm at mcherm.com writes: One small comment: The conversion specifier consists of a sequence of zero or more characters, each of which can consist of any printable character except for a non-escaped '}'. Escaped? How are they escaped? (with '\'?) If so, how are backslashes escaped (with '\\'?) And does the mechanism un-escape these for you before passing them to __format__? Later... - Variable field width specifiers use a nested version of the {} syntax, allowing the width specifier to be either a positional or keyword argument: {0:{1}.{2}d}.format(a, b, c) This violates the specification given above... it has non-escaped '}' characters. Make up one rule and be consistant. What would you suggest? I'd be interested in hearing what kinds of ideas people have for fixing these problems. - -- Talin ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] PEP 3101 Update
I wrote: - Variable field width specifiers use a nested version of the {} syntax, allowing the width specifier to be either a positional or keyword argument: {0:{1}.{2}d}.format(a, b, c) This violates [the rule that '}' must be escaped] Talin writes: What would you suggest? I'd be interested in hearing what kinds of ideas people have for fixing these problems. Honestly? I propose that the PEP not provide any means to pass format specifiers as arguments. After all, one PEP need not support everything anyone would ever want to do with string interpolation. Fixed format attributes are powerful enough for nearly all applications, and those needing a more powerful tool can either use multiple interpolation passes (simple and obvious, but a bit ugly) or define a custom formatting class. In fact, if _I_ were writing the PEP, I'd probably have opted for simplicity in a few more areas. For one thing, where you have: string.format() will format each field using the following steps: 1) See if the value to be formatted has a __format__ method. If it does, then call it. 2) Otherwise, check the internal formatter within string.format that contains knowledge of certain builtin types. 3) Otherwise, call str() or unicode() as appropriate. I would have left out (2) by adding __format__ methods to those built-in types just to keep the description (and the implementation) as simple as possible. And probably I would have ommitted the whole ability to support custom formatting classes. Not that they're not a nice idea, but they are a separate feature which can be built on top of the basic format() method and I would have tried to take one small step at a time. But please don't read this as saying I object to the above ideas... I wouldn't have said anything if you hadn't asked what my approach would be. -- Michael Chermside ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Python sprint mechanics
[Tim Peters, on giving commit privs to a sprinter after extracting a signed PSF contributor form] The more realistically ;-) I try to picture the suggested alternatives, the more sensible this one sounds. ... [Martin v. Löwis] I completely agree. Just make sure you master the mechanics of adding committers. So there's a practical problem: is that procedure documented somewhere? And who is _able_ to do this? For example, taking the you literally, I doubt I have access to the machine(s) on which it would need to be done. I'd be happy to learn how to do it, and to document the procedure (if it's not already documented -- I couldn't find it), if someone can teach me the ropes. However ... speaking as a PSF Director, I wouldn't be comfortable with this unless sprinters signed a PSF contribution form beforehand. Else we get code in the PSF repository with clear-as-mud copyright and licensing issues. Having contribution forms in place would also ease fears that sprint output might be subverted to non-open status. That would be desirable, indeed. It shouldn't be too difficult to collect the forms on site. More like herding cows than herding cats ;-) ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] PEP 3102: Keyword-only arguments
On Sun, May 07, 2006, BJ?rn Lindqvist wrote: I do know enough about Python to know that the make_person function is a really bad example. The one obvious way to write make_peson is to use four positional arguments, name, age, phone, location and not complicate the function by throwing in required keyword arguments. It would be nice to instead see some real examples of the usefulness of the required keyword-only arguments. See previous discussion about super() -- I don't have time to look up examples right now. -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ Argue for your limitations, and sure enough they're yours. --Richard Bach ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] [Python-checkins] Python Regression Test Failures basics (1)
On 5/8/06, Neal Norwitz [EMAIL PROTECTED] wrote: test_ctypestest test_ctypes failed -- Traceback (most recent call last):File /home/neal/python/trunk/Lib/ctypes/test/test_python_api.py, line 41, in test_PyInt_Longself.failUnlessEqual(grc(42), ref42) AssertionError: 336 != 337We've been seeing this error for a while now, and given the test, it isn't entirely surprising. The test tries to do what regrtest -R:: also does: check for refcount leakage. I'm not entirely sure why it's failing as I can't reproduce it (although it could be because 42's refcount is actually 42 :) but it does seem to me that this kind of refleak-checking is somewhat redundant in the Python testsuite, and it is obvious to me that the breakage is precisely because it's being run in the Python testsuite (which is a lot less reliable an environment than ctypes' own, standalone testsuite.) Thomas, given the refcount-leakage-coverage the ctypes tests are getting in the Python distribution, do you want to keep running these tests? Is there a way to not run them in the Python testsuite, but still keep them for the standalone tests? (If you want that, that is.) Alternatively, we could try to fix the test. If the problem is indeed what I think it is (42's refcount being 42 or 41 or 43 at the first grc() call there; I'm not sure) we could perhaps work around it, using something like: Index: Lib/ctypes/test/test_python_api.py===--- Lib/ctypes/test/test_python_api.py (revision 45940)+++ Lib/ctypes/test/test_python_api.py (working copy) @@ -35,6 +35,11 @@ def test_PyInt_Long(self): ref42 = grc(42)+ if ref42 == 42:+ # 42's refcount was 42, but since grc() returned 42, it's now 43.+ # We want to adjust ref42 without tossing our own reference to 42 + # (or the refcount will go back down to 42.)+ old42, ref42 = ref42, ref42 + 1 pythonapi.PyInt_FromLong.restype = py_object self.failUnlessEqual(pythonapi.PyInt_FromLong (42), 42)(Untested, since I can't reproduce, but I think I have it right.)-- Thomas Wouters [EMAIL PROTECTED]Hi! I'm a .signature virus! copy me into your .signature file to help me spread! ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Python sprint mechanics
Tim Peters wrote: [Tim Peters, on giving commit privs to a sprinter after extracting a signed PSF contributor form] The more realistically ;-) I try to picture the suggested alternatives, the more sensible this one sounds. ... [Martin v. Löwis] I completely agree. Just make sure you master the mechanics of adding committers. Part of the mechanics also involves getting the users set-up on their own machines. For me, it was a complete PITA because of the Tortoise/Putty/Pageant/SSH2 dance and then trying to get Python to compile with the only compiler I had (MSVC++6). The advantage of a separate sprint repository is that we can essentially leave it unsecured and make it easy for everyone to freely checkin / checkout and experiment. For the Iceland sprint and bug days, we need a procedure that is minimizes the time lost for getting everyone set. For bug days, it is especially critical because a half-day lost may eat-up most of the time available for contributing. For the Iceland sprint, it is important because this is just one of many set-up tasks (others include downloading and compiling psyco, pypy, etc). Raymond ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Python sprint mechanics
[Raymond Hettinger] Part of the mechanics also involves getting the users set-up on their own machines. Yes. For me, it was a complete PITA because of the Tortoise/Putty/Pageant/SSH2 dance and then trying to get Python to compile with the only compiler I had (MSVC++6). The advantage of a separate sprint repository is that we can essentially leave it unsecured and make it easy for everyone to freely checkin / checkout and experiment. This seems to be mixing up unrelated problems. For example, the repository in use has nothing to do with that Python became hard to compile under MSVC 6, right? For a new library module, sure, any repository will do for development ( if it contains new C code, then compiler setup is required regardless of repository). If, OTOH, someone is looking to tweak existing code in the Python core, then svn.python.org is the obvious place to work from. You may (unsure) have been a unique case wrt Tortoise/Putty/Pageant/SSH2: I expect most open-source programmers working on Windows already have those installed (e.g., I did, and long before Python required them). Tortoise isn't necessary, but the PuTTY tools are. I expect (but don't know) that learning how to use SVN (or SVK) correctly would be a bigger setup cost for those who haven't already used them. Signing a PSF contrib form and getting an SSH2 key installed for svn.python.org are definitely hassles. OTOH, new code can't ever get into Python without signing that form, and collecting forms at a sprint is a lot easier for most people than hassling with snail mail or faxing. So I'd like to collect forms at the sprint regardless of which repository is in use. For the Iceland sprint and bug days, we need a procedure that is minimizes the time lost for getting everyone set. For bug days, it is especially critical because a half-day lost may eat-up most of the time available for contributing. For the Iceland sprint, it is important because this is just one of many set-up tasks (others include downloading and compiling psyco, pypy, etc). I'm far less hopeful about easing the pain for bug days -- that's overwhelmingly a repeated one person generates a small patch, then bugs someone else to review and commit dance. Sprints are more about people actively collaborating, and across days. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com