Re: [ANN] PyLint 0.27 / logilab-astng 0.24.2
On 01 mars 07:41, Melton Low (devl) wrote: Hi Sylvain, Hi, Clicking on the download linked from [1] below gives me an error. Same with logilab-astng link [2]. Not Found The requested URL /pub/pylint/pylint-0.27.0.tar.gz was not found on this server. Apache/2.2.16 (Debian) mod_ssl/2.2.16 OpenSSL/0.9.8o Server at download.logilab.org Port 80 Maybe I need to wait for the server to be updated? sorry, I forgot a step. Fixed now. thx and sorry for the incovenience -- Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (05.62.17.16.42) Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations Développement logiciel sur mesure: http://www.logilab.fr/services CubicWeb, the semantic web framework:http://www.cubicweb.org -- http://mail.python.org/mailman/listinfo/python-list
Encoding problem in python
I have a problem with encoding in python 27 shell. when i write this in the python shell: w=u'العربى' It gives me the following error: Unsupported characters in input any help? -- http://mail.python.org/mailman/listinfo/python-list
Re: Encoding problem in python
On 2013-03-04 10:37, yomnasala...@gmail.com wrote: I have a problem with encoding in python 27 shell. when i write this in the python shell: w=u'العربى' It gives me the following error: Unsupported characters in input any help? Maybe it is not Python related. Did you get an exception? Can you send a full traceback? I suspect that the error comes from your terminal, and not Python. Please make sure that your terminal supports UTF-8 encoding. Alternatively, try creating a file with this content: # -*- encoding: UTF-8 -*- w=u'العربى' Save it as UTF-8 encoded file test.py (with an UTF-8 compatible editor, for example Geany) and run it as a command: python test.py If it works then it is sure that the problem is with your terminal. It will be an OS limitation, not Python's limitation. Best, Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: Encoding problem in python
On Mon, 04 Mar 2013 01:37:42 -0800, yomnasalah91 wrote: I have a problem with encoding in python 27 shell. when i write this in the python shell: w=u'العربى' It gives me the following error: Unsupported characters in input any help? Firstly, please show the COMPLETE error, including the full traceback. Python errors look like (for example): py x = ord(100) Traceback (most recent call last): File stdin, line 1, in module TypeError: ord() expected string of length 1, but int found Copy and paste the complete traceback. Secondly, please describe your environment: - What operating system and version are you using? Linux, Windows, Mac OS, something else? Which version or distro? - Which console or terminal application? E.g. cmd.exe (Windows), konsole, xterm, something else? - Which shell? E.g. the standard Python interpreter, IDLE, bpython, something else? My guess is that this is not a Python problem, but an issue with your console. You should always have your console set to use UTF-8, if possible. I expect that your console is set to use a different encoding. In that case, see if you can change it to UTF-8. For example, using Gnome Terminal on Linux, I can do this: py w = u'العربى' py print w العربى and it works fine, but if I change the encoding to WINDOWS-1252 using the Set character encoding menu command, the terminal will not allow me to paste the string into the terminal. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Triple nested loop python (While loop insde of for loop inside of while loop)
Am 01.03.2013 17:28, schrieb Isaac Won: What I really want to get from this code is m1 as I told. For this purpose, for instance, values of fpsd upto second loop and that from third loop should be same, but they are not. Actually it is my main question. You are not helping yourself... In any case, please drop everything not necessary to demostrate the problem before posting. This makes it easier to see what is going wrong both for you and others. Also make sure that others can actually run the code. Read this carefully, I didn't write that to fill up empty space. Also, read Eric S. Raymond's essay on asking smart questions (you can easily locate it online), which the problems with your question in a much more general way. Uli -- http://mail.python.org/mailman/listinfo/python-list
Python SUDS issue
Hi Guys, I am pretty new to web services. After some googling found that python suds is a suitable module to create web service client. I am trying to create a client but its giving me an error which is quite confusing for me. Here is my code: from suds.client import Client wsdlurl = 'https://46.51.221.138/PBExternalServices/v1/soap?wsdl' client = Client(wsdlurl) print client And following is the error that occurs on trying to print client. Traceback (most recent call last): File trysuds.py, line 3, in module client = Client(wsdlurl) File C:\Python25\Lib\site-packages\suds\client.py, line 112, in __init__ self.wsdl = reader.open(url) File C:\Python25\Lib\site-packages\suds\reader.py, line 152, in open d = self.fn(url, self.options) File C:\Python25\Lib\site-packages\suds\wsdl.py, line 159, in __init__ self.build_schema() File C:\Python25\Lib\site-packages\suds\wsdl.py, line 220, in build_schema self.schema = container.load(self.options) File C:\Python25\Lib\site-packages\suds\xsd\schema.py, line 95, in load child.dereference() File C:\Python25\Lib\site-packages\suds\xsd\schema.py, line 323, in dereference midx, deps = x.dependencies() File C:\Python25\Lib\site-packages\suds\xsd\sxbasic.py, line 469, in dependencies raise TypeNotFound(self.ref) suds.TypeNotFound: Type not found: '(GetAccountBalanceFaultResponse, http://www.payback.net/lmsglobal/xsd/v1/types, )' Appreciate your help. Thanks in advance, VGNU -- http://mail.python.org/mailman/listinfo/python-list
Question on for loop
Hi all, I'm super new to python, just fyi. In the piece of code below, secretWord is a string and lettersGuessed is a list. I'm trying to find out if ALL the characters of secretWord are included in lettersGuessed, even if there are additional values in the lettersGuessed list that aren't in secretWord. What this code is doing is only checking the first character of secretWord and then returning True or False. How do I get it to iterate through ALL of the characters of secretWord? for character in secretWord: if character not in lettersGuessed: return True return False Thanks! Ro -- http://mail.python.org/mailman/listinfo/python-list
Re: Question on for loop
In fact this code is already doing what you want, but if the second character, by example, is not in secrectWord it'll jump out of the for and return. If you want that interact through the all characters and maybe count how many them are in the secrectWord, just take of the return there or do some list comprehension like: [ r for r in secrecWord if r in lettersGuessed] . []'s On Mon, Mar 4, 2013 at 9:18 AM, newtopython roshen.set...@gmail.com wrote: Hi all, I'm super new to python, just fyi. In the piece of code below, secretWord is a string and lettersGuessed is a list. I'm trying to find out if ALL the characters of secretWord are included in lettersGuessed, even if there are additional values in the lettersGuessed list that aren't in secretWord. What this code is doing is only checking the first character of secretWord and then returning True or False. How do I get it to iterate through ALL of the characters of secretWord? for character in secretWord: if character not in lettersGuessed: return True return False Thanks! Ro -- http://mail.python.org/mailman/listinfo/python-list -- Leônidas S. Barbosa (Kirotawa) Engenheiro de Software - IBM (LTC - Linux Technology Center) MsC Sistemas e Computação Bacharel em Ciências da Computação. blog nerd: corecode.wordpress.com/ http://corecode.wordpress.com/User linux : #480879 Mais sábio é aquele que sabe que não sabe (Sócrates) smile and wave - =D + o/ (Penguins of Madagascar) 日本語の学生です。 コンピュータサイエンスの学位. -- http://mail.python.org/mailman/listinfo/python-list
Re: Question on for loop
On Mon, Mar 4, 2013 at 7:18 AM, newtopython roshen.set...@gmail.com wrote: Hi all, I'm super new to python, just fyi. Welcome. Next time write a better subject line, and be sure the code you post is actually the code you are running. Provide the results you want and what you get. Provide the traceback if there is one In the piece of code below, secretWord is a string and lettersGuessed is a list. I'm trying to find out if ALL the characters of secretWord are included in lettersGuessed, even if there are additional values in the lettersGuessed list that aren't in secretWord. What this code is doing is only checking the first character of secretWord and then returning True or False. How do I get it to iterate through ALL of the characters of secretWord? for character in secretWord: if character not in lettersGuessed: I am guessing that the next two lines are actually indented in your script so I am changing them here return True return False The first time your if block is checked it will return True or False. Since you haven't shown this code in a function, as written it won't run at all. Your question makes no sense. What would it mean to look through each character and return True or False? What would make the result True? All matches, some matches? Thanks! Ro -- http://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python SUDS issue
On Mon, Mar 4, 2013 at 5:37 AM, VGNU Linux vgnuli...@gmail.com wrote: Hi Guys, I am pretty new to web services. After some googling found that python suds is a suitable module to create web service client. I am trying to create a client but its giving me an error which is quite confusing for me. Here is my code: from suds.client import Client wsdlurl = 'https://46.51.221.138/PBExternalServices/v1/soap?wsdl' What happens when you type this in your browser: https://46.51.221.138/PBExternalServices/v1/soap?wsdl client = Client(wsdlurl) print client And following is the error that occurs on trying to print client. Traceback (most recent call last): File trysuds.py, line 3, in module client = Client(wsdlurl) File C:\Python25\Lib\site-packages\suds\client.py, line 112, in __init__ self.wsdl = reader.open(url) File C:\Python25\Lib\site-packages\suds\reader.py, line 152, in open d = self.fn(url, self.options) File C:\Python25\Lib\site-packages\suds\wsdl.py, line 159, in __init__ self.build_schema() File C:\Python25\Lib\site-packages\suds\wsdl.py, line 220, in build_schema self.schema = container.load(self.options) File C:\Python25\Lib\site-packages\suds\xsd\schema.py, line 95, in load child.dereference() File C:\Python25\Lib\site-packages\suds\xsd\schema.py, line 323, in dereference midx, deps = x.dependencies() File C:\Python25\Lib\site-packages\suds\xsd\sxbasic.py, line 469, in dependencies raise TypeNotFound(self.ref) suds.TypeNotFound: Type not found: '(GetAccountBalanceFaultResponse, http://www.payback.net/lmsglobal/xsd/v1/types, )' Appreciate your help. Thanks in advance, VGNU -- http://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Question on for loop
On 03/04/2013 07:18 AM, newtopython wrote: Hi all, I'm super new to python, just fyi. Welcome to the Python list. In the piece of code below, secretWord is a string and lettersGuessed is a list. I'm trying to find out if ALL the characters of secretWord are included in lettersGuessed, even if there are additional values in the lettersGuessed list that aren't in secretWord. What this code is doing is only checking the first character of secretWord and then returning True or False. How do I get it to iterate through ALL of the characters of secretWord? for character in secretWord: if character not in lettersGuessed: return True return False Please post a complete sample when possible, and make sure you copy/paste it, not just retype it and hope. As written, it'll throw an exception when return is encountered. But before that, it'll complain about the indentation of the return True. Perhaps you have something like: def has_some_behavior(secretWord, lettersGuessed): for character in secretWord: if character not in lettersGuessed: return True return False If so, please copy the whole thing from your code, and explain just how you call it (what arguments are passed), what it returned, and what's wrong with that behavior. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Encoding problem in python
2013/3/4 yomnasala...@gmail.com: I have a problem with encoding in python 27 shell. when i write this in the python shell: w=u'العربى' It gives me the following error: Unsupported characters in input any help? -- http://mail.python.org/mailman/listinfo/python-list Hi, I guess, you are using the built-in IDLE shell with python 2.7 and this is a specific limitation of its handling of some unicode characters (in some builds and OSes - narrow-unicode, Windows, most likely?) and its specific error message - not the usual python traceback mentioned in other posts). If it is viable, using python 3.3 instead would solve this problem for IDLE: Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)] on win32 Type copyright, credits or license() for more information. w='العربى' w 'العربى' (note the missing u in unicode literal before the starting quotation mark, which would be the usual usage in python 3, but python 3.3 also silently ignores u... for compatibility.) w=u'العربى' w 'العربى' If python 2.7 is required, another shell is probably needed (unless I am missing some option to make IDLE work for this input); e.g. the following works in pyshell - part of the wxpython GUI library http://www.wxpython.org/ w=u'العربى' w u'\u0627\u0644\u0639\u0631\u0628\u0649' print w العربى hth, vbr -- http://mail.python.org/mailman/listinfo/python-list
Different behavior with multiprocessing
Hi all. Recently I discovered a strange behavior with multiprocessing library and call to function os.system (a different behavior under Linux and Windows to be more specific). I have this simple testing script: import sys import os from multiprocessing import Process def do_fork(cmd): ret = os.system(cmd) # print result of call print ret os._exit(ret) if __name__ == __main__: cmds = [ dir, xy ] procs = [] for cmd in cmds: proc = Process(target=do_fork, args=(cmd, )) proc.start() procs.append( proc ) for proc in procs: proc.join() print exitcode: %d % proc.exitcode print ok This script just starts 2 processes. Each process executes one command in system shell and exits setting it's exit code same as exit code of a system call. There are 2 commands: dir (which works fine on Windows and Linux) and xy (which is supposed to fail under both systems). The strange thing is that when I run this script under Windows I get this output: 0 1 exitcode: 0 exitcode: 1 ok The first 0 and 1 are results of os.system call which are printed from child processes. Rest of lines are printed from main process. This is expected output. But when I run same script on Linux, what I get is this: 0 32512 exitcode: 0 exitcode: 0 ok Although the second command fails and returns exit code 32512, the exit code from process in parent process gives me 0. I tried to change the script to use fork() instead of Process but the result was same. Can anybody explain me what's the problem here? (I use Python 2.6 on both Windows and Linux machines) -- http://mail.python.org/mailman/listinfo/python-list
Re: Question on for loop
if character not in lettersGuessed: return True return False assuming a function is being used to pass each letter of the letters guessed inside a loop itself that only continues checking if true is returned, then that could work. It is however more work than is needed. If you made secretword a list,you could just set(secretword)set(lettersguessed) and check the result is equal to secretword. -- http://mail.python.org/mailman/listinfo/python-list
Re: Different behavior with multiprocessing
On Tue, Mar 5, 2013 at 1:31 AM, Tomas Kotal tomas.ko...@gmail.com wrote: But when I run same script on Linux, what I get is this: 0 32512 Under Unix, the return value from os.system() encodes more than one piece of information: http://docs.python.org/2/library/os.html#os.system http://docs.python.org/2/library/os.html#os.wait 32512 is 127*256, meaning that the shell exited with return code 127 when given an unrecognized command. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: i need help
On Sunday, March 3, 2013 6:45:26 PM UTC, Kwpolska wrote: On Sun, Mar 3, 2013 at 7:46 AM, Michael Torrie torr...@gmail.com wrote: On 02/21/2013 03:18 AM, leonardo wrote: thanks, problem solved Apparently not. The shift key on your keyboard still seems to be non-functional. ;) -- http://mail.python.org/mailman/listinfo/python-list It is! How else could he type those two question marks and 10 double-quotes? -- Kwpolska http://kwpolska.tk | GPG KEY: 5EAAEA16 stop html mail| always bottom-post http://asciiribbon.org| http://caliburn.nl/topposting.html Onscreen Keyboard? -- http://mail.python.org/mailman/listinfo/python-list
Embedding a for inside an html template for substitution
Hello pythonistas! I'am tryign to populate a table with dictionary keys and values: Foe that iam using an html template and the questions is what i should write inside 'files.html' so then then the python script populate the table. table trthSuperHost - Economy/th/tr trtdΧώρος στο δίσκο: 1 GB/td/tr trtdΜηνιαία Κίνηση δεδομένων: 1 GB/td/tr trtdControl Panel: cPanel 11 Fantastico Deluxe/td/tr trtdDomains: 1/td/tr trtdSubdomains: 1/td/tr trtdFTP Accounts: 1/td/tr trtdEmails (POP3): 2/td/tr trtdWebMail: [ RoundCube|Horde|Squirrel ]: ΝΑΙ/td/tr trtdMysql Databases: 2/td/tr /table Instead of writing the above html data inside my html template how would i write it with a for that then will be substituted by the python script? can you please write an example for me that user files.html and gets populates by files.py ? i want os ee how it lloks like please! Thank you. -- http://mail.python.org/mailman/listinfo/python-list
fixed broken links for the latest pylint/astng release
Hi there, last week I announced the latest and greatest pylint/astng release but didn't noticed at that time that the download links on our web site were broken, and that the upload to pypi failed. This is now fixed, for those who tried during the mean time. Sorry for the convenience, -- Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (05.62.17.16.42) Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations Développement logiciel sur mesure: http://www.logilab.fr/services CubicWeb, the semantic web framework:http://www.cubicweb.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Different behavior with multiprocessing
Under Unix, the return value from os.system() encodes more than one piece of information: http://docs.python.org/2/library/os.html#os.system http://docs.python.org/2/library/os.html#os.wait 32512 is 127*256, meaning that the shell exited with return code 127 when given an unrecognized command. ChrisA Well the point is not the difference between return values of os.system under Windows and Linux. The point is that I set the exist code of child process with os._exit() which works fine on Windows but on Linux the process.exitcode returns always 0. What is very strange is, that if I set return code to some other value, like: ... os._exit( len(cmd) ) ... Then I got exit codes 3 and 2 under Linux, which is correct. But when I do something like this: ... ret = os.system(cmd) print ret # this print real value, like 32512 os._exit(ret) # exitcode of this child process will be 0 on Linux ... It doesn't work, which seems very strange to me. -- http://mail.python.org/mailman/listinfo/python-list
Re: Different behavior with multiprocessing
Dne pondělí, 4. března 2013 15:31:41 UTC+1 Tomas Kotal napsal(a): Hi all. Recently I discovered a strange behavior with multiprocessing library and call to function os.system (a different behavior under Linux and Windows to be more specific). I have this simple testing script: import sys import os from multiprocessing import Process def do_fork(cmd): ret = os.system(cmd) # print result of call print ret os._exit(ret) if __name__ == __main__: cmds = [ dir, xy ] procs = [] for cmd in cmds: proc = Process(target=do_fork, args=(cmd, )) proc.start() procs.append( proc ) for proc in procs: proc.join() print exitcode: %d % proc.exitcode print ok This script just starts 2 processes. Each process executes one command in system shell and exits setting it's exit code same as exit code of a system call. There are 2 commands: dir (which works fine on Windows and Linux) and xy (which is supposed to fail under both systems). The strange thing is that when I run this script under Windows I get this output: 0 1 exitcode: 0 exitcode: 1 ok The first 0 and 1 are results of os.system call which are printed from child processes. Rest of lines are printed from main process. This is expected output. But when I run same script on Linux, what I get is this: 0 32512 exitcode: 0 exitcode: 0 ok Although the second command fails and returns exit code 32512, the exit code from process in parent process gives me 0. I tried to change the script to use fork() instead of Process but the result was same. Can anybody explain me what's the problem here? (I use Python 2.6 on both Windows and Linux machines) Seems like I found the problem: os._exit probably takes as parametr unsigned char, so it uses as error code whatever value it gets modulo 256: os._exit(1) # process.exitcode == 1 os._exit(255) # process.exitcode == 255 os._exit(256) # process.exitcode == 0 os._exit(257) # process.exitcode == 1 os._exit(32512) # process.exitcode == 0 So on Linux it's necesary to call something like this: os._exit( os.system(cmd) 8 ) Because the first byte of return value on Linux is number of signal which kills the process and the second one is actual exit code. http://docs.python.org/2/library/os.html#os.wait -- http://mail.python.org/mailman/listinfo/python-list
Re: Different behavior with multiprocessing
On Tue, Mar 5, 2013 at 2:35 AM, Tomas Kotal tomas.ko...@gmail.com wrote: Seems like I found the problem: os._exit probably takes as parametr unsigned char, so it uses as error code whatever value it gets modulo 256: os._exit(1) # process.exitcode == 1 os._exit(255) # process.exitcode == 255 os._exit(256) # process.exitcode == 0 os._exit(257) # process.exitcode == 1 os._exit(32512) # process.exitcode == 0 So on Linux it's necesary to call something like this: os._exit( os.system(cmd) 8 ) Because the first byte of return value on Linux is number of signal which kills the process and the second one is actual exit code. Yep. I had a reply part-written but you beat me to it! That is indeed what you need if you want to chain return values. However, why are you using os._exit? Check out the note here: http://docs.python.org/2/library/os.html#os._exit ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Question on for loop
On Monday, March 4, 2013 6:18:20 AM UTC-6, newtopython wrote: [Note: Post has be logically re-arranged for your comprehensive pleasures] for character in secretWord: if character not in lettersGuessed: return True return False What this code is doing is only checking the first character of secretWord and then returning True or False. How do I get it to iterate through ALL of the characters of secretWord? Your code is a fine example of: attempting to solve too many problems at the same time. If you are having trouble understanding how to iterate over a sequence, then why would you complicate that learning experience by injecting other unsolved problems into the mix? First, solve the iteration problem. Then expand. ## START INTERACTIVE SESSION ## py s = 'multiplicity' py for char in s: ... print char m u l t i p l i c i t y ## END INTERACTIVE SESSION ## Now, we have a simple base from which to build! In the piece of code [ABOVE], secretWord is a string and lettersGuessed is a list. I'm trying to find out if ALL the characters of secretWord are included in lettersGuessed, even if there are additional values in the lettersGuessed list that aren't in secretWord. First, step away from your interpreter! Now, grab a pen and paper and write down the steps required to compare two sequences in real life. 1. Create a list of letters guessed and a string representing the secret word. secretWord = 'multiplicity' lettersGuessed = 'aeiouy' 2. For each letter in secretWord, look in lettersGuessed and see if you can find the letter, then make a note of your findings. If the letter is in IN both sequences, write [letter]=True, if not, write [letter]=False. However, this algorithm is rather naive. What happens if one or both list contain the same letter numerous times (f.e. multiplicity has 3 i chars)? Do we want the user to provide a guess for all three i chars, or will just a single guess al la price is right will do the trick? Also, do we care about the char order? Or are we merely allowing the user to guess all the letters of the word in ANY order (that seems to be your intent here!)? In any event i am not going to just gift wrap and answer for you. There are many methods of solving this problem, some are elegant, some or not elegant, some use built-in functions, some use list comprehensions, and some could just use a for loop and a single built-in function. I would highly suggest that you figure this out using the latter. Until you can achieve this, forget about list comprehension or any advanced stuff. But most importantly: Build your code in small incremental steps and solve ONE issue at a time. This is the path of a wise problem solver. -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding a for inside an html template for substitution
On 03/04/2013 08:14 AM, Ferrous Cranus wrote: Instead of writing the above html data inside my html template how would i write it with a for that then will be substituted by the python script? What templating system are you using? Django's? can you please write an example for me that user files.html and gets populates by files.py ? If you're using a CGI script, just use a normal python for loop and print out the stuff you want using this kind of notation: for x in xrange(4): print trtd{0}/td/tr.format(x) Another alternative is to make your own templating system. Have it load and parse the html file (maybe using one of the xml or html parsers), and substitude some sort of field marker for data. But that is re-inventing the wheel. http://wiki.python.org/moin/Templating -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-ideas] string.format() default variable assignment
Ignoring my own posting ban, since I've clearly been misunderstood .. On Sat, Mar 2, 2013 at 10:21 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sat, 02 Mar 2013 21:11:04 -0500, David Robinow wrote: Do you consider it rude that you choose to use a newsreader, thus inconveniencing those of us who use the mailing list, as God intended. How the flying fuck does my choice of where and how *I* read this forum inconvenience YOU? Talk about an overactive sense of entitlement. The world does not revolve around you and I do not arrange my day to suit your preferences. This surprises me. Not the language but the content, since the inconvenience was explicitly discussed. Many list members use gmail. It works for me. I never see double posts. gmail knows not to do that. The lack of a reply to list option would not concern me if everybody else used gmail. I could just use reply all, nobody would see double posts, and we're all happy. However, some people prefer to read comp.lang.python. Thus if I use what is most convenient me, the news users see double posts. To avoid being thought rude (please note that many people are, or 'were' in the case of python-list, unaware of this issue and should be classified as ignorant rather than rude) I need to, after clicking Reply All Move mouse to CC: area. Highlight python-list address C-x (i.e., CUT) Move mouse to TO: area. Highlight the address (of the poster to whom I am replying) C-v (i.e., PASTE) Is that horribly difficult? No, and I intend to do it in the future. I'm mostly a lurker anyway (I knew python better 10 years ago when I was still working - inactivity and advanced age have made me dumber. I mostly read python-list for recreation) so it's not a big deal. I might be annoyed if I posted more. But here's what I don't understand. Why does somebody who posts as much as Steven (and thanks for that. Getting cussed at occasionally is a cheap price for all the free advice) not set up a simple mail filter which trashes all mail from python-list. Wouldn't that solve the problem? Or am I misunderstanding something? -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-ideas] string.format() default variable assignment
Crap. I just forgot to do what I just said I would do and didn't go through my inconvenient sequence. Sorry, Steven. It was unintentional. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is it impossible to create a compiler than can compile Python to machinecode like C?
On 2013-02-28, kramer65 kram...@gmail.com wrote: I'm using Python for a while now and I love it. There is just one thing I cannot understand. There are compilers for languages like C and C++. why is it impossible to create a compiler that can compile Python code to machinecode? The main issue is that python has dynamic typing. The type of object that is referenced by a particular name can vary, and there's no way (in general) to know at compile time what the type of object foo is. That makes generating object code to manipulate foo very difficult. My reasoning is as follows: When GCC compiles a program written in C++, it simply takes that code and decides what instructions that would mean for the computer's hardware. What does the CPU need to do, what does the memory need to remember, etc. etc. If you can create this machinecode from C++, then I would suspect that it should also be possible to do this (without a C-step in between) for programs written in Python. Where is my reasoning wrong here? Is that because Python is dynamically typed? Yes. Does machinecode always need to know whether a variable is an int or a float? Yes. Not only might it be an int or a float, it might be a string, a list, a dictionary, a network socket, a file, or some user-defined object type that the compiler has no way of knowing about. And if so, can't you build a compiler which creates machinecode that can handle both ints and floats in case of doubt? That's pretty much what you've got now. The Python compiler compiles the source code as much as it can, and the VM is the machinecode that can handle both ints and floats. Or is it actually possible to do, but so much work that nobody does it? I googled around, and I *think* it is because of the dynamic typing, but I really don't understand why this would be an issue.. Can you explain how to generate machine code to handle any possible object type than any Python user might ever create? -- Grant Edwards grant.b.edwardsYow! for ARTIFICIAL at FLAVORING!! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Question on for loop
On Mon, Mar 4, 2013 at 7:34 AM, Bryan Devaney bryan.deva...@gmail.com wrote: if character not in lettersGuessed: return True return False assuming a function is being used to pass each letter of the letters guessed inside a loop itself that only continues checking if true is returned, then that could work. It is however more work than is needed. If you made secretword a list,you could just set(secretword)set(lettersguessed) and check the result is equal to secretword. Check the result is equal to set(secretword), I think you mean. set(secretword).issubset(set(lettersguessed)) might be slightly more efficient, since it would not need to build and return an intersection set. One might also just do: all(letter in lettersguessed for letter in secretword) Which will be efficient if lettersguessed is already a set. -- http://mail.python.org/mailman/listinfo/python-list
Re: i need help
On Mon, Mar 4, 2013 at 8:07 AM, Bryan Devaney bryan.deva...@gmail.com wrote: On Sunday, March 3, 2013 6:45:26 PM UTC, Kwpolska wrote: It is! How else could he type those two question marks and 10 double-quotes? Onscreen Keyboard? Or voice recognition, perhaps. We have no idea what the OP's actual input system might be, which is why it might be best not to harass him over something so trivial as uncapitalized letters. One post in this thread pointing it out was plenty. -- http://mail.python.org/mailman/listinfo/python-list
Re: i need help
On Mon, 04 Mar 2013 07:07:53 -0800, Bryan Devaney wrote: On Sunday, March 3, 2013 6:45:26 PM UTC, Kwpolska wrote: On Sun, Mar 3, 2013 at 7:46 AM, Michael Torrie torr...@gmail.com wrote: On 02/21/2013 03:18 AM, leonardo wrote: thanks, problem solved Apparently not. The shift key on your keyboard still seems to be non-functional. ;) -- http://mail.python.org/mailman/listinfo/python-list It is! How else could he type those two question marks and 10 double-quotes? -- Kwpolska http://kwpolska.tk | GPG KEY: 5EAAEA16 stop html mail| always bottom-post http://asciiribbon.org| http://caliburn.nl/topposting.html Onscreen Keyboard? using alt the numeric keypad ? alt 62, alt 34 -- New York's got the ways and means; Just won't let you be. -- The Grateful Dead -- http://mail.python.org/mailman/listinfo/python-list
Re: Question on for loop
El 04/03/13 09:18, newtopython escribió: Hi all, I'm super new to python, just fyi. In the piece of code below, secretWord is a string and lettersGuessed is a list. I'm trying to find out if ALL the characters of secretWord are included in lettersGuessed, even if there are additional values in the lettersGuessed list that aren't in secretWord. What this code is doing is only checking the first character of secretWord and then returning True or False. How do I get it to iterate through ALL of the characters of secretWord? for character in secretWord: if character not in lettersGuessed: return True return False Thanks! Ro Indent the return True line so that it is inside the if clause. -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding a for inside an html template for substitution
Τη Δευτέρα, 4 Μαρτίου 2013 5:59:34 μ.μ. UTC+2, ο χρήστης Michael Torrie έγραψε: On 03/04/2013 08:14 AM, Ferrous Cranus wrote: Instead of writing the above html data inside my html template how would i write it with a for that then will be substituted by the python script? What templating system are you using? Django's? can you please write an example for me that user files.html and gets populates by files.py ? If you're using a CGI script, just use a normal python for loop and print out the stuff you want using this kind of notation: for x in xrange(4): print trtd{0}/td/tr.format(x) Another alternative is to make your own templating system. Have it load and parse the html file (maybe using one of the xml or html parsers), and substitude some sort of field marker for data. But that is re-inventing the wheel. http://wiki.python.org/moin/Templating Firstly thank you for your answer, but iam a bit confised. can i just put the liens you provided me inside files.html and thwy will work? Thats pure pythjon code! for x in xrange(4): print trtd{0}/td/tr.format(x) wont html complain? -- http://mail.python.org/mailman/listinfo/python-list
How to Nest Structs?
Hi, I'm trying to nest the info_header, info_body, and info_trailer structs (see below) into a data_packet struct. Does anyone know how I can/should accomplish this? Thanks. batch_header_format = struct.Struct('!c2h') info_header_format = struct.Struct('!2hl') mkt_status_format = struct.Struct('!c') info_trailer_format = struct.Struct('!hc') mkt_session_codes = [b'PO',b'PC',b'CO',b'CC',b'CK',b'CL'] mkt_type = [b'N',b'S',b'O',b'A',b'C',b'G'] batch_header = batch_header_format.pack(b'1',1,1024) total_size = info_header_format.size + mkt_status_format.size + info_trailer_format.size # Combine following into data struct. info_header = info_header_format.pack(int(binascii.hexlify(mkt_session_codes[random.randint(0,5)])), total_size, 124) info_body = mkt_status_format.pack(mkt_type[random.randint(0,5)]) info_trailer = info_trailer_format.pack(0, b'\r') -Ari -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-ideas] string.format() default variable assignment
On 03/04/2013 11:15 AM, David Robinow wrote: Crap. I just forgot to do what I just said I would do and didn't go through my inconvenient sequence. Sorry, Steven. It was unintentional. FWIW, you don't have to bother moving the python-list address to a To: field. Just remove the personal address that's there. See I saved you a few keystrokes. To: blank CC: python-list should work fine. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Read csv file and create a new file
What you wrote seems interesting but i haven't understood. Can you explain in simple words considering i'm italian and i'm not understanding so well some terms you use. Sorry, i'm sure you are suggesting something really valid but can't understand it. Marco. -- http://mail.python.org/mailman/listinfo/python-list
Python script not working on windows 7 but works fine on linux
The following scripts are working fine on linux but, using the same version, can't work on windows because i receive the following message: Script: import json import urllib import csv url = http://bitcoincharts.com/t/markets.json; response = urllib.urlopen(url); data = json.loads(response.read()) f = open(/home/io/btc_trading/markets.csv,wb) c = csv.writer(f) #apre un file di testo e legge il contenuto del file inserendolo in una stringa esclusioni_file = open('/home/io/btc_trading/exclusions.txt','r') esclusioni = [] for line in esclusioni_file: esclusioni.append(line.strip()) #print(esclusioni) # write headers c.writerow([Currency,Symbol,Bid, Ask, Volume]) for d in data : if d[currency] SLL: #esclude la valuta di secondlife SLL if d[bid] is not None and d[ask] is not None: if d[symbol] not in esclusioni: #print d[symbol] c.writerow([str(d[currency]),str(d[symbol]),str(d [bid]),str(d[ask]),str(d[currency_volume])]) #esclusioni.close() Windows error : Traceback (most recent call last): File C:\btc_trading\scripts \import_json_2_csv_from_web_and_exclusions.py, line 10, in module f = open(/home/io/btc_trading/markets.csv,wb) IOError: [Errno 2] No such file or directory: '/home/io/btc_trading/ markets.csv' -- http://mail.python.org/mailman/listinfo/python-list
Re: Python script not working on windows 7 but works fine on linux
On 03/04/2013 11:06 AM, io wrote: esclusioni_file = open('/home/io/btc_trading/exclusions.txt','r') Windows error : Traceback (most recent call last): File C:\btc_trading\scripts \import_json_2_csv_from_web_and_exclusions.py, line 10, in module f = open(/home/io/btc_trading/markets.csv,wb) IOError: [Errno 2] No such file or directory: '/home/io/btc_trading/ markets.csv' The error tells you everything you need to know: the file system has no path/file called /home/io/btc_trading/markets.csv I imagine your CSV file lives in a different location on your Windows 7 system (which also uses back-slashes '\' instead of forward-slashes '/', so you'll need to maybe do a try/except around the open() call to open a Windows path like open(c:\\users\\io\\Documents\\markets.csv) or whatever. OR you'll need to do some OS detection ahead of time to set the file path properly. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python script not working on windows 7 but works fine on linux
Am 04.03.13 20:06, schrieb io: The following scripts are working fine on linux but, using the same version, can't work on windows because i receive the following message: snip f = open(/home/io/btc_trading/markets.csv,wb) Windows error : Traceback (most recent call last): File C:\btc_trading\scripts \import_json_2_csv_from_web_and_exclusions.py, line 10, in module f = open(/home/io/btc_trading/markets.csv,wb) IOError: [Errno 2] No such file or directory: '/home/io/btc_trading/ markets.csv' Are you actually reading that error message? You have an absolute path in script! This /home/io... would something like C:/btc_trading/... on Windows. This is not a Python question, it is a Linux/Windows question. Ask your local IT guy. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: Python script not working on windows 7 but works fine on linux
io mar...@libero.it: The following scripts are working fine on linux but, using the same version, can't work on windows because i receive the following message: Thats because there is No such file or directory: '/home/io/btc_trading/ on that Windows PC. -- Wir danken für die Beachtung aller Sicherheitsbestimmungen -- http://mail.python.org/mailman/listinfo/python-list
Re: Python script not working on windows 7 but works fine on linux
Genius! The code i posted was an example. My real code was c:\btc_trading i was just missing the double slashes! Thanks , thankyou very much. :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python script not working on windows 7 but works fine on linux
Thanks, btw ...i'm the IT guy! I was missing the double slash as dougas suggested!++Thanks anyway. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python script not working on windows 7 but works fine on linux
On Tue, Mar 5, 2013 at 6:59 AM, io mar...@libero.it wrote: Genius! The code i posted was an example. My real code was c:\btc_trading i was just missing the double slashes! Thanks , thankyou very much. :-) Even on Windows, you can use / as a directory separator. This generally saves you the trouble of switching to \\ for everything; though still, absolute paths are often wrong. But at least you can use relative paths safely! ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Python script not working on windows 7 but works fine on linux
On 3/4/2013 2:20 PM, ian douglas wrote: I imagine your CSV file lives in a different location on your Windows 7 system (which also uses back-slashes '\' instead of forward-slashes '/', Forward slashes work fine on Windows except for invoking the executable at a Command Prompt command line, where '/' marks an option. open('/programs/python33/python.exe') _io.TextIOWrapper name='/programs/python33/python.exe' mode='r' encoding='cp1252' -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: How to Nest Structs?
Try unpacking the nested struct as a fixed width string and then unpacking the string. Then unpack the string On Monday, March 4, 2013 10:22:07 AM UTC-8, Ari King wrote: Hi, I'm trying to nest the info_header, info_body, and info_trailer structs (see below) into a data_packet struct. Does anyone know how I can/should accomplish this? Thanks. batch_header_format = struct.Struct('!c2h') info_header_format = struct.Struct('!2hl') mkt_status_format = struct.Struct('!c') info_trailer_format = struct.Struct('!hc') mkt_session_codes = [b'PO',b'PC',b'CO',b'CC',b'CK',b'CL'] mkt_type = [b'N',b'S',b'O',b'A',b'C',b'G'] batch_header = batch_header_format.pack(b'1',1,1024) total_size = info_header_format.size + mkt_status_format.size + info_trailer_format.size # Combine following into data struct. info_header = info_header_format.pack(int(binascii.hexlify(mkt_session_codes[random.randint(0,5)])), total_size, 124) info_body = mkt_status_format.pack(mkt_type[random.randint(0,5)]) info_trailer = info_trailer_format.pack(0, b'\r') -Ari -- http://mail.python.org/mailman/listinfo/python-list
فيس بوك facebook
فيس بوك facebook https://www.facebook.com/pages/%D9%86%D8%AA%D8%A7%D8%A6%D8%AC-%D8%A7%D9%84%D8%A7%D9%85%D8%AA%D8%AD%D8%A7%D9%86%D8%A7%D8%AA-%D9%88%D8%A7%D9%84%D8%AC%D8%A7%D9%85%D8%B9%D8%A7%D8%AA-%D9%88%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%8A%D8%A7%D8%AA/299719160065550?ref=hl -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is it impossible to create a compiler than can compile Python to machinecode like C?
The main issue is that python has dynamic typing. The type of object that is referenced by a particular name can vary, and there's no way (in general) to know at compile time what the type of object foo is. That makes generating object code to manipulate foo very difficult. Could you help me understand this better? For example, if you have this line in the Python program: foo = 'some text' bar = {'apple':'fruit'} If the interpreter can determine at runtime that foo is a string and bar is a dict, why can't the compiler figure that out at compile time? Or is the problem that if later in the program you have this line: foo = 12 now foo is referring to an integer object, not a string, and compilers can't have two names referring to two different types of objects? Something like that? I in no way doubt you that this is not possible, I just don't understand enough about how compiling works to yet get why dynamic typing is a problem for compilers. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is it impossible to create a compiler than can compile Python to machinecode like C?
On Tuesday, March 5, 2013 6:55:06 AM UTC+8, CM wrote: The main issue is that python has dynamic typing. The type of object that is referenced by a particular name can vary, and there's no way (in general) to know at compile time what the type of object foo is. That makes generating object code to manipulate foo very difficult. Could you help me understand this better? For example, if you have this line in the Python program: foo = 'some text' bar = {'apple':'fruit'} If the interpreter can determine at runtime that foo is a string and bar is a dict, why can't the compiler figure that out at compile time? Or is the problem that if later in the program you have this line: foo = 12 now foo is referring to an integer object, not a string, and compilers can't have two names referring to two different types of objects? Something like that? I in no way doubt you that this is not possible, I just don't understand enough about how compiling works to yet get why dynamic typing is a problem for compilers. Thanks. The dynamic type part is normally in the higher level components of objects and functions and generators. Of course if one can be sure of the types of variables used in some functions then that is the cython way to speed up pure OOP python programs in executions. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is it impossible to create a compiler than can compile Python to machinecode like C?
On 3/4/2013 5:55 PM, CM wrote: Could you help me understand this better? For example, if you have this line in the Python program: foo = 'some text' bar = {'apple':'fruit'} If the interpreter can determine at runtime that foo is a string and bar is a dict, why can't the compiler figure that out at compile time? Or is the problem that if later in the program you have this line: foo = 12 now foo is referring to an integer object, not a string, and compilers can't have two names referring to two different types of objects? I believe you mean one name referring to multiple types. Something like that? Something like that. In python, objects are strongly typed, names do not have types. Or if you prefer, names are typed according to their current binding, which can freely change. As for why this can be an advantage, consider this simple function. def min2(a, b): if a = b: return a else: return b When the def statement is executed, the names 'a' and 'b' have no binding and therefore no type, not even a temporary type. In a statically typed language, either you or the compiler must rewrite that function for every pair of types that are ever input to min2. If the compiler does it, it either has to analyze an entire program, or it have to compile variations on the fly, as needed. The latter is what the psycho module, and, I believe, the pypy jit compiler does. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is it impossible to create a compiler than can compile Python to machinecode like C?
On Tue, Mar 5, 2013 at 9:55 AM, CM cmpyt...@gmail.com wrote: The main issue is that python has dynamic typing. The type of object that is referenced by a particular name can vary, and there's no way (in general) to know at compile time what the type of object foo is. That makes generating object code to manipulate foo very difficult. Could you help me understand this better? For example, if you have this line in the Python program: foo = 'some text' bar = {'apple':'fruit'} If the interpreter can determine at runtime that foo is a string and bar is a dict, why can't the compiler figure that out at compile time? Or is the problem that if later in the program you have this line: foo = 12 now foo is referring to an integer object, not a string, and compilers can't have two names referring to two different types of objects? Something like that? I in no way doubt you that this is not possible, I just don't understand enough about how compiling works to yet get why dynamic typing is a problem for compilers. Python doesn't have variables with values; it has names, which may (or may not) point to objects. Dynamic typing just means that one name is allowed to point to multiple different types of object at different times. The problem with dynamic typing is more one of polymorphism. Take this expression as an example: foo += bar; In C, the compiler knows the data types of the two variables, and can compile that to the appropriate code. If they're both integers, that'll possibly become a single machine instruction that adds two registers and stores the result back. In C++, foo could be a custom class with an operator+= function. The compiler will know, however, what function to call; unless it's a virtual function, in which case there's a run-time check to figure out what subclass foo is of, and then the function is called dynamically. In Python, *everything* is a subclass of PyObject, and every function call is virtual. That += operation is backed by the __iadd__ function, defined by PyObject and possibly overridden by whatever type foo is. So, at run time, the exact function is looked up. C++ is most definitely a compiled language, at least in most implementations I've seen. But it has the exact same issue as Python has: true dynamism requires run-time lookups. That's really what you're seeing here; it's nothing to do with any sort of compiled vs interpreted dichotomy, but with compile time vs run time lookups. In C, everything can be done at compile time; in Python, most things are done at run time. It's mainly a matter of degree. A more dynamic language needs to do more work at run time. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is it impossible to create a compiler than can compile Python to machinecode like C?
On Mar 4, 2013 3:02 PM, CM cmpyt...@gmail.com wrote: The main issue is that python has dynamic typing. The type of object that is referenced by a particular name can vary, and there's no way (in general) to know at compile time what the type of object foo is. That makes generating object code to manipulate foo very difficult. Could you help me understand this better? For example, if you have this line in the Python program: foo = 'some text' bar = {'apple':'fruit'} If the interpreter can determine at runtime that foo is a string and bar is a dict, why can't the compiler figure that out at compile time? Or is the problem that if later in the program you have this line: foo = 12 now foo is referring to an integer object, not a string, and compilers can't have two names referring to two different types of objects? Something like that? I in no way doubt you that this is not possible, I just don't understand enough about how compiling works to yet get why dynamic typing is a problem for compilers. Thanks. -- http://mail.python.org/mailman/listinfo/python-list In the case of literals, the compiler can figure out type information (and I believe it does do some constant folding). But as soon as you let something else get in between you and the constant, you lose all guarantees. import random if random.random() 0.5 : spam = 3 else: spam = hello world Then you get into monkey patching and dealing with types that may not be defined at compile time. The only way a python compiler could convert that to x86 assembly is if generated code that would look up the type information at runtime. You'd basically be outputting a python interpreter. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is it impossible to create a compiler than can compile Python to machinecode like C?
On Mon, 04 Mar 2013 16:36:36 +, Grant Edwards wrote: On 2013-02-28, kramer65 kram...@gmail.com wrote: I'm using Python for a while now and I love it. There is just one thing I cannot understand. There are compilers for languages like C and C++. why is it impossible to create a compiler that can compile Python code to machinecode? The main issue is that python has dynamic typing. The type of object that is referenced by a particular name can vary, and there's no way (in general) to know at compile time what the type of object foo is. That makes generating object code to manipulate foo very difficult. That's only a limitation with a static compiler that tries to generate fast machine code at compile time. A JIT compiler can generate fast machine code at runtime. The idea is that the time you save by running more optimized code is greater than the time it costs to generate that code each time you run. If not, then you just run the normal byte-code you would have run, and you've lost very little. This has been a very successful approach. Psyco worked very well, and it's successor PyPy seems to work even better. PyPy, on average, runs about 5-6 times faster than CPython, and for some tasks about 50 times faster. That makes it broadly speaking as fast as Java and approaching C, and even in some circumstances even beat static C compilers. (Admittedly only under very restrictive circumstances.) The downside is that JIT compilers need a lot of memory. To oversimplify, you might take source code like this: x = a + b A static compiler knows what types a and b are, and can turn it into a single fairly compact piece of machine code. Using my own crappy invented machine code notation: ADD a, b STORE x A JIT compiler has to generate a runtime check and one or more fast branches, plus a fallback: CASE (a and b are both ints): ADD a, b STORE x CASE (a and b are both strings): COPY a, x CONCATENATE b, x OTHERWISE: execute byte code to add two arbitrary objects The above is probably nothing like the way PyPy actually works. Anyone interested in how PyPy really works should spend some time reading their website and blog. http://pypy.org/ I can especially recommend this to give you a flavour for just how complicated this sort of thing can become: http://morepypy.blogspot.com.au/2011/01/loop-invariant-code-motion.html -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Python script not working on windows 7 but works fine on linux
On Mon, 04 Mar 2013 11:20:28 -0800, ian douglas wrote: The error tells you everything you need to know: the file system has no path/file called /home/io/btc_trading/markets.csv I imagine your CSV file lives in a different location on your Windows 7 system (which also uses back-slashes '\' instead of forward-slashes '/', Windows understands forward slashes in paths too. You can make your code (almost) platform-independent, and avoid a lot of problems with unescaped backslashes, by always using forward slashes in paths. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Python script not working on windows 7 but works fine on linux
On 2013.03.04 19:58, Steven D'Aprano wrote: Windows understands forward slashes in paths too. You can make your code (almost) platform-independent, and avoid a lot of problems with unescaped backslashes, by always using forward slashes in paths. Or use os.path.join, the entire purpose of which is to create suitable paths dynamically. -- CPython 3.3.0 | Windows NT 6.2.9200 / FreeBSD 9.1 -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-ideas] string.format() default variable assignment
On Mon, 04 Mar 2013 11:09:10 -0500, David Robinow wrote: But here's what I don't understand. Why does somebody who posts as much as Steven (and thanks for that. Getting cussed at occasionally is a cheap price for all the free advice) not set up a simple mail filter which trashes all mail from python-list. Wouldn't that solve the problem? Or am I misunderstanding something? When I'm working in my backyard garden, it's a real drag to put garden refuse into the green waste bin for collection. I have to cut it up into manageable-sized pieces, put them in a big carry bag, carry it through the house, then empty the bag into the green waste collection bin the local council supplies. What a drag! Maybe I should have thought of this before moving into my house, but I'm stuck with it now, moving to a new house would be difficult and expensive. Besides, apart from this one little difficulty, I like it here. Since I have all sorts of good excuses why doing the right thing is too much trouble, I just toss any plant trimmings over the fence into my neighbour's yard. It's easy for him to deal with it, all he has to do is get a goat to eat the garden waste I toss over the fence, and his problem is solved. I'm actually doing him a favour by tossing my garden trimmings into his yard. If he doesn't get a goat, the trimmings will rot and turn into compost, which improves the soil in his garden. He'll thank me some day. I really don't understand why he thinks I'm being rude. He should be grateful, not upset. If anyone is being rude, it's him, expecting me to carry all that garden waste through the house into the collection bin. Doesn't he understand how hard that is for me? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-ideas] string.format() default variable assignment
On Tue, Mar 5, 2013 at 1:42 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: It's easy for him to deal with it, all he has to do is get a goat to eat the garden waste I toss over the fence, and his problem is solved. Sounds like someone got Steven's goat. *dives for cover* ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Python script not working on windows 7 but works fine on linux
On Tuesday, March 5, 2013 3:20:28 AM UTC+8, ian douglas wrote: On 03/04/2013 11:06 AM, io wrote: esclusioni_file = open('/home/io/btc_trading/exclusions.txt','r') Windows error : Traceback (most recent call last): File C:\btc_trading\scripts \import_json_2_csv_from_web_and_exclusions.py, line 10, in module f = open(/home/io/btc_trading/markets.csv,wb) IOError: [Errno 2] No such file or directory: '/home/io/btc_trading/ markets.csv' The error tells you everything you need to know: the file system has no path/file called /home/io/btc_trading/markets.csv I imagine your CSV file lives in a different location on your Windows 7 system (which also uses back-slashes '\' instead of forward-slashes '/', so you'll need to maybe do a try/except around the open() call to open a Windows path like open(c:\\users\\io\\Documents\\markets.csv) or whatever. OR you'll need to do some OS detection ahead of time to set the file path properly. Well, I'll suggest an old trick I did long time ago to resolve the platform dependent problem in python. Just write a generator as a buffered input method to work under some file of some OS correctly first, then you can pass the generator which is tested rigorously to act properly in the function or the object which will use the generator to sip up the data to perform jobs. -- http://mail.python.org/mailman/listinfo/python-list
** UPDATE ** ~ The Perfect Guide To Actionable Programming Thank You ~
Thanks for the few answers, though those few were very Helpful. The problem was that some people (even after 4 or more years of university), especially including almost all beginners, do not know how to start building something that does something helpful for soceity and everyone around them -- and this is yet to be resolved. I read a whole bunch of reviews of the learning resources I linked to last month. Here's one I Love -- There should be exaggerated claims of ultimate learning outcomes without evidence[1] My response, attached with the answers below for reference: When wonderful talents do things like kickstarter.com/projects/1369857650/real-python-for-web-development-featuring-web2pyhttp://www.kickstarter.com/projects/1369857650/real-python-for-web-development-featuring-web2py-- I wonder about what is even more significant -- Is it effective? Does it solve the problem? When I (and others far newer than me) have a serious problem like this, you know, we care very much for accurate and reliable data. When people say Learn Python the Hardway is probably the best resource you listed.. [and] you *will *learn the material.. when clearly it doesn't meet standards: I have seeen plenty of stackoverflow and student questions about it. In short, it's horrible. I start to wonder about the reliability of their judgement, and how partial they really are. Even if A friend of mine wrote the course is not factor we care about. Maybe hardway was the highest Quality resource out of those (I personally liked the MIT videos from what I've seen). So maybe, but best in the room with a low ceiling isn't very good. I try really really hard not to touch objects of low quality (4.9 stars) http://www.amazon.com/Programming-Python-Mark-Lutz/dp/0596158106 I've been trying to learn programming for 8 years, so I'm a great canidiate. So Michael, I would gladly give you any feedback on the usability of your product anytime you ask :) [1] http://blog.oreillyschool.com/2011/12/my-thoughts-on-codecademy.html On Thu, Feb 21, 2013 at 11:32 AM, Philipp Hagemeister phi...@phihag.de wrote: http://learnpythonthehardway.org/book/ I have never used that myself, but I have seeen plenty of stackoverflow and student questions about it. In short, it's horrible. The book mostly consists of basic Python programs, and beginners often fail to grasp even the most basic structures demonstrated, mainly because they're not explained. The book has some of the easy-to-approach informality of, say, the Head First ones, but fails to contain the the actual explanations for it. (And I have no idea why one would start with Python 2.x, given that everything's strange in there - instead of relying on the intuitive grasp that both a and ä are single character strings, and that print is a function like any other, they have to work with a lot of magic and hand-waving) - Philipp On Thu, Feb 21, 2013 at 11:10 AM, Mark Janssen dreamingforw...@gmail.com wrote: Sorry, I gave you the wrong book (a different Lutz book). The correct title is _Programming Python_, by Mark Lutz. It's like 1600 pages and is application focused. Cheers! mark On Thu, Feb 21, 2013 at 7:40 AM, Michael Herman herma...@gmail.com wrote: Hi Claira, I understand how hard it can be. Learn Python the Hardway is probably the best resource you listed. It's a bit unorganized, but you *will *learn the material if you go through all the exercises and homework problems. That said, the author does dive into some areas that are not really necessary for beginners, which is a problem with most Python books. Check out http://www.realpython.com/. It's one of the best resources out there. A friend of mine wrote the course. Right now, I am in the process of writing a companion course called Real Python for the Web, where you learn how to develop websites. So, you would start with the first course to learn the syntax and then you could move onto the second course to learn web development. The Kickstarter is live for the second course - http://kck.st/VQj8hq There is a special right now where you can get both courses for $25 on the Kickstarter. Plus, once I hit $15k, which should be in the next few days, I will hit a stretch goal for making video tutorials for the first course. Anyway, sorry to plug my product - but I feel your pain, which is why Real Python was developed in the first place: Less syntax and theory, more coding and learning. Learning by doing. Let me know if you have any more questions. Best, Michael On Thu, Feb 21, 2013 at 2:08 AM, Claira wavecla...@gmail.com wrote: The problem: I've done reading (like on quora), and it seems lots of beginners (and I know first-hand for me), and even for those that have done 4 years at university -- that they say they don't know how to build something after all the theory and stuff. Even though I'm not going to be a programmer, in the future, there may be something that would need
Re: Embedding a for inside an html template for substitution
On 03/04/2013 01:06 PM, Ferrous Cranus wrote: What do you advise me to do? Generate html via python code like print '''stuf..''' or use an html templating system? Up until now i was using the first method and i though it would be a nice idea to seperate design from code. But please also provide me a simple example of 'files.html' and 'files.py' so i can understand how does the templating system you mentioned work. Was it Django?! Just generating html code is simple, but it does become a bit messy over time. Check out that link in my previous e-mail to a list of python templating engines. Choose one and try it. No I cannot provide any example code. I haven't used any of these systems; I'm just googling for you. Most of them come with examples anyway. Check out, among others: http://www.cheetahtemplate.org/docs/users_guide_html/ And actually this one uses cheetah to do static pages (not a full-blown web app): http://www.ivy.fr/tahchee/ I do recommend you at least take a look at Django. It may be overkill for your needs. It does contain a templating engine, but it also contains a whole lot more useful things for doing web-based applications. Here's the link in case you missed it: http://wiki.python.org/moin/Templating -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-ideas] string.format() default variable assignment
On Monday 04 March 2013 23:00:31 Chris Angelico did opine: On Tue, Mar 5, 2013 at 1:42 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: It's easy for him to deal with it, all he has to do is get a goat to eat the garden waste I toss over the fence, and his problem is solved. Sounds like someone got Steven's goat. *dives for cover* ChrisA Thats why this list is worth staying on. :) FWIW, I'd pulled the cover down tight and hide for a while. Cheers, Gene -- There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order. -Ed Howdershelt (Author) My web page: http://coyoteden.dyndns-free.com:85/gene is up! My views http://www.armchairpatriot.com/What%20Has%20America%20Become.shtml You stay here, Audrey -- this is between me and the vegetable! -- Seymour, from _Little Shop Of Horrors_ I was taught to respect my elders, but its getting harder and harder to find any... -- http://mail.python.org/mailman/listinfo/python-list
Re: Python SUDS issue
Hi, Typing URL in the browser displays document tree as a web page. Is it right or there is something wrong with it ? Regards, VGNU On Mon, Mar 4, 2013 at 6:45 PM, Joel Goldstick joel.goldst...@gmail.comwrote: On Mon, Mar 4, 2013 at 5:37 AM, VGNU Linux vgnuli...@gmail.com wrote: Hi Guys, I am pretty new to web services. After some googling found that python suds is a suitable module to create web service client. I am trying to create a client but its giving me an error which is quite confusing for me. Here is my code: from suds.client import Client wsdlurl = 'https://46.51.221.138/PBExternalServices/v1/soap?wsdl' What happens when you type this in your browser: https://46.51.221.138/PBExternalServices/v1/soap?wsdl client = Client(wsdlurl) print client And following is the error that occurs on trying to print client. Traceback (most recent call last): File trysuds.py, line 3, in module client = Client(wsdlurl) File C:\Python25\Lib\site-packages\suds\client.py, line 112, in __init__ self.wsdl = reader.open(url) File C:\Python25\Lib\site-packages\suds\reader.py, line 152, in open d = self.fn(url, self.options) File C:\Python25\Lib\site-packages\suds\wsdl.py, line 159, in __init__ self.build_schema() File C:\Python25\Lib\site-packages\suds\wsdl.py, line 220, in build_schema self.schema = container.load(self.options) File C:\Python25\Lib\site-packages\suds\xsd\schema.py, line 95, in load child.dereference() File C:\Python25\Lib\site-packages\suds\xsd\schema.py, line 323, in dereference midx, deps = x.dependencies() File C:\Python25\Lib\site-packages\suds\xsd\sxbasic.py, line 469, in dependencies raise TypeNotFound(self.ref) suds.TypeNotFound: Type not found: '(GetAccountBalanceFaultResponse, http://www.payback.net/lmsglobal/xsd/v1/types, )' Appreciate your help. Thanks in advance, VGNU -- http://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com -- http://mail.python.org/mailman/listinfo/python-list
Pythonic way for retrieving value for a nested dictionary.
For a typical dict: i.e. d = { '1': 'a', '2', 'b' } I might use something like: d.get('1', None) To get the value of 1. What would be the most pythonic way of getting a nested value of a dictionary within a list: some_list = [{ 'item': { 'letter': 'b', 'word': 'bar' }}, { 'item': { 'letter': 'c', 'word': 'charcoal' }}] Currently I am looping through the list as such: for item in some_list: print item['item']['letter'] One other method explored was: item.get('item').get('letter') Is a double get the best way? Doesn't seem right to me. Thank you in advance for your help -- http://mail.python.org/mailman/listinfo/python-list
Re: Python SUDS issue
VGNU Linux vgnuli...@gmail.com writes: ... Here is my code: from suds.client import Client wsdlurl = 'https://46.51.221.138/PBExternalServices/v1/soap?wsdl' client = Client(wsdlurl) print client And following is the error that occurs on trying to print client. Traceback (most recent call last): ... dereference midx, deps = x.dependencies() File C:\Python25\Lib\site-packages\suds\xsd\sxbasic.py, line 469, in dependencies raise TypeNotFound(self.ref) suds.TypeNotFound: Type not found: '(GetAccountBalanceFaultResponse, http://www.payback.net/lmsglobal/xsd/v1/types, )' Looks like a bug in the WSDL description of the web service. It seems to reference a type GetAccountBalanceFaultResponse associated with the namespace http://www.payback.net/lmsglobal/xsd/v1/types;, but suds cannot find the type. Maybe an import is missing in the WSDL description. -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic way for retrieving value for a nested dictionary.
On 03/05/2013 01:48 AM, Lowly Minion wrote: For a typical dict: i.e. d = { '1': 'a', '2', 'b' } I might use something like: d.get('1', None) To get the value of 1. What would be the most pythonic way of getting a nested value of a dictionary within a list: some_list = [{ 'item': { 'letter': 'b', 'word': 'bar' }}, { 'item': { 'letter': 'c', 'word': 'charcoal' }}] Currently I am looping through the list as such: for item in some_list: print item['item']['letter'] One other method explored was: item.get('item').get('letter') Is a double get the best way? Doesn't seem right to me. Thank you in advance for your help I'm not sure what the puzzle is. Use [key] if you know the key exists, and use get( key, default) if you don't. But be aware that if the first key doesn't exist, then the default had better be a dict (rather than something like None), or the second lookup will throw an exception, even if you use get. One other possibility, depending on just what you're doing with the data, is to wrap it in a try/catch. However, if you know exactly what the keys are, perhaps you should use a namedtuple instead of a dict. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding a for inside an html template for substitution
Τη Δευτέρα, 4 Μαρτίου 2013 5:14:00 μ.μ. UTC+2, ο χρήστης Νίκος Γκρ33κ έγραψε: Hello pythonistas! I'am tryign to populate a table with dictionary keys and values: Foe that iam using an html template and the questions is what i should write inside 'files.html' so then then the python script populate the table. table trthSuperHost - Economy/th/tr trtdΧώρος στο δίσκο: 1 GB/td/tr trtdΜηνιαία Κίνηση δεδομένων: 1 GB/td/tr trtdControl Panel: cPanel 11 Fantastico Deluxe/td/tr trtdDomains: 1/td/tr trtdSubdomains: 1/td/tr trtdFTP Accounts: 1/td/tr trtdEmails (POP3): 2/td/tr trtdWebMail: [ RoundCube|Horde|Squirrel ]: ΝΑΙ/td/tr trtdMysql Databases: 2/td/tr /table Instead of writing the above html data inside my html template how would i write it with a for that then will be substituted by the python script? can you please write an example for me that user files.html and gets populates by files.py ? i want os ee how it lloks like please! Thank you. Thank you Michael, i have decided to use cheetahtemplate. It seems nice and simple, djanfo indeed is an overkill for me needs. -- http://mail.python.org/mailman/listinfo/python-list
[issue17328] Fix reference leak in dict_setdefault() in case of resize failure
Serhiy Storchaka added the comment: LGTM. This is 3.3+ only issue as far as I understand. -- nosy: +benjamin.peterson versions: -Python 2.6, Python 2.7, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17328 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17345] Portable and extended type specifiers for array module
New submission from Nikita Nemkin: Currently array module only provides platform-dependent type specifiers. It would be very nice to have platform-independent specifiers in addition to that, matching the struct module. For example array('H') - an array of little-endian 2-byte integers. This issue crops up every time when I use array(). Binary data usually comes in some predefined format and a manual matching to native format has to be done (assuming I want to write portable code). A useful extra would be to support multi-element struct specifiers and present an array of tuples in this case. For example array('iff') - an array of tuples (int, float, float) with native types. -- components: Library (Lib) messages: 183425 nosy: nnemkin priority: normal severity: normal status: open title: Portable and extended type specifiers for array module type: enhancement versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17345 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17278] SIGSEGV in _heapqmodule.c
Changes by Raymond Hettinger raymond.hettin...@gmail.com: -- Removed message: http://bugs.python.org/msg183401 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17278 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17278] SIGSEGV in _heapqmodule.c
Raymond Hettinger added the comment: Antoine, thanks for the patch. This looks like a reasonable solution that is fast and prevents segfaults. -- assignee: rhettinger - pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17278 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15216] Support setting the encoding on a text stream after creation
Nick Coghlan added the comment: That's a fair point - I think it's acceptable to throw an error in the case of *already decoded* characters that haven't been read. There's also a discussion on python-ideas about an explicit API for clearing the internal buffers, and pushing data back into a stream. If that is added, then set_encoding() would be free to error out if there was any already buffered data - it would be up to the application to call clear_buffer() before calling set_encoding(), and deal with an such data appropriately (such as calling push_data() with the results of the clear_buffer() call) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15216 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15216] Support setting the encoding on a text stream after creation
Nick Coghlan added the comment: Oops, meant to link to my post in the thread about a buffer manipulation API: http://mail.python.org/pipermail/python-ideas/2013-March/019769.html -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15216 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17346] Pickle tests do not test protocols 0, 1, and 2 for bytes
New submission from Marius Gedminas: I was reading Lib/test/pickletester.py when I noticed that test_bytes loops over all the protocols but doesn't actually use the loop variable anywhere. Attached patch should fix this. -- components: Tests files: actually-test-all-protocols.diff keywords: patch messages: 183429 nosy: mgedmin priority: normal severity: normal status: open title: Pickle tests do not test protocols 0, 1, and 2 for bytes type: behavior versions: Python 3.3 Added file: http://bugs.python.org/file29302/actually-test-all-protocols.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17346 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17346] Pickle tests do not test protocols 0, 1, and 2 for bytes
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti stage: - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17346 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17347] bsddb._openDBEnv() should not touch current directory
New submission from Florian Weimer: This code: def _openDBEnv(cachesize): e = db.DBEnv() if cachesize is not None: if cachesize = 20480: e.set_cachesize(0, cachesize) else: raise error, cachesize must be = 20480 e.set_lk_detect(db.DB_LOCK_DEFAULT) e.open('.', db.DB_PRIVATE | db.DB_CREATE | db.DB_THREAD | db.DB_INIT_LOCK | db.DB_INIT_MPOOL) return e causes Berkeley DB to read the DB_CONFIG file from the current directory, which may have unexpected side effects. Unfortunately, Berkeley DB still reads ./DB_CONFIG even if the first argument to DBEnv.open() is None/NULL, so the only way to suppress this behavior seems a non-existing or known-to-by-empty directory (such as /var/empty). -- components: Extension Modules messages: 183430 nosy: fweimer priority: normal severity: normal status: open title: bsddb._openDBEnv() should not touch current directory type: behavior versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17347 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17348] Unicode - encoding seems to be lost for inputs of unicode chars
New submission from Pradyun Gedam: In IDLE, I have spotted a peculiar problem. I have attached an .png file which is a screen capture of 'session' on IDLE. It seems that the Unicode character that has been input, loses its encoding. My 'session' Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32 Type copyright, credits or license() for more information. c = u'€' ord(c) 128 c.encode('utf-8') '\xc2\x80' c u'\x80' print c c = u'\u20ac' ord(c) 8364 c.encode('utf-8') '\xe2\x82\xac' c u'\u20ac' print c € -- components: IDLE messages: 183431 nosy: Pradyun.Gedam priority: normal severity: normal status: open title: Unicode - encoding seems to be lost for inputs of unicode chars versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17348 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17347] bsddb._openDBEnv() should not touch current directory
Jesús Cea Avión added the comment: This is a standard Berkeley DB behavior. Can I suggest you to report this issue to Oracle forums? http://docs.oracle.com/cd/E17276_01/html/programmer_reference/env_db_config.html https://forums.oracle.com/forums/forum.jspa?forumID=271 Closing as invalid. if you disagree, please reopen. -- nosy: +jcea resolution: - invalid stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17347 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16620] Avoid using private function glob.glob1() in msi module and tools
Serhiy Storchaka added the comment: I have added some comments on Rietveld. Note that glob.glob() and glob.glob1() returns different filenames. The first returns full paths and the second returns bare filenames without a directory path. Workarounding this may require more in-depth changes to the code. Actually this is a low priority issue. It is no so bad to use private functions from other modules inside Python stdlib. But it can be a bad example for a third party code. -- components: +Windows priority: normal - low ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16620 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13598] string.Formatter doesn't support empty curly braces {}
Phil Elson added the comment: I didn't see a test case relating to the example in his comment, namely f.format({0:{}}, 'foo', 5) Did I miss it? The example should fail, which it wouldn't have done with the patch previously proposed. I believe the case is covered by the block: with self.assertRaises(ValueError): fmt.format(foo{1}{}, bar, 6) Though there is no harm in adding another test along the lines of: with self.assertRaises(ValueError): fmt.format({0:{}}, bar, 6) If you think it is worthwhile? I'm uncertain which documentation to update since the method which has had its signature updated is private and is called solely by Formatter.vformat . Cheers, -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13598 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17299] Test cPickle with real files
Serhiy Storchaka added the comment: I have added comments on Rietveld. Perhaps it will be worth to create mixings for cStringIO.StringIO, BytesIO and file object and then mix them to other tests. Note that there is no sense to change pure Python pickle tests. Python implementation uses the same code for all streams. It's C implementation needs specialized tests (in Lib/test/test_cpickle.py). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17299 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17299] Test cPickle with real files
Serhiy Storchaka added the comment: David, yes, this is 2.7 only issue. The code was broken recently (see msg182979 in issue13555) due to insufficient testing. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17299 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17349] wsgiref.simple_server.demo_app is not PEP-3333 compatible
New submission from Andrey Lebedev: Under certain circumstances, wsgiref.simple_server.demo_app may return unicode data, but that is prohibited by PEP-. This happens if environ with unicode key is passed to demo_app. Unicode keys are then written to StringIO instance, automatically making its value unicode. Type of environ keys is not strictly mandated by PEP-, however output of WSGI application is: When called by the server, the application object must return an iterable yielding zero or more bytestrings., see http://www.python.org/dev/peps/pep-/#specification-details Test case is attached. -- components: Library (Lib) files: wsgirefbug.py messages: 183437 nosy: Andrey.Lebedev priority: normal severity: normal status: open title: wsgiref.simple_server.demo_app is not PEP- compatible type: behavior versions: Python 2.7 Added file: http://bugs.python.org/file29303/wsgirefbug.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17349 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17346] Pickle tests do not test protocols 0, 1, and 2 for bytes
Serhiy Storchaka added the comment: LGTM. -- nosy: +serhiy.storchaka versions: +Python 3.2, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17346 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16851] Hint about correct ismethod and isfunction usage
Thomas Kluyver added the comment: I agree that the docs for inspect.ismethod() for Python 2 are wrong. The docs say: Return true if the object is a bound method written in Python. However, it also returns True for an unbound method: class A: ... def meth(self): ... pass ... A.meth unbound method A.meth import inspect inspect.ismethod(A.meth) True -- nosy: +takluyver ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16851 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17094] sys._current_frames() reports too many/wrong stack frames
Stefan Ring added the comment: When I originally worked on this, I noticed that _PyThread_CurrentFrames also iterates over all interpreters. Because I have no experience with or use for multiple interpreters, I intentionally left it out of my patch, but shouldn't it be taken into account for a real patch? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17094 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1124861] subprocess fails on GetStdHandle in interactive GUI
Tomgu added the comment: Here I get one problem need help. In python 2.7.5 version I write a script test.py as below ### import subprocess fileID=file('test1.log','w') process_response = subprocess.call('netsh wlan show\ interface',stdout=fileID,shell=True) fileID.flush() fileID.close() ### It run in windows7 os MSDOS console is OK and I try to run it in STAF command C:\ STAF local PROCESS START COMMAND python C:\test.py WAIT STDERRTOSTDOUT RETURNSTDOUT Response { Return Code: 1 Key: None Files : [ { Return Code: 0 Data : Traceback (most recent call last): File C:\test.py, line 3, in module process_response = subprocess.call('netsh wlan show interface',stdout=fileID ,shell=True) File C:\Python27\lib\subprocess.py, line 493, in call return Popen(*popenargs, **kwargs).wait() File C:\Python27\lib\subprocess.py, line 672, in __init__ errread, errwrite) = self._get_handles(stdin, stdout, stderr) File C:\Python27\lib\subprocess.py, line 784, in _get_handles p2cread = self._make_inheritable(p2cread) File C:\Python27\lib\subprocess.py, line 823, in _make_inheritable _subprocess.DUPLICATE_SAME_ACCESS) WindowsError: [Error 6] The handle is invalid } ] I just start to learn python, I dont know how to resolve, need help. -- nosy: +gwtking type: - compile error versions: +Python 2.7 -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1124861 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1124861] subprocess fails on GetStdHandle in interactive GUI
Tomgu added the comment: Update, the python version is '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]' -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1124861 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16382] Better warnings exception for bad category
Phil Elson added the comment: Ok. I think I've done all of the actions from the reviews. I'm not sure if I should remove the old patches or not? Thanks, -- Added file: http://bugs.python.org/file29304/pelson_warnings_fix_4.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16382 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17350] Use STAF call python script will case 1124861 issue in 2.7.2 version
New submission from Tomgu: Here I get one problem use STAF call python and need help. In python 2.7.2 version I write a script test.py as below ### import subprocess fileID=file('test1.log','w') process_response = subprocess.call('netsh wlan show\ interface',stdout=fileID,shell=True) fileID.flush() fileID.close() ### It run in windows7 os MSDOS console is OK and I try to run it in STAF command C:\ STAF local PROCESS START COMMAND python C:\test.py WAIT STDERRTOSTDOUT RETURNSTDOUT Response { Return Code: 1 Key: None Files : [ { Return Code: 0 Data : Traceback (most recent call last): File C:\test.py, line 3, in module process_response = subprocess.call('netsh wlan show interface',stdout=fileID ,shell=True) File C:\Python27\lib\subprocess.py, line 493, in call return Popen(*popenargs, **kwargs).wait() File C:\Python27\lib\subprocess.py, line 672, in __init__ errread, errwrite) = self._get_handles(stdin, stdout, stderr) File C:\Python27\lib\subprocess.py, line 784, in _get_handles p2cread = self._make_inheritable(p2cread) File C:\Python27\lib\subprocess.py, line 823, in _make_inheritable _subprocess.DUPLICATE_SAME_ACCESS) WindowsError: [Error 6] The handle is invalid } ] Like known issue 1124861. I just start to learn python, I dont know how to resolve, need help. -- messages: 183444 nosy: gwtking priority: normal severity: normal status: open title: Use STAF call python script will case 1124861 issue in 2.7.2 version type: crash versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17350 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17094] sys._current_frames() reports too many/wrong stack frames
Stefan Ring added the comment: (Regarding your test) I have also noticed in the past that joining threads after a fork has caused hangs occasionally, although that might have resulted from the messed up _current_frames. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17094 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15866] encode(..., 'xmlcharrefreplace') produces entities for surrogate pairs
Serhiy Storchaka added the comment: I prefer a little different (simpler for me) form: for (p = collstart; p collend;) { Py_UCS4 ch = *p++; if ((0xD800 = ch ch = 0xDBFF) (p collend) (0xDC00 = *p *p = 0xDFFF)) { ch = ch 0x03FF) 10) | ((Py_UCS4)*p++ 0x03FF)) + 0x1); } str += sprintf(str, #%d;, (int)ch); } And please look at the loop above (determine replacement size). It should be corrected too. It will be simpler to use a buffer with static size (``char buffer[2+29+1+1];``) as in charmap encoder. Perhaps charmap encoder should be fixed too (and common code extracted to separate function). I doubt about '\ud83d\udc9d' on wide build. Is it right to encode it as b'#128157;' and not as b'#55357;#56477;'? This will be compatible with narrow build but will break compatibility with 3.3+. What is less evil? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15866 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11787] File handle leak in TarFile lib
Serhiy Storchaka added the comment: Actually it was fixed in issue16477. ;) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11787 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17346] Pickle tests do not test protocols 0, 1, and 2 for bytes
Roundup Robot added the comment: New changeset a982feb29584 by Ezio Melotti in branch '3.2': #17346: make sure pickle tests are run against all protocols. Initial patch by Marius Gedminas. http://hg.python.org/cpython/rev/a982feb29584 New changeset 796de4f7df07 by Ezio Melotti in branch '3.3': #17346: merge with 3.2. http://hg.python.org/cpython/rev/796de4f7df07 New changeset 5c8a5cfe25b0 by Ezio Melotti in branch 'default': #17346: merge with 3.3. http://hg.python.org/cpython/rev/5c8a5cfe25b0 New changeset 654136546895 by Ezio Melotti in branch '2.7': #17346: make sure pickle tests are run against all protocols. http://hg.python.org/cpython/rev/654136546895 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17346 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17346] Pickle tests do not test protocols 0, 1, and 2 for bytes
Ezio Melotti added the comment: Fixed, thanks for the report and the patch! -- assignee: - ezio.melotti resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17346 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16997] subtests
Nick Coghlan added the comment: I think I have figured out what bothers me about the expectedfailure changes, and they actually relate to how expectedfailure was implemented in the first place: I had previously assumed that decorator was an *annotating* decorator - that it set an attribute on the function to indicate it was expected to fail, and the test execution machinery then took that into account when deciding how to interpret the test result. The fact that it is instead a *wrapping* decorator is what made the addition of subtest support far more complicated than I expected. However, I'm wondering if it might still be possible to avoid the need for a thread local context to handle the combination of expected failures and subtests when we have access to the test caseby adding the annotation that I expected to be there in the first place. Can't we: 1. Update the expectedfailure decorator to also set _expecting_failure = True on the wrapped test case function 2. Update unittest.TestCase.__init__ to do: self._expecting_failure = hasattr(testMethod, '__func__') and getattr(testMethod.__func__, '_expecting_failure', False) 3. Update unittest._SubTest.__init__ to do: self._expecting_failure = test_case._expecting_failure 4. Update testPartExecutor to check if test_case._expecting_failure: instead of the current check of the thread local context -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16997 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17322] urllib.request add_header() currently allows trailing spaces (and other weird stuff)
R. David Murray added the comment: A crazy idea that occurred to me was to create an rfc822-style-header management module, and share it between email, http, and urllib. We'd probably break too many things backward-compatibility wise if we did that, but I still think it is an interesting thought :) On the other hand, having thought about this particular issue some more: in the email package we have the constraint of needing to be able to exactly reproduce the input data, whereas in the http world that constraint does not apply. So in the http world, given that headers are *already* being transformed by the code in question (title casing), it seems reasonable that blank stripping also be done, even just from an API standpoint. Really I guess the only question is how likely this is to break existing code. I'm pretty sure it is small enough that doing this in 3.4 would be fine, but I don't know how to estimate if it is small enough to also change it in maintenance releases. Since this particular bit is a new standard, maybe we just go with 3.4? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17322 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16997] subtests
Michael Foord added the comment: Getting rid of the thread local would be an improvement, and the change to how expected failures is done sounds good too. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16997 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13598] string.Formatter doesn't support empty curly braces {}
Vinay Sajip added the comment: I believe the case is covered by the block: [snip] Ah, right. I wasn't sure that was the exact same code path that was being exercised. But I didn't look very closely. If you think it is worthwhile? Only if it exercises a different code path. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13598 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16997] subtests
Antoine Pitrou added the comment: However, I'm wondering if it might still be possible to avoid the need for a thread local context to handle the combination of expected failures and subtests when we have access to the test caseby adding the annotation that I expected to be there in the first place. But that would break use cases where you use @expectedFailure on a function called by the test method, not directly on the test method itself. I don't really care about those use cases myself, but not breaking them is the reason I chose not to change the @expectedFailure implementation. I'll let Michael decide :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16997 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10590] Parameter type error for xml.sax.parseString(string, ...)
Serhiy Storchaka added the comment: Low-level part already extracted to issue17089 and committed. Issue16986 has a similar patch for cElementTree. The main part of path was moved to issue2175 which is now pre-requisite for issue16986 and for this issue. It contains additional tests and additional fixes. It is hard and little sense to split them on separated patches. Let's move the discussion to issue2175. And then the patch for this issue will be small and simple, only several lines and one test. At least this issue is less important and actually can be considered as a new feature. -- stage: patch review - needs patch type: behavior - enhancement versions: -Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10590 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10590] Parameter type error for xml.sax.parseString(string, ...)
Changes by Serhiy Storchaka storch...@gmail.com: Removed file: http://bugs.python.org/file28757/sax_parse.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10590 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16986] ElementTree incorrectly parses strings with declared encoding not UTF-8
Serhiy Storchaka added the comment: Eli, this issue no longer has open pre-requisites. Issue10590 was replaced by issue17089 which closed now. Issue17089 fixed Python interface to expat parser, but cElementTree uses C interface of expat directly and the proposed pathes fix it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16986 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10590] Parameter type error for xml.sax.parseString(string, ...)
Eli Bendersky added the comment: Serhiy, OK - I'll look at #2175 first. But yes, Christian is right, let's wait for the security issues to be resolved first. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10590 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com