[issue8943] Bug in InteractiveConsole /pickle
Change by Steve Holden : -- nosy: -holdenweb ___ Python tracker <https://bugs.python.org/issue8943> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34311] locale.format() and locale.format_string() cast Decimals to float
Steve Holden added the comment: Verified. Methododology: 1. Copied test_localise.py from the PR into a master checkout. 2. Added a null locale.localize. 3. Verified that all new tests failed. .. code-block:: Ran 64 tests in 0.023s FAILED (errors=4, skipped=4) (base) blockhead:cpython sholden$ vi Lib/locale.py (base) blockhead:cpython sholden$ ./python.exe -m test.test_locale ...F...testing with ('tr_TR', 'ISO8859-9') .testing with 'en_US.UTF-8'... .testing with 'en_US.UTF-8'... .testing with 'en_US.UTF-8'... .testing with 'en_US.UTF-8'... .testing with 'en_US.UTF-8'... .testing with 'en_US.UTF-8'... .testing with 'en_US.UTF-8'... .testing with 'en_US.UTF-8'... F == FAIL: test_localize_invalid_format (__main__.TestEnUSLocalize) -- Traceback (most recent call last): File "/Users/sholden/cpython/Lib/test/test_locale.py", line 613, in test_localize_invalid_format locale.localize('foo') AssertionError: ValueError not raised == FAIL: test_localize (__main__.TestfrFRLocalize) -- Traceback (most recent call last): File "/Users/sholden/cpython/Lib/test/test_locale.py", line 625, in test_localize self._test_localize('5.00', '5,00') File "/Users/sholden/cpython/Lib/test/test_locale.py", line 601, in _test_localize self.assertEqual(locale.localize(value, grouping=grouping), out) AssertionError: '5.00' != '5,00' - 5.00 ? ^ + 5,00 ? ^ -- Ran 64 tests in 0.024s FAILED (failures=2, skipped=4) 4. Checked out cedk/locale_format branch. 5. Observed that all locale tests now pass. Seems to me like this one should be good to go, so I've changed the stage to "commit review" and await the application of some core developer's commit bit. -- nosy: +holdenweb stage: patch review -> commit review ___ Python tracker <https://bugs.python.org/issue34311> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37490] poor documentation for .startswith, .endswith
Steve Holden added the comment: "Is the same as" is a little misleading - "gives the same result as" would be better, since there is little doubt actually slicing the subject strings would be massively less efficient in looping contexts. The re module offers the start and end arguments to so many functions/methods for precisely this reason, so perhaps that module's documentation will contain helpful wording that could be copied or referenced. -- nosy: +holdenweb ___ Python tracker <https://bugs.python.org/issue37490> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Fwd: [PSF-Community] Announcing IndyPy Web Conf - August 23, 2019
-- Forwarded message - From: MaryBeth Okerson Date: Wed, Jun 19, 2019 at 3:45 PM Subject: [PSF-Community] Announcing IndyPy Web Conf - August 23, 2019 To: group-organiz...@python.org , psf-commun...@python.org Hello all! IndyPy is excited to announce the call for proposals is open for the IndyPy Web Conf. This conference will include 21 speakers and 3 tracks of presentations. Save the date: August 23, 2019 - 8am - 5pm Forum Conference & Events Center 11313 USA Parkway Fishers, IN We are looking for speakers on the following topics: - Django - Flask - Pyramid - Tornado - TurboGears - REST APIs - Web Security - microservices - websockets - Plone - Guillotina - Zope - YOUR TOPIC HERE Please submit your proposal here: https://www.papercall.io/indypy-web-conf-2019 Submissions are due by: July 8th, 2019 Registration is now open - http://bit.ly/WebConf19 Early bird pricing is $85/person until July 25th. On July 26th, General Admission increases to $125/person. Student pricing is also available for $65/person with valid student ID. Join us for this conference focused on Python on the Web and meet your fellow Pythonistas! Thank you, MaryBeth Okerson Marketing & Event Coordinator -- Six Feet Up, Inc. Python & Cloud Expert Consulting Direct Line: +1 (317) 861-5948 x605 Email: maryb...@sixfeetup.com https://sixfeetup.com ___ PSF-Community mailing list psf-commun...@python.org https://mail.python.org/mailman/listinfo/psf-community -- %(web_page_url)slistinfo/%(_internal_name)s Support the Python Software Foundation: http://www.python.org/psf/donations/
[issue15443] datetime module has no support for nanoseconds
Change by Steve Holden : -- nosy: -holdenweb ___ Python tracker <https://bugs.python.org/issue15443> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: [Python-Dev] [RELEASE] Python 3.6.4rc1 and 3.7.0a3 now available for testing
Ned, In your role as a representative of the many fine release managers Python has had over the years I'd like to thank you for continuing to make high-quality software available to a large and growing community. And thanks to everyone who contributes to Python so the majority just get to enjoy it. Seasons greetings Steve Steve Holden On Wed, Dec 6, 2017 at 2:29 AM, Ned Deily <n...@python.org> wrote: > Announcing the immediate availability of Python 3.6.4 release candidate 1 > and of Python 3.7.0 alpha 3! > > Python 3.6.4rc1 is the first release candidate for Python 3.6.4, the next > maintenance release of Python 3.6. While 3.6.4rc1 is a preview release > and, > thus, not intended for production environments, we encourage you to explore > it and provide feedback via the Python bug tracker ( > https://bugs.python.org). > 3.6.4 is planned for final release on 2017-12-18 with the next maintenance > release expected to follow in about 3 months. You can find Python 3.6.4rc1 > and more information here: > https://www.python.org/downloads/release/python-364rc1/ > > Python 3.7.0a3 is the third of four planned alpha releases of Python 3.7, > the next feature release of Python. During the alpha phase, Python 3.7 > remains under heavy development: additional features will be added > and existing features may be modified or deleted. Please keep in mind > that this is a preview release and its use is not recommended for > production environments. The next preview release, 3.7.0a4, is planned > for 2018-01-08. You can find Python 3.7.0a3 and more information here: > https://www.python.org/downloads/release/python-370a3/ > > -- > Ned Deily > n...@python.org -- [] > > ___ > Python-Dev mailing list > python-...@python.org > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: https://mail.python.org/mailman/options/python-dev/ > steve%40holdenweb.com > -- https://mail.python.org/mailman/listinfo/python-list
[issue26732] multiprocessing sentinel resource leak
Steve Holden added the comment: IIRC sockets can be marked as inheritable or not. It seems to me it would be a useful enhancement to allow the same determination for the pipes. -- nosy: +holdenweb ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26732> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1116520] Prefix search is filesystem-centric
Steve Holden added the comment: Don't forget that the built-in modules may need to be available before the zipimporter is. A long time ago (when sys.metapath was introduced) I experimented with imports from non-filesystem sources and that hit me until I realised what was going on. S Steve Holden On Sun, Dec 25, 2016 at 5:48 PM, Patrik Iselind <rep...@bugs.python.org> wrote: > > Patrik Iselind added the comment: > > Is it enough to include everything in the Lib folder, excluding > __pycache__, site-packages and the test folder in Lib? Would that be > representative enough? > > Patrik Iselind > > Den 2016-12-25 kl. 17:31, skrev Brett Cannon: > > Brett Cannon added the comment: > > > > Originally zip file importing was faster than standard importing from > disk because of the fewer stat calls, but importlib caches such things so I > don't know if it's still beneficial. As for space savings, I have no idea; > you can try zipping the files yourself to find out the space savings. > > > > -- > > > > ___ > > Python tracker <rep...@bugs.python.org> > > <http://bugs.python.org/issue1116520> > > ___ > > -- > > ___ > Python tracker <rep...@bugs.python.org> > <http://bugs.python.org/issue1116520> > ___ > -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue1116520> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28205] Add optional suffix to str.join
Steve Holden added the comment: If you are going to add such a keyword argument, wouldn't it make sense to maintain compatibility with print, and use end=terminator? -- nosy: +holdenweb ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28205> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15443] datetime module has no support for nanoseconds
Steve Holden added the comment: I agree on reflection that a single nanoseconds integral value makes more sense. This then requires refactoring of the existing code so that existing tests continue to pass using a microsecond property. Code using ONLY nanoseconds is a disjoint case, for which new tests will be required. It clearly cannot be expected to be backwards compatible with pre-implementation versions. Does it make sense to define behaviour for cases where the user attempts to MIX microseconds and nanoseconds? One validation I would suggest if so is that in the presence of a microseconds specification a constraint of 0 <= nanoseconds < 1000 must be imposed. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15443> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27842] Order CSV header fields
Steve Holden added the comment: A pleasure. Pretty heavily committed at present, but all Python related so maybe there'll be more small positive improvements. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27842> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27842] Order CSV header fields
Steve Holden added the comment: OK, here's what I think should be close to the final patch. I've updated the documentation, rebuilt it and verified it reads OK, and confirmed that the new code passes all tests except those skipped for platform reasons (I think they expect a Windows environment). This includes the new test to confirm that ordering is retained over all 120 possible combinations of five keys. Please let me know if any further updates are needed. -- Added file: https://bugs.python.org/file44235/csv_full.patch ___ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue27842> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27842] Order CSV header fields
Steve Holden added the comment: Is there another way? :) Sent from my iPhone > On 26 Aug 2016, at 12:16, Raymond Hettinger <rep...@bugs.python.org> wrote: > > > Raymond Hettinger added the comment: > > Consider using itertools.permutations() to generate the 120 cases cases. > > The news entry goes into Misc/NEWS (there is not .txt extension). > > -- > > ___ > Python tracker <rep...@bugs.python.org> > <https://bugs.python.org/issue27842> > ___ -- ___ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue27842> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27842] Order CSV header fields
Steve Holden added the comment: Testing could be interesting. I'm thinking of generating five random string keys with a couple of rows of data, creating csv StringIOs (using pure Python) for all 120 combinations and verifying that they read back in the order they were written. We should also test that OrderedDicts write correctly with a DictWriter and the same key sets. It's a fairly haphazard test plan, so I'll be happy to hear more thorough suggestions. We could at a pinch reduce the number of keys to three if speed considerations dictate. BTW, what happened to NEWS.txt? :) -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27842> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27842] Order CSV header fields
Steve Holden added the comment: Sorry, deleted the originally submitted (incorrect) patch file. -- Added file: http://bugs.python.org/file44203/csv.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27842> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27842] Order CSV header fields
Changes by Steve Holden <st...@holdenweb.com>: Removed file: http://bugs.python.org/file44202/csv.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27842> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27842] Order CSV header fields
New submission from Steve Holden: It's sometimes annoying that a csv.DictReader doesn't retain the field ordering given in the first line of the file. Sometimes it matters. This patch converts the reader so that it returns an OrderedDict rather than a plain dict, thereby retaining the ordering. All tests still pass (though I haven't yet added a test to verify that the field ordering *is* retained - didn't think it was worth it if the patch won't be added, but will happily add that test otherwise). I have updated the documentation, but was unable in the time available to find out how to correctly reference the OrderedDict class so that it was correctly hyperlinked. -- components: Library (Lib) files: csv.patch hgrepos: 353 keywords: needs review, patch messages: 273486 nosy: holdenweb priority: normal severity: normal stage: patch review status: open title: Order CSV header fields versions: Python 3.6 Added file: http://bugs.python.org/file44202/csv.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27842> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27680] Reduce Github pull request rate
Steve Holden added the comment: Hmm. Tried making a PR to a forked copy and didn't see it. Probably just incompetence on my part. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27680> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27680] Reduce Github pull request rate
Steve Holden added the comment: I don't seem to be able to activate the PR template, but if you are happy it works then I guess this would be a belt-and-braces change. If nobody merges it and it gets closed that's fine, but if it obviates just a few pull requests it will save both the core devs and the contributors some time. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27680> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27680] Reduce Github pull request rate
Steve Holden added the comment: Hmm, not sure I quite understand how to interact with this tracker. So here's an updated patch that I thought I had already submitted ... -- Added file: http://bugs.python.org/file44006/README2.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27680> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27680] Reduce Github pull request rate
New submission from Steve Holden: I have seen a relatively large number of pull requests via the Github mirror repository, because would-be contributors presumably just look on Github and, having found Python there, assume this is the place for contributions. The standard README file gives no clue that the Github repository should not be used as the basis for contributory pull requests, and neither should it. Fortunately Github will display a README.md file in preference to REAMDE when one is found. This patch adds a message, highly visible to Github users, that they are in the wrong place. For an indication of how the Github page will then look, visit https://github.com/holdenweb/python/tree/README where the patch is already installed. -- assignee: docs@python components: Documentation files: README.patch keywords: needs review, patch messages: 271958 nosy: docs@python, holdenweb priority: normal severity: normal stage: patch review status: open title: Reduce Github pull request rate type: enhancement Added file: http://bugs.python.org/file44004/README.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27680> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15443] datetime module has no support for nanoseconds
Steve Holden added the comment: BTW, I presume it's a bug in the issue tracker that my view of this message ends after a few lines of msg166386? Makes it rather difficult to track the issue! -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15443> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15443] datetime module has no support for nanoseconds
Steve Holden added the comment: Just wanted to add a couple of comments here in case there's any interest. In our missions to make the world's market data available we deal with financial exchanges, many of whom are already recording event data at nanosecond resolution. Further, I believe the decision to use a separate nanoseconds field to be essentially correct. While it may well introduce some arithmetical complexity its value in backwards compatibility should be regarded as paramount. If I understand it correctly, the new nanosecond resolution times would continue to be correctly handled (module loss of nanosecond resolution) when handled as current microsecond date-times. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15443> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15443] datetime module has no support for nanoseconds
Steve Holden added the comment: Just wanted to add a couple of comments here in case there's any interest. In our missions to make the world's market data available we deal with financial exchanges, many of whom are already recording event data at nanosecond resolution. Further, I believe the decision to use a separate nanoseconds field to be essentially correct. While it may well introduce some arithmetical complexity its value in backwards compatibility should be regarded as paramount. If I understand it correctly, the new nanosecond resolution times would continue to be correctly handled (module loss of nanosecond resolution) when handled as current microsecond date-times. -- nosy: +holdenweb ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15443> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26449] Tutorial on Python Scopes and Namespaces uses confusing 'read-only' terminology
Steve Holden added the comment: I don't agree there is any place for the term "read-only" in this document. A reader who doesn't understand it or seeks clarification is likely to end up at a page like https://en.wikipedia.org/wiki/Read-only. I submit that nowhere except the documentation under discussion are they likely to find any suggestion that a read-only variable can in fact be changed, and hence I regard the discussion as extremely misleading. Surely it would be better to focus on the fundamental point here, which is that IN THE ABSENCE OF A global OR nonlocal DECLARATION, ASSIGNMENT BINDS IN THE LOCAL NAMESPACE in a function. If this point is correctly emphasised it should then be relatively easy to explain that in the absence of such an assignment in the function body in question, the standard name resolution algorithm operates, and that the global and non-local declarations change the effect of assignments to operate on the namespace that is identified by the standard name resolution algorithm. It's too easy to confuse newcomers, and there seems to be general agreement that this piece is confusing. I'll be happy to attempt a rewrite of this section if we can agree on the goals. -- nosy: +holdenweb ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26449> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
UK Python Training Day
Are you interested in Python training for yourself or others? Can you get to London on 9 December, 2014? If so I would very much like to meet you, and have reserved a venue in Westminster with refreshments and lunch. Starting in 2015 I plan to do more training in Europe (initially in the UK) and so would like to discuss the kind of Python training that will be most effective in those markets. The event starts at 10:00 am and runs until 4:40 pm. If you would like to attend for lunch then reservations are required, and are otherwise helpful. Please sign up at https://www.eventbrite.com/e/uk-python-training-day-tickets-14720737121 regards Steve -- Steve Holden st...@holdenweb.com +1 571 484 6266 @holdenweb -- https://mail.python.org/mailman/listinfo/python-list
New Python Course
Hi everybody, I am pleased to announce the availability of a Python Programming Skills Lab in London on December 9, 2014 in The Church House, Westminster. The blurb follows. Led by Steve Holden, a well-known educator and member of the Python community, this one-day lab presents Python programmers with the opportunity to increase their Python skill level in a relatively short time. As an optional extra those registering can purchase two hours remote consulting, which can (for example) be used to address confidential issues unsuitable for discussion in class. A little more detail about this development can be found at http://holdenweb.blogspot.com/2014/11/a-new-python-class.html and you can register at http://pythonskills14121.eventbrite.com I hope to see you there. regards -- Steve Holden st...@holdenweb.com +1 571 484 6266 @holdenweb -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
New Python Course
Hi everybody, I am pleased to announce the availability of a Python Programming Skills Lab in London on December 9, 2014 in The Church House, Westminster. The blurb follows. Led by Steve Holden, a well-known educator and member of the Python community, this one-day lab presents Python programmers with the opportunity to increase their Python skill level in a relatively short time. As an optional extra those registering can purchase two hours remote consulting, which can (for example) be used to address confidential issues unsuitable for discussion in class. A little more detail about this development can be found at http://holdenweb.blogspot.com/2014/11/a-new-python-class.html and you can register at http://pythonskills14121.eventbrite.com I hope to see you there. regards -- Steve Holden st...@holdenweb.com +1 571 484 6266 @holdenweb -- https://mail.python.org/mailman/listinfo/python-list
[issue21904] Multiple closures accessing the same non-local variable always see the same value
New submission from Steve Holden: When repeated use of a nonlocal variable is made (e.g. to define multiple functions in a loop) ideally the closure should reflect the value of the local variable at the time of use. This should at least be explicitly documented if the behavior is considered not to be a bug. The code sample attached shows that the closures produced operate differently inside and outside the enclosing function. Without an explicit nonlocal declaration the closure should not be able to affect the nonlocal variable's value (which anyway hardly makes sense once the enclosing namespace has been destroyed), so I think it's possible to argue that this behavior is a bug, but I'd value comments from experienced developers. -- files: bugreport.py keywords: needs review messages: 222094 nosy: holdenweb priority: normal severity: normal status: open title: Multiple closures accessing the same non-local variable always see the same value type: behavior versions: Python 2.7, Python 3.3 Added file: http://bugs.python.org/file35829/bugreport.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21904 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21904] Multiple closures accessing the same non-local variable always see the same value
Steve Holden added the comment: Indeed the issue is that the pointer is to the local variable rather than its value at time of closure defnition. Not being familiar with the way cells are used, I am unsure as to how the closure keeps the whole namespace alive (that would seem to require a frame rather than just a simple cell). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21904 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21904] Multiple closures accessing the same non-local variable always see the same value
Steve Holden added the comment: I believe (though my belief is untrammeled by anything as useful as knowledge of the code: my diagnostic skills are largely psychic) that the cell essentially takes over the reference from the local namespace of the about-to-terminate lexically surrounding function. This would appear to be a logical time to create closure cells, as there is effectively no need to create them for functions that will be destroyed. So I imagine any remaining function objects accessible from the return expression will be fixed up at that point. This has the rather unpleasant side effect of capturing the value on surrounding function return rather than closure function creation. The behavior exhibited, in my opinion, shows that there would be strong advantages to creating the closures dynamically, even though I can understand that pathological cases might require much work. It might have to be benchmarked before a decision, I suppose. I couldn't say off-hand how many people are dynamically trying to create multiple closures from a single namespace. It seems to me that the principle of least surprise would suggest a change be adopted, but I may be the only one who's surprised. I have documented this issue in more detail on my blog at http://holdenweb.blogspot.co.uk/2014/07/closures-arent-easy.html and will report back if anything of substance emerges. Otherwise I'll just leave this closed. Thanks for your comment and consideration. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21904 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7423] nested generator expression produces strange results
Steve Holden added the comment: In my experience the devs are pretty well in touch with the user base (though they don't always acknowledge its input). If you leave a programming language at the first sign of wart I fear yo may eventually run out of languages. -- nosy: +holdenweb ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7423 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21074] Too aggressive constant folding
Steve Holden added the comment: Is a fix really required? Are we really supposed to protect programmers from their own folly by second-guessing when constant folding might be required and when it might not? How is hte interpreter supposed to know the function isn't called? The simple solution to this problem is available in Python: simply declare a manifest constant and use that instead: UNCALLED_SIZE = 2**32 def uncalled(): x = b'x' * UNCALLED_SIZE I'd recommend closing this issue (though I'm glad that people are concerned with optimization, I don't think that an optimizer should be too concerned with those rare cases when their optimization doesn't optimize. But I'm not going to close it: wiser heads than mine are required. -- nosy: +holdenweb ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21074 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19871] json module won't parse a float that starts with a decimal point
Steve Holden added the comment: How about: A simple JSON decoder that converts between JSON string representations and Python data structures? -- nosy: +holdenweb ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19871 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20098] email policy needs a mangle_from setting
Steve Holden added the comment: This is an easy issue? -- nosy: +holdenweb ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20098 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20809] isabspath receiving path value on None in ditdutils.dist.py
Steve Holden added the comment: I hope the title change is helpful. It's not clear from the report what module is being installed, or even whether that is a relevant factor. -- nosy: +holdenweb title: isabspath fails if path is None - isabspath receiving path value on None in ditdutils.dist.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20809 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20809] isabspath receiving path value of None in ditdutils.dist.py
Steve Holden added the comment: Typo, sorry -- title: isabspath receiving path value on None in ditdutils.dist.py - isabspath receiving path value of None in ditdutils.dist.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20809 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20809] isabspath receiving path value of None in distutils.dist.py
Steve Holden added the comment: Further typo, sorry again. -- title: isabspath receiving path value of None in ditdutils.dist.py - isabspath receiving path value of None in distutils.dist.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20809 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20809] isabspath receiving path value of None in distutils.dist.py
Steve Holden added the comment: The submitted patch does not approach the issue, since the real question is WHY is the function being passed a None argument in the first place. Without extensive testing there would be no guarantees that this change would not result in breakage elsewhere. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20809 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
OSCON Call for Participation opens
OSCON, the annual Open Source Convention held in Portland OR, will be held next year from July 20-24. The call for participation has now been published, and there will again be a Python track. Please see the full call at http://www.oscon.com/oscon2014/public/cfp/308. Submissions for 3-hour tutorials and 40-minute talks are due by January 30, 2104. regards Steve -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
DjangoCon US 2012
Pythonistas: We are happy to remind all Django users that DjangoCon US is in DC this year, from September 3-8 (main conference September 4-6). Early bird pricing is available until August 3, and the schedule will be published shortly after this announcement is made. http://djangocon.us/ Since this is DjangoCon's first ever visit to the East coast we are hoping for good attendance from up and down the East coast, but some delegates will come from as far away as Australia, so Americans have no excuse! regards Steve -- The Open Bastion is the Holden Web http://TheOpenBastion.com/ subsidiary responsible forhttp://holdenweb.com/ technical events such as DjangoCon http://djangocon.us/ -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
DjangoCon US 2012
Pythonistas: We are happy to remind all Django users that DjangoCon US is in DC this year, from September 3-8 (main conference September 4-6). Early bird pricing is available until August 3, and the schedule will be published shortly after this announcement is made. http://djangocon.us/ Since this is DjangoCon's first ever visit to the East coast we are hoping for good attendance from up and down the East coast, but some delegates will come from as far away as Australia, so Americans have no excuse! regards Steve -- The Open Bastion is the Holden Web http://TheOpenBastion.com/ subsidiary responsible forhttp://holdenweb.com/ technical events such as DjangoCon http://djangocon.us/ -- http://mail.python.org/mailman/listinfo/python-list
[issue13208] Problems with urllib on windows
Steve Holden st...@holdenweb.com added the comment: I have just tested this against the 2.7.1 release on Windows 7 and it runs fine. I suspect there may have been some transient error with the reporter's system or network, but if this still fails for him then reopening will be appropriate with more information about the exact nature of the fault. -- nosy: +holdenweb resolution: - works for me ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13208 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13208] Problems with urllib on windows
Steve Holden st...@holdenweb.com added the comment: Oops, sorry, meant to close this issue. Hope that's OK. -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13208 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2801] Py30a5 float.is_integer() raises ValueError
Steve Holden st...@holdenweb.com added the comment: ValueError: (11, 'Resource temporarily unavailable') looks to me like a Cygwin error relating to Windows' DLLs and the difficulty of mapping them to unique memory locations. I very much doubt it's a real issue with Python, so closing the issue appears to be the correct decision in the absence of further contradictory information from the OP. -- nosy: +holdenweb ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2801 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Community Involvement
Haven't had much Cc input so far, but this one is definitely worth following up on. Thanks! regards Steve On Aug 4, 2011, at 5:42 PM, Eric Snow wrote: On Wed, Aug 3, 2011 at 9:14 PM, Steve Holden st...@holdenweb.com wrote: [Ccs appreciated] After some three years labor I (@holdenweb) at last find myself approaching the completion of the Python Certificate Series with O'Reilly School of Technology (@OReillySchool). At OSCON last week the team fell to talking about the final assignment (although the Certificate is not a certification, students only progress by answering real quiz questions, not the usual multiple-choice task). Success also requires that they complete a project at the end of each (of the ~60) lesson(s). We would ideally like the last project to to be something that demonstrates at least some minimal involvement with the Python community. Something like get a Python answer upvoted on StackOverflow, for example, or getting a question answered on c.l.p. At the same time it shouldn't be anything that places a burden on the community (otherwise the hundredth student would be abused and the thousandth murdered). So I wondered if anyone had any good ideas. While not as community as the mailing lists, perhaps they could post a recipe to the activestate. -eric regards Steve -- Steve Holden st...@holdenweb.com -- http://mail.python.org/mailman/listinfo/python-list -- Steve Holden st...@holdenweb.com -- http://mail.python.org/mailman/listinfo/python-list
Community Involvement
[Ccs appreciated] After some three years labor I (@holdenweb) at last find myself approaching the completion of the Python Certificate Series with O'Reilly School of Technology (@OReillySchool). At OSCON last week the team fell to talking about the final assignment (although the Certificate is not a certification, students only progress by answering real quiz questions, not the usual multiple-choice task). Success also requires that they complete a project at the end of each (of the ~60) lesson(s). We would ideally like the last project to to be something that demonstrates at least some minimal involvement with the Python community. Something like get a Python answer upvoted on StackOverflow, for example, or getting a question answered on c.l.p. At the same time it shouldn't be anything that places a burden on the community (otherwise the hundredth student would be abused and the thousandth murdered). So I wondered if anyone had any good ideas. regards Steve -- Steve Holden st...@holdenweb.com -- http://mail.python.org/mailman/listinfo/python-list
[issue12580] Documentation error in Decimal module
New submission from Steve Holden st...@holdenweb.com: We see in the Quick-Start Tutorial (py3k section 8.4.1) the following example: Decimal(3.14) Decimal('3.140124344978758017532527446746826171875') In actua; fact one would expect an exception from that code, which should perhaps instead read Decimal.from_float(3.14) Decimal('3.140124344978758017532527446746826171875') This class method is the recommended way to convert floats to decimal when necessary. -- assignee: georg.brandl messages: 140531 nosy: georg.brandl, holdenweb priority: normal severity: normal status: open title: Documentation error in Decimal module versions: Python 3.1, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12580 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12580] Documentation error in Decimal module
Changes by Steve Holden st...@holdenweb.com: -- components: +Documentation ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12580 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12580] Documentation error in Decimal module
Steve Holden st...@holdenweb.com added the comment: Sorry about that. I was using 3.1, as you will have gathered. -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12580 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: How to pop the interpreter's stack?
On 12/26/2010 2:14 PM, kj wrote: In mailman.301.1293383804.6505.python-l...@python.org Ethan Furman et...@stoneleaf.us writes: You failed to mention that cleverness is not a prime requisite of the python programmer -- in fact, it's usually frowned upon. That's the party line, anyway. I no longer believe it. I've been crashing against one bit of cleverness after another in Python's unification of types and classes... Well if you can find a way to implement a class system that doesn't use clever tricks *in its implementation* please let me know. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Trying to parse a HUGE(1gb) xml file
On 12/23/2010 4:34 PM, Stefan Sonnenberg-Carstens wrote: For large datasets I always have huge question marks if one says xml. But I don't want to start a flame war. I agree people abuse the spirit of XML using it to transfer gigabytes of data, but what else are they to use? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the the best style and theory of writing a complier in your language
On 12/23/2010 5:01 PM, small Pox wrote: What is the the best style and theory of writing a complier in your language Maybe a book will suffice. http://something-argumentative/ I want to parse the contents of the above link into hebrew audio. CHEERIOS Sure you do. regareds Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the the best style and theory of writing a complier in your language
On 12/24/2010 2:21 AM, Juha Nieminen wrote: In comp.lang.c++ small Pox smallpox...@gmail.com wrote: http://... You should take your religion somewhere else. And you should learn that by re-posting their links you assist spammers. -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: issubclass(dict, Mapping)
On 12/22/2010 9:20 AM, kj wrote: [...] I suspect this is another abstraction leak (dict is *supposed* to be a Python class like all others, but in fact it's not *really*. You see, once upon a time...). So your suspicions are to be placed above the knowledge of those who really do understand Python's object model? That seems like a recipe for cargo cult programming ... I conclude that, for me to understand Python's (rather leaky) object model abstraction, I have to understand its underlying implementation. Unfortunately, as far as I know, there's no other choice but to study the source code, since there's no other more readable description of this implementation. You don't have to understand the implementation (there are at least five different implementations, which one will you choose as your standard?) Maybe there are fewer abstraction leaks in 3.0... Python deliberately exposes introspection interfaces, which you may use if you wish. As with all introspectable languages (including Java) if you push the envelope you are likely to hit corner cases. As Steven d'Aprano has already said, these *are* corner cases and not the whole of the language. Don't worry about having a complete knowledge of the language before you start to use it. That can induce paralysis ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Catching user switching and getting current active user from root on linux
On 12/22/2010 2:28 PM, mpnordland wrote: ok, I'll give one more chance. First, to pacify those who hate google groups: What is a good usenet client? Thunderbird is OK for me (I follow about three groups normally). I access the comp.lang.python group vie the Gmane (Main) service, where for some strange resaon best known to the gmane admins it is called gmane.comp.python.general. Ho, hum. I seem to remember Outlook Express was a fairly decent NNTP client as well, and Tim Peters says I'm not just blowing smoke up your ass. second, How should I set up this proxy so that when a connection is made, it request's authentication, and then log's the request, if authentication is not gotten, how do I have it block (or firewall) the request? Furthermore, I would like for the proxy to be squid. So all of the nitty gritty should have to do with squid. I would recommend you take a look at the Spambayes code, which does all that sort of stuff apparently quite reliably. If you aren't yet proficient enough with Python to understand the code on your own look for a Python Meetup or a local or regional conference to meet people who will helpyou answer your questions. Increasingly there are workspaces like HacDC springing up to give people access to advanced technologies at everyday prices. You could look for such a group locally. There's lots of energy from people once they realise that what gets built can help them. Squid is a different matter. For that, probably if you go on an IRC channel (freenode.net is what I use, but others have their favorites). Maybe #squid? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Catching user switching and getting current active user from root on linux
On 12/20/2010 12:54 PM, mpnordland wrote: I give up, I will never try to use a usenet group again. For the ones of you who tried to help thank you. You helped to identify some of my troubles, as for you @usernet, you are a troll Don't give up after one experience. Usenet can be really useful as long as you know who to listen to and who to ignore ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Class-override of a sort-key method?
On 12/20/2010 7:10 PM, Chris Rebert wrote: On Mon, Dec 20, 2010 at 3:23 PM, pythonlist.cali...@spamgourmet.com wrote: Hi all - it would seem that these days, all the cool kids use the sort function's 'key' kwarg in order to sort a list of custom objects quickly. Really? They don't bother to define __cmp__ or similar? Sounds lazy and poorly structured. That sounds to me like a potentially ill-informed response. Unfortunately, as opposed to using 'cmp', where you can implent __cmp__ to get 'automatic sorting' in a similar fashion, there doesn't seem to be a direct analogue for a class-overridable method for providing a sort key. (ie, something like '__sortkey__' or '__key__'). Why do you talk about implementing __cmp__? Why should this be necessary? Just simply delegate to key comparison in your __cmp__ (or similar) method(s). Assuming, of course, that you are conveniently sorting only object over which you have complete control ... Is there one, and I'm just missing it? If not, are there any plans to add one? (I did a quick search of the PEP list, and the only hits for 'sort' I saw had to do with sorting dictionaries by value). If you know at class-definiton-time how you want instances to be sorted, then just define __cmp__ (or the rich comparison methods) appropriately, possibly even delegating to a comparison of keys (as the class defines them). For example: from functools import total_ordering @total_ordering class Person(object): def __init__(self, first_name, last_name): self.first_name = first_name self.last_name = last_name @property def _key(self): Identifying key for a Person, by which they are sorted return (self.last_name, self.first_name) def __eq__(self, other): return isinstance(other, Person) and self._key == other._key def __lt__(self, other): return self._key other._key If you want to abstract even this away, then just write a class decorator; there's no need to add yet another (rather complicated due to all the interactions with the existing comparison methods) special method. But the *real* point is (as the documentation attempts to point out) that by providing the key argument it gets called only once per element, whereas the cmp argument (or the objects' __cmp__() method if you insist on letting sort delegate to that) gets called every time two objects have to be compared. If cmp is a Python function (or equivalently if __cmp__() is a Python method) then calling it will take much longer than calling hte built-in default routines. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Redundant importing of modules
On 12/20/2010 8:36 PM, Jshgwave wrote: When writing a function that uses a module such as NumPy, it is tempting to include the statement import numpy or import numpy as np in the definition of the function, in case the function is used in a script that hasn't already imported NumPy. That could lead to the script issuing the import numpy command more than once. Does Python know to disregard redundant import commands? Oh, yes (as long as they are imported by the same name each time). There's a dict at sys.modules that has a key for each loaded module's name. When an attempt is made to import a module the first thing the interpreter does is to look at sys.modules. If it has the correct key in it then the assumption is that the module has already been imported, and its namespace is made available as the module name immediately. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: If/then style question
On 12/17/2010 9:38 AM, Steven D'Aprano wrote: On Fri, 17 Dec 2010 09:09:49 -0500, Rob Richardson wrote: First, just to clarify, I don't think the indentation I saw was what was originally posted. The else must be indented to match the if, and the two statements under else are in the else block. The return statement is indented at the same level as the for statement, so that it will be executed after the for loop exits. Correct? I think that what you are missing is that for-loops can include an else clause too, like this: for x in (1,2,3): ... print(x) ... else: ... print(finished) ... 1 2 3 finished The else block runs after the for block, unless you exit the entire block by returning, raising an exception, or using break: for x in (1,2,3): ... print(x) ... if x == 3: break ... else: ... print(finished) ... 1 2 3 Does that clear up what is going on? This construct appears to be unpopular in actual use, and when it comes up in classes and seminars there is always interesting debate as people discuss potential uses and realise there are useful applications. I think the choice of keyword is probably not Guido's crowning language achievement, but then since the English keywords don't make natural sense to those who speak other languages it's at least fair that there should be one that isn't totally natural to English speakers. A small price to pay for all the other keywords not being Dutch. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: If/then style question
On 12/17/2010 11:13 AM, Tim Golden wrote: On 17/12/2010 15:53, Steve Holden wrote: [... snip example of for-else ...] This construct appears to be unpopular in actual use, and when it comes up in classes and seminars there is always interesting debate as people discuss potential uses and realise there are useful applications. I use this not infrequently, and I like it when it seems to be an elegant way to express the code path. But I still misremember from time to time and assume that the else clause fires when the for loop is empty. Yes, that's a common misconception. The classical use is something like for item in possibilities: if item == target: break else: raise NotFound(Didn't find it) Though of course arguably that logic might be expressed in other ways, such as if target not in possibilities: raise NotFound(Didn't find it) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: while True or while 1
On 12/16/2010 5:44 AM, BartC wrote: On 12/12/2010 2:32 PM, Christian Heimes wrote: Am 12.12.2010 19:31, schrieb Steve Holden: $ python -m timeit -n20 -- i = 0 while 1: i+=1 if i == 100: break 20 loops, best of 3: 89.7 msec per loop $ python -m timeit -n20 -- i = 0 while True: i+=1 if i == 100: break 20 loops, best of 3: 117 msec per loop No argue with that! I was merely making a point that while 1 executes different byte code than while True. Readability is important but sometimes speed is of the essence. while 1 is one of the few tricks to speed up tight loops a bit. OK, but the figures you quote save you 27.3 ms per million iterations, for a grand total saving of 27.3 ns per iteration. So a bit is hardly worth considering for most programs, is it? One these is 30% faster than the other. That's an appreciable difference, which you can't really just dismiss. And you can't tell what the overall effect on a program will be: perhaps the loop will be in a library function , which might be called billions of times. It might. But if the code it is calling does *anything* at all significant I can promise you that spending an extra 30% purely on the looping construct will still make a negligible difference to a program's execution time, and there are almost certainly going to be many other aspects of performance that will yield greater benefits from tuning. I realise that there are going to be some people who just flatly say since 'while 1:' is quicker I am going to use it every time, and that their programs will still work. And I still maintain that (for English speakers) while True: is to be preferred. shol...@lifeboy ~ $ python -m timeit -- i = 1 while True: i += 1 if i == 100: break 10 loops, best of 3: 157 msec per loop shol...@lifeboy ~ $ python -m timeit -- i = 1 while True: i += 1 if i == 100: break x = i+1 10 loops, best of 3: 238 msec per loop shol...@lifeboy ~ $ python -m timeit -- i = 1 while 1: i += 1 if i == 100: break 10 loops, best of 3: 116 msec per loop shol...@lifeboy ~ $ python -m timeit -- i = 1 while 1: i += 1 if i == 100: break x = i+1 10 loops, best of 3: 195 msec per loop If binding a simple arithmetic expression adds more to the loop than the difference between while 1: and while True: you are wasting your time thinking about the savings under all but the most rigorous circumstances. Fortunately there is no penalty for ignoring my advice. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: string identity and comparison
On 12/16/2010 6:55 AM, Jean-Michel Pichavant wrote: Fellows, I'd like to illutrate the fact that comparing strings using identity is, most of the time, a bad idea. However I'm searching a short example of code that yields 2 differents object for the same string content. id('foo') 3082385472L id('foo') 3082385472L Anyone has that kind of code ? JM id(foo) 2146743808 id (f+o+o) 2146744096 regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: O'Reilly Python Certification
Each lesson required you to complete a practical assignment. You submit these assignments for evaluation, and do not proceed to the next lesson until your assignment reaches a satisfactory standard. Thus, less experienced students will tend to have more interaction with their tutors. A class will typically have between twelve and sixteen lessons. There are also quizzes and a final practical project. regards Steve On 12/16/2010 12:12 PM, Matty Sarro wrote: So how exactly does the class work? Is it like an elementary CS class where you have a teacher, assignments, etc. Or is it more like a guided tour through the O'Reilly Python book/cookbook? On Thu, Dec 16, 2010 at 10:40 AM, Ethan Furman et...@stoneleaf.us wrote: Please don't top-post. :) Nitin Pawar wrote: Can someone provide any links or any starting points on how to apply and what are the prerequisites http://www.oreillyschool.com/certificates/python-programming.php No prerequisites that I could see, and currently they are running a 25% discount promotional. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: If/then style question
On 12/16/2010 11:32 PM, Carl Banks wrote: On Dec 16, 2:56 pm, Ryan Kelly r...@rfk.id.au wrote: On Thu, 2010-12-16 at 21:49 +, John Gordon wrote: (This is mostly a style question, and perhaps one that has already been discussed elsewhere. If so, a pointer to that discussion will be appreciated!) When I started learning Python, I wrote a lot of methods that looked like this: def myMethod(self, arg1, arg2): if some_good_condition: if some_other_good_condition: if yet_another_good_condition: do_some_useful_stuff() exitCode = good1 else: exitCode = bad3 else: exitCode = bad2 else: exitCode = bad1 return exitCode But lately I've been preferring this style: def myMethod(self, arg1, arg2): if some_bad_condition: return bad1 elif some_other_bad_condition: return bad2 elif yet_another_bad_condition: return bad3 do_some_useful_stuff() return good1 I like this style more, mostly because it eliminates a lot of indentation. However I recall one of my college CS courses stating that one entry, one exit was a good way to write code, and this style has lots of exits. Are there any concrete advantages of one style over the other? one entry, one exit has its good points, but it's *way* overquoted and overused. Do you raise any exceptions? Do you call any functions that might raise exceptions? If so, you've got multiple exit points already. I think this style a lot more important in a language like C where you have to be super-careful about cleaning up after yourself. The single exit point makes it easier to verify that all cleanup tasks have been performed. Assuming you're using with or try-finally then you just don't need such guarantees in python. Even without the cleanup issue, sometimes you want to edit a function to affect all return values somehow. If you have a single exit point you just make the change there; if you have mulitple you have to hunt them down and change all of them--if you remember to. I just got bit by that one. It's a trade-off. Readability and/or conciseness versus error robustness. I tend to go for the former but mileage varies. Heaven forfend you should just wrap the existing function inside another one which takes its name, if all its returns need to be altered. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter polling example: file copy with progress bar
On 12/14/2010 11:52 PM, JohnWShipman wrote: you know how us ancient Unix weenies are. Indeed we do ... ;-) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Proposed changes to logging defaults
On 12/15/2010 5:03 AM, Vinay Sajip wrote: On Dec 15, 8:46 am, John Nagle na...@animats.com wrote: You're assuming that theloggingpackage has the right to blither on the default sys.stderr. There are many cases in which it should not. The program could be running in a web server, and output would end up in the output HTML. The program could be running as a subprocess, and the output could end up in the pipe back to the the parent. sys.stderr might be connected to a dead pipe, and writing to it would then kill the program. So this change could break existing programs in subtle ways. I'm not assuming anything, and the rationale for the change is described in detail in the linked-to post. The reason for posting the link on this list is to give people advance warning of the changes, so they can see if they're affected and take the appropriate action. Note that since this change only affects the user who is using Python 3.2 and has not configured logging. Since the necessary configuration is easy to do, I'm assuming people who might be affected can easily update their code in time for the 3.2 release. I might add that any web server that sends sys.stderr to the HTTP output stream is not likely to be professionally managed. It's far preferable, in the general case, to ensure that logging messages do not enter the stdout-stdin pipelines carrying information between coordinating processes. If a current task is assuming the prior logging package's behavior and analysing a process's stdout for messages it arguably needs fixing anyway, though I agree that breakage of any kind is unfortunate. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Links and pointers to basics of soap and suds
On 12/15/2010 7:38 AM, srinivas hn wrote: Hi All, I am very new to the soap and its python client suds.Can anyone tell me how the actual will happens i nthe webservices including suds and soap API. That's a bit like saying I need to go around the corner. Would you mind teaching me to drive?. Google for phrases like web services architecture and SOAP WSDL to get some idea of how these technologies are put together. This assumes, of course, that you already possess a fair idea of how the web is put together. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Dealing with pywin32 on Linux
On 12/15/2010 8:51 AM, Benedict Verheyen wrote: On 15/12/2010 14:37, Tim Golden wrote: Well I'm not sure how far something like WINE would take you, but I suggest that trying to develop Windows-specific code in a Linux Dev environment is creating a rod for your own back. For the specific case you mention, you should be able to switch, lock, stock barrel to python-ldap or other LDAP modules. But that means a fairly major rewrite, plus that's only one issue. None of the Windows-specific stuff will work: registry, win32api calls, whatever you're pulling out of the pywin32 packages. TJG Hi, thanks for your answer. For the moment, i only need to connect to AD to authenticate. But you raise a good point that if I need more functionality, I will encounter problems. Benedict: Have you considered running a virtual Windows machine to handle the specific issues that really require a Windows environment? If the loading isn't at brutal levels VirtualBox is a very adequate solution, and of course Python user VMWare has a full range of industrial-grade solutions for virtualization. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: while True or while 1
On 12/15/2010 8:10 AM, Hans-Peter Jansen wrote: On Tuesday 14 December 2010, 21:38:47 Arnaud Delobelle wrote: Christian Heimes li...@cheimes.de writes: [...] Tres Seavers once told me a joke like this: True = not not Who's at the door? # say it out loud! This was back in the old days of Zope 2.5 and Python 2.1, which didn't have True and False. I almost used: True = to be or not to be # that is the question That's wrong: to be or not to be 'to be' You need to wrap it with bool() at least (even without interpreting Pythons answer to the duality contradiction of consciousness for now ;-)) but didn't dare! Yeah, if Hamlet had been a Python programmer that play would have been a light comedy. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: O'Reilly Python Certification
On 12/15/2010 12:54 PM, Ethan Furman wrote: So I just got an e-mail from O'Reilly and their School of Technology about a Python Certification course... anybody have any experience with this? It also says Steve Holden is involved -- is this True? (Steve?) Well, it's not not not False. You think O'Reilly would publish lies on their web site? :-) I am a little more that involved. In ham and eggs the chicken is involved. I am committed, like the pig, having got three of the four classes into production after almost two years' work. So for those of you who may have wondered why I have been on c.l.py only sporadically lately, now you know. The certificate will come from the University of Illinois after approximately 160 hours of study. By the end of the series you should have a substantial corpus of Python code that you have typed in yourself, understand and can discuss with potential employers and others. You will have a fair knowledge of Python and you will be accustomed to test-driven development. ~Ethan~ PS Can you tell I've been programming? ;) I would really like to hear from anyone who takes the class. I would like to ensure that it is kept up to date and relevant with continuous improvements, and feedback will be invaluable in helping me to achieve this goal. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: O'Reilly Python Certification
On 12/15/2010 3:40 PM, Tim Chase wrote: On a more serious note, it would be interesting to know if it's possible to test out of the certification for those of us that have been using Python for a long time. That's an interesting idea - let a bunch of experienced Python users tell me what a lousy job I have done of explaining the language. :) Seriously, I would be interested, and it's a terrific idea. I can't do anything before January, but if anyone is interested in taking part in such a review of the materials I'd be grateful if they would contact me privately by email on a no promises basis. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: O'Reilly Python Certification
On 12/15/2010 4:21 PM, Stefan Sonnenberg-Carstens wrote: Am 15.12.2010 22:11, schrieb Steve Holden: On 12/15/2010 3:40 PM, Tim Chase wrote: On a more serious note, it would be interesting to know if it's possible to test out of the certification for those of us that have been using Python for a long time. That's an interesting idea - let a bunch of experienced Python users tell me what a lousy job I have done of explaining the language. :) Seriously, I would be interested, and it's a terrific idea. I can't do anything before January, but if anyone is interested in taking part in such a review of the materials I'd be grateful if they would contact me privately by email on a no promises basis. regards Steve I think he meant: take the test without study first. I'd be interested in both, though. There isn't a test. The award of the certificate is based on providing working solutions to projects at the end of each lesson. Bear in mind I have not spoken to my O'Reilly contacts about whether they would be OK with such a scheme, hence the no promises. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: default argument in method
On 12/13/2010 12:14 PM, Godson Gera wrote: On Sun, Dec 12, 2010 at 5:05 PM, ernest nfdi...@gmail.com mailto:nfdi...@gmail.com wrote: Hi, I'd like to have a reference to an instance attribute as default argument in a method. It doesn't work because self is not defined at the time the method signature is evaluated. For example: class C(object): def __init__(self): self.foo = 5 def m(self, val=self.foo): return val Raises NameError because 'self' is not defined. You can defined foo outside the __init__ and can access it inside methods using self.foo class C(object): foo=5 def __init__(self): print self.foo def m(self,val=foo): return val class attributes can be accessed with out self before them in method signatures. However, becareful if you change the value of foo inside any method, the method signature will still hold on to old value. You are, of course, correct. It might be more accurate to say that if C.foo is rebound this does not change the binding of the val default value. Change the value of foo could be though to include mutate a mutable value, but in that case both C.foo and the method's val parameter would still be bound to the same object. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: while True or while 1
On 12/12/2010 10:30 AM, Christian Heimes wrote: Am 12.12.2010 15:14, schrieb Max Countryman: I'm sure this has been brought up many times, but a quick Googling didn't yield the decisive results I was hoping for, so I apologize if this has already been addressed in great detail somewhere else. I am wondering what the rationale is behind preferring while True over while 1? For me, it seems that using True provides more clarity, but is that the only benefit? Is while 1 more prone to errors? In Python 2.x, while 1 is slightly faster than while True. The interpreter can't optimize while True because the name True can be bind to another value. In Python 3.x it's no longer possible to rebind the names True and False just like None in Python 2.x Would you care to quantify how much CPU time that optimization will typically save for a loop of fair magnitude (say, a billion iterations)? Python is designed to provide readable code. Writing while True: ... is much more legible than its pre-True couterpart while 1: ... and is, I'd say, therefore to be preferred (except in a code base intended to compile on 2.2 and before). regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: while True or while 1
On 12/12/2010 2:32 PM, Christian Heimes wrote: Am 12.12.2010 19:31, schrieb Steve Holden: Would you care to quantify how much CPU time that optimization will typically save for a loop of fair magnitude (say, a billion iterations)? The difference is minimal but measurable for very tight loops. $ python -m timeit -n20 -- i = 0 while 1: i+=1 if i == 100: break 20 loops, best of 3: 89.7 msec per loop $ python -m timeit -n20 -- i = 0 while True: i+=1 if i == 100: break 20 loops, best of 3: 117 msec per loop In Python 2.x the peep hole optimizer can't remove the global lookup and check for trueness for while True. Yes, you said that already and I certainly didn't disagree. [...] Python is designed to provide readable code. Writing while True: ... is much more legible than its pre-True couterpart while 1: ... No argue with that! I was merely making a point that while 1 executes different byte code than while True. Readability is important but sometimes speed is of the essence. while 1 is one of the few tricks to speed up tight loops a bit. OK, but the figures you quote save you 27.3 ms per million iterations, for a grand total saving of 27.3 ns per iteration. So a bit is hardly worth considering for most programs, is it? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: instance has no __call__ method
On 12/10/2010 5:20 AM, frank cui wrote: Hi all, I'm a novice learner of python and get caught in the following trouble and hope experienced users can help me solve it:) Code: --- $ cat Muffle_ZeroDivision.py #!/usr/bin/env python class MuffledCalculator: muffled = False def clac(self,expr): try: return eval(expr) except: if self.muffled: print 'Division by zero is illegal' else: raise -- $ python Python 2.7 (r27:82500, Sep 16 2010, 18:03:06) [GCC 4.5.1 20100907 (Red Hat 4.5.1-3)] on linux2 Type help, copyright, credits or license for more information. import Muffle_ZeroDivision calc = Muffle_ZeroDivision.MuffledCalculator() calc = ('10/2') calc = Muffle_ZeroDivision.MuffledCalculator() calc('10/2') Traceback (most recent call last): File stdin, line 1, in module AttributeError: MuffledCalculator instance has no __call__ method There is an AttributeError that this instance doesn't have the __call__ method, so how to add this kind of method to my instance? Thanks a lot in advance. Regards Frank.Cui Try renaming your .calc() method to .__call__(). That way the method will be called when you perform a function call on an instance. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: 64 bit memory usage
On 12/10/2010 2:03 PM, Rob Randall wrote: I manged to get my python app past 3GB on a smaller 64 bit machine. On a test to check memory usage with gc disabled only an extra 6MB was used. The figures were 1693MB to 1687MB. This is great. Thanks again for the help. Do remember, though, that with the GC turned off you will lose memory if you accidentally create cyclic data structures, since they will never be reclaimed. It doesn't sound like this is an issue, but I wanted this to act as a warning to others who might come across your solution but have programmed less carefully. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python critique
On 12/11/2010 6:46 AM, Lie Ryan wrote: On 12/11/10 11:37, Dan Stromberg wrote: On Fri, Dec 10, 2010 at 3:51 PM, John Nagle na...@animats.com wrote: On 12/10/2010 3:25 PM, Stefan Behnel wrote: Benjamin Kaplan, 11.12.2010 00:13: On Fri, Dec 10, 2010 at 5:46 PM, Octavian Rasnita wrote: The only scopes Python has are module and function. There's more. Both a lambda, and in Python 3.x, list comprehensions, introduce a new scope. And classes and methods. Also, class scope and instance scope, though similar, are distinct scopes. Python also have the hidden interpreter-level scope (the __builtins__). But classes and instances don't have scopes. They have namespaces. That is, if we are talking about lexical scoping. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python critique
On 12/11/2010 6:46 AM, Lie Ryan wrote: Also, class scope and instance scope, though similar, are distinct scopes. Python also have the hidden interpreter-level scope (the __builtins__). Kindly ignore my last post. Class scopes are lexical, instance scopes are not. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python distribution recommendation?
On 12/11/2010 9:31 AM, Octavian Rasnita wrote: Ok, thank you all for your recommendations. I think I will install ActivePython because it seems that it offers more features for Windows programming than the other distro (by default, which is important for a beginner). I will use WxPython and not other GUIS like QT, Tk or GTK because they are not accessible for screen readers, so I will also need to install WxPython if ActiveState's Python doesn't include it. I must say that wxPython has been one of the most consistently easy packages to install over the last ten years. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: little emacs lisp tutorial on turning a url into a link
On 12/10/2010 4:52 AM, small Pox wrote: [... irrelevant stuff...] I advocate neither anti semitism nor pro semitism. just the rule of law that treats people equally and fairly and where money does not count. this cannot be achieved without demolishing fractional reserve lending, and not without making the courts free and preventing knowledge monopolies. If a certain group is going up disproportionately, then there is something to look at. I see everyone work as hard as anyone else. This is completely off-topic for c.l.py. Kindly bugger off. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: use of __new__ to permit dynamic completion within (any?) IDE ?
On 12/8/2010 1:01 PM, gst wrote: As I told I try to have some kind of ultimate autocompletion, always working for this kind of case (I know exactly that a certain member of a certain class' instance will always have the same type but my IDE doesn't seem to guess/know it.. ; I guess the best answer would be : bad IDE, change IDE but I'm guessing that others IDE can't do a lot better in this case. If you'd told us which IDE you were using we might have offered better advice, but you seem to want to keep that a secret (my IDE tells us nothing). regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: is py2exe still active ?
Octavian: It's great that you want to let people know about bugs. Put yourself in the position of the package maintainer, however. She or he doesn't spend all day working on cxFreeze, and probably doesn't even do a Google search on cxFreeze very often. So they are unlikely to find out about this problem form your well-intentioned note. It's just possible nobody does care, as I can't find a link to an issue tracker - the best I could advise in this case would be to join the mailing list by visiting https://lists.sourceforge.net/lists/listinfo/cx-freeze-users regards Steve On 12/7/2010 6:49 PM, Octavian Rasnita wrote: This packager is also nice. If someone cares, I've discovered a small bug in it. If Python is installed on another drive than C under Windows, the cxfreeze.bat file still calls Python on the drive C and it doesn't work until it is corrected. Octavian - Original Message - From: Cbast sebastien.fri...@gmail.com Newsgroups: comp.lang.python To: python-list@python.org Sent: Tuesday, December 07, 2010 5:00 PM Subject: Re: is py2exe still active ? On Dec 7, 8:23 am, Anders Persson anders.u.pers...@gmail.com wrote: Hi! When a look att py2exe homepage it is not looking like mutch happen, as a beginner i was thinking to start with Python 3, but i like to now if py2exe will be for 3 too. Is any one have any info ? I don't have the answer about py2exe, but I'm using cxFreeze to create executables with Python 3.1, if it's what you're looking for. http://cx-freeze.sourceforge.net/ -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Collision of rotated rectangles without pygame
On 12/7/2010 9:53 AM, John Nagle wrote: On 12/5/2010 2:49 PM, Martin Manns wrote: Hello, I am looking for a Python library for 2D collision checks of rotated rectangles. Currently, I have found vizier 0.5b that is based on pygame. Since I do not want to add a pygame dependency to my app, I replaced the pygame.rect.Rect by a wxPython wx.Rect (see code below). However, collision checks do not work correctly, i. e. identical rects are not found to be colliding: Probably because you seem to be trying to compute the intersection point for coincident lines, which is not well-defined. I don't have time to debug this, but you might want to get some basic books on game programming and graphics. Incidentally, a dictionary lookup in Python is far more expensive than computing trig functions. If you need to speed this up for large numbers of rectangles, there are algorithms that are several orders of magnitude faster. Realistically, though, this is the kind of problem that runs slow in CPython. That appears to be (from a rather limited investigation) a wild-assed assertion unjustified by anything other than preconceptions. With d as a dict containing 100 random numbers from (0,1) I see this: def fm(): ... x = random.random() ... return math.sin(x) ... def fd(): ... x = random.random() ... return x in d ... timeit.timeit(fm) 0.58099985122680664 timeit.timeit(fd) 0.5524577636719 Of course it's possible that the random number generation is dominating, but I'd still like to see some proof. I know for a fact that dict lookup has been extensively optimized, and while I am no longer involved in numerical computing it seems to me there's still a lot to do to compute a sin unless your CPU will do it for you. regards Steve This is why you don't write your own collision library. (I once did, for 3D, but that was in 1996, when it was cutting-edge technology.) John Nagle -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Perceived inconsistency in py3k documentation
On 12/6/2010 8:00 PM, Antoine Pitrou wrote: On Sun, 05 Dec 2010 14:47:38 -0500 Terry Reedy tjre...@udel.edu wrote: On 12/5/2010 3:31 AM, Greg wrote: For future reference, 1) At http://docs.python.org/py3k/reference/datamodel.html: 2) At http://docs.python.org/py3k/library/stdtypes.html: do not work because of the trailing :s, at least not with FireFox. Work fine here. The problem isn't Firefox, it is your e-mail or news client. Antoine. In my case also the links don't work, because my newsreader (Thunderbird) makes the assumption that the colons are part of the URLs. This behavior is common enough that people need to be aware of it. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Exception handling in Python 3.x
On 12/7/2010 5:58 AM, John Nagle wrote: PEP 255, like too much Python literature, doesn't distinguish clearly between the language definition and implementation detail. It says The mechanics of StopIteration are low-level details, much like the mechanics of IndexError in Python 2.1. Applications shouldn't be explicitly using StopIteration. So you don't think that we should rely on iterables with no __iter__() method to raise IndexError to terminate iterations when their __getitem__() is called with an invalid index? The IndexError mechanism was, to the best of my less-than-complete knowledge, used by all pre-2.2 implementations. The quoted paragraph appears to be intended to reassure the applications programmer that there is no normal need to handle StopIteration specially - just as there was no need to handle IndexError specially. IronPython doesn't do StopIteration the same way CPython does. http://ironpython.codeplex.com/wikipage?title=IPy1.0.xCPyDifferences Perhaps not, but the only difference is what happens on repeated calls to next() after the iterator is exhausted. The iterator still terminates by raising a StopIteration error. I have no idea what Shed Skin does, but to the extent that iterators don't raise StopIteration on exhaustion I'd say it is in error. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Exception handling in Python 3.x
On 12/7/2010 1:48 AM, MRAB wrote: Perhaps Python could use Guido's time machine to check whether the sequence will yield another object in the future. :-) Since there's only one time machine that would effectively be a lock across all Python interpreters. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: completely implicit interpolation based on a frame object
On 12/8/2010 2:49 AM, Edward Peschko wrote: All, Ok, it looks like in order to implement a tracer that does interpolation, I'm going to have to hack around with frames. Perl's interpolation is fairly straightforward, to do interpolation of $a == 1 all you need to do is put quotes around $a == 1 to have $a evaluated. So, I'd like to do the same thing with python. It looks like I can do the same thing with frames, ie: interpolate_frame(frame, if not wx.Platform == '__WXMAC' ) would interpolate wx based off of the frame that you passed to interpolate_frame, because wx is in the f_locals or f_globals dictionary. Hence, this would become: loc_wx = _first_defined(frame.f_locals[wx], frame.f_globals[wx]) return if not , loc_wx.Platform , == \__WXMAC\ which would then do the interpolation. I guess my question is - has something like this been released? I see some close hits, namely Evan Forsmark's http://www.evanfosmark.com/2008/06/string-interpolation-in-python/ but I don't see anything exact, and getting this right would be fairly tricky, so I was hoping for canned solution. Any ideas would be great on this, including pitfalls that people see in implementing it. http://docs.python.org/library/string.html#template-strings regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparison with False - something I don't understand
On 12/6/2010 9:14 AM, Paul Rubin wrote: m...@distorted.org.uk (Mark Wooding) writes: The most obvious improvement is resumable exceptions. You know, I've heard the story from language designers several times over, that they tried putting resumable exceptions into their languages and it turned out to be a big mess, so they went to termination exceptions that fixed the issue. Are there any languages out there with resumable exceptions? Escaping to a debugger doesn't really count as that. I guess one way to do it would be call a coroutine to handle the exception, and either continue or unwind after the continue returns, but doing it in a single-threaded system just seems full of hazards. I seem to remember PL/1 has resumable exceptions, but I don't ever remember finding a real use for them. And it's so long since I used PL/1 I may be mistaken. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How to add data into exisitng Excel file at next open row?
On 12/3/2010 6:21 PM, noydb wrote: How can you determine the next open row in an existing Excel file such that you can start adding data to the cells in that row? As in below, I want a variable in place of the 6 (row 6 in the four ws1.Cells(x,1) lines), but have no other way of knowing what row I am on besides looking to the first free cell in column A. How to do? Examples I see make it seem really complicated - this can't be that hard. Thanks for any help. worksheet = C:\\Excel_Reports\\ea + ea + report# + .xls xlApp = win32com.client.Dispatch(Excel.Application) xlApp.Visible = 1 xlApp.Workbooks.Open(worksheet) ## for existing file ##xlApp.SheetsInNewWorkbook = 1 ##wb = xlApp.Workbooks() ws1 = xlApp.Worksheets(1) ws1.Cells(6,1).Value = selection ws1.Cells(6,2).Value = count ws1.Cells(6,3).Value = epcFloat ws1.Cells(6,8).Value = currentGMT wb.SaveAs(worksheet) wb.Close(False) ## False/1 You might want to take a look at the xlrd library. This lets you read Excel spreadsheets even on Unix platforms and without the use of COM magic. There's also an xlwt module for writing spreadsheets. However I understand that the two together may not be as convenient as modifying a spreadsheet in place. In particular, if sh is a spreadsheet then sh.nrows gives you the number of rows currently used in the sheet. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: class attribute confusion
On 12/3/2010 11:58 PM, Steven D'Aprano wrote: Right. If you define a *class* attribute, it lives in the class, not the instance, and so all instances share the same value. Unless, of course, an instance binds the same name in its namespace, in which case it will (usually) mask the class attribute for that instance. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Which non SQL Database ?
On 12/5/2010 12:59 AM, CM wrote: SQlite itself is around 300 kilobytes. That's negligible. It is also already in Python, so you'd have to purposefully exclude it in creating your executable to save those 300 kb and thus the 1/13th of a second additional time it would take average (3.9 MB/s) users to download your app if it were included. Just as a matter of interest where do you get the information that the average user has a 3.9 MB/s path to the Internet? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparison with False - something I don't understand
On 12/2/2010 11:42 PM, Harishankar wrote: One of the reasons why I feared to do this is because I need to know each and every exception that might be thrown by the function and litter my top-level code with too many exception handlers. You appear to be suffering from the delusion that all exceptions must be caught and handled. This is far from being the case. But still, better to have your top-level code littered with exception handlers than to have your functions littered with if statements. Quite often it's impossible for the function to know what needs to be done when a specific conditions arises, in which case (presumably) you have to return some error code and test for that ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparison with False - something I don't understand
On 12/2/2010 9:13 AM, Harishankar wrote: On Thu, 02 Dec 2010 22:19:25 +1100, Ben Finney wrote: More details of the problem you're trying to solve would help with giving specific advice. I'm writing functions with multiple points of failure exits. I use return False as a way to flag the error condition rather than raising exceptions. But under certain circumstances, the function can also return empty lists which equate to false when using the condition like: # myfunction () can return a list of tuples, but can also return an empty # list under certain conditions since it's query a database and the result # can be empty also result = myfunction (vars) if not result: # error condition Now above I first realized that the function can also return an empty list under some conditions and so changed it to if result == False: # error condition But now I realize that it's better to use is if result is False: # error condition That is how my problem arose. Did you think about using exceptions to handle exceptional conditions? If you are new to Python it may not be the obvious soltuion, but it can greatly simplify program logic. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparison with False - something I don't understand
On 12/2/2010 9:56 AM, Harishankar wrote: 3. Philosophically I think exception handling is the wrong approach to error management. I have never grown up programming with exceptions in C and I couldn't pick up the habit with python either. Did I mention that I detest try blocks? try blocks seem ugly and destroy code clarity at least in my view. And enclosing single statements under separate try blocks seem to add a lot of clutter. Whereas lots of nested if statements to test that multiple errors have all not occurred is a model of clarity? This sounds to me like a prejudice that will harm your Python development. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparison with False - something I don't understand
On 12/2/2010 1:31 PM, Terry Reedy wrote: It turns out that try block are computationally lighter weight (faster) for normal execution ;-) Though that alone would hardly be sufficient reason to use them. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's equivalent to Main calling program and subprograms
On 12/1/2010 12:08 PM, m b wrote: if __name__ == __main__: main() What does this mean? /Mikael It's a standard way of allowing programs to test themselves. When a module is imported its __name__ attribute us bound to the name of the module. When the module is run as a main program (from the command line) its __name__ attribute is set to __main__. The main() call just calls a function that (presumably) tests the functions the module provides. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: SAX unicode and ascii parsing problem
On 11/30/2010 3:43 PM, goldtech wrote: Hi, I'm trying to parse an xml file using SAX. About half-way through a file I get this error: Traceback (most recent call last): File C:\Python26\Lib\site-packages\pythonwin\pywin\framework \scriptutils.py, line 325, in RunScript exec codeObject in __main__.__dict__ File E:\sc\b2.py, line 58, in module parser.parse(open(r'ppb5.xml')) File C:\Python26\Lib\xml\sax\expatreader.py, line 107, in parse xmlreader.IncrementalParser.parse(self, source) File C:\Python26\Lib\xml\sax\xmlreader.py, line 123, in parse self.feed(buffer) File C:\Python26\Lib\xml\sax\expatreader.py, line 207, in feed self._parser.Parse(data, isFinal) File C:\Python26\Lib\xml\sax\expatreader.py, line 304, in end_element self._cont_handler.endElement(name) File E:\sc\b2.py, line 51, in endElement d.write(csv+\n) UnicodeEncodeError: 'ascii' codec can't encode characters in position 146-147: ordinal not in range(128) I'm using ActivePython 2.6. I trying to figure out the simplest fix. If there's a Python way to just take the source XML file and covert/ process it so this will not happen - that would be best. Or should I just update to Python 3 ? I tried this but nothing changed, I thought this might convert it and then I'd paerse the new file - didn't work: uc = open(r'E:\sc\ppb4.xml').read().decode('utf8') ascii = uc.decode('ascii') mex9 = open( r'E:\scrapes\ppb5.xml', 'w' ) mex9.write(ascii) Again I'm looking for something simple even it's a few more lines of codes...or upgrade(?) Thanks, appreciate any help. mex9.close() I'm just as stumped as I was when you first asked this question 13 minutes ago. ;-) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Change one list item in place
On 11/30/2010 8:28 PM, MRAB wrote: On 01/12/2010 01:08, Gnarlodious wrote: This works for me: def sendList(): return [item0, item1] def query(): l=sendList() return [Formatting only {0} into a string.format(l[0]), l[1]] query() However, is there a way to bypass the l=sendList() and change one list item in-place? Possibly a list comprehension operating on a numbered item? There's this: return [Formatting only {0} into a string.format(x) if i == 0 else x for i, x in enumerate(sendList())] but that's too clever for its own good. Keep it simple. :-) I quite agree. That solution is so clever it would be asking for a fight walking into a bar in Glasgow. However, an unpacking assignment can make everything much more comprehensible [pun intended] by removing the index operations. The canonical solution would be something like: def query(): x, y = sendList() return [Formatting only {0} into a string.format(x), y] regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list