Re: Beginner. 2d rotation gives unexpected results.
On Tue, 23 Jul 2013 15:11:43 +0200, Peter Otten wrote: The conversion to int introduces a rounding error that accumulates over time. Most floating point calculations introduce a rounding error. If the calculations are iterated, the error will accumulate. In general, you want to avoid accumulating entire transformations. E.g. if you want a spinning object, maintain the cumulative rotation angle and rotate the original points each frame. If you must accumulate transformations, you need to actively work to maintain any desired invariants. E.g. if a transformation is supposed to be orthonormal (all axes perpendicular and of unit length), you should renormalise it periodically, otherwise the lengths and angles will change over time. -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange behaviour with os.linesep
On Tue, 23 Jul 2013 13:42:13 +0200, Vincent Vande Vyvre wrote: On Windows a script where de endline are the system line sep, the files are open with a double line in Eric4, Notepad++ or Gedit but they are correctly displayed in the MS Bloc-Notes. I suspect the problem lies with Eric4, Notepad++ and Gedit. Do you perhaps have to manually tell them that the file uses Windows line separators? I recommend opening the file in a hex editor and seeing for yourself what line separators are used. Example with this code: -- # -*- coding: utf-8 -*- import os L_SEP = os.linesep def write(): strings = ['# -*- coding: utf-8 -*-\n', 'import os\n', 'import sys\n'] with open('writetest.py', 'w') as outf: for s in strings: outf.write(s.replace('\n', L_SEP)) write() -- The syntax `s.replace('\n', L_SEP)`is required for portability. I don't think it is. Behaviour is a little different between Python 2 and 3, but by default, Python uses Universal Newlines. When you open a file in text mode, arbitrary line separators should be automatically translated to \n when reading, and \n will be automatically translated to os.line_sep when writing. http://docs.python.org/3/library/functions.html#open http://docs.python.org/2/library/functions.html#open Some further discussion here: http://stackoverflow.com/questions/12193047/is-universal-newlines-mode- supposed-to-be-default-behaviour-for-open-in-python -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Python testing tools
On Saturday, July 20, 2013 1:11:12 AM UTC-7, Ben Finney wrote: cutems93 ms2...@cornell.edu writes: I am currently doing some research on testing software for Python. I found that there are many different types of testing tools. These are what I've found. You will find these discussed at the Python Testing Tools Taxonomy URL:http://wiki.python.org/moin/PythonTestingToolsTaxonomy. Hope that helps. Thank you, but I already read this page before I posted this question. What I want to know is whether you personally use these tools other than unit testing tools. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python testing tools
Thank you, but I already read this page before I posted this question. What I want to know is whether you personally use these tools other than unit testing tools. I tried using one of the mock tools a few years ago. I found it didn't fit my brain very well. (Maybe it was just me.) I use pylint all the time, and coverage from time-to-time, have used nose in the past, but not for my current stuff. All are worth your time. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Python testing tools
On Tuesday, July 23, 2013 11:04:23 AM UTC-7, Skip Montanaro wrote: Thank you, but I already read this page before I posted this question. What I want to know is whether you personally use these tools other than unit testing tools. I tried using one of the mock tools a few years ago. I found it didn't fit my brain very well. (Maybe it was just me.) I use pylint all the time, and coverage from time-to-time, have used nose in the past, but not for my current stuff. All are worth your time. Skip Thank you! What tool do you use for coverage? And have you used pychecker? I heard it is as good as pylint. What do you think? -Min S. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python testing tools
Thank you! What tool do you use for coverage? coverage. :-) And have you used pychecker? Yes, in fact, I used to use a wrapper script I wrote that ran both pylint and pychecker, then massaged the output into suitable-for-emacs-next-error-command I heard it is as good as pylint. What do you think? They overlap a fair bit, but do somewhat different things. S -- http://mail.python.org/mailman/listinfo/python-list
Re: Python testing tools
On Tuesday, July 23, 2013 11:33:10 AM UTC-7, Skip Montanaro wrote: Thank you! What tool do you use for coverage? coverage. :-) And have you used pychecker? Yes, in fact, I used to use a wrapper script I wrote that ran both pylint and pychecker, then massaged the output into suitable-for-emacs-next-error-command I heard it is as good as pylint. What do you think? They overlap a fair bit, but do somewhat different things. S Could you please elaborate on the difference of the two? I heard pylint does not import your source code when it is analyzing, while pychecker does. Does that make some difference? Moreover, do you personally like pylint or pycheker and why? Thank you!! -Min S. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python testing tools
Could you please elaborate on the difference of the two? I heard pylint does not import your source code when it is analyzing, while pychecker does. Does that make some difference? Moreover, do you personally like pylint or pycheker and why? I haven't followed pychecker development for awhile. Pylint seems more actively maintained, though I could be wrong. The import issue is one significant difference, important if you are trying to check scripts which have side effects when imported. It's not a matter of like or not. I use what works and can easily be fit into the way I work. Both pylint and pychecker satisfy that constraint. S -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On Tue, Jul 23, 2013 at 8:06 PM, Duncan Booth duncan.booth@invalid.invalid wrote: Excellent idea, I'll tell the email forwarding service to rewrite their system immediately. Yes. If they are using your domain in the MAIL FROM command and not using your mail servers, then yes, you should tell them, and use a different service until they fix that. It is not SPF's fault. It is a fundamental error of protocol, which SPF checks are highlighting. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] SPF - was Re: Simple Python script as SMTP server for outgoing e-mails?
On Wed, Jul 24, 2013 at 1:12 AM, Michael Torrie torr...@gmail.com wrote: On 07/23/2013 03:30 AM, Chris Angelico wrote: On Tue, Jul 23, 2013 at 7:19 PM, Chris Angelico ros...@gmail.com wrote: Ah, there's a solution to this one. You simply use your own envelope-from address; SPF shouldn't be being checked for the From: header. There's an example, by the way, of this exact technique right here - python-list@python.org sends mail to me with an envelope-from of python-list-bounces+rosuav=gmail@python.org - which passes SPF, since python.org has a TXT record designating the sending IP as one of theirs. It doesn't matter that invalid.invalid (your supposed domain) doesn't have an SPF record, nor would it be a problem if it had one that said v=spf1 -all, because that domain wasn't checked. Mailing lists are doing the same sort of forwarding that you're doing. This is good and all, and I think I will modify my local postfix mail server I use for personal stuff, just for correctness' sake. Correctness is a worthwhile reason to do something :) I hadn't spent much time studying SPF in depth before, but after reading your comments (which were insightful) I'm now more convinced that SPF is worthless than ever, at least as a spam prevention mechanism. Spammers can use throwaway domains that publish very non-strict SPF records, and spam to their hearts content with random forged from addresses and SPF checks pass. The only way around that is to enforce SPF on the From: header in the e-mail itself, which we all agree is broken. I've been reading this: http://www.openspf.org/FAQ/SPF_is_not_about_spam There are several things that SPF achieves, but mainly it's a measure of trust. If you receive email from a domain I run, and the SPF record permits the IP that sent it to you, you can have a high degree of confidence that it really is from that domain. Suppose, for instance, that (pick a bank, any bank) has a strict SPF record. Someone tries to send a phishing email purporting to be from that bank. They then have to use a different envelope-from address, which instantly marks the mail as suspicious to anyone who's checking. But more likely, what they'll do is simply ignore SPF and send it anyway. That means that any MTA that checks SPF records is immediately freed of all that bad mail - which is more than just spam, it's a major vulnerability (thinking here of corporate networks where all the company's mail goes through a central server, and then a whole lot of non-technical people read it). In the same way that banks assure us that they will *never* ask for your password, they could also assure us that they will *never* send account information from any other domain. Spammers look for the easy pickings. If your X million addresses become (X-1),999,900 because a few servers are rejecting their mail, what do they care? But those hundred people now haven't seen that spam. Sure, spammers can easily get around SPF checks... but that won't get all that likely until the bulk of MTAs start checking. For now, we can take all the benefit. Later on, the world can look to other solutions. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On Mon, 22 Jul 2013 08:54:11 -0400, Eric S. Johansson e...@harvee.org wrote: try http://emailrelay.sourceforge.net/ Thanks. I did find it, but it says it's not a full MTA: E-MailRelay is not a routing MTA. It forwards e-mail to a pre-configured SMTP server, regardless of any message addressing or DNS redirects. http://emailrelay.sourceforge.net/userguide.html#SH_1_2 IOW, it'll just send outbound e-mails to my ISP's MTA, so I'm back at square one. -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On Mon, 22 Jul 2013 08:10:10 -0600, Michael Torrie torr...@gmail.com wrote: Where did you look? Here's one I found. It's not the real sendmail program, but it implements the interface which is all you need: http://glob.com.au/sendmail/ I just googled for sendmail win32 Thanks, but I need an MTA, not just a command-line app, so I can send e-mails from my e-mail client and just change the SMTP line in the configuration. -- http://mail.python.org/mailman/listinfo/python-list
Converting a list of lists to a single list
I think that itertools may be able to do what I want but I have not been able to figure out how. I want to convert an arbitrary number of lists with an arbitrary number of elements in each list into a single list as follows. Say I have three lists: [[A0,A1,A2], [B0,B1,B2] [C0,C1,C2]] I would like to convert those to a single list that looks like this: [A0,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2,A1,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2,A2,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2] An easier way to visualize the pattern I want is as a tree. A0 B0 C0 C1 C2 B1 C0 C1 C2 B2 C0 C1 C2 A1 B0 C0 C1 C2 B1 C0 C1 C2 B2 C0 C1 C2 A2 B0 C0 C1 C2 B1 C0 C1 C2 B2 C0 C1 C2 -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On Mon, 22 Jul 2013 10:14:15 -0400, Kevin Walzer k...@codebykevin.com wrote: http://www.hmailserver.com Thanks. hMailServer was one of the apps I checked, and I was just making sure there weren't something simpler, considering my needs, ideally something like Mongoose MTA. Regardless, because of the SPAM anti-measures mentioned above, it seems like I was over-optimistic about running an MTA and sending e-mails from my home computer :-/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Converting a list of lists to a single list
El 23/07/13 23:52, st...@divillo.com escribió: [[A0,A1,A2], [B0,B1,B2] [C0,C1,C2]] Hi, I think you are looking for itertools.chain, or in this case, itertools.chain.from_iterable: In [1]: x = [['A0','A1','A2'], ['B0','B1','B2'], ['C0','C1','C2']] In [2]: import itertools In [3]: [ y for y in itertools.chain.from_iterable(x)] Out[3]: ['A0', 'A1', 'A2', 'B0', 'B1', 'B2', 'C0', 'C1', 'C2'] HTH -- http://mail.python.org/mailman/listinfo/python-list
Re: Python testing tools
cutems93 ms2...@cornell.edu writes: On Saturday, July 20, 2013 1:11:12 AM UTC-7, Ben Finney wrote: You will find these discussed at the Python Testing Tools Taxonomy URL:http://wiki.python.org/moin/PythonTestingToolsTaxonomy. Hope that helps. Thank you, but I already read this page before I posted this question. (You will benefit from also reading and applying URL:http://wiki.python.org/moin/GoogleGroupsPython before using Google Groups. My advice: choose a different interface to this forum, Google Groups is terrible.) What I want to know is whether you personally use these tools other than unit testing tools. Yes, I do :-) What are you actually wanting to learn, beyond a collection of “this is what I use” stories? -- \ “The way to build large Python applications is to componentize | `\ and loosely-couple the hell out of everything.” —Aahz | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Converting a list of lists to a single list
On 23/07/2013 22:52, st...@divillo.com wrote: I think that itertools may be able to do what I want but I have not been able to figure out how. I want to convert an arbitrary number of lists with an arbitrary number of elements in each list into a single list as follows. Say I have three lists: [[A0,A1,A2], [B0,B1,B2] [C0,C1,C2]] I would like to convert those to a single list that looks like this: [A0,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2,A1,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2,A2,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2] An easier way to visualize the pattern I want is as a tree. A0 B0 C0 C1 C2 B1 C0 C1 C2 B2 C0 C1 C2 A1 B0 C0 C1 C2 B1 C0 C1 C2 B2 C0 C1 C2 A2 B0 C0 C1 C2 B1 C0 C1 C2 B2 C0 C1 C2 Using recursion: def tree_list(items): if len(items) == 1: return items[0] sublist = tree_list(items[1 : ]) result = [] for item in items[0]: result.append(item) result.extend(sublist) return result items = [[A0,A1,A2], [B0,B1,B2], [C0,C1,C2]] print(tree_list(items)) -- http://mail.python.org/mailman/listinfo/python-list
Re: Converting a list of lists to a single list
: On 23 July 2013 17:52, st...@divillo.com wrote: Say I have three lists: [[A0,A1,A2], [B0,B1,B2] [C0,C1,C2]] I would like to convert those to a single list that looks like this: [A0,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2,A1,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2,A2,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2] How's this: from itertools import chain def treeify(seq): if seq: return list(chain(*([x] + treeify(seq[1:]) for x in seq[0]))) else: return [] treeify([['A0', 'A1', 'A2'], ['B0', 'B1', 'B2'], ['C0', 'C1', 'C2']]) ['A0', 'B0', 'C0', 'C1', 'C2', 'B1', 'C0', 'C1', 'C2', 'B2', 'C0', 'C1', 'C2', 'A1', 'B0', 'C0', 'C1', 'C2', 'B1', 'C0', 'C1', 'C2', 'B2', 'C0', 'C1', 'C2', 'A2', 'B0', 'C0', 'C1', 'C2', 'B1', 'C0', 'C1', 'C2', 'B2', 'C0', 'C1', 'C2'] -[]z. -- http://mail.python.org/mailman/listinfo/python-list
Re: Converting a list of lists to a single list
On 7/23/2013 5:52 PM, st...@divillo.com wrote: I think that itertools may be able to do what I want but I have not been able to figure out how. A recursive generator suffices. I want to convert an arbitrary number of lists with an arbitrary number of elements in each list into a single list as follows. Say I have three lists: [[A0,A1,A2], [B0,B1,B2] [C0,C1,C2]] I would like to convert those to a single list that looks like this: [A0,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2, A1,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2, A2,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2] def crossflat(lofl): if lofl: first = lofl.pop(0) for o in first: yield o yield from crossflat(lofl.copy()) A0, A1, A2 = 100, 101, 102 B0, B1, B2 = 10, 11, 12 C0, C1, C2 = 0, 1, 2 LL = [[A0, A1, A2], [B0, B1, B2], [C0, C1, C2]] cfLL = list(crossflat(LL)) print(cfLL) assert cfLL == [ A0, B0, C0, C1, C2, B1, C0, C1, C2, B2, C0, C1, C2, A1, B0, C0, C1, C2, B1, C0, C1, C2, B2, C0, C1, C2, A2, B0, C0, C1, C2, B1, C0, C1, C2, B2, C0, C1, C2] passes -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Python 3: dict dict.keys()
Back in Python 2.x days I had a good grip on dict and dict.keys(), and when to use one or the other. Then Python 3 came on the scene with these things called 'views', and while range couldn't be bothered, dict jumped up and down shouting, I want some! So now, in Python 3, .keys(), .values(), even .items() all return these 'view' thingies. And everything I thought I knew about when to use one or the other went out the window. For example, if you need to modify a dict while iterating over it, use .keys(), right? Wrong: -- d = {1: 'one', 2:'two', 3:'three'} -- for k in d.keys(): ... if k == 1: ... del d[k] ... Traceback (most recent call last): File stdin, line 1, in module RuntimeError: dictionary changed size during iteration If you need to manipulate the keys (maybe adding some, maybe deleting some) before doing something else with final key collection, use .keys(), right? Wrong: -- dk = d.keys() -- dk.remove(2) Traceback (most recent call last): File stdin, line 1, in module AttributeError: 'dict_keys' object has no attribute 'remove' I understand that the appropriate incantation in Python 3 is: -- for k in list(d) ...... or -- dk = list(d) -- dk.remove(2) which also has the added benefit of working the same way in Python 2. So, my question boils down to: in Python 3 how is dict.keys() different from dict? What are the use cases? -- ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: non sequitur: [OT] SPF - was Re: Simple Python script as SMTP server for outgoing e-mails?
On Tue, 23 Jul 2013 19:59:01 -0400, Dennis Lee Bieber wrote: {Liaden culture seems heavy on personal honor, and comments tend (to me) be worded to avoid any chance of being interpreted as disparaging of the person with whom one is speaking... Hmmm, pity such modes can't be enforced on the newsgroups G} Are you implying that failure to avoid disparaging others in newsgroups is harmful? That disparages me. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3: dict dict.keys()
On Tue, 23 Jul 2013 18:16:08 -0700, Ethan Furman wrote: Back in Python 2.x days I had a good grip on dict and dict.keys(), and when to use one or the other. Then Python 3 came on the scene with these things called 'views', and while range couldn't be bothered, dict jumped up and down shouting, I want some! So now, in Python 3, .keys(), .values(), even .items() all return these 'view' thingies. And everything I thought I knew about when to use one or the other went out the window. Surely not. The fundamental behaviour of Python's data model hasn't changed. Lists are lists, views are views, and iterators are iterators. Only the way you get each has changed. - If in Python 2, you used the viewkeys() method, that's been renamed keys() in Python 3. So d.viewkeys() = d.keys(). - If in Python 2, you used the keys() method, it returns a list, and like any function that has been made lazy instead of eager in Python 3 (e.g. map, zip, filter) if you want the same behaviour, simply call list manually. So d.keys() = list(d.keys()). - If in Python 2, you used the iterkeys() methods, it returns a simple iterator, not a view. So d.iterkeys() = iter(d.keys()). None of these distinctions really matter if all you are doing is iterating over the keys, without modifying the dict. Not in Python 2, nor in Python 3. And naturally the same applies to the various flavours of *items and *values. For example, if you need to modify a dict while iterating over it, use .keys(), right? Wrong: -- d = {1: 'one', 2:'two', 3:'three'} -- for k in d.keys(): ... if k == 1: ... del d[k] ... Traceback (most recent call last): File stdin, line 1, in module RuntimeError: dictionary changed size during iteration Fundamentally, this behaviour has not changed from Python 2: you should not iterate over a data structure while changing it, instead you should make a copy of the data you iterate over. In Python 2, d.keys() makes a copy and returns a list, so in Python 3 you would call list(d.keys()). If you need to manipulate the keys (maybe adding some, maybe deleting some) before doing something else with final key collection, use .keys(), right? Wrong: -- dk = d.keys() -- dk.remove(2) Traceback (most recent call last): File stdin, line 1, in module AttributeError: 'dict_keys' object has no attribute 'remove' Repeat after me: In Python 2, d.keys() returns a list of keys, so if I want a list of keys in Python 3, call list explicitly list(d.keys()). I understand that the appropriate incantation in Python 3 is: -- for k in list(d) ...... or -- dk = list(d) -- dk.remove(2) which also has the added benefit of working the same way in Python 2. So, my question boils down to: in Python 3 how is dict.keys() different from dict? What are the use cases? *shrug* For most purposes, there is no difference, especially when merely iterating over the dict. Such differences as exist are trivial: - if you need an actual callable function or method, say to pass to some other function, you can do this: for method in (d.items, d.keys, d.values): process(method) instead of this: # untested for method in (d.items, d.keys, lambda d=d: iter(d)): process(method) - d.keys() is a view, not the dict itself. That's a pretty fundamental difference: compare dir(d.keys()) with dir(d). Basically, views are set-like, not list-like. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: how: embed + extend to control my running app?
i'm targeting Mac and Windows. Let's skip the thing about it should work when my app isn't running, just assume it's going to be embedded, no pipes or sockets necessary. For Mac, I understand i need to create (?) a python.dylib, but i find no directions for that at the expected location: http://docs.python.org/2/extending/embedding.html is there some wiki page explaining how to create this for use in MacOS / Xcode? Now for Windows: same thing, i think i must create a .dll, right? Is there a tutorial for that? After that, i can link to these items, then in my C++ app, just #include Python.h and i've covered step 1. -- http://mail.python.org/mailman/listinfo/python-list
Re: Converting a list of lists to a single list
On Wed, Jul 24, 2013 at 8:34 AM, Rafael Durán Castañeda rafadurancastan...@gmail.com wrote: In [3]: [ y for y in itertools.chain.from_iterable(x)] Out[3]: ['A0', 'A1', 'A2', 'B0', 'B1', 'B2', 'C0', 'C1', 'C2'] Complete aside, given that this has already been pointed out as solving a different problem: Any time you see a list comp that just does [ x for x in foo ], check to see if it can be replaced by a simple list constructor: [ y for y in itertools.chain.from_iterable(x)] ['A0', 'A1', 'A2', 'B0', 'B1', 'B2', 'C0', 'C1', 'C2'] list(itertools.chain.from_iterable(x)) ['A0', 'A1', 'A2', 'B0', 'B1', 'B2', 'C0', 'C1', 'C2'] A bit simpler and achieves the same. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
PyGLet on Python 3
On 07/21/2013 08:10 PM, Joseph Clark wrote: John, have you taken a look at pyglet? It's an alternative to pygame and I found it pretty slick once I got the hang of it. There is a development version that's compatible with python 3 and I've never had a bug with it. It wraps OpenGL itself so there are no additional dependencies. // joseph w. clark , phd , visiting research associate \\ university of nebraska at omaha - college of IST Hi Joe, Thanks for the PyGLet recommendation. I like OpenGL. Unfortunately, I can't seem to get PyGLet to work, even though the pyglet.org front page claims that the major 1.2alpha1 release brings pyglet to Python 3. I followed the links to this page: https://code.google.com/p/pyglet/downloads/list?q=1.2alpha1 I installed pyglet on my Linux system's Python 3.3 using distutils, as I have done with many other packages. But I can't run test.py, nor can I even get as far as importing pyglet from my Python 3.3 interpreter command line. The obstacle is apparently Python 2.x-style print statements, which are found throughout tests.py and pyglet/__init__.py. Does anyone know an efficient way around this problem? Thanks! -- http://mail.python.org/mailman/listinfo/python-list
tkinter progress bar
Hi, How can I add a tkinter progress bar in python 3.2 to start before a loop and end after it. I am looking for a very simple solution. def MyFunc(): Start progress bar for fileName in fileList: … End progress bar Thanks a lot in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to tick checkboxes with the same name?
malay...@gmail.com wrote: I faced a problem: to implement appropriate search program I need to tick few checkboxes which turned out to have the same name (name=a, id=a1,a2,a3,a4). Set_input('a', True) does not work (I use Grab library), For all but the most popular projects a url works wonders. I'm assuming http://grablib.org this command leads to the error checkboxgroup must be set to a sequence. I don't understand what the sequence actually is, so I'm stuck with how to tick the checkboxes. If I were to guess: set_input(a, [True, True, True, True]) but I don't see that form documented on page http://docs.grablib.org/api/ext_form.html If it doesn't work try set_input_by_id(_a1, True) set_input_by_id(_a2, True) and so on. -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
Chris Angelico ros...@gmail.com wrote: On Tue, Jul 23, 2013 at 12:08 AM, Michael Torrie torr...@gmail.com wrote: On 07/22/2013 06:51 AM, Chris Angelico wrote: Thanks for the tip. I didn't know about SPF http://en.wikipedia.org/wiki/Sender_Policy_Framework It's a great way of detecting legit vs forged mail. If anyone tries to send mail purporting to be from anyth...@kepl.com.au and the receiving mail server is checking SPF records, it'll be rejected after one cheap DNS lookup. It's a simple and cacheable way to ask the owning server, Is this guy allowed to send mail for you?. (The 192.168 block in my SPF record above is permitted to allow some intranet conveniences; omit it unless you need it.) Yes setting SPF records will help your mail be accepted by other servers, but I disagree with your appeal to make mail server SPF handling as strict as your server does. SPF has problems in a number of situations which could cause legitimate mail to be rejected. In my last job I could only use SPF as one spam factor, not as a basis for rejection. If legit mail is rejected for failing an SPF check, it's the sending admin's problem, not yours. You should never have problems with it if it's set up correctly. And since rejected mail gets reported to the transmitting MTA, you don't need to drop it in a spambox or anything. It's not spam, it's simply invalid mail (equivalent to something sent to a dud address). If you want your emails to have the best chance of arriving your SPF should list servers you use but not deny that there might be others. I have a very common situation where an overly strict SPF may cause problems: Like many people I have multiple email addresses which all end up in the same inbox. The one I most commonly give out to businesses bounces the email unchanged to the gmail inbox that I use. That means all emails I receive through that email address appear to Google to have originated from the forwarding servers. An SPF record from the original sender that claims to have a complete list of originating servers will therefore fail validation. It isn't Google's fault: they can't ignore the forwarding step otherwise spammers could bypass SPF simply by claiming to be forwarding the emails. It is simply a limitation of the SPF protocol. Fortunately they only use SPF as one indicator so real messages still get through. -- Duncan Booth -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter progress bar
Am 23.07.13 08:52, schrieb hsiw...@walla.com: Hi, How can I add a tkinter progress bar in python 3.2 to start before a loop and end after it. I am looking for a very simple solution. def MyFunc(): Start progress bar for fileName in fileList: … End progress bar 1. There is a progress bar widget in ttk. At the beginning, you set maximum to the number of files in your list 2. In the loop, you set value of the progressbar to the current file number. You can also attach a variable 3. The bar is only redrawn when you process events. The simplest way to do this is by calling update() on the progress bar, which processes all pending events. Despite of it looking like a method, update() is really a global function within Tcl and updates all widgets in your interface. You must make sure, therefore, that the user does not trigger another event which interferes with your download, such as pressing the button for starting it again. The easiest way is to disable the button at the begin and reenable it at the end. 4. If processing of a single file takes a long time, the only way to have the GUI responsive is to put the work in a background thread. That seems to be more involved. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On Tue, Jul 23, 2013 at 6:06 PM, Duncan Booth duncan.booth@invalid.invalid wrote: Chris Angelico ros...@gmail.com wrote: On Tue, Jul 23, 2013 at 12:08 AM, Michael Torrie torr...@gmail.com wrote: On 07/22/2013 06:51 AM, Chris Angelico wrote: Thanks for the tip. I didn't know about SPF http://en.wikipedia.org/wiki/Sender_Policy_Framework It's a great way of detecting legit vs forged mail. If anyone tries to send mail purporting to be from anyth...@kepl.com.au and the receiving mail server is checking SPF records, it'll be rejected after one cheap DNS lookup. It's a simple and cacheable way to ask the owning server, Is this guy allowed to send mail for you?. (The 192.168 block in my SPF record above is permitted to allow some intranet conveniences; omit it unless you need it.) Yes setting SPF records will help your mail be accepted by other servers, but I disagree with your appeal to make mail server SPF handling as strict as your server does. SPF has problems in a number of situations which could cause legitimate mail to be rejected. In my last job I could only use SPF as one spam factor, not as a basis for rejection. If legit mail is rejected for failing an SPF check, it's the sending admin's problem, not yours. You should never have problems with it if it's set up correctly. And since rejected mail gets reported to the transmitting MTA, you don't need to drop it in a spambox or anything. It's not spam, it's simply invalid mail (equivalent to something sent to a dud address). If you want your emails to have the best chance of arriving your SPF should list servers you use but not deny that there might be others. That usually makes the SPF record completely useless. The whole point is to say that random addresses on the internet _will not_ send mail from you. I have a very common situation where an overly strict SPF may cause problems: Like many people I have multiple email addresses which all end up in the same inbox. The one I most commonly give out to businesses bounces the email unchanged to the gmail inbox that I use. That means all emails I receive through that email address appear to Google to have originated from the forwarding servers. An SPF record from the original sender that claims to have a complete list of originating servers will therefore fail validation. Ah, there's a solution to this one. You simply use your own envelope-from address; SPF shouldn't be being checked for the From: header. Forwarding and using the original sender's address in the SMTP 'MAIL FROM' command is forging mail from them, so it is correct for that to be thrown out. The mail is coming from your own account, so you put your address in it, and you might even be able to put an uber-strict SPF record like v=spf1 ip4:1.2.3.4 -all which is quick to process and guarantees that nobody can pretend to forward mail on your behalf. The checks are for the *current connection*, not anything earlier. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On Tue, Jul 23, 2013 at 7:19 PM, Chris Angelico ros...@gmail.com wrote: Ah, there's a solution to this one. You simply use your own envelope-from address; SPF shouldn't be being checked for the From: header. There's an example, by the way, of this exact technique right here - python-list@python.org sends mail to me with an envelope-from of python-list-bounces+rosuav=gmail@python.org - which passes SPF, since python.org has a TXT record designating the sending IP as one of theirs. It doesn't matter that invalid.invalid (your supposed domain) doesn't have an SPF record, nor would it be a problem if it had one that said v=spf1 -all, because that domain wasn't checked. Mailing lists are doing the same sort of forwarding that you're doing. (Apologies to those who read this as a newsgroup, for whom this won't be as parallel an example. But it's still the case, just not for the posts you receive.) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter progress bar
Dear Christian, Thanks for the help. Can you please add a source example as I am new with Tkinter. Cheers. -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
Chris Angelico ros...@gmail.com wrote: On Tue, Jul 23, 2013 at 6:06 PM, Duncan Booth duncan.booth@invalid.invalid wrote: I have a very common situation where an overly strict SPF may cause problems: Like many people I have multiple email addresses which all end up in the same inbox. The one I most commonly give out to businesses bounces the email unchanged to the gmail inbox that I use. That means all emails I receive through that email address appear to Google to have originated from the forwarding servers. An SPF record from the original sender that claims to have a complete list of originating servers will therefore fail validation. Ah, there's a solution to this one. You simply use your own envelope-from address; SPF shouldn't be being checked for the From: header. Forwarding and using the original sender's address in the SMTP 'MAIL FROM' command is forging mail from them, so it is correct for that to be thrown out. The mail is coming from your own account, so you put your address in it, and you might even be able to put an uber-strict SPF record like v=spf1 ip4:1.2.3.4 -all which is quick to process and guarantees that nobody can pretend to forward mail on your behalf. The checks are for the *current connection*, not anything earlier. sarcasm Excellent idea, I'll tell the email forwarding service to rewrite their system immediately. Or I could just tell Google to rewrite their email system to know about and strip off the forwarding service's headers: that's probably about as easy. Or maybe I could just ask you to add the forwarder's SPF record into your own? /sarcasm I know that I could arrange things so that my emails don't trigger this situation, but that isn't the point. The point is that this situation happens quite commonly, therefore you as the sender of an email with a strict SPF are going to find systems rejecting emails you send that would get through if you have a less strict one. That is of course your choice, but many users of email would prefer to maximise the chance of the email they send arriving rather than reducing slightly the chance of people they may not even know receiving spam. You could also try combining SPF with DKIM although that has its own, different failure scenarios. -- Duncan Booth -- http://mail.python.org/mailman/listinfo/python-list
Re: Play Ogg Files
On 07/23/2013 01:19 AM, David Hutto wrote: Devyn, are you just trying to use this in an application? Would a browser based web app work. I ask because there will still be some sort of DB interaction, so could it be an option to go with a browser command? On Mon, Jul 22, 2013 at 8:37 PM, alex23 wuwe...@gmail.com mailto:wuwe...@gmail.com wrote: On 20/07/2013 10:25 PM, Devyn Collier Johnson wrote: I have not heard of Pyaudio; I will look into that. As for Pygame, I have not been able to find any good documentation for playing audio files. Plus, I recently learned that Pygame is not Python3 compatible. Another option would be Pyglet, which uses the cross-platform binary AVBin to provide sound support. It may not provide as much control as PyAudio, but given your example usage it might be a bit more straightforward: pyglet.media.load('boot.ogg', streaming=False).play() http://www.pyglet.org/doc/programming_guide/simple_audio_playback.html The latest development release provides support for Python 3: https://code.google.com/p/pyglet/downloads/list?q=1.2alpha1 -- http://mail.python.org/mailman/listinfo/python-list -- Best Regards, David Hutto /*CEO:*/ _http://www.hitwebdevelopment.com_ I will be playing an ogg file as a bootup sound for a chatbot that runs in a terminal. There are no web-applications. I will be looking into the different suggestions that I was offered. So far, Pyglet seems to be the best. Once I have officially decided and implemented an idea, I will share my choice with everyone. Mahalo, DCJ -- http://mail.python.org/mailman/listinfo/python-list
Strange behaviour with os.linesep
On Windows a script where de endline are the system line sep, the files are open with a double line in Eric4, Notepad++ or Gedit but they are correctly displayed in the MS Bloc-Notes. Example with this code: -- # -*- coding: utf-8 -*- import os L_SEP = os.linesep def write(): strings = ['# -*- coding: utf-8 -*-\n', 'import os\n', 'import sys\n'] with open('writetest.py', 'w') as outf: for s in strings: outf.write(s.replace('\n', L_SEP)) write() -- The syntax `s.replace('\n', L_SEP)`is required for portability. Regards - Vincent V.V -- http://mail.python.org/mailman/listinfo/python-list
Beginner. 2d rotation gives unexpected results.
Hello! This is my first post, nice to meet you all! I`m biology student from Russia, trying to learn python to perform some simple simulations. Here`s my first problem. I`m trying to perform some simple 2d vector rotations in pygame, in order to learn the basics of linear algebra and 2d transformations. So far i understand matrix multiplication pretty well, and probably all my math is right. Eventually i`m planning to write Poly class, and use it to rotate and translate some simple shapes. But when i try and write it in the program, i get very weird results, like all points of rectangle with coordinates [0,0],[0,100],[100,0],[100,100] start to go spiral and eventually shrink to the center. Although even Excel calculations with this formulas give me right result. I use Python 3.3 on Windows Xp. What is wrong with my code? [code]import pygame import math as m black = ( 0, 0, 0) white = ( 255, 255, 255) green = ( 0, 255, 0) red = ( 255, 0, 0) class Poly(): pos = [100,100] #x and y coordinates of a point rot = m.radians(1) #rotation in degrees def draw(self): #draw point pygame.draw.circle(screen,white,self.pos,10,0) def rotate(self): # rotation method sin = m.sin(self.rot) #calculationg sin and cos cos = m.cos(self.rot) x_rot = int(self.pos[0]*cos-self.pos[1]*sin) #mulpitplicating vector to rotation matrix y_rot = int(self.pos[0]*sin+self.pos[1]*cos) self.pos[0] = x_rot #set new coordinates to a point self.pos[1] = y_rot a = Poly() #Some simple sample points giving rectangle b = Poly() c = Poly() d = Poly() b.pos = [0,100] c.pos = [100,0] d.pos = [0,0] pygame.init() size = [700,500] screen = pygame.display.set_mode(size) done = False clock = pygame.time.Clock() while done == False: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True a.rotate() #perform rotation b.rotate() c.rotate() d.rotate() screen.fill(black) a.draw() #draw point b.draw() c.draw() d.draw() pygame.display.flip() clock.tick(30) pygame.quit()[/code] P.S. Sorry for my english, bit rusty in that department. -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange behaviour with os.linesep
On Tue, Jul 23, 2013 at 7:42 AM, Vincent Vande Vyvre vincent.vandevy...@swing.be wrote: On Windows a script where de endline are the system line sep, the files are open with a double line in Eric4, Notepad++ or Gedit but they are correctly displayed in the MS Bloc-Notes. Example with this code: --** # -*- coding: utf-8 -*- import os L_SEP = os.linesep def write(): strings = ['# -*- coding: utf-8 -*-\n', 'import os\n', 'import sys\n'] with open('writetest.py', 'w') as outf: for s in strings: outf.write(s.replace('\n', L_SEP)) I must ask why you are setting strings with a newline line ending only to replace them later with os.linesep. This seems convoluted compared to doing something like def write(): strings = ['#-*- coding: utf-8 -*-', 'import os', 'import sys'] with open('writetest.py', 'w') as outf: for s in strings: outf.write(s) outf.write(L_SEP) Or something equivalent. If, however, the source strings come from a file you've created somewhere (and are loaded by reading in that file line by line), then I can see a problem. DOS line endings are carriage returns ('\r\n'), whereas standard UNIX files use just newlines ('\n'). Therefore, if you are using the code: s.replace('\n', L_SEP) in Windows, using a Windows-generated file, then what you are likely doing is converting the string sequence '\r\n' into '\r\r\n', which is not what you want to do. I can imagine some text editors interpreting that as two endlines (since there are 2 \r's). Indeed, when I execute the code: l = open('test.txt', 'w') l.write('This is the first line\r\r\n') l.write('This is the second\r\r\n') l.close() on UNIX and open the resulting file in gedit, it is double-spaced, but if I just dump it to the screen using 'cat', it is single-spaced. If you want to make your code a bit more cross-platform, you should strip out all types of end line characters from the strings before you write them. So something like this: with open('writetest.py', 'w') as outf: for s in strings: outf.write(s.rstrip('\r\n')) outf.write(L_SEP) Hope this helps, Jason -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner. 2d rotation gives unexpected results.
haven't used pygame that much, but it sounds like you drew Z. You have [0,0],[0,100],[100,0],[100, 100] 0,0 is the top left, if I recall 0, 100 would be the lower left, then you move to100, 0 which would go diagonal to the top right, and then 100,100 to the lower right, this is assuming 0,0 is the upper left. for a square you would go,[0,0],[0,100],[100,100],[100,0]then back to [0,0] to complete the square. This is assuming that 0,0 is the upper left, the coords are x,y in the brackets, and the increase in x takes you the right, and the increase in y takes you down. If that doesn't work,I'll download it later, and try it out. On Tue, Jul 23, 2013 at 8:34 AM, en...@yandex.ru wrote: Hello! This is my first post, nice to meet you all! I`m biology student from Russia, trying to learn python to perform some simple simulations. Here`s my first problem. I`m trying to perform some simple 2d vector rotations in pygame, in order to learn the basics of linear algebra and 2d transformations. So far i understand matrix multiplication pretty well, and probably all my math is right. Eventually i`m planning to write Poly class, and use it to rotate and translate some simple shapes. But when i try and write it in the program, i get very weird results, like all points of rectangle with coordinates [0,0],[0,100],[100,0],[100,100] start to go spiral and eventually shrink to the center. Although even Excel calculations with this formulas give me right result. I use Python 3.3 on Windows Xp. What is wrong with my code? [code]import pygame import math as m black = ( 0, 0, 0) white = ( 255, 255, 255) green = ( 0, 255, 0) red = ( 255, 0, 0) class Poly(): pos = [100,100] #x and y coordinates of a point rot = m.radians(1) #rotation in degrees def draw(self): #draw point pygame.draw.circle(screen,white,self.pos,10,0) def rotate(self): # rotation method sin = m.sin(self.rot) #calculationg sin and cos cos = m.cos(self.rot) x_rot = int(self.pos[0]*cos-self.pos[1]*sin) #mulpitplicating vector to rotation matrix y_rot = int(self.pos[0]*sin+self.pos[1]*cos) self.pos[0] = x_rot #set new coordinates to a point self.pos[1] = y_rot a = Poly() #Some simple sample points giving rectangle b = Poly() c = Poly() d = Poly() b.pos = [0,100] c.pos = [100,0] d.pos = [0,0] pygame.init() size = [700,500] screen = pygame.display.set_mode(size) done = False clock = pygame.time.Clock() while done == False: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True a.rotate() #perform rotation b.rotate() c.rotate() d.rotate() screen.fill(black) a.draw() #draw point b.draw() c.draw() d.draw() pygame.display.flip() clock.tick(30) pygame.quit()[/code] P.S. Sorry for my english, bit rusty in that department. -- http://mail.python.org/mailman/listinfo/python-list -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner. 2d rotation gives unexpected results.
en...@yandex.ru wrote: This is my first post, nice to meet you all! Welcome! I`m biology student from Russia, trying to learn python to perform some simple simulations. Here`s my first problem. I`m trying to perform some simple 2d vector rotations in pygame, in order to learn the basics of linear algebra and 2d transformations. So far i understand matrix multiplication pretty well, and probably all my math is right. Eventually i`m planning to write Poly class, and use it to rotate and translate some simple shapes. But when i try and write it in the program, i get very weird results, like all points of rectangle with coordinates [0,0],[0,100],[100,0],[100,100] start to go spiral and eventually shrink to the center. Although even Excel calculations with this formulas give me right result. I use Python 3.3 on Windows Xp. What is wrong with my code? def rotate(self): # rotation method sin = m.sin(self.rot) #calculationg sin and cos cos = m.cos(self.rot) x_rot = int(self.pos[0]*cos-self.pos[1]*sin) #mulpitplicating The conversion to int introduces a rounding error that accumulates over time. vector to rotation matrix y_rot = int(self.pos[0]*sin+self.pos[1]*cos) self.pos[0] = x_rot #set new coordinates to a point self.pos[1] = y_rot One way to keep the error low is to keep the float values in self.pos and do the rounding on the fly when you display the point: class Poly(): def __init__(self, color, pos, rot=m.radians(1)): self.color = color self.pos = pos self.rot = rot def draw(self): x, y = self.pos pygame.draw.circle(screen, self.color, [350+int(x), 250+int(y)], 10, 0) def rotate(self): sin = m.sin(self.rot) cos = m.cos(self.rot) x_rot = self.pos[0]*cos-self.pos[1]*sin y_rot = self.pos[0]*sin+self.pos[1]*cos self.pos = [x_rot, y_rot] a = Poly(white, [100, 100]) b = Poly(green, [0, 100]) c = Poly(blue, [100, 0]) d = Poly(red, [0, 0]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange behaviour with os.linesep
Le 23/07/2013 14:39, Jason Swails a écrit : On Tue, Jul 23, 2013 at 7:42 AM, Vincent Vande Vyvre vincent.vandevy...@swing.be mailto:vincent.vandevy...@swing.be wrote: On Windows a script where de endline are the system line sep, the files are open with a double line in Eric4, Notepad++ or Gedit but they are correctly displayed in the MS Bloc-Notes. Example with this code: -- # -*- coding: utf-8 -*- import os L_SEP = os.linesep def write(): strings = ['# -*- coding: utf-8 -*-\n', 'import os\n', 'import sys\n'] with open('writetest.py', 'w') as outf: for s in strings: outf.write(s.replace('\n', L_SEP)) I must ask why you are setting strings with a newline line ending only to replace them later with os.linesep. This seems convoluted compared to doing something like def write(): strings = ['#-*- coding: utf-8 -*-', 'import os', 'import sys'] with open('writetest.py', 'w') as outf: for s in strings: outf.write(s) outf.write(L_SEP) Or something equivalent. If, however, the source strings come from a file you've created somewhere (and are loaded by reading in that file line by line), then I can see a problem. DOS line endings are carriage returns ('\r\n'), whereas standard UNIX files use just newlines ('\n'). Therefore, if you are using the code: s.replace('\n', L_SEP) in Windows, using a Windows-generated file, then what you are likely doing is converting the string sequence '\r\n' into '\r\r\n', which is not what you want to do. I can imagine some text editors interpreting that as two endlines (since there are 2 \r's). Indeed, when I execute the code: l = open('test.txt', 'w') l.write('This is the first line\r\r\n') l.write('This is the second\r\r\n') l.close() on UNIX and open the resulting file in gedit, it is double-spaced, but if I just dump it to the screen using 'cat', it is single-spaced. If you want to make your code a bit more cross-platform, you should strip out all types of end line characters from the strings before you write them. So something like this: with open('writetest.py', 'w') as outf: for s in strings: outf.write(s.rstrip('\r\n')) outf.write(L_SEP) Hope this helps, Jason The '\n' are in the original file. I've tested these other versions: --- def write(): strings = ['# -*- coding: utf-8 -*-\n', 'import os\n', 'import sys\n'] with open('writetest.py', 'w') as outf: txt = L_SEP.join([s.rstip() for s in strings]): outf.write(txt) -- --- def write(): strings = ['# -*- coding: utf-8 -*-', 'import os', 'import sys'] with open('writetest.py', 'w') as outf: txt = L_SEP.join( strings): outf.write(txt) -- Las, no changes, always correctly displayed in MS bloc-notes but with double line in other éditors. -- Vincent V.V. Oqapy https://launchpad.net/oqapy . Qarte https://launchpad.net/qarte . PaQager https://launchpad.net/paqager -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange behaviour with os.linesep
Le 23/07/2013 15:10, Vincent Vande Vyvre a écrit : The '\n' are in the original file. I've tested these other versions: --- def write(): strings = ['# -*- coding: utf-8 -*-\n', 'import os\n', 'import sys\n'] with open('writetest.py', 'w') as outf: txt = L_SEP.join([s.rstip() for s in strings]): outf.write(txt) -- --- def write(): strings = ['# -*- coding: utf-8 -*-', 'import os', 'import sys'] with open('writetest.py', 'w') as outf: txt = L_SEP.join( strings): outf.write(txt) -- Las, no changes, always correctly displayed in MS bloc-notes but with double line in other éditors. Also with: def count(): with open('c:\\Users\\Vincent\\writetest.py', 'r') as inf: lines = inf.readlines() for l in lines: print(l, len(l)) count() -- The output is: -- ('# -*- coding: utf-8 -*-\r\n', 25) ('import os\r\n', 11) ('import sys', 10) -- Vincent V.V. Oqapy https://launchpad.net/oqapy . Qarte https://launchpad.net/qarte . PaQager https://launchpad.net/paqager -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter progress bar
On Tue, Jul 23, 2013 at 5:38 AM, hsiw...@walla.com wrote: Dear Christian, Thanks for the help. Can you please add a source example as I am new with Tkinter. http://docs.python.org/2/library/ttk.html#progressbar You can do something like this: #!/usr/bin/env python import Tkinter as tk import ttk import time class MainApp(tk.Frame): def __init__(self, master): tk.Frame.__init__(self, master) self.progress = ttk.Progressbar(self, maximum=10) self.progress.pack(expand=1, fill=tk.BOTH) self.progress.bind(Button-1, self._loop_progress) def _loop_progress(self, *args): for i in range(10): self.progress.step(1) # Necessary to update the progress bar appearance self.update() # Busy-wait time.sleep(2) if __name__ == '__main__': root = tk.Tk() app = MainApp(root) app.pack(expand=1, fill=tk.BOTH) root.mainloop() This is a simple stand-alone app that (just) demonstrates how to use the ttk.Progressbar widget. HTH, Jason -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange behaviour with os.linesep
On Tue, Jul 23, 2013 at 9:26 AM, Vincent Vande Vyvre vincent.vandevy...@swing.be wrote: Le 23/07/2013 15:10, Vincent Vande Vyvre a écrit : The '\n' are in the original file. I've tested these other versions: --**- def write(): strings = ['# -*- coding: utf-8 -*-\n', 'import os\n', 'import sys\n'] with open('writetest.py', 'w') as outf: txt = L_SEP.join([s.rstip() for s in strings]): outf.write(txt) -- --**- def write(): strings = ['# -*- coding: utf-8 -*-', 'import os', 'import sys'] with open('writetest.py', 'w') as outf: txt = L_SEP.join( strings): outf.write(txt) -- Las, no changes, always correctly displayed in MS bloc-notes but with double line in other éditors. Also with: --**-- def count(): with open('c:\\Users\\Vincent\\**writetest.py', 'r') as inf: lines = inf.readlines() for l in lines: print(l, len(l)) Unrelated comment, but in general it's (much) more efficient to iterate through a file rather than iterate through a list of strings generated by readlines(): def count(): with open('c:\\Users\\Vincent\\writetest.py', 'r') as inf: for l in lines: print(l, len(l)) It's also fewer lines of code. ('# -*- coding: utf-8 -*-\r\n', 25) ('import os\r\n', 11) ('import sys', 10) Then it seems like there is an issue with your text editors that do not play nicely with DOS-style line endings. Gedit on my linux machine displays the line endings correctly (that is, '\r\n' is rendered as a single line). Good luck, Jason -- http://mail.python.org/mailman/listinfo/python-list
[OT] SPF - was Re: Simple Python script as SMTP server for outgoing e-mails?
On 07/23/2013 03:30 AM, Chris Angelico wrote: On Tue, Jul 23, 2013 at 7:19 PM, Chris Angelico ros...@gmail.com wrote: Ah, there's a solution to this one. You simply use your own envelope-from address; SPF shouldn't be being checked for the From: header. There's an example, by the way, of this exact technique right here - python-list@python.org sends mail to me with an envelope-from of python-list-bounces+rosuav=gmail@python.org - which passes SPF, since python.org has a TXT record designating the sending IP as one of theirs. It doesn't matter that invalid.invalid (your supposed domain) doesn't have an SPF record, nor would it be a problem if it had one that said v=spf1 -all, because that domain wasn't checked. Mailing lists are doing the same sort of forwarding that you're doing. This is good and all, and I think I will modify my local postfix mail server I use for personal stuff, just for correctness' sake. I hadn't spent much time studying SPF in depth before, but after reading your comments (which were insightful) I'm now more convinced that SPF is worthless than ever, at least as a spam prevention mechanism. Spammers can use throwaway domains that publish very non-strict SPF records, and spam to their hearts content with random forged from addresses and SPF checks pass. The only way around that is to enforce SPF on the From: header in the e-mail itself, which we all agree is broken. I've been reading this: http://www.openspf.org/FAQ/SPF_is_not_about_spam Not very encouraging. When the other expensive options for going after spammers who have valid SPF records, they propose domain blacklists as a solution. -- http://mail.python.org/mailman/listinfo/python-list
[issue16809] Tk 8.6.0 introduces TypeError. (Tk 8.5.13 works)
alejandro autalan added the comment: Hello. I tried 'tkinter_split.patch' patch against 3.3.2, but a fix for grid_info function is also needed. #test.py import tkinter as tk root = tk.Tk() b = tk.Button(root, text='Button') b.grid() print(b.grid_info()) root.mainloop() Here's is the script's output: alejandro@vostro1:~/tmp$ cpython3.3 test.py Traceback (most recent call last): File test.py, line 10, in module print(b.grid_info()) File /home/alejandro/apps/cpython3.3.2/lib/python3.3/tkinter/__init__.py, line 2024, in grid_info if value[:1] == '.': TypeError: '_tkinter.Tcl_Obj' object is not subscriptable -- nosy: +alejandroautalan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16809 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15805] Add stdout redirection tool to contextlib
Nick Coghlan added the comment: Can we go paint bikesheds somewhere else now, please? Raymond has persuaded me as contextlib maintainer that this small addition is worth making as a way of factoring out repeated calls to print with a file redirection in simple user scripts where thread safety isn't a concern. I think more sophisticated tools are also potentially worthwhile, but *not here*. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15805 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18526] Add resource management/guarding to unittest
Changes by Robert Collins robe...@robertcollins.net: -- nosy: +rbcollins ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18526 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18526] Add resource management/guarding to unittest
Robert Collins added the comment: I'll do a full review shortly, but at the conceptual level, I don't see any benefit in making a new SkipTest base class, other than instantly breaking other runners when an unknown exception is raised. SkipTest is part of the API. Making a new exception part of the API requires a strong reason - not just 'we want to show it differently' but 'we want the runner to behave differently. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18526 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18526] Add resource management/guarding to unittest
Michael Foord added the comment: My question is, is this generally useful enough for test suites beyond the Python standard library. Essentially it provides a command line interface to specialized test skipping. I *still* feel that a generalized mechanism for adding command line options to the standard test runner would allow for this and a myriad of other slightly specialized use cases. It's hard to see how to do that cleanly without full blown extension machinery (which I'm in favour of and have prototyped but it is a *much* bigger change set). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18526 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8716] test_tk/test_tkk_guionly fails on OS X if run from buildbot slave daemon -- crashes Python
Ronald Oussoren added the comment: I just noticed that the Tk tests still get skipped on my machine, and rediscovered this issue. The reason that MacOS.WMAvailable() returns False on the buildbot is because it runs ./python.exe, which is not part of an application bundle and therefore has no GUI access. To easily reproduce with a framework install: * Note that MacOS.WMAvailable() returns True when you run the python/pythonw when you are logged in to the machine * Now copy /Library/Framework/Python.frameworks/Versions/Current/Resources/Python.app/Contents/MacOS/Python to python.exe * Run ./python.exe and note that MacOS.WMAvailable() now returns False (and that sys.prefix still refers to the framework) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8716 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17899] os.listdir() leaks FDs if invoked on FD pointing to a non-directory
Larry Hastings added the comment: Looks like it's too late for Christian, he's already generated the report with Coverity: https://docs.google.com/file/d/0B5wQCOK_TiRiMWVqQ0xPaDEzbkU/edit But I'm still interested in putting this to bed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17899 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17496] OS X test for Tk availability in runtktests.py doesn't work
Ronald Oussoren added the comment: To respond to my own message: running a small Tcl script is not good enough, the process environment of python itself is also important. In particular, GUI frameworks only work from inside an application bundle (or by using some undocumented private APIs) and that's why the Tk tests cannot work on OSX without installing. BTW. I just verified that MacOS.WMAvailable() works just fine in 64-bit processes (python 2.7 on OSX 10.8), and according to the header files the API functions used in its implementation (and the corresponding python code in 3.x) are not deprecated. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17496 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18526] Add resource management/guarding to unittest
Antoine Pitrou added the comment: Does registerResource() mutate some kind of global per-process state? This doesn't sound like a good idea. (and even less so the default resources, IMO: these are stdlib test suite-specific) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18526 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17899] os.listdir() leaks FDs if invoked on FD pointing to a non-directory
Christian Heimes added the comment: That's a preliminary report I made a couple of days ago. I posted it on G+ for some friends, it got re-posted by the official Python account and gone viral on Twitter. The interview is tonight. Coverity is probably going to create their own report after the interview. The save_errno approach is a common technique and not a hack. On modern systems with threading support the errno variable is a carefully crafted macro that wraps an internal function + thread local storage. Several Python files like signalmodule, faulthandler and more are using save_errno. Yes, we are pedantic. Sometimes it's not easy to cope with but we are creating a hell of a shiny piece of software. :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17899 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18535] termios.tcgetattr should return namedtuple
New submission from anatoly techtonik: Names of field for tuple returned by tcgetattr are already in documentation at http://docs.python.org/2/library/termios.html It would be nice to get them into code. -- components: Library (Lib) messages: 193595 nosy: techtonik priority: normal severity: normal status: open title: termios.tcgetattr should return namedtuple type: enhancement versions: Python 2.7, Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18535 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18535] termios.tcgetattr should return namedtuple
anatoly techtonik added the comment: Actually namedtuple doesn't suit the use case well. The use case is to read termios config, (re)set flags set it back. The attributes should be mutable. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18535 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue791968] Arguments tooltip wrong if def contains tuple
ariel brunner added the comment: It seems like the solution has caused a different issue: now, when defining a function with factional default arguments, the tuple text replaces the correct values in the tooltip. Here's an example - def f(a=0.5): pass f( tooltip shows - (a=0tuple), i.e. replaces the .5 with tuple. -- nosy: +ariel_bruner ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue791968 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18535] termios.tcgetattr should return namedtuple
Amaury Forgeot d'Arc added the comment: namedtuple has a _replace method, but I agree that it would be an incompatible change. namedlist someone? class tcattributes(object): __slots__ = ['iflag', 'oflag', 'cflag', 'lflag', 'ispeed', 'ospeed', 'cc'] def __new__(cls, values): self = object.__new__(cls) for attr, value in zip(cls.__slots__, values): setattr(self, attr, value) return self def __getitem__(self, index): return getattr(self, self.__slots__[index]) -- nosy: +amaury.forgeotdarc ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18535 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15805] Add stdout redirection tool to contextlib
Barry A. Warsaw added the comment: On Jul 23, 2013, at 04:24 AM, Alexander Belopolsky wrote: @contextlib.contextmanager def redirect_stdout(stream): old_stdout = sys.stdout sys.stdout = stream yield sys.stdout = old_stdout Make that: @contextlib.contextmanager def redirect_stdout(stream): old_stdout = sys.stdout sys.stdout = stream try: yield finally: sys.stdout = old_stdout and I'll be able to remove those 8 lines of code from all my other code bases :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15805 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18536] 李浩在 Google+ 上分享了一条信息
New submission from 浩 李: Forwarded conversation Subject: 李浩在 Google+ 上分享了一条信息 From: *李浩 (Google+)* noreply-6e55d...@plus.google.com Date: 2013/7/23 To: hk45...@gmail.com 李浩分享了一条信息https://plus.google.com/_/notifications/emlink?emr=03756893426188686779emid=CNi3kdLaxbgCFcTD3godEgYAAApath=%2F100970428986760683840%2Fposts%2FD6dgVePoxpudt=1374585664867ub=49 。 https://plus.google.com/_/notifications/emlink?emr=03756893426188686779emid=CNi3kdLaxbgCFcTD3godEgYAAApath=%2F100970428986760683840dt=1374585664867ub=49 https://plus.google.com/_/notifications/emlink?emr=03756893426188686779emid=CNi3kdLaxbgCFcTD3godEgYAAApath=%2F100970428986760683840%2Fposts%2FD6dgVePoxpudt=1374585664867ub=49 你收到此通知是因为李浩曾在你所订阅的某个圈子中。 Google Inc., 1600 Amphitheatre Pkwy, Mountain View, CA 94043 USA -- From: *李浩 (Google+)* noreply-6e55d...@plus.google.com Date: 2013/7/23 To: hk45...@gmail.com 李浩分享了一条信息https://plus.google.com/_/notifications/emlink?emr=16080280340979752301emid=COjbmdTaxbgCFQQk3QodzBsAAApath=%2F100970428986760683840%2Fposts%2FD6dgVePoxpudt=1374585669204ub=49 。 https://plus.google.com/_/notifications/emlink?emr=16080280340979752301emid=COjbmdTaxbgCFQQk3QodzBsAAApath=%2F100970428986760683840dt=1374585669204ub=49 https://plus.google.com/_/notifications/emlink?emr=16080280340979752301emid=COjbmdTaxbgCFQQk3QodzBsAAApath=%2F100970428986760683840%2Fposts%2FD6dgVePoxpudt=1374585669204ub=49 你收到此通知是因为李浩在你的“关注对象”圈子中。你可以更改https://plus.google.com/_/notifications/emlink?emr=16080280340979752301emid=COjbmdTaxbgCFQQk3QodzBsAAApath=%2Fstream%2Fcircles%2Fp4921781a0fa899dd%2Fop%2Fufedt=1374585669204ub=49 此圈子的通知设置。 Google Inc., 1600 Amphitheatre Pkwy, Mountain View, CA 94043 USA -- messages: 193600 nosy: 浩.李 priority: normal severity: normal status: open title: 李浩在 Google+ 上分享了一条信息 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18536 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18535] termios.tcgetattr should return namedtuple
Antoine Pitrou added the comment: Returning a list was probably silly to begin with (a dict would have been more natural). However, I don't think I want to see such a thing as a namedlist in the stdlib. :-( -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18535 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18536] 李浩在 Google+ 上分享了一条信息
Changes by Antoine Pitrou pit...@free.fr: -- resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18536 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18534] File name attribute should always be a text string
Antoine Pitrou added the comment: You can never assume that name will be a string: f = open(0, r) f.name 0 This may be a bit of a bad idea API-wise, but changing it now will start breaking code, so I think we should leave it as-is. -- nosy: +aronacher, pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18534 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18293] ssl.wrap_socket (cert_reqs=...), getpeercert, and unvalidated certificates
Antoine Pitrou added the comment: getpeercert() has a crappy API to begin with, but we can't change its behaviour for fear of breaking existing code (and, even, breaking it security-wise). Adding a parameter would make the API even more awful. Which is why I support Christian's idea of exposing a new API, either: - to expose the full cert chain (even if not validated) - or to set the cert verify callback -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18293 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18458] libedit history offset workaround
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18458 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18520] Fixes bugs found by pyfailmalloc during Python initialization
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18520 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18512] sys.stdout.write does not allow bytes in Python 3.x
Martin v. Löwis added the comment: Rephrasing R.David's question: ntrrgc: Did you consult any documentation (browsing or searching), and if so, where did you look? -- nosy: +loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18512 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18521] [cppcheck] Full report
Ronald Oussoren added the comment: What is cppcheck? The report contains some very dodgy false positives, like: [Modules/_cursesmodule.c:1095]: (style) Variable 'rtn' is assigned a value that is never used. [Modules/_cursesmodule.c:1097]: (style) Unused variable: break 1) The rtn is used further on the function 2) break is not a variable at all, but a C keyword There are also valid messages, but there appear to be a lot of false positives (based on the limited amount of checking that I've done) -- nosy: +ronaldoussoren ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18521 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18460] .chm documentation files advertised in download.html but not there.
Martin v. Löwis added the comment: The CHM files for 2.7.x and 3.3.x are now there. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18460 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18460] .chm documentation files advertised in download.html but not there.
Changes by Martin v. Löwis mar...@v.loewis.de: -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18460 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18211] -Werror=statement-after-declaration problem
Ronald Oussoren added the comment: I also don't understand why the optimization level shouldn't be used when building 3th-party extensions. Removing the -O flag for build_ext would be a regression compared to the current behavior because 3th-party extensions would suddenly be compiled with less optimization than before and extension authors would have to arrange for those flags themselves. That's fine on platforms using a compiler with a command-line interface that's simular to GCC, but the are compilers that don't (such as a number of vendor compilers for the various commercial unix systems). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18211 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18537] bool.toggle()
New submission from James Lu: the bool type should have a toggle() function -- messages: 193608 nosy: James.Lu priority: normal severity: normal status: open title: bool.toggle() type: enhancement versions: Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18537] bool.toggle()
Eric V. Smith added the comment: bool instances are immutable, so all value.toggle() could do is the same as not value. That is, return a new bool with the toggled value. -- nosy: +eric.smith resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18537] bool.toggle()
James Lu added the comment: I mean, return a value, some people like this style. james On Tue, Jul 23, 2013 at 12:10 PM, Eric V. Smith rep...@bugs.python.orgwrote: Eric V. Smith added the comment: bool instances are immutable, so all value.toggle() could do is the same as not value. That is, return a new bool with the toggled value. -- nosy: +eric.smith resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18537 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18537] bool.toggle()
Eric V. Smith added the comment: Since it would be the same as not value, I can't imagine this would be added to the language. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18537] bool.toggle()
James Lu added the comment: well, filter() could take the function not lambda x:not x james On Tue, Jul 23, 2013 at 12:23 PM, Eric V. Smith rep...@bugs.python.orgwrote: Eric V. Smith added the comment: Since it would be the same as not value, I can't imagine this would be added to the language. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18537 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18521] [cppcheck] Full report
Julien Nabet added the comment: quotation from http://en.wikipedia.org/wiki/Cppcheck : Cppcheck is a static code analysis tool for the C and C++ programming languages or from http://cppcheck.sourceforge.net/ Cppcheck is a static analysis tool for C/C++ code. Unlike C/C++ compilers and many other analysis tools it does not detect syntax errors in the code. Cppcheck primarily detects the types of bugs that the compilers normally do not detect. The goal is to detect only real errors in the code (i.e. have zero false positives). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18521 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18537] bool.toggle()
Eric V. Smith added the comment: If that's your concern, you can use operator.not_. import operator filter(operator.not_, [False, True, False, False, True]) [False, False, False] -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17899] os.listdir() leaks FDs if invoked on FD pointing to a non-directory
Larry Hastings added the comment: I swear I've seen a compiler where you couldn't assign to errno. But now I'm pretty sure it was MSVC, and possibly a version back in the 90s. So I'm happy to live in a world where errno is an lvalue. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17899 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18534] File name attribute should always be a text string
Serhiy Storchaka added the comment: Seconded Antoine. -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18534 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue791968] Arguments tooltip wrong if def contains tuple
Ned Deily added the comment: Ariel, if you think there is a problem, please open a new issue with all the pertinent information. This issue was closed long ago. -- nosy: +ned.deily ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue791968 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18521] [cppcheck] Full report
Ronald Oussoren added the comment: It doesn't really live up to its description. From the start of the 'filtered' list: * Messages about PyThread_acquire_lock appear to be false positives, that name is a function that's called by the macros expanded on those lines. * Syntax error in _ctypes.h: the code is ugly, but is valid C; the message is about: else if PySlice_Check(item) { This is valid because PySlice_Check is a macro that expands into an expression with parentheses: #define PySlice_Check(op) (Py_TYPE(op) == PySlice_Type) That said, I would have used explicit parentheses here. * unused variable in _ctypes_test.c: false positives, the variable is used in a function call two lines lower. * callproc.c:1620: False positive because the tool doesn't know that PyMem_Malloc is a malloc function and returns unitialized memory (the first one that isn't a problem with the tool) * messages about alloca: correct, I haven't looked seriously if the use of alloca is defensible here. * callproc.c:751: False positive, the variable is used by some macros that are used in the function. * the unused 'rtn' variable and 'break' in cursesmodule I've mentioned in a previous message. I haven't checked the rest of the list, but so far I'm not impressed by this tool. That's too bad, static analysis tools can be helpful in improving code quality. The high rate of false positives might be due to the preprocessor feature described in chapter 3 of the manual, the tool seems to be confused a lot by code that uses macros. Getting it to run properly on the CPython tools might therefore require significant tuning. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18521 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14853] test_file.py depends on sys.stdin being unseekable
Antoine Pitrou added the comment: Elena, your patch looks ok to me, thank you. Could you sign a contributor's agreement? http://www.python.org/psf/contrib/ (or have you already done so?) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14853 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18533] Avoid error from repr() of recursive dictview
Ben North added the comment: New patch including tests attached, against 3.3. Terry Reedy's example above now gives d = {} d[1] = d.keys() d[2] = d.values() d {1: dict_keys([1, 2]), 2: dict_values([dict_keys([1, 2]), ...])} which I think is preferable. Summary of patch: dictobject.c: dictview_repr() now uses a Py_ReprEnter() / Py_ReprLeave() pair to check for recursion, and produces ... if so. I think I've got the behaviour correct in the case that PySequence_List() fails, but couldn't find a way to trigger this in testing. test_dictviews.py: test_recursive_repr() checks for the correct string (containing ...) rather than a RuntimeError. test_deeply_nested_repr() is a new function, aiming to replace the original test_recursive_repr(). It checks that a RuntimeError is raised in the case of a non-recursive but deeply nested structure. Under --with-pydebug, ./python -m test.regrtest -R20:30 test_dictviews passes. -- Added file: http://bugs.python.org/file31022/non-error-recursive-dictview-3.3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18533 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18538] `python -m dis `
Changes by Michele Orrù maker...@gmail.com: -- components: Library (Lib) nosy: maker priority: normal severity: normal status: open title: `python -m dis ` type: enhancement versions: Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18538 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18538] `python -m dis ` relying on argparse
New submission from Michele Orrù: I feel a little bit embarassed for this patch; while reading the stdlib's Lib/dis.py file, I saw that the _test() function parses by itself sys.argv. I tried to clean it up using argparse; diff and manual tests attached. -- title: `python -m dis ` - `python -m dis ` relying on argparse Added file: http://bugs.python.org/file31023/issue18538.log ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18538 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18519] test_sqlite crashes on OS X tiger 3.x buildbot
R. David Murray added the comment: OK, this makes much more sense to me now :) I take it the overflow error is the only one the C code could ever raise? If so, the patch looks good to me. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18519 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18538] `python -m dis ` relying on argparse
STINNER Victor added the comment: Please attach your patch separatly. -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18538 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18533] Avoid error from repr() of recursive dictview
STINNER Victor added the comment: non-error-recursive-dictview-3.3.patch: small nit, initialize result to NULL, instead of setting it to NULL only in case of error. It makes the code more readable and it is the common coding style to handle errors. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18533 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18538] `python -m dis ` relying on argparse
Changes by Michele Orrù maker...@gmail.com: -- keywords: +patch Added file: http://bugs.python.org/file31024/issue18538.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18538 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18534] File name attribute should always be a text string
Nick Coghlan added the comment: Ouch, that complicates matters :( It also occurs to me that given the existence of the opener callback, name could be just about any type :P -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18534 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com