Re: import problem
On Mon, 2013-09-16 at 02:56 +, Steven D'Aprano wrote: On Mon, 16 Sep 2013 06:53:26 +0430, Mohsen Pahlevanzadeh wrote: Dear all, i have the following two line codes: import ui.interface.interface obj = ui.interface.interface.InterfaceCodes() ###333 I have same code in another package and work fine. but i get the : #3 This traceback following suggests that your package is a complete tangled mess of wild card imports. Perhaps I am misreading something, but the following suggests that your package is highly coupled, with strong dependencies between different modules. This is a poor design and will give you many, many problems. As you are already having. Do you understand what I mean when I talk about modules being highly coupled? Are you a Java or C++ developer learning Python? Your code suggests to me that you might be. If you are, you should read these to get some ideas of how your Java intuitions will lead you astray in Python: http://dirtsimple.org/2004/12/python-is-not-java.html http://dirtsimple.org/2004/12/java-is-not-python-either.html I assume that everything under the amlak directory is your code. Is that correct? Here's the traceback again: Traceback (most recent call last): File ./main.py, line 31, in module from materials.materials import * File /home/mohsen/codes/amlak/amlak/src/materials/materials.py, line 40, in module from ui.interface.interface import * File /home/mohsen/codes/amlak/amlak/src/ui/interface/interface.py, line 32, in module from ui.materialsFrame import * File /home/mohsen/codes/amlak/amlak/src/ui/materialsFrame.py, line 24, in module from ui.materialsFindFrame import * File /home/mohsen/codes/amlak/amlak/src/ui/materialsFindFrame.py, line 14, in module from common.objects.objects import * File /home/mohsen/codes/amlak/amlak/src/common/objects/objects.py, line 28, in module obj = ui.interface.interface.InterfaceCodes() AttributeError: 'module' object has no attribute 'interface' ### So your main module does a wild-card import from materials.materials, which does a wild-card import from ui.interface.interface, which does a wild-card import from ui.materialsFrame, which does a wild-card import from ui.materialsFindFrame, which does a wild-card import from common.objects.objects, which requires ui.interface.interface to have already been loaded and imported. But it hasn't been, because it is still being imported. The *immediate* problem is that, in effect, before you can import ui.interface.interface, you need to import ui.interface.interface. Obviously this is going to cause you problems. Google on recursive imports to learn about the sorts of problems and how to avoid them. The second problem is that, in general, you should try to avoid wild-card imports. They're not always bad, but they were really invented for use in the interactive interpreter so you can do things like this: from math import * sqrt(42) sin(1.5) Using them inside non-interactive code is not forbidden exactly, but it is frowned upon since it makes understanding your code harder. The third problem is that your code layout looks like you are fighting Python, trying to force it to be something it is not. For starters, if you're writing packages that look like this: ui.interface.interface that's simply poor design for Python. My guess is that you might be following the Java convention of putting exactly one class per source file. That is not the way Python code should be written. Modules should contain all the related classes and functions, at least up to the point that the module becomes so large that it is painful to work with. How large is that? In my opinion, this is getting close to the maximum I personally would be comfortable with: http://hg.python.org/cpython/file/3.3/Lib/decimal.py although some people might be happy with large files. But what is important is that related code should be together in the one file, not split across multiple modules and multiple packages. If you are trying to future proof your code, and thinking today it is small, but one day it will be big and will need to be a package with dozens of modules, that doesn't matter. Don't write the code you think you will need in five years. Write the code you need now. Google YAGNI for more. I am sorry that I cannot just give you a simple one-line fix for your error. As far as I can see, the fix is to re-design the package so that it is flatter, with fewer imports, and avoid the recursive import. Good luck! -- Steven Dear Steven, I moved all of files to root of source directory, And create an put my constructor to objects.py
Re: Tryign to send mail via a python script by using the local MTA
Στις 16/9/2013 4:52 πμ, ο/η Steven D'Aprano έγραψε: Hi Nikos, I'm now going to put as much care and attention into my answer as you put into your question. Have uy tryed imprting os first? u nmeed to do improt os first or it wont work., When you give evidence of caring about the questions you ask, I'll start caring about the answers I give you. On Sun, 15 Sep 2013 08:54:48 -0700, Ferrous Cranus wrote: try: # prepare mail data FROM = random_char(10) + '@' + random_char(10) + '.com' TO = nikos.gr...@gmail.com SUBJECT = random_char( 50 ) MESSAGE = random_char( 500 ) os.system( echo %s | mailx -v -r %s -s %s %s % (MESSAGE, FROM, SUBJECT, TO) ) print( h2font color=blue%sη αποστολή προς %s επετεύχθη!/font/h2 % (times, TO) ) except Exception as e: print( sendmail = , date, repr( sys.exc_info() ) ) sys.exit(0) Steven of course i have imported the 'os' module. I try to send mail from different FROM filed just like as a visitor guest will use the webform to compete his own email. but since you ask here is the whole code with the function displayed too. #= # if html form is submitted then send user mail #= def random_char( y, chars=string.ascii_uppercase + string.digits ): return ''.join( random.choice(chars) for x in range(y) ) for times in range(0, 1): try: # prepare mail data FROM = random_char(10) + '@' + random_char(10) + '.com' TO = nikos.gr...@gmail.com SUBJECT = random_char( 50 ) MESSAGE = random_char( 500 ) os.system( echo %s | mailx -v -r %s -s %s %s % (MESSAGE, FROM, SUBJECT, TO) ) print( h2font color=blue%sη αποστολή προς %s επετεύχθη!/font/h2 % (times, TO) ) except Exception as e: print( sendmail = , date, repr( sys.exc_info() ) ) sys.exit(0) == Is there a way to avoid the hostname and the ip address from being revealed when i'am sending an email? Because the mails finally got delivered to my gmail account after many hours of delay, and in the headers they are detailes like hostname and ip address of my server which i dont want to be revealed. i can alter FROM, TO, subject, message can i also alter the hostname fo the server the the mail derived from? -- https://mail.python.org/mailman/listinfo/python-list
Re: import problem
On Mon, 2013-09-16 at 11:14 +0430, Mohsen Pahlevanzadeh wrote: On Mon, 2013-09-16 at 02:56 +, Steven D'Aprano wrote: On Mon, 16 Sep 2013 06:53:26 +0430, Mohsen Pahlevanzadeh wrote: Dear all, i have the following two line codes: import ui.interface.interface obj = ui.interface.interface.InterfaceCodes() ###333 I have same code in another package and work fine. but i get the : #3 This traceback following suggests that your package is a complete tangled mess of wild card imports. Perhaps I am misreading something, but the following suggests that your package is highly coupled, with strong dependencies between different modules. This is a poor design and will give you many, many problems. As you are already having. Do you understand what I mean when I talk about modules being highly coupled? Are you a Java or C++ developer learning Python? Your code suggests to me that you might be. If you are, you should read these to get some ideas of how your Java intuitions will lead you astray in Python: http://dirtsimple.org/2004/12/python-is-not-java.html http://dirtsimple.org/2004/12/java-is-not-python-either.html I assume that everything under the amlak directory is your code. Is that correct? Here's the traceback again: Traceback (most recent call last): File ./main.py, line 31, in module from materials.materials import * File /home/mohsen/codes/amlak/amlak/src/materials/materials.py, line 40, in module from ui.interface.interface import * File /home/mohsen/codes/amlak/amlak/src/ui/interface/interface.py, line 32, in module from ui.materialsFrame import * File /home/mohsen/codes/amlak/amlak/src/ui/materialsFrame.py, line 24, in module from ui.materialsFindFrame import * File /home/mohsen/codes/amlak/amlak/src/ui/materialsFindFrame.py, line 14, in module from common.objects.objects import * File /home/mohsen/codes/amlak/amlak/src/common/objects/objects.py, line 28, in module obj = ui.interface.interface.InterfaceCodes() AttributeError: 'module' object has no attribute 'interface' ### So your main module does a wild-card import from materials.materials, which does a wild-card import from ui.interface.interface, which does a wild-card import from ui.materialsFrame, which does a wild-card import from ui.materialsFindFrame, which does a wild-card import from common.objects.objects, which requires ui.interface.interface to have already been loaded and imported. But it hasn't been, because it is still being imported. The *immediate* problem is that, in effect, before you can import ui.interface.interface, you need to import ui.interface.interface. Obviously this is going to cause you problems. Google on recursive imports to learn about the sorts of problems and how to avoid them. The second problem is that, in general, you should try to avoid wild-card imports. They're not always bad, but they were really invented for use in the interactive interpreter so you can do things like this: from math import * sqrt(42) sin(1.5) Using them inside non-interactive code is not forbidden exactly, but it is frowned upon since it makes understanding your code harder. The third problem is that your code layout looks like you are fighting Python, trying to force it to be something it is not. For starters, if you're writing packages that look like this: ui.interface.interface that's simply poor design for Python. My guess is that you might be following the Java convention of putting exactly one class per source file. That is not the way Python code should be written. Modules should contain all the related classes and functions, at least up to the point that the module becomes so large that it is painful to work with. How large is that? In my opinion, this is getting close to the maximum I personally would be comfortable with: http://hg.python.org/cpython/file/3.3/Lib/decimal.py although some people might be happy with large files. But what is important is that related code should be together in the one file, not split across multiple modules and multiple packages. If you are trying to future proof your code, and thinking today it is small, but one day it will be big and will need to be a package with dozens of modules, that doesn't matter. Don't write the code you think you will need in five years. Write the code you need now. Google YAGNI for more. I am sorry that I cannot just give you a simple one-line fix for your error. As far as I can see, the fix is to re-design the package so that it is flatter, with fewer imports, and
Help regarding python facepy library
Hello all, I am using python facepy library to fetch data from facebook. It was running fine. The problem now is I just changed my system and now getting error that says certificate verify failed. Here my code and exception log both are given below. The library that I have used is https://pypi.python.org/pypi/facepy Code is given below. # import facepy from facepy import GraphAPI,exceptions import json graph = GraphAPI('my fb access token') fb_dump = open('D:\\Malhar Data\\Projects\\Social Media Web Project\\TestGround\\temp\\Output\\output.txt', 'w') try: pages = graph.get('AhmedabadUniversity/posts', page=True) all_pages = [] for page in pages: all_pages = all_pages + page[data] except exceptions.OAuthError, error: if error.code == 2: print Unexpected error occured elif error.code == 803: print Alias or Page does not exist for d in all_pages: fb_dump.write(Message : + d.get('message','None').encode(UTF-8, ignore)) fb_dump.close() ## Exception log is given below. D:\Malhar Data\Projects\Social Media Web Project\TestGround\temppython fbgrabbe r.py C:\Python26\lib\site-packages\facepy\graph_api.py:199: DeprecationWarning: BaseE xception.message has been deprecated as of Python 2.6 raise HTTPError(exception.message) Traceback (most recent call last): File fbgrabber.py, line 14, in module for page in pages: File C:\Python26\Lib\site-packages\facepy\graph_api.py, line 212, in paginat e result, url = load(method, url, data) File C:\Python26\Lib\site-packages\facepy\graph_api.py, line 199, in load raise HTTPError(exception.message) facepy.exceptions.HTTPError: [Errno 1] _ssl.c:480: error:14090086:SSL routines:S SL3_GET_SERVER_CERTIFICATE:certificate verify failed I tried generating new token and run the script but got same error. I didn't find any solution of this problem. If anybody is able to figure out the problem, please help me. Thank you, Malhar Vora -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
Op 16-09-13 03:52, Steven D'Aprano schreef: Hi Nikos, I'm now going to put as much care and attention into my answer as you put into your question. Have uy tryed imprting os first? u nmeed to do improt os first or it wont work., When you give evidence of caring about the questions you ask, I'll start caring about the answers I give you. And why do you find it necessary to impart your careless answer on the list? If you find he doesn't show enough care about the questions he asks, why don't you just ignore him, instead of showing us all that you too can contribute in a careless manner? -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
On Mon, Sep 16, 2013 at 5:29 PM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: Op 16-09-13 03:52, Steven D'Aprano schreef: Hi Nikos, I'm now going to put as much care and attention into my answer as you put into your question. Have uy tryed imprting os first? u nmeed to do improt os first or it wont work., When you give evidence of caring about the questions you ask, I'll start caring about the answers I give you. And why do you find it necessary to impart your careless answer on the list? If you find he doesn't show enough care about the questions he asks, why don't you just ignore him, instead of showing us all that you too can contribute in a careless manner? bceause its funnyer that way? Also, how will other people learn that they should put some effort into their questions? If people are only ever corrected privately, nobody will learn from anyone else. Orders of magnitude more people will read this than just the OP, which is why I still respond to jmf about Unicode even though I know he isn't listening. It's worth it for the hundreds (thousands? millions? Maybe even more?) of other people who'll read and learn. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
On Mon, Sep 16, 2013 at 5:29 PM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: instead of showing us all that you too can contribute in a careless manner? Also: It takes effort to contribute usefully in a way that looks careless :) It's not saving effort, it's making a point. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
Στις 16/9/2013 10:29 πμ, ο/η Antoon Pardon έγραψε: Op 16-09-13 03:52, Steven D'Aprano schreef: Hi Nikos, I'm now going to put as much care and attention into my answer as you put into your question. Have uy tryed imprting os first? u nmeed to do improt os first or it wont work., When you give evidence of caring about the questions you ask, I'll start caring about the answers I give you. And why do you find it necessary to impart your careless answer on the list? If you find he doesn't show enough care about the questions he asks, why don't you just ignore him, instead of showing us all that you too can contribute in a careless manner? My question is not careless. I have stated exactly the problem and shown relevant code of what i'm trying to accomplish. 1 have almost 10 responses and not even one of them is being a proper answer to my initial question. My question is clear. -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
Op 16-09-13 09:44, Chris Angelico schreef: On Mon, Sep 16, 2013 at 5:29 PM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: Op 16-09-13 03:52, Steven D'Aprano schreef: Hi Nikos, I'm now going to put as much care and attention into my answer as you put into your question. Have uy tryed imprting os first? u nmeed to do improt os first or it wont work., When you give evidence of caring about the questions you ask, I'll start caring about the answers I give you. And why do you find it necessary to impart your careless answer on the list? If you find he doesn't show enough care about the questions he asks, why don't you just ignore him, instead of showing us all that you too can contribute in a careless manner? bceause its funnyer that way? Funny for who? Personnaly I was rather amused by some of the reactions that Nikos received and that were ill received by some people here. So why should your of steve's fun trump my amusment? Also, how will other people learn that they should put some effort into their questions? If people are only ever corrected privately, nobody will learn from anyone else. Orders of magnitude more people will read this than just the OP, I didn't complain about his respons being public. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
On Mon, Sep 16, 2013 at 6:07 PM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: Also, how will other people learn that they should put some effort into their questions? If people are only ever corrected privately, nobody will learn from anyone else. Orders of magnitude more people will read this than just the OP, I didn't complain about his respons being public. http://www.catb.org/esr/faqs/smart-questions.html#not_losing Sometimes, things are better said than not-said. In fact, that's *often* true. Maybe it's unpleasant for the person the jab is aimed at; maybe it feels awkward for you, as an onlooker. But for the good of python-list, Nikos has to be told that putting minimal effort into his questions is a bad thing, and if you're going to say that, may as well say it in a funny way. Plus, Steven was making a solid point, too. So if you want Nikos to be ignored by anyone who can't be completely friendly, what you'll end up with is materially less content on the list. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
Op 16-09-13 09:46, Chris Angelico schreef: On Mon, Sep 16, 2013 at 5:29 PM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: instead of showing us all that you too can contribute in a careless manner? Also: It takes effort to contribute usefully in a way that looks careless :) It's not saving effort, it's making a point. So what? The end result is still a contribution that looks like it was carelessly written. Do you think making a point is an end that justifies any kind of means? If not why do you argue in a way that suggest just that. If yes, does that mean baiting Nikos is all right if it makes a point, or responding somewhat obnoxious to him? -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
On Mon, Sep 16, 2013 at 6:12 PM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: Op 16-09-13 09:46, Chris Angelico schreef: On Mon, Sep 16, 2013 at 5:29 PM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: instead of showing us all that you too can contribute in a careless manner? Also: It takes effort to contribute usefully in a way that looks careless :) It's not saving effort, it's making a point. So what? The end result is still a contribution that looks like it was carelessly written. It's a contribution that SAYS that it looks carelessly written. I think most people here are intelligent enough to know that that's different from actual carelessness. Do you think making a point is an end that justifies any kind of means? If not why do you argue in a way that suggest just that. If yes, does that mean baiting Nikos is all right if it makes a point, or responding somewhat obnoxious to him? In a debate, you make points and counterpoints. In most debates, you also gain (or lose) points for style. Steven scored plenty of the latter IMO. You're here making a straw-man and a false dichotomy; I believe that making a point is sufficient justification for what Steven and I did, but I don't think it justifies any kind of means. I would not, for instance, destroy Nikos's server, data, or access to either, to make a point; and history will confirm this. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
Op 16-09-13 10:19, Chris Angelico schreef: On Mon, Sep 16, 2013 at 6:12 PM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: Op 16-09-13 09:46, Chris Angelico schreef: On Mon, Sep 16, 2013 at 5:29 PM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: instead of showing us all that you too can contribute in a careless manner? Also: It takes effort to contribute usefully in a way that looks careless :) It's not saving effort, it's making a point. So what? The end result is still a contribution that looks like it was carelessly written. It's a contribution that SAYS that it looks carelessly written. I think most people here are intelligent enough to know that that's different from actual carelessness. The question is, should they care about that difference. The end result is a contribution that is just as hard to read. Do you think making a point is an end that justifies any kind of means? If not why do you argue in a way that suggest just that. If yes, does that mean baiting Nikos is all right if it makes a point, or responding somewhat obnoxious to him? In a debate, you make points and counterpoints. In most debates, you also gain (or lose) points for style. Steven scored plenty of the latter IMO. And why should we accept you as the arbiter for this? You're here making a straw-man and a false dichotomy; I believe that making a point is sufficient justification for what Steven and I did, but I don't think it justifies any kind of means. Then your argument was incomplete, because it just mentioned making a point as if that in itself was sufficient. I would not, for instance, destroy Nikos's server, data, or access to either, to make a point; and history will confirm this. No it doesn't. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
On Mon, Sep 16, 2013 at 6:43 PM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: Op 16-09-13 10:19, Chris Angelico schreef: It's a contribution that SAYS that it looks carelessly written. I think most people here are intelligent enough to know that that's different from actual carelessness. The question is, should they care about that difference. The end result is a contribution that is just as hard to read. Is it, really? I throw the question open: Is it really just as difficult to read a deliberately-pointed-out sloppiness as an actual one? And is it as much of a problem to the list? In a debate, you make points and counterpoints. In most debates, you also gain (or lose) points for style. Steven scored plenty of the latter IMO. And why should we accept you as the arbiter for this? We shouldn't. Style points are per-listener. In my eyes he did well. You may well disagree. You're here making a straw-man and a false dichotomy; I believe that making a point is sufficient justification for what Steven and I did, but I don't think it justifies any kind of means. Then your argument was incomplete, because it just mentioned making a point as if that in itself was sufficient. Context. Context. Context. Sufficient justification for what it was used for. You do not seriously believe that that needs to be spelled out? I would not, for instance, destroy Nikos's server, data, or access to either, to make a point; and history will confirm this. No it doesn't. No? He gave me his root password - check the list archives. I did none of the above three destructive actions (nor any other destructive action), even though it would have made my point much stronger to do so. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
Op 16-09-13 10:48, Chris Angelico schreef: On Mon, Sep 16, 2013 at 6:43 PM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: Op 16-09-13 10:19, Chris Angelico schreef: It's a contribution that SAYS that it looks carelessly written. I think most people here are intelligent enough to know that that's different from actual carelessness. The question is, should they care about that difference. The end result is a contribution that is just as hard to read. Is it, really? I throw the question open: Is it really just as difficult to read a deliberately-pointed-out sloppiness as an actual one? And is it as much of a problem to the list? Do you think improt is easier to read when written so deliberatly instead of out of carelessness? In a debate, you make points and counterpoints. In most debates, you also gain (or lose) points for style. Steven scored plenty of the latter IMO. And why should we accept you as the arbiter for this? We shouldn't. Style points are per-listener. In my eyes he did well. You may well disagree. Why do you keep introducing your personal appreciations while at the same time you admit they don't carry much weight. You're here making a straw-man and a false dichotomy; I believe that making a point is sufficient justification for what Steven and I did, but I don't think it justifies any kind of means. Then your argument was incomplete, because it just mentioned making a point as if that in itself was sufficient. Context. Context. Context. Sufficient justification for what it was used for. You do not seriously believe that that needs to be spelled out? Your context adds nothing. The only thing that the context would add, is that in this specific case you think that the end justifies the means but it doesn't explain in any way on what grounds you think so. Those that took Nikos to task earlier for his behaviour probably though their end justified the means too. So yes, if you don't want to give the impression that you are simply ad hoccing what you personnally don't have a problem with, you'd better spell a few things out. I would not, for instance, destroy Nikos's server, data, or access to either, to make a point; and history will confirm this. No it doesn't. No? He gave me his root password - check the list archives. I did none of the above three destructive actions (nor any other destructive action), even though it would have made my point much stronger to do so. You behaved in a way some people clearly thought of a questionable. So for those people you have established you are prepared to exhibit questionable behaviour to make your point. So I think there are a number of people who will think of you as not trustable enough to withhold the behaviour in question here, when you think it would be necessary to make your point. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
Στις 16/9/2013 12:40 μμ, ο/η Antoon Pardon έγραψε: Op 16-09-13 10:48, Chris Angelico schreef: On Mon, Sep 16, 2013 at 6:43 PM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: Op 16-09-13 10:19, Chris Angelico schreef: It's a contribution that SAYS that it looks carelessly written. I think most people here are intelligent enough to know that that's different from actual carelessness. The question is, should they care about that difference. The end result is a contribution that is just as hard to read. Is it, really? I throw the question open: Is it really just as difficult to read a deliberately-pointed-out sloppiness as an actual one? And is it as much of a problem to the list? Do you think improt is easier to read when written so deliberatly instead of out of carelessness? In a debate, you make points and counterpoints. In most debates, you also gain (or lose) points for style. Steven scored plenty of the latter IMO. And why should we accept you as the arbiter for this? We shouldn't. Style points are per-listener. In my eyes he did well. You may well disagree. Why do you keep introducing your personal appreciations while at the same time you admit they don't carry much weight. You're here making a straw-man and a false dichotomy; I believe that making a point is sufficient justification for what Steven and I did, but I don't think it justifies any kind of means. Then your argument was incomplete, because it just mentioned making a point as if that in itself was sufficient. Context. Context. Context. Sufficient justification for what it was used for. You do not seriously believe that that needs to be spelled out? Your context adds nothing. The only thing that the context would add, is that in this specific case you think that the end justifies the means but it doesn't explain in any way on what grounds you think so. Those that took Nikos to task earlier for his behaviour probably though their end justified the means too. So yes, if you don't want to give the impression that you are simply ad hoccing what you personnally don't have a problem with, you'd better spell a few things out. I would not, for instance, destroy Nikos's server, data, or access to either, to make a point; and history will confirm this. No it doesn't. No? He gave me his root password - check the list archives. I did none of the above three destructive actions (nor any other destructive action), even though it would have made my point much stronger to do so. You behaved in a way some people clearly thought of a questionable. So for those people you have established you are prepared to exhibit questionable behaviour to make your point. So I think there are a number of people who will think of you as not trustable enough to withhold the behaviour in question here, when you think it would be necessary to make your point. Look, i want this to stop. Open your own thread and discuss this if you like. This is a thread i opened for a specific question and all i see its irrelevant answers. -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
Look, i want this to stop. Open your own thread and discuss this if you like. This is a thread i opened for a specific question and all i see its irrelevant answers. Hi Ferrous, The problem is not in your Python code. You can debug it from the command line by typing the 'echo ... | mailx' command your Python code is executing. Somewhere on your local SMTP or on Google's SMTP, your message is not being processed the way you want it. There are many things that could cause this -- SPF, DKIM, reverse DNS not being correct, the From address being 'faked', or one of about a hunderd other factors. It's most likely an issue in your local SMTP server's configuration. You'll have to dive into the logs and do some research on how SMTP works nowadays to find out what's happening. But think about this: if I could send mail as nikos.gr...@gmail.com, just by typing a shell command, how could we ever trust e-mail to be from who it really is? What if I send mail as barack.ob...@whitehouse.gov? What you're doing may look like spam from Google's point of view, and that's why I think you're not receiving the message. -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
On Mon, 16 Sep 2013 12:06:06 +0200, Joost Molenaar wrote: It's most likely an issue in your local SMTP server's configuration. I'm not convinced about that. All the evidence is that OPs local mta delivers the message to google. I think the issue is that google are deciding the message is junk and dropping it in the bit recycling bin. This is just as likely to be a feature of the random_char(50) subject and random_char(500) message text as it is any local mta settings. I have no idea what OPs random_char(x) does, but I also see no proof it doesn't insert data that's illegal in subject or body. Even if it creates a wholly valid message subject and body, it might look like something spammy to google. starttls suggests that whatever his mta is, it's using some form of auth to communicate with gmail. It looks like his mail is delivered to the google servers. If he's trying to prove communication works, he might be better off using a message subject of test and a message body of this is a test message. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
Στις 16/9/2013 2:21 μμ, ο/η Denis McMahon έγραψε: On Mon, 16 Sep 2013 12:06:06 +0200, Joost Molenaar wrote: It's most likely an issue in your local SMTP server's configuration. I'm not convinced about that. All the evidence is that OPs local mta delivers the message to google. I think the issue is that google are deciding the message is junk and dropping it in the bit recycling bin. This is just as likely to be a feature of the random_char(50) subject and random_char(500) message text as it is any local mta settings. I have no idea what OPs random_char(x) does, but I also see no proof it doesn't insert data that's illegal in subject or body. Even if it creates a wholly valid message subject and body, it might look like something spammy to google. starttls suggests that whatever his mta is, it's using some form of auth to communicate with gmail. It looks like his mail is delivered to the google servers. If he's trying to prove communication works, he might be better off using a message subject of test and a message body of this is a test message. Hello Denis and thanks for dropping into the conversation. here is the code again with the random function definition: # = # if html form is submitted then send user mail # = def random_char( y, chars=string.ascii_uppercase + string.digits ): return ''.join( random.choice(chars) for x in range(y) ) for times in range(0, 10): try: # prepare mail data FROM = random_char(8) + '@' + random_char(5) + '.com' TO = nkou...@ath.forthnet.gr SUBJECT = random_char( 50 ) MESSAGE = random_char( 500 ) os.system( echo %s | mailx -v -r %s -s %s %s % (MESSAGE, FROM, SUBJECT, TO) ) print( h2font color=blue%sη αποστολή προς %s επετεύχθη!/font/h2 % (times, TO) ) except Exception as e: print( sendmail = , date, repr( sys.exc_info() ) ) sys.exit(0) = i have sent 10 mails to my personal Google account and i though they were never get delivered but it seems that every half an hour or so, one-by-one come into appearance into my GMail account which i access via Thunderbird! I don't know whats delaying them so long but they do come. What i want now is to be able to alter the hostname of my server so the mails wont indicate that they derive from superhost.gr as they aare now sen in the mail headers. I will show you an example when one more mail arrive into my gmail account. -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Am 16.09.2013 13:21, schrieb Denis McMahon: If he's trying to prove communication works, he might be better off using a message subject of test and a message body of this is a test message. Generally, he might be best off if he didn't use os.system() with string-interpolated (without escaping or any such) and user-specified (!) parameters to send out the mail using mailx though a sub-shell. This begs of using his mailer script for code injection as his web-server user, and I'm amazed that nobody has commented on that so far. - -- - --- Heiko. -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.20 (MingW32) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSNuxTAAoJEDMqpHf921/Sd8IH/2BcapK/dNqbs/PDz3LZLiUS JYYmNaWSjui7KYJsA/A8R3XVaM0eyHkYI8dr8Jx6hPdPJyeE27MCKddF3GlYs17Z iO1AydR2J8kYjXgVLrCWtfH3taB6ryUko6sOe1j/u0hYbQOATxuBPvxTVK4Wmi85 1m8unw9NvlTelAREg6WLudqpE9i115dns87+FTNcgNd3ieppJw+Cv2Mp6z3Yn3he y0W9yMqH1LV4oW/6arZVVIcaWDHCb1I0L++aC8JLnOHYz1osf+34BbHHBcY6Qkty reon+sWKwrlJ56o8Zi1Lx97ymxXxuvUtJS/5WGpRh/XLWYVBGCX3XA42DKqscQk= =xENG -END PGP SIGNATURE- -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Am 16.09.2013 13:37, schrieb Ferrous Cranus: What i want now is to be able to alter the hostname of my server so the mails wont indicate that they derive from superhost.gr as they aare now sen in the mail headers. There is no way to do that, as the Received:-header which you complain about is inserted by Google mail servers. - -- - --- Heiko. -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.20 (MingW32) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSNu8bAAoJEDMqpHf921/SFjwH/RXH79ynaWTkdeYWc3koAPvv wQJKaiYy0FMJgV0JoZqWcg6xc/gEfoyBVvMlxTjSI9Jq44Ay6p3xYl4mCV9Oxplc nx3SD8XKE6HV8H8cdUE+MAVxcI4mhz43so6yG7vWFJskuKZMC4zCwnP3F2Wt3zNK EpgYyyKSCG+5KOhnOryw3lVQ0qlsqp02/cEQbn3iWtoe5ojh8qFr+bHL1vs02gtK 16YgKXre+69ne1hs4Hcyj1OKzYHU+YJmP6WTbdIXFXv1ujS3pf0vjpPWLX8f02Y1 n0HHBL0hWvm9+rbxYXera75jQUqY0v042fDjajhKNa/Sq36OBeoW6vt5hysDBxc= =4HLT -END PGP SIGNATURE- -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
Στις 16/9/2013 2:44 μμ, ο/η Heiko Wundram έγραψε: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Am 16.09.2013 13:37, schrieb Ferrous Cranus: What i want now is to be able to alter the hostname of my server so the mails wont indicate that they derive from superhost.gr as they aare now sen in the mail headers. There is no way to do that, as the Received:-header which you complain about is inserted by Google mail servers. true. Even if now i have stopped using Google's SMTP Server as a means for sending out mails and i have decided to use my local MTA instead, at the very moment Google's POP servers receive the mail they still add a RECEIVE header revealing the hostname of the server that initiated the contact. Correct? But even so, if we alter for example the hostname of our server to a different name then wouldn't Google use that to identify the server thus protecting the real identity(hostname that is) of the server that initiated the connection? -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Am 16.09.2013 14:11, schrieb Ferrous Cranus: But even so, if we alter for example the hostname of our server to a different name then wouldn't Google use that to identify the server thus protecting the real identity(hostname that is) of the server that initiated the connection? Why on earth would you want to do that? Mail routing headers are there for a reason. - -- - --- Heiko. -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.20 (MingW32) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSNvbTAAoJEDMqpHf921/SUMoH/2iX9pw0DiOWqHzAj1igbswY tlQVigpz8eprFpsl84JW0+NAOFcpy65VdmwynJ57+qhHvChpdygGoNYjtStP37nF oYbMNHs2gRA+dbhl3xxjedGgIzQinGM7aiy+7ZGU/KIGHorMykV0eUDQaObklFNb oepbNMu1yo2U2PWyBHxlH8iehyECFdeKfLRJX6YrkT5jSS7EKKn6UuaCLKRMYJNN sClGe4J5x5GnIsPtPSWK73rdmYtY/vLmM9P4tDKCBAJvdW5nU52EXLlMNzWu8lPS wvg6bor1/meYPxfzIcmIvKTiYZ+omkmQ8iPkOGEupPCKp8SRB9J2iq8nQA0mYo4= =1cDc -END PGP SIGNATURE- -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
Op 16-09-13 14:11, Ferrous Cranus schreef: Στις 16/9/2013 2:44 μμ, ο/η Heiko Wundram έγραψε: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Am 16.09.2013 13:37, schrieb Ferrous Cranus: What i want now is to be able to alter the hostname of my server so the mails wont indicate that they derive from superhost.gr as they aare now sen in the mail headers. There is no way to do that, as the Received:-header which you complain about is inserted by Google mail servers. true. Even if now i have stopped using Google's SMTP Server as a means for sending out mails and i have decided to use my local MTA instead, at the very moment Google's POP servers receive the mail they still add a RECEIVE header revealing the hostname of the server that initiated the contact. Correct? But even so, if we alter for example the hostname of our server to a different name then wouldn't Google use that to identify the server thus protecting the real identity(hostname that is) of the server that initiated the connection? No, google will probably find out that the name your server identifies with, will not correspond with the IP address it is connected to and will write a receive line that will reflect that fact, using reverse DNS to report the real hostname of your computer. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Is %z broken for return values of time.gmtime()?
I’m wondering whether this is expected: Python 3.3.2 (default, May 21 2013, 11:50:47) [GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin Type help, copyright, credits or license for more information. import time time.strftime(%F %T %z, time.gmtime(40 * 365 * 86400)) '2009-12-22 00:00:00 +0100‘ According to the documentation of time.gmtime(), it returns a struct_time in UTC, but %z is replaced by +0100, which is the UTC offset of my OS’s time zone without DST, but DST is currently in effect here (but was not at the timestamp passed to gmtime()). 40 * 365 * 86400 seconds is a bit less than 40 Years. I’m using a date near to today to rule out any peculiarities with dates that are long in the past. Using a date at which DST was active yields the same result: time.strftime(%F %T %z, time.gmtime(40.5 * 365 * 86400)) '2010-06-22 12:00:00 +0100' Why is my OS’s time zone used for formatting a struct_time with the UTC time zone? I’m running OS X 10.8.4, my OS’s time zone is set to CET/CEST. Regards Michael smime.p7s Description: S/MIME cryptographic signature -- https://mail.python.org/mailman/listinfo/python-list
How is this list comprehension evaluated?
Hello, I'm making Python mini-projects and now I'm making a Latin Square (Latin Square: http://en.wikipedia.org/wiki/Latin_square) So, I started watching example code and I found this question on Stackoverflow: http://stackoverflow.com/questions/5313900/generating-cyclic-permutations-reduced-latin-squares-in-python It uses a list comprenhension to generate the Latin Square, I'm am a newbie to Python, and I've tried to figure out how this is evaluated: a = [1, 2, 3, 4] n = len(a) [[a[i - j] for i in range(n)] for j in range(n)] I don't understand how the i and the j changes. On my way of thought it is evaluated like this: [[a[0 - 0] for 0 in range(4)] for 0 in range(4)] [[a[1 - 1] for 1 in range(4)] for 1 in range(4)] [[a[2 - 2] for 2 in range(4)] for 2 in range(4)] [[a[3 - 3] for 3 in range(4)] for 3 in range(4)] But I think I'm wrong... So, could you explain me as above? It would help me a lot. Thanks for reading! -- https://mail.python.org/mailman/listinfo/python-list
Re: How is this list comprehension evaluated?
Op 16-09-13 15:43, Arturo B schreef: Hello, I'm making Python mini-projects and now I'm making a Latin Square (Latin Square: http://en.wikipedia.org/wiki/Latin_square) So, I started watching example code and I found this question on Stackoverflow: http://stackoverflow.com/questions/5313900/generating-cyclic-permutations-reduced-latin-squares-in-python It uses a list comprenhension to generate the Latin Square, I'm am a newbie to Python, and I've tried to figure out how this is evaluated: a = [1, 2, 3, 4] n = len(a) [[a[i - j] for i in range(n)] for j in range(n)] I don't understand how the i and the j changes. On my way of thought it is evaluated like this: [[a[0 - 0] for 0 in range(4)] for 0 in range(4)] [[a[1 - 1] for 1 in range(4)] for 1 in range(4)] [[a[2 - 2] for 2 in range(4)] for 2 in range(4)] [[a[3 - 3] for 3 in range(4)] for 3 in range(4)] But I think I'm wrong... So, could you explain me as above? It would help me a lot. Thanks for reading! Just start your python interpreter and type the following [[(i,j) for i in range(3)] for j in range(3)] That should give you a clue. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: import problem
On 16/9/2013 00:05, Mohsen Pahlevanzadeh wrote: thank you, you gave me how to get fish instead of fish, it's very better. I'd suggest you make a diagram showing each file and indicate what files it imports by an arrow. If any arrows form a circle, you (may) have recursive imports. You should try to organize your code so you don't have any loops in the above diagram. In reasonable designs, you can do that by factoring out some of the code into new bubbles. But if you have too many bubbles already, that just makes it harder to keep track of. The recursion can sometimes be debugged more easily by eliminating the from xxx import * forms., which really hides what things you get. You'll only get those symbols already defined in the particular loop, (which is generaly the ones defined before its import statment) and you won't find out about the missing one till you try to use it later. It can sometimes be mitigated by using from xxx import y1, y2 where you explicitly define those things before the import statement. However, both of these require you to have the imports somewhere NOT at the top of the file. And that can cause other problems. Best is to avoid any loops in the diagram. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: How is this list comprehension evaluated?
On 09/16/2013 07:43 AM, Arturo B wrote: It uses a list comprenhension to generate the Latin Square, I'm am a newbie to Python, and I've tried to figure out how this is evaluated: a = [1, 2, 3, 4] n = len(a) [[a[i - j] for i in range(n)] for j in range(n)] I don't understand how the i and the j changes. On my way of thought it is evaluated like this: It helps to convert it to a conventional for loop to see how it works: a = [1, 2, 3, 4] n = len(a) resultj = [] for j in range(n): resulti = [] for i in range(n): resulti.append(a[i-j]) resultj.append(resulti) -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
Στις 16/9/2013 3:56 μμ, ο/η Antoon Pardon έγραψε: Op 16-09-13 14:11, Ferrous Cranus schreef: Στις 16/9/2013 2:44 μμ, ο/η Heiko Wundram έγραψε: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Am 16.09.2013 13:37, schrieb Ferrous Cranus: What i want now is to be able to alter the hostname of my server so the mails wont indicate that they derive from superhost.gr as they aare now sen in the mail headers. There is no way to do that, as the Received:-header which you complain about is inserted by Google mail servers. true. Even if now i have stopped using Google's SMTP Server as a means for sending out mails and i have decided to use my local MTA instead, at the very moment Google's POP servers receive the mail they still add a RECEIVE header revealing the hostname of the server that initiated the contact. Correct? But even so, if we alter for example the hostname of our server to a different name then wouldn't Google use that to identify the server thus protecting the real identity(hostname that is) of the server that initiated the connection? No, google will probably find out that the name your server identifies with, will not correspond with the IP address it is connected to and will write a receive line that will reflect that fact, using reverse DNS to report the real hostname of your computer. We need to try it to see if it will work, or perhaps we can alter both the hostname and ip address variables on the server to some other values so that google will use them too. It will not detect the real hostname or the real ip this way since both values will be not true. -- https://mail.python.org/mailman/listinfo/python-list
Re: Confessions of a terrible programmer
On Friday, September 6, 2013 10:26:07 PM UTC+5:30, Steven D'Aprano wrote: Not specifically about Python, but still relevant: http://blog.kickin-the-darkness.com/2007/09/confessions-of-terrible-programmer.html Nice post -- thanks! Prompted this from me http://blog.languager.org/2013/09/poorest-computer-users-are-programmers.html -- https://mail.python.org/mailman/listinfo/python-list
statsmodels.api
Hi, I intalled an executable version of statsmodels library for Windows 32-bit. When I import it in my Python Shell no problem occurs buy when I write: import statsmodels.api as sm the following error arises: Traceback (most recent call last): File pyshell#1, line 1, in module import statsmodels.api File C:\Python33\lib\site-packages\statsmodels\api.py, line 1, in module from . import iolib, datasets, tools File C:\Python33\lib\site-packages\statsmodels\iolib\__init__.py, line 1, in module from .foreign import StataReader, genfromdta, savetxt File C:\Python33\lib\site-packages\statsmodels\iolib\foreign.py, line 20, in module import statsmodels.tools.data as data_util File C:\Python33\lib\site-packages\statsmodels\tools\__init__.py, line 1, in module from .tools import add_constant, categorical File C:\Python33\lib\site-packages\statsmodels\tools\tools.py, line 8, in module from scipy.interpolate import interp1d File C:\Python33\lib\site-packages\scipy\interpolate\__init__.py, line 150, in module from .interpolate import * File C:\Python33\lib\site-packages\scipy\interpolate\interpolate.py, line 12, in module import scipy.special as spec File C:\Python33\lib\site-packages\scipy\special\__init__.py, line 529, in module from ._ufuncs import * Why? Thanks for any help you will want to give me! Davide -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
Στις 16/9/2013 3:56 μμ, ο/η Antoon Pardon έγραψε: Op 16-09-13 14:11, Ferrous Cranus schreef: Στις 16/9/2013 2:44 μμ, ο/η Heiko Wundram έγραψε: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Am 16.09.2013 13:37, schrieb Ferrous Cranus: What i want now is to be able to alter the hostname of my server so the mails wont indicate that they derive from superhost.gr as they aare now sen in the mail headers. There is no way to do that, as the Received:-header which you complain about is inserted by Google mail servers. true. Even if now i have stopped using Google's SMTP Server as a means for sending out mails and i have decided to use my local MTA instead, at the very moment Google's POP servers receive the mail they still add a RECEIVE header revealing the hostname of the server that initiated the contact. Correct? But even so, if we alter for example the hostname of our server to a different name then wouldn't Google use that to identify the server thus protecting the real identity(hostname that is) of the server that initiated the connection? No, google will probably find out that the name your server identifies with, will not correspond with the IP address it is connected to and will write a receive line that will reflect that fact, using reverse DNS to report the real hostname of your computer. Τhis si the headers i would like to delete because i dont want them to be used when sending mail: X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - my.superhost.gr X-AntiAbuse: Original Domain - superhost.gr X-AntiAbuse: Originator/Caller UID/GID - [500 501] / [47 12] X-AntiAbuse: Sender Address Domain - mail.org X-Get-Message-Sender-Via: my.superhost.gr: authenticated_id: nikos/only user confirmed/virtual account not confirmed Can these be remoevd when i send mail? -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
Στις 16/9/2013 7:15 μμ, ο/η Ferrous Cranus έγραψε: Στις 16/9/2013 3:56 μμ, ο/η Antoon Pardon έγραψε: Op 16-09-13 14:11, Ferrous Cranus schreef: Στις 16/9/2013 2:44 μμ, ο/η Heiko Wundram έγραψε: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Am 16.09.2013 13:37, schrieb Ferrous Cranus: What i want now is to be able to alter the hostname of my server so the mails wont indicate that they derive from superhost.gr as they aare now sen in the mail headers. There is no way to do that, as the Received:-header which you complain about is inserted by Google mail servers. true. Even if now i have stopped using Google's SMTP Server as a means for sending out mails and i have decided to use my local MTA instead, at the very moment Google's POP servers receive the mail they still add a RECEIVE header revealing the hostname of the server that initiated the contact. Correct? But even so, if we alter for example the hostname of our server to a different name then wouldn't Google use that to identify the server thus protecting the real identity(hostname that is) of the server that initiated the connection? No, google will probably find out that the name your server identifies with, will not correspond with the IP address it is connected to and will write a receive line that will reflect that fact, using reverse DNS to report the real hostname of your computer. Τhis si the headers i would like to delete because i dont want them to be used when sending mail: X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - my.superhost.gr X-AntiAbuse: Original Domain - superhost.gr X-AntiAbuse: Originator/Caller UID/GID - [500 501] / [47 12] X-AntiAbuse: Sender Address Domain - mail.org X-Get-Message-Sender-Via: my.superhost.gr: authenticated_id: nikos/only user confirmed/virtual account not confirmed Can these be remoevd when i send mail? and this too: Received: from nikos by my.superhost.gr with local (Exim 4.80.1) (envelope-from i6zkg...@mail.org) id 1VLam4-0004nG-TJ I wish this not to be displayed. -- https://mail.python.org/mailman/listinfo/python-list
Weird ttk behaviour
Hi all, I've just started trying to learn how to use ttk, and I've discovered something that I don't understand. I'm using Python 3.3.0 in Linux Mint 15. Suppose I create the following module: # begin tkderp.py import tkinter as tk import tkinter.messagebox as _ from tkinter import ttk from imp import reload _root = tk.Tk() _root.withdraw() def f(): style = ttk.Style(_root) style.theme_create('newtheme', parent = 'default') tk.messagebox.showwarning('test', 'test') style.theme_use('newtheme') tk.messagebox.showwarning('test', 'test') # end tkderp.py The function f() is supposed to spawn two warning dialogs. AIUI, the style.theme.use('newtheme') line shouldn't make any difference - it would refresh any existing ttk widgets and alter the appearance of any subsequently created ones if I had changed any of the new theme's settings, but in the above context nothing it does should be discernible to the user. If I try to call f() the first warning gets shown, but the second one causes an exception: Python 3.3.1 (default, Apr 17 2013, 22:30:32) [GCC 4.7.3] on linux Type help, copyright, credits or license for more information. import tkderp tkderp.f() Traceback (most recent call last): File stdin, line 1, in module File /home/phil/Python/tkderp.py, line 17, in f tk.messagebox.showwarning('test', 'test') File /usr/lib/python3.3/tkinter/messagebox.py, line 87, in showwarning return _show(title, message, WARNING, OK, **options) File /usr/lib/python3.3/tkinter/messagebox.py, line 72, in _show res = Message(**options).show() File /usr/lib/python3.3/tkinter/commondialog.py, line 48, in show s = w.tk.call(self.command, *w._options(self.options)) _tkinter.TclError: unknown color name If I try reloading the module and calling the function again, this time the first of the two warnings raises the exception. Since I don't really understand how the ttk.Style class works, I can't say whether this behaviour is expected or not. But here's what's weird. Suppose that I comment out the last two lines in the definition of f(), like so: # begin modified tkderp.py import tkinter as tk import tkinter.messagebox as _ from tkinter import ttk from imp import reload _root = tk.Tk() _root.withdraw() def f(): style = ttk.Style(_root) style.theme_create('newtheme', parent = 'default') tk.messagebox.showwarning('test', 'test') #style.theme_use('newtheme') #tk.messagebox.showwarning('test', 'test') # end modified tkderp.py Unsurprisingly, importing the module and calling f() displays a single warning dialog and raises no exception. If I then uncomment those two lines, reload the module and call f() again (by entering tkderp.reload(tkderp).f()), the function works like it was supposed to in the first place: two warnings, no exceptions. I can reload the module as many times as I like and f() will continue to work without any problems. On Windows 7 (sys.version is '3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64 bit (AMD64)]') there's no problem; f() works fine in the first place. Does anybody know what's going on? -- https://mail.python.org/mailman/listinfo/python-list
Re: statsmodels.api
On 09/16/2013 08:37 AM, Davide Dalmasso wrote: Hi, I intalled an executable version of statsmodels library for Windows 32-bit. When I import it in my Python Shell no problem occurs buy when I write: import statsmodels.api as sm the following error arises: Traceback (most recent call last): File pyshell#1, line 1, in module import statsmodels.api File C:\Python33\lib\site-packages\statsmodels\api.py, line 1, in module from . import iolib, datasets, tools File C:\Python33\lib\site-packages\statsmodels\iolib\__init__.py, line 1, in module from .foreign import StataReader, genfromdta, savetxt File C:\Python33\lib\site-packages\statsmodels\iolib\foreign.py, line 20, in module import statsmodels.tools.data as data_util File C:\Python33\lib\site-packages\statsmodels\tools\__init__.py, line 1, in module from .tools import add_constant, categorical File C:\Python33\lib\site-packages\statsmodels\tools\tools.py, line 8, in module from scipy.interpolate import interp1d File C:\Python33\lib\site-packages\scipy\interpolate\__init__.py, line 150, in module from .interpolate import * File C:\Python33\lib\site-packages\scipy\interpolate\interpolate.py, line 12, in module import scipy.special as spec File C:\Python33\lib\site-packages\scipy\special\__init__.py, line 529, in module from ._ufuncs import * We'll need the rest of the traceback, as it will have the actual error. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
Re: statsmodels.api
In eac9f1af-74e0-4eb0-8719-766894b52...@googlegroups.com Davide Dalmasso davide.dalma...@gmail.com writes: Hi, I intalled an executable version of statsmodels library for Windows 32-bit. When I import it in my Python Shell no problem occurs buy when I write: import statsmodels.api as sm the following error arises: Traceback (most recent call last): File pyshell#1, line 1, in module import statsmodels.api File C:\Python33\lib\site-packages\statsmodels\api.py, line 1, in module from . import iolib, datasets, tools File C:\Python33\lib\site-packages\statsmodels\iolib\__init__.py, line 1, in module from .foreign import StataReader, genfromdta, savetxt File C:\Python33\lib\site-packages\statsmodels\iolib\foreign.py, line 20, in module import statsmodels.tools.data as data_util File C:\Python33\lib\site-packages\statsmodels\tools\__init__.py, line 1, in module from .tools import add_constant, categorical File C:\Python33\lib\site-packages\statsmodels\tools\tools.py, line 8, in module from scipy.interpolate import interp1d File C:\Python33\lib\site-packages\scipy\interpolate\__init__.py, line 150, in module from .interpolate import * File C:\Python33\lib\site-packages\scipy\interpolate\interpolate.py, line 12, in module import scipy.special as spec File C:\Python33\lib\site-packages\scipy\special\__init__.py, line 529, in module from ._ufuncs import * This error traceback appears incomplete. Did you paste the whole thing? -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies -- https://mail.python.org/mailman/listinfo/python-list
Re: Is %z broken for return values of time.gmtime()?
On Mon, Sep 16, 2013, at 9:15, Michael Schwarz wrote: According to the documentation of time.gmtime(), it returns a struct_time in UTC, but %z is replaced by +0100, which is the UTC offset of my OS’s time zone without DST, but DST is currently in effect here (but was not at the timestamp passed to gmtime()). The struct_time type does not include information about what timezone it is in. You can use datetime.datetime (e.g. datetime.datetime.fromtimestamp(40 * 365 * 86400,datetime.timezone.utc) - the datetime.datetime class has a strftime method. You should be aware that %F and %T are not portable and won't work on windows for example. -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
On Sep 16, 2013, at 12:15 PM, Ferrous Cranus nikos.gr...@gmail.com wrote: Στις 16/9/2013 3:56 μμ, ο/η Antoon Pardon έγραψε: Op 16-09-13 14:11, Ferrous Cranus schreef: Στις 16/9/2013 2:44 μμ, ο/η Heiko Wundram έγραψε: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Am 16.09.2013 13:37, schrieb Ferrous Cranus: What i want now is to be able to alter the hostname of my server so the mails wont indicate that they derive from superhost.gr as they aare now sen in the mail headers. There is no way to do that, as the Received:-header which you complain about is inserted by Google mail servers. true. Even if now i have stopped using Google's SMTP Server as a means for sending out mails and i have decided to use my local MTA instead, at the very moment Google's POP servers receive the mail they still add a RECEIVE header revealing the hostname of the server that initiated the contact. Correct? But even so, if we alter for example the hostname of our server to a different name then wouldn't Google use that to identify the server thus protecting the real identity(hostname that is) of the server that initiated the connection? No, google will probably find out that the name your server identifies with, will not correspond with the IP address it is connected to and will write a receive line that will reflect that fact, using reverse DNS to report the real hostname of your computer. Τhis si the headers i would like to delete because i dont want them to be used when sending mail: X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - my.superhost.gr X-AntiAbuse: Original Domain - superhost.gr X-AntiAbuse: Originator/Caller UID/GID - [500 501] / [47 12] X-AntiAbuse: Sender Address Domain - mail.org X-Get-Message-Sender-Via: my.superhost.gr: authenticated_id: nikos/only user confirmed/virtual account not confirmed Can these be remoevd when i send mail? -- https://mail.python.org/mailman/listinfo/python-list You realize that removing those headers will, in all likelihood, make Google reject your mail and refuse to either forward or deliver it. They have been added to reduce spam, and the more you attempt to obfuscate your header information, the more you make your mail look exactly like spam. -Bill -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
On Mon, 16 Sep 2013 19:23:15 +0300, Ferrous Cranus wrote: Τhis si the headers i would like to delete because i dont want them to be used when sending mail: X-AntiAbuse: ... and this too: Received: .. This is probably your mta, not python, see your mta config. OFF TOPIC IN comp.lang.python -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Weird ttk behaviour
16.09.13 19:28, Rotwang написав(ла): On Windows 7 (sys.version is '3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64 bit (AMD64)]') there's no problem; f() works fine in the first place. Does anybody know what's going on? What _root.wantobjects() returns? -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
On Mon, 16 Sep 2013 18:02:20 +0300, Ferrous Cranus wrote: We need to try it to see if it will work, or perhaps we can alter both the hostname and ip address variables on the server to some other values so that google will use them too. It will not detect the real hostname or the real ip this way since both values will be not true. It may however detect that your are presenting an ip and or hostname that does not match the host you are connecting with, and increase the spf score on the messages to the point that the messages get rejected either in the google mta or downstream due to their spf score. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Is %z broken for return values of time.gmtime()?
On 2013-W38-1, at 19:56, random...@fastmail.us wrote: On Mon, Sep 16, 2013, at 9:15, Michael Schwarz wrote: According to the documentation of time.gmtime(), it returns a struct_time in UTC, but %z is replaced by +0100, which is the UTC offset of my OS’s time zone without DST, but DST is currently in effect here (but was not at the timestamp passed to gmtime()). The struct_time type does not include information about what timezone it is in. Uhm … Python 3.3 introduced the tm_gmtoff member of struct_time, which contains the offset to UTC. I thought, %z was also introduced in Python 3.3 and so I thought it would use that field. What time zone does it use then? Does it always use the system's time zone? You can use datetime.datetime (e.g. datetime.datetime.fromtimestamp(40 * 365 * 86400,datetime.timezone.utc) - the datetime.datetime class has a strftime method. I do use that, but I was using time.localtime() to convert a POSIX timestamp to a date using the system's timezone and saw that while a struct_time produced by time.localtime() and formatted using time.strftime() shows the correct time zone (+0100 and +0200 here), it does not for a struct_time produced by time.gmtime(). I think that's strange. You should be aware that %F and %T are not portable and won't work on windows for example. I’m aware of that, but thanks. I was toying around and just needed to print the rest of the date. Regards Michael smime.p7s Description: S/MIME cryptographic signature -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
On Mon, Sep 16, 2013 at 3:09 PM, Denis McMahon denismfmcma...@gmail.comwrote: On Mon, 16 Sep 2013 18:02:20 +0300, Ferrous Cranus wrote: We need to try it to see if it will work, or perhaps we can alter both the hostname and ip address variables on the server to some other values so that google will use them too. It will not detect the real hostname or the real ip this way since both values will be not true. It may however detect that your are presenting an ip and or hostname that does not match the host you are connecting with, and increase the spf score on the messages to the point that the messages get rejected either in the google mta or downstream due to their spf score. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list Nikos, You have to start with a historical perspective. Email was very open in the beginning of the internet. Before there were bad actors. Since that time, email has become the internet service most used for bad purposes, to deliver bad payloads, spoof people into visiting fake websites to induce them to give away private information, etc. So, the email services have gotten more particular about what they deem safe email in lots of different ways. If you want to do these various odd and misleading things to the emails you send out, you will have to understand how to 'beat the systems' that have been employed to stop that stuff. Having read your questions here for the last year(s) I don't believe this is an area in which you excel. You always want quick answers to questions that often show your complete lack basic understanding of the question domain. If you really want to plod along with this email spoofing, why not take a couple of weeks to read all about how email works on the internet, how email has been used to deliver viruses and spoofing schemes. After you understand that stuff well enough to show your competence in a forum where there are other email experts, as your questions there. As has been pointed out by several people here, your questions are not python language issues, they are issues relating to how email protocols work. So, study up and go to an email experts group and good luck! -- Joel Goldstick http://joelgoldstick.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
Στις 16/9/2013 8:53 μμ, ο/η William Ray Wing έγραψε: On Sep 16, 2013, at 12:15 PM, Ferrous Cranus nikos.gr...@gmail.com wrote: Στις 16/9/2013 3:56 μμ, ο/η Antoon Pardon έγραψε: Op 16-09-13 14:11, Ferrous Cranus schreef: Στις 16/9/2013 2:44 μμ, ο/η Heiko Wundram έγραψε: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Am 16.09.2013 13:37, schrieb Ferrous Cranus: What i want now is to be able to alter the hostname of my server so the mails wont indicate that they derive from superhost.gr as they aare now sen in the mail headers. There is no way to do that, as the Received:-header which you complain about is inserted by Google mail servers. true. Even if now i have stopped using Google's SMTP Server as a means for sending out mails and i have decided to use my local MTA instead, at the very moment Google's POP servers receive the mail they still add a RECEIVE header revealing the hostname of the server that initiated the contact. Correct? But even so, if we alter for example the hostname of our server to a different name then wouldn't Google use that to identify the server thus protecting the real identity(hostname that is) of the server that initiated the connection? No, google will probably find out that the name your server identifies with, will not correspond with the IP address it is connected to and will write a receive line that will reflect that fact, using reverse DNS to report the real hostname of your computer. Τhis si the headers i would like to delete because i dont want them to be used when sending mail: X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - my.superhost.gr X-AntiAbuse: Original Domain - superhost.gr X-AntiAbuse: Originator/Caller UID/GID - [500 501] / [47 12] X-AntiAbuse: Sender Address Domain - mail.org X-Get-Message-Sender-Via: my.superhost.gr: authenticated_id: nikos/only user confirmed/virtual account not confirmed Can these be remoevd when i send mail? -- https://mail.python.org/mailman/listinfo/python-list You realize that removing those headers will, in all likelihood, make Google reject your mail and refuse to either forward or deliver it. They have been added to reduce spam, and the more you attempt to obfuscate your header information, the more you make your mail look exactly like spam. -Bill But i wish to try it, is there a way to try to remove them? For starters, does my MTA add them as additional headers to my mail or Google adds them by default ? -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
Στις 16/9/2013 10:09 μμ, ο/η Denis McMahon έγραψε: On Mon, 16 Sep 2013 18:02:20 +0300, Ferrous Cranus wrote: We need to try it to see if it will work, or perhaps we can alter both the hostname and ip address variables on the server to some other values so that google will use them too. It will not detect the real hostname or the real ip this way since both values will be not true. It may however detect that your are presenting an ip and or hostname that does not match the host you are connecting with, and increase the spf score on the messages to the point that the messages get rejected either in the google mta or downstream due to their spf score. We have to try it to know for sure. For example do ou know how can a later the hostname the MTA uses to identify the server? -- https://mail.python.org/mailman/listinfo/python-list
New on python
hello everyone, I am a beginner in python programming language, so I need help with the basics, the synthaxes, functions, please help me -- https://mail.python.org/mailman/listinfo/python-list
Re: New on python
On Tue, Sep 17, 2013 at 8:27 AM, Ibrahima Barry ibscofi...@gmail.com wrote: hello everyone, I am a beginner in python programming language, so I need help with the basics, the synthaxes, functions, please help me Welcome! Python tutorials can be found all over the internet. Here's one good one: http://docs.python.org/3/tutorial/ Have fun! ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Weird ttk behaviour
On Tue, Sep 17, 2013 at 2:28 AM, Rotwang sg...@hotmail.co.uk wrote: If I then uncomment those two lines, reload the module and call f() again (by entering tkderp.reload(tkderp).f()), the function works like it was supposed to in the first place: two warnings, no exceptions. I can reload the module as many times as I like and f() will continue to work without any problems. Reloading modules in Python is a bit messy. Are you able to tinker with it and make it work in some way without reloading? It'd be easier to figure out what's going on that way. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: New on python
Ibrahima Barry ibscofi...@gmail.com writes: hello everyone, I am a beginner in python programming language Welcome, and congratulations on finding Python. so I need help with the basics, the synthaxes, functions, please help me At the Python website you can find a page linking to other documentation URL:http://python.org/doc/, especially the Python tutorial URL:http://docs.python.org/3/tutorial/. The Python Wiki has a page specially for beginners guides URL:https://wiki.python.org/moin/BeginnersGuide. Good hunting! -- \ “There's a certain part of the contented majority who love | `\anybody who is worth a billion dollars.” —John Kenneth | _o__)Galbraith, 1992-05-23 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
How do I calculate a mean with python?
Hey I am new to python so go easy, but I wanted to know how to make a program that calculates the maen. List = [15, 6, 6, 7, 8, 9, 40] def mean(): global themean, thesum for i in List: thecount = List.count(i) thesum = sum(List) themean = thesum / thecount Why doesn't this work? -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
On Mon, 16 Sep 2013 18:02:20 +0300, Ferrous Cranus wrote: We need to try it to see if it will work, or perhaps we can alter both the hostname and ip address variables on the server to some other values so that google will use them too. It will not detect the real hostname or the real ip this way since both values will be not true. Are you planning on sending spam? Or some other criminal activity? I cannot fathom for the life of me a legitimate reason for your website to use a fake IP address and hostname when sending email. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I calculate a mean with python?
On 09/17/2013 12:33 AM, William Bryant wrote: Hey I am new to python so go easy, but I wanted to know how to make a program that calculates the maen. List = [15, 6, 6, 7, 8, 9, 40] def mean(): global themean, thesum for i in List: thecount = List.count(i) thesum = sum(List) themean = thesum / thecount Why doesn't this work? Hello, William.. How about you try to execute one bit of your program, and if that works, try to add to it. Try list = [15, 6] list.count(1) And see if what it gives you back is what you expected. If not, why ? -- ~Jugurtha Hadjar, -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I calculate a mean with python?
On Mon, 16 Sep 2013 16:33:35 -0700, William Bryant wrote: Hey I am new to python so go easy, but I wanted to know how to make a program that calculates the maen. List = [15, 6, 6, 7, 8, 9, 40] def mean(): global themean, thesum for i in List: thecount = List.count(i) thesum = sum(List) themean = thesum / thecount Why doesn't this work? Let me start by saying that the above is not best practice for how to write functions, and I'll explain why later, but for now I'll just fix the problem with the calculation. You have List = [15, 6, 6, 7, 8, 9, 40] and then the mean function walks through each of the items 15, 6, 6, 7, ... counting how many times that item is found: for i in List: thecount = List.count(i) thesum = sum(List) So the first time, i gets the value 15, thecount calculates List.count(15) which is 1, thesum calculates sum(List) which is 91, and the end of the loop is reached. The second time around, i gets the value 6, then thecount calculates List.count(6) which is 2, thesum calculates sum(List) *again*, which is still 91, and the end of the loop is reached. Third time around, i gets the value 6 again, thecount again gets the value 2, thesum yet again sums up List which still hasn't changed, so yet again gets 91. And so on, and so on, until the last iteration, where i gets the value 40, thecount calculates List.count(40) which is 1, thesum re-calculates the sum yet again, still getting the exact same result 91, and finally the for-loop comes to an end. Now the final calculation occurs: themean = thesum/thecount which is 91/1 or just 91. What do you actually want? It's much simpler: you want to count the *total* number of items, 7, not by counting each item individually. The total number of items is given by the length of the list: len(List) returns 7. And you want to sum the list once, there's no need to sum it 7 times. So the first step is to get rid of the for-loop, just calculate thesum = sum(List) once, and thecount = len(List) once. Once you've done that, please write back with your new code, because I think there will be some more improvements to be made. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I calculate a mean with python?
On 17/09/2013 00:33, William Bryant wrote: Hey I am new to python so go easy, but I wanted to know how to make a program that calculates the maen. List = [15, 6, 6, 7, 8, 9, 40] def mean(): global themean, thesum You're iterating through every number in the list... for i in List: counting how many times each number occurs in the list: thecount = List.count(i) This line calculates the sum of the numbers on every iteration: thesum = sum(List) This line divides the sum of the numbers by the last count: themean = thesum / thecount Why doesn't this work? It does work; it just doesn't calculate the mean! What you end up with is: themean = sum(List) / List.count(40) What you _really_ want is the sum of the numbers divided by the number of numbers (i.e. the length of the list). -- https://mail.python.org/mailman/listinfo/python-list
Re: How is this list comprehension evaluated?
In article eae87c72-f62d-4815-bb69-ca862ff78...@googlegroups.com, Arturo B a7xrturo...@gmail.com wrote: Hello, I'm making Python mini-projects and now I'm making a Latin Square (Latin Square: http://en.wikipedia.org/wiki/Latin_square) So, I started watching example code and I found this question on Stackoverflow: http://stackoverflow.com/questions/5313900/generating-cyclic-permutations-redu ced-latin-squares-in-python It uses a list comprenhension to generate the Latin Square, I'm am a newbie to Python, and I've tried to figure out how this is evaluated: a = [1, 2, 3, 4] n = len(a) [[a[i - j] for i in range(n)] for j in range(n)] You can re-write any list comprehension as a for loop. In this case you have to un-wrap this one layer at a time. First step: a = [1, 2, 3, 4] n = len(a) temp1 = [] for j in range(n): temp2 = [a[i - j] for i in range(n)] temp1.append(item) then, unwrap the next layer: a = [1, 2, 3, 4] n = len(a) temp1 = [] for j in range(n): temp2 = [] for i in range(n): temp3 = a[i - j] temp2.append(temp3) temp1.append(item) Does that make it any easier to understand? -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I calculate a mean with python?
On 09/17/2013 12:33 AM, William Bryant wrote: Hey I am new to python so go easy, but I wanted to know how to make a program that calculates the maen. List = [15, 6, 6, 7, 8, 9, 40] def mean(): global themean, thesum for i in List: thecount = List.count(i) thesum = sum(List) themean = thesum / thecount Why doesn't this work? You want to compute the arithmetic mean, I suppose .. Which is the sum of all, divided by the number of samples. i.e: If you have n numbers or elements, your mean (arithmetic) would be mean = sum(elements)/n. Right ? And then, n also doesn't need to be in the loop and list.count(i) gives the occurrences of i in your list, which you don't need. list.count(15) gives 1. thesum/list.count(15) doesn't change. -- ~Jugurtha Hadjar, -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I calculate a mean with python?
On 16Sep2013 16:33, William Bryant gogobe...@gmail.com wrote: | Hey I am new to python so go easy, but I wanted to know how to make a program that calculates the maen. | | List = [15, 6, 6, 7, 8, 9, 40] | def mean(): | global themean, thesum | for i in List: | thecount = List.count(i) | thesum = sum(List) | themean = thesum / thecount | | Why doesn't this work? Well: - always include the output you get from your program, and say why you think it is incorrect - just style: we tend to name variables in lower case in Python, and classes with an upper case letter; List is a bit odd (but list is taken; how about values?) - more than style: WHY are you using global variables; just return the mean from the function! - teh variable List inside the function is _local_; your function does not accept a parameter - sum(List) sums the whole list you run it many times why? - what do you think count() does? - you should print i, thecount and thesum on each iteration of the list; it will help you see what your function is doing, and therefore to figure out what it is doing wrong I would write a mean like this: def mean(values): return sum(values) / len(values) There are circumstances where that is simplistic, but it is the classic definition of the mean. Cheers, -- Cameron Simpson c...@zip.com.au Microsoft Mail: as far from RFC-822 as you can get and still pretend to care. - Abby Franquemont-Guillory abb...@tezcat.com -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I calculate a mean with python?
On 16/9/2013 19:33, William Bryant wrote: Hey I am new to python so go easy, but I wanted to know how to make a program that calculates the maen. List = [15, 6, 6, 7, 8, 9, 40] def mean(): global themean, thesum for i in List: thecount = List.count(i) thesum = sum(List) themean = thesum / thecount Why doesn't this work? Besides all the other comments, you also neglected calling this function. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: Tryign to send mail via a python script by using the local MTA
On 2013-09-17 00:15, Ferrous Cranus wrote: X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - my.superhost.gr X-AntiAbuse: Original Domain - superhost.gr X-AntiAbuse: Originator/Caller UID/GID - [500 501] / [47 12] X-AntiAbuse: Sender Address Domain - mail.org X-Get-Message-Sender-Via: my.superhost.gr: authenticated_id: nikos/only user confirmed/virtual account not confirmed For starters, does my MTA add them as additional headers to my mail or Google adds them by default ? Given that there are headers in there that know about your UID/GID, it has to be a locally-running process that adds them. No remote server (even as powerful as Gmail is) should/can know this legitimately without being told. Thus, it's clearly your local MTA. But i wish to try it, is there a way to try to remove them? You could manage your own SMTP connection. If only Python had some built in library that handled SMTP, that would be great! Then you would be able to instantiate some SMTP object, connect to another server, optionally authenticating, then send mail, and close the connection. That would be so awesome! :-D -tkc -- https://mail.python.org/mailman/listinfo/python-list
Qt connect and first connect or unicode
Dear all, Unfortunately, i confused and need help... the following code is: ### ##CheckBox: QtCore.QObject.connect(self.checkBox, QtCore.SIGNAL(_fromUtf8(toggled(bool))), lambda: self.materialsInstance.setFilterDict(C,self,name,self.lineEdit.text())) QtCore.QObject.connect(self.checkBox_2, QtCore.SIGNAL(_fromUtf8(toggled(bool))), lambda: self.materialsInstance.setFilterDict(C,self,bought_price,persianToInteger(unicode(self.lineEdit_2.text() QtCore.QObject.connect(self.checkBox_4, QtCore.SIGNAL(_fromUtf8(toggled(bool))), lambda: self.materialsInstance.setFilterDict(C,self,stock,persianToInteger(unicode(self.lineEdit_3.text() ##LineEdit QtCore.QObject.connect(self.lineEdit, QtCore.SIGNAL(_fromUtf8(editingFinished())), lambda: self.materialsInstance.setFilterDict(L,self,name,self.lineEdit.text())) QtCore.QObject.connect(self.lineEdit_2, QtCore.SIGNAL(_fromUtf8(editingFinished())), lambda: self.materialsInstance.setFilterDict(L,self,bought_price,persianToInteger(unicode(self.lineEdit_2.text() QtCore.QObject.connect(self.lineEdit_3, QtCore.SIGNAL(_fromUtf8(editingFinished())), lambda: self.materialsInstance.setFilterDict(L,self,stock,persianToInteger(unicode(self.lineEdit_3.text() QtCore.QObject.connect(self.lineEdit, QtCore.SIGNAL(_fromUtf8(editingFinished())), lambda: self.materialsInstance.responseToRequestForData(self)) QtCore.QObject.connect(self.lineEdit_2, QtCore.SIGNAL(_fromUtf8(editingFinished())), lambda: self.materialsInstance.responseToRequestForData(self)) QtCore.QObject.connect(self.lineEdit_3, QtCore.SIGNAL(_fromUtf8(editingFinished())), lambda: self.materialsInstance.responseToRequestForData(self)) QtCore.QObject.connect(self.lineEdit, QtCore.SIGNAL(_fromUtf8(returnPressed())), lambda: self.materialsInstance.responseToRequestForData(self)) QtCore.QObject.connect(self.lineEdit_2, QtCore.SIGNAL(_fromUtf8(returnPressed())), lambda: self.materialsInstance.responseToRequestForData(self)) QtCore.QObject.connect(self.lineEdit_3, QtCore.SIGNAL(_fromUtf8(returnPressed())), lambda: self.materialsInstance.responseToRequestForData(self)) ##PushButton: QtCore.QObject.connect(self.pushButtonSearch, QtCore.SIGNAL(_fromUtf8(clicked())), lambda: self.materialsInstance.responseToRequestForData(self)) def setFilterDict(self,widget,obj,field,lineEditContent): if field not in obj.materialsInstance.filterNameDict.keys(): obj.materialsInstance.filterNameDict.update({field:lineEditContent}) Description: I have 3 widget: 1. CheckBox: a. name b. bought_price c. stock 2. LineEdit : a. name b. bought_price c. stock 3. One PushButton i have three slot: 1. responseToRequestForData() 2.setFilterDict() 3.unSetFilterDict() responseToRequestForData(): start to search in DB setFilterDict(): fill a dict from my LineEdit Problem: My name is filled in dict but its value doesn't fill up. b and c don't have any problem. Yours, Mohsen -- https://mail.python.org/mailman/listinfo/python-list
Re: Qt connect and first connect or unicode
On Tue, 2013-09-17 at 08:42 +0430, Mohsen Pahlevanzadeh wrote: Dear all, Unfortunately, i confused and need help... the following code is: ### ##CheckBox: QtCore.QObject.connect(self.checkBox, QtCore.SIGNAL(_fromUtf8(toggled(bool))), lambda: self.materialsInstance.setFilterDict(C,self,name,self.lineEdit.text())) QtCore.QObject.connect(self.checkBox_2, QtCore.SIGNAL(_fromUtf8(toggled(bool))), lambda: self.materialsInstance.setFilterDict(C,self,bought_price,persianToInteger(unicode(self.lineEdit_2.text() QtCore.QObject.connect(self.checkBox_4, QtCore.SIGNAL(_fromUtf8(toggled(bool))), lambda: self.materialsInstance.setFilterDict(C,self,stock,persianToInteger(unicode(self.lineEdit_3.text() ##LineEdit QtCore.QObject.connect(self.lineEdit, QtCore.SIGNAL(_fromUtf8(editingFinished())), lambda: self.materialsInstance.setFilterDict(L,self,name,self.lineEdit.text())) QtCore.QObject.connect(self.lineEdit_2, QtCore.SIGNAL(_fromUtf8(editingFinished())), lambda: self.materialsInstance.setFilterDict(L,self,bought_price,persianToInteger(unicode(self.lineEdit_2.text() QtCore.QObject.connect(self.lineEdit_3, QtCore.SIGNAL(_fromUtf8(editingFinished())), lambda: self.materialsInstance.setFilterDict(L,self,stock,persianToInteger(unicode(self.lineEdit_3.text() QtCore.QObject.connect(self.lineEdit, QtCore.SIGNAL(_fromUtf8(editingFinished())), lambda: self.materialsInstance.responseToRequestForData(self)) QtCore.QObject.connect(self.lineEdit_2, QtCore.SIGNAL(_fromUtf8(editingFinished())), lambda: self.materialsInstance.responseToRequestForData(self)) QtCore.QObject.connect(self.lineEdit_3, QtCore.SIGNAL(_fromUtf8(editingFinished())), lambda: self.materialsInstance.responseToRequestForData(self)) QtCore.QObject.connect(self.lineEdit, QtCore.SIGNAL(_fromUtf8(returnPressed())), lambda: self.materialsInstance.responseToRequestForData(self)) QtCore.QObject.connect(self.lineEdit_2, QtCore.SIGNAL(_fromUtf8(returnPressed())), lambda: self.materialsInstance.responseToRequestForData(self)) QtCore.QObject.connect(self.lineEdit_3, QtCore.SIGNAL(_fromUtf8(returnPressed())), lambda: self.materialsInstance.responseToRequestForData(self)) ##PushButton: QtCore.QObject.connect(self.pushButtonSearch, QtCore.SIGNAL(_fromUtf8(clicked())), lambda: self.materialsInstance.responseToRequestForData(self)) def setFilterDict(self,widget,obj,field,lineEditContent): if field not in obj.materialsInstance.filterNameDict.keys(): obj.materialsInstance.filterNameDict.update({field:lineEditContent}) Description: I have 3 widget: 1. CheckBox: a. name b. bought_price c. stock 2. LineEdit : a. name b. bought_price c. stock 3. One PushButton i have three slot: 1. responseToRequestForData() 2.setFilterDict() 3.unSetFilterDict() responseToRequestForData(): start to search in DB setFilterDict(): fill a dict from my LineEdit Problem: My name is filled in dict but its value doesn't fill up. b and c don't have any problem. Yours, Mohsen I see same output in console: {'stock': 2, 'name': PyQt4.QtCore.QString(u''), 'bought_price': 23} -- https://mail.python.org/mailman/listinfo/python-list
[issue19030] inspect.getmembers and inspect.classify_class_attrs mishandle descriptors
Nick Coghlan added the comment: types is the OO equivalent to functools these days, in addition to its original role of exposing the internal type objects that aren't builtins. However, it seems to me that the fix for issue 1785 is simply *wrong*: it eliminated the exceptions at the expense of sometimes returning the *wrong answer*. The change in that issue means the inspect module isn't implementing the descriptor protocol correctly, and thus may provide a raw descriptor object when attempting to retrieve that attribute will return something else. Instead of the current behaviour, the inspect module should be trying getattr *first*, and only falling back to peeking in the __dict__ directly if that throws an exception. -- title: Make inspect.getmembers and inspect.classify_class_attrs Enum aware - inspect.getmembers and inspect.classify_class_attrs mishandle descriptors ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19030 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19015] Too long command returns 32512
Sworddragon added the comment: I have figured out that system() in C can only take up to 65533 arguments after a command (so it is a 16 bit issue). Giving one more argument will result in the return code 32512 (which implies the exit code 127). -- resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19015 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11708] argparse: suggestion for formatting optional positional args
Changes by paul j3 ajipa...@gmail.com: -- nosy: +paul.j3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11708 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13824] argparse.FileType opens a file and never closes it
Changes by paul j3 ajipa...@gmail.com: -- nosy: +paul.j3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13824 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14365] argparse: subparsers, argument abbreviations and ambiguous option
Changes by paul j3 ajipa...@gmail.com: -- nosy: +paul.j3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14365 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9694] argparse required arguments displayed under optional arguments
Changes by paul j3 ajipa...@gmail.com: -- nosy: +paul.j3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9694 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12558] Locale-dependent exception for float width argument to Tkinter widget constructor
Serhiy Storchaka added the comment: I am presuming that tk truncates fractional parts as int() does; if not, use round(). Tk uses both truncated and rounded value. $ rlwrap wish % canvas .c .c % .c configure -width 10.1 % .c configure -width -width width Width 10c 10 % .c configure -width 10.9 % .c configure -width -width width Width 10c 11 As you can see 10.9 gives both 10c and 11. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12558 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19033] Python 3 won't go on PC-BSD 9.1
R. David Murray added the comment: We have FreeBSD buildbots. Python 3.0 is an ancient version of Python3 (in Internet years, at least :) Please try again with python 3.3, the current stable version of Python3. If that doesn't work, you should contact the pc-bsd support, since Python3 clearly configures and builds on FreeBSD (since it works on the buildbots). (That said, note that the FreeBSD port does have some patches that provide better integration with the FreeBSD ports system...I don't know if PC-BSD uses the ports system or not, so that might or might not be relevant.) -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19033 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19033] Python 3 won't go on PC-BSD 9.1
Changes by Ned Deily n...@acm.org: -- status: open - closed type: behavior - ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19033 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19033] Python 3 won't go on PC-BSD 9.1
Ned Deily added the comment: http://www.python.org/download/ http://www.freebsd.org/cgi/ports.cgi?query=python3stype=allsektion=all -- nosy: +ned.deily resolution: - out of date stage: - committed/rejected ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19033 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12558] Locale-dependent exception for float width argument to Tkinter widget constructor
Serhiy Storchaka added the comment: Oh, sorry, 10c is unrelated. Tk uses rounding. I don't know if it requires somewhere actual non-integer values. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12558 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19029] tix.py uses StringType
Roundup Robot added the comment: New changeset 9eab3e745061 by Serhiy Storchaka in branch '3.3': Issue #19029: Change non-existing since 3.0 StringType to str. http://hg.python.org/cpython/rev/9eab3e745061 New changeset 95b3efe3d7b7 by Serhiy Storchaka in branch 'default': Issue #19029: Change non-existing since 3.0 StringType to str. http://hg.python.org/cpython/rev/95b3efe3d7b7 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19029 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18975] timeit: Use thousands separators and print number of loops per second
Antoine Pitrou added the comment: I'm fine with the change too. Tim, what do you think? Speaking of which, some examples were really done with an old machine: $ python -m timeit 'try:' ' str.__bool__' 'except AttributeError:' ' pass' - 10 loops, best of 3: 15.7 usec per loop + 100 loops, best of 3: 0.701 usec per loop (1425528 loops/s) :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18975 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19030] inspect.getmembers and inspect.classify_class_attrs mishandle descriptors
Antoine Pitrou added the comment: However, it seems to me that the fix for issue 1785 is simply *wrong*: it eliminated the exceptions at the expense of sometimes returning the *wrong answer*. The underlying problem is that those functions are not very well-specified (actually, classify_class_attrs() is not specified at all: it's undocumented). The main consumer of inspect in the stdlib is pydoc, and pydoc being broken by third-party libraries with non-trivial descriptors was a major nuisance. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19030 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19032] __reduce_ex__ on lock object
Antoine Pitrou added the comment: I don't really know. It simply looks like the default implementation of __reduce_ex__. Is it important? -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19032 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19034] More useful repr for Tcl_Obj
New submission from Serhiy Storchaka: Currently the repr() for Tcl_Obj is not very useful. It exposes only Tcl type name and Tcl object address. import tkinter.ttk tv = tkinter.ttk.Treeview() tv.tag_configure('test', foreground='blue') {} str(tv.tag_configure('test', 'foreground')) 'blue' tv.tag_configure('test', 'foreground') color object at 0xb70f84b8 You need explicitly call str to get more useful information. This is awkward when Tcl object hidden deeply in tuples or other data structure, or reported in a backtrace. Actually every Tcl object can be represented as a string. I propose to expose this representation in repr(). With proposed patch the output of the last command will be: color object: 'blue'. -- components: Tkinter files: tkinter_repr.patch keywords: patch messages: 197881 nosy: gpolo, serhiy.storchaka, terry.reedy priority: normal severity: normal stage: patch review status: open title: More useful repr for Tcl_Obj type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file31791/tkinter_repr.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19034 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18975] timeit: Use thousands separators and print number of loops per second
Serhiy Storchaka added the comment: Inconsistency: sec per loop vs. loops/s. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18975 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19029] tix.py uses StringType
Changes by Serhiy Storchaka storch...@gmail.com: -- assignee: - serhiy.storchaka resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19029 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19030] inspect.getmembers and inspect.classify_class_attrs mishandle descriptors
Nick Coghlan added the comment: Right, we definitely want inspect to swallow the exceptions from descriptors. My suggestion is merely to switch the order to be: 1. Try getattr 2. If that throws an exception, check __dict__ directly 3. If neither works (e.g. due to a buggy __dir__ method), ignore the attribute entirely. The problem at the moment is *working* descriptors that are designed to fall back on the metaclass lookup are being mishandled. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19030 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19030] inspect.getmembers and inspect.classify_class_attrs mishandle descriptors
Antoine Pitrou added the comment: Right, we definitely want inspect to swallow the exceptions from descriptors. My suggestion is merely to switch the order to be: 1. Try getattr 2. If that throws an exception, check __dict__ directly 3. If neither works (e.g. due to a buggy __dir__ method), ignore the attribute entirely. Are you talking about descriptors defined on the class or the metaclass? :-) -- title: inspect.getmembers and inspect.classify_class_attrs mishandle descriptors - inspect.getmembers and inspect.classify_class_attrs mishandle descriptors ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19030 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18975] timeit: Use thousands separators and print number of loops per second
Jakub Stasiak added the comment: That's right, I was actually wondering about it few minutes before you pointed it out. Find new patch attached. -- Added file: http://bugs.python.org/file31792/timeit-v4-actual-changes.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18975 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1065986] Fix pydoc crashing on unicode strings
Akira Kitada added the comment: Attaching a modified version of issue1065986.patch. The differences are: - Added _binstr(), which is str() that works with unicode objects. - Changed getdoc() to return encoded docstrings/comments - Used _binstr() to convert __version__, __date__, __author__ and __credits__ to str -- Added file: http://bugs.python.org/file31793/issue1065986-2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1065986 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19032] __reduce_ex__ on lock object
Ram Rachum added the comment: I use that to test whether an object is pickleable or not. It used to work in Python 2. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19032 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11798] Test cases not garbage collected after run
Michael Foord added the comment: If we're sure suite._cleanupis a *good* api for this then fine to expose it (and document) it as a public api. I'll take a look at it in a bit. Test suites will still have to do *some* monkeying around to set suite.cleanup (presumably in load_tests), so I'm not sure it's much more convenient... -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11798 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19016] autospecced namedtuples should be truthy by default
Michael Foord added the comment: The problem is that the change you're proposing is backwards incompatible. Code using MagicMock and objects with length will break. -- assignee: - michael.foord versions: +Python 3.4 -Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19016 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18996] unittest: more helpful truncating long strings
Michael Foord added the comment: Awesome, thanks for this work. The only thing I'd say is that if _common_shorten is always called with two args - and safe_repr is always called on them - then why not have it take two args and call safe_repr on them? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18996 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19030] inspect.getmembers and inspect.classify_class_attrs mishandle descriptors
Nick Coghlan added the comment: On the class, since that's the case which is breaking here (instances are already OK, since they trigger the success path in the custom descriptors) -- title: inspect.getmembers and inspect.classify_class_attrs mishandle descriptors - inspect.getmembers and inspect.classify_class_attrs mishandle descriptors ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19030 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19032] __reduce_ex__ on lock object
Antoine Pitrou added the comment: I use that to test whether an object is pickleable or not. It used to work in Python 2. Well, the obvious way to do it would be to call pickle.dumps() on the object, IMO :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19032 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19032] __reduce_ex__ on lock object
Ram Rachum added the comment: Wrong, because the object itself could be pickleable but refer to a different object which is non-pickleable. I want to know whether the object itself, without any object it refers to, is pickleable. Also, pickling an object could be very resource-intensive, depending on its size. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19032 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16129] No good way to set 'PYTHONIOENCODING' when embedding python.
Brecht Van Lommel added the comment: With the language summit passed some time ago, is there now a more clear picture of how this would fit in the initialisation process? Any idea of what a proper implementation would look like, or is the message still to wait? -- nosy: +Brecht.Van.Lommel ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16129 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19032] __reduce_ex__ on lock object
Antoine Pitrou added the comment: Wrong, because the object itself could be pickleable but refer to a different object which is non-pickleable. I want to know whether the object itself, without any object it refers to, is pickleable. I think you're being too picky. Unless you're manually added stuff to your Lock's attributes, there isn't a practical difference between the two situations. Also, pickling an object could be very resource-intensive, depending on its size. Well, this is a Lock here, not an ISO file. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19032 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14984] netrc module allows read of non-secured .netrc file
Barry A. Warsaw added the comment: @RDM: Please commit to 2.6 and null merge to 2.7. Thanks! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14984 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18050] embedded interpreter or virtualenv fails with ImportError: cannot import name MAXREPEAT
Serhiy Storchaka added the comment: Well. While the running different versions of binaries and Python files is not a good idea, perhaps we can apply this change. But only for 2.7 and 3.3. There is no need in this garbage in 3.4. I'm still not sure that there are no other inconsistencies between old static binaries and newer Python files. -- assignee: - serhiy.storchaka keywords: +patch stage: needs patch - patch review versions: -Python 3.4 Added file: http://bugs.python.org/file31794/sre_MAXREPEAT.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18050 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18985] Improve the documentation in fcntl module
Vajrasky Kok added the comment: Updated patch based on Ezio's review. I reverted back the changes to Nul and module documentation (since it is not so clear whether we should categorize flock as Unix routine or not). -- Added file: http://bugs.python.org/file31795/fix_documentation_on_fcntl_module_v2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18985 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19035] tokenize.generate_tokens treat '\f' symbol as the end of file (when reading in unicode)
New submission from Alexey Umnov: I execute the following code on the attached file 'text.txt': import tokenize import codecs with open('text.txt', 'r') as f: reader = codecs.getreader('utf-8')(f) tokens = tokenize.generate_tokens(reader.readline) The file 'text.txt' has the following structure: first line with some text, then '\f' symbol (0x0c) on the second line and then some text on the last line. The result is that the function 'generate_tokens' ignores everything after '\f'. I've made some debugging and found out the following. If the file is read without using codecs (in ascii-mode), there are considered to be 3 lines in the file: 'text1\n', '\f\n', 'text2\n'. However in unicode-mode there are 4 lines: 'text1\n', '\f', '\n', 'text2\n'. I guess this is an intended behaviour since 2.7.x, but this causes a bug in tokenize module. Consider the lines 317-329 in tokenize.py: ... column = 0 while pos max: # measure leading whitespace if line[pos] == ' ': column += 1 elif line[pos] == '\t': column = (column//tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos += 1 if pos == max: break ... The last 'break' corresponds to the main parsing loop and makes the parsing stop. Thus the lines that consist of (' ', '\t', '\f') characters and don't end with '\n' are treated as the end of file. -- components: Library (Lib) files: tokens.txt messages: 197899 nosy: Alexey.Umnov priority: normal severity: normal status: open title: tokenize.generate_tokens treat '\f' symbol as the end of file (when reading in unicode) type: behavior versions: Python 2.7 Added file: http://bugs.python.org/file31796/tokens.txt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19035 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18857] urlencode of a None value uses the string 'None'
Claudiu.Popa added the comment: No problem, David, working on these patches is just an occasion for me to learn more and be useful at the same time. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18857 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18704] IDLE: PEP8 Style Check Integration
R. Jayakrishnan added the comment: I would prefer this issue concludes with a navigation to the new proposed enhancement. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18704 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19030] inspect.getmembers and inspect.classify_class_attrs mishandle descriptors
Ethan Furman added the comment: Switching the order to try getattr first is going to make getting the doc from the descriptor problematic -- we have no way of knowing if the descriptor doc goes with the object we got back from getattr. Current patch adds VirtualAttribute to types, and reworks inspect.classify_class_attrs, inspect.getmembers, and Enum to use that instead of _RouteClassAttributeToGetattr (which has been removed). Tests are still needed for the new VirtualAttribute. Not sure VirtualAttribute is the best name; other ideas: - InstanceProperty - AttributeProperty - HiddenClassProperty -- stage: - patch review Added file: http://bugs.python.org/file31797/issue19030.stoneleaf.02.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19030 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com