Re: Why isn't my re.sub replacing the contents of my MS Word file?
Le mardi 13 mai 2014 22:26:51 UTC+2, MRAB a écrit : On 2014-05-13 20:01, scottca...@gmail.com wrote: On Tuesday, May 13, 2014 9:49:12 AM UTC-4, Steven D'Aprano wrote: You may have missed my follow up post, where I said I had not noticed you were operating on a binary .doc file. If you're not willing or able to use a full-blown doc parser, say by controlling Word or LibreOffice, the other alternative is to do something quick and dirty that might work most of the time. Open a doc file, or multiple doc files, in a hex editor and *hopefully* you will be able to see chunks of human-readable text where you can identify how en-dashes and similar are stored. I created a .doc file and opened it with UltraEdit in binary (Hex) mode. What I see is that there are two characters, one for ndash and one for mdash, each a single byte long. 0x96 and 0x97. So I tried this: fStr = re.sub(b'\0x96',b'-',fStr) that did nothing in my file. So I tried this: fStr = re.sub(b'0x97',b'-',fStr) which also did nothing. So, for fun I also tried to just put these wildcards in my re.findall so I added |Part \0x96|Part \0x97to no avail. Obviously 0x96 and 0x97 are NOT being interpreted in a re.findall or re.sub as hex byte values of 96 and 97 hexadecimal using my current syntax. So here's my question...if I want to replace all ndash or mdash values with regular '-' symbols using re.sub, what is the proper syntax to do so? Thanks! 0x96 is a hexadecimal literal for an int. Within a string you need \x96 (it's \x for 2 hex digits, \u for 4 hex digits, \U for 8 hex digits). b'0x61' == b'0x61' True b'0x96' == b'\x96' False - Python and the coding of characters is an unbelievable mess. - Unicode a joke. - I can make Python failing with any valid sequence of chars I wish. - There is a difference between look, my code work with my chars and this code is safely working with any chars. jmf -- https://mail.python.org/mailman/listinfo/python-list
Re: Need help to write data onto an XML file after reading data from another xml file
I try to add an edge with the source id and destination id over a loop but this is the error I am getting. And the range for the for addEdge is something I have no clue about. python export.py --output topology.xml --xml germany50.xml Traceback (most recent call last): File export.py, line 239, in module main(sys.argv[1:]) File export.py, line 234, in main network.addEdge( PHY_LINKS( j , sourcen, destnn, sid, did, cap_bdw) ) File /home/srva/Approach_Read.py, line 89, in addEdge self.nodes[ edge.SourceID ].addInEdge( edge ) IndexError: list index out of range Thank You -- https://mail.python.org/mailman/listinfo/python-list
Re: Fortran
On Wed, 14 May 2014 07:35:35 +0300, Marko Rauhamaa wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: On Tue, 13 May 2014 22:57:16 +0300, Marko Rauhamaa wrote: Producing an effective JIT for Python seems like a formidable challenge but not impossible in principle. Or in practice. http://pypy.org/ I'm having a hard time finding information on how well it performs wrt Java, for example. Did PyPy truly find the Philosophers' Stone? I don't understand your question. PyPy doesn't do anything with Java. In principle you could use PyPy's underlying toolchain to build a Java compiler, similar to the Python, Prolog and PHP compilers already made, but nobody has done so for Java so far as I know. http://morepypy.blogspot.com.au/2012/07/hello-everyone.html Or do you mean, how does PyPy compare with insert name of Java compiler here? I don't know. There are some old benchmarks here: http://attractivechaos.wordpress.com/2011/04/25/my-programming-language- benchmarks-plb/ but the person doing the benchmarks is by his own admission not a skilled Python programmer. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything you did not want to know about Unicode in Python 3
Le mardi 13 mai 2014 10:08:45 UTC+2, Johannes Bauer a écrit : On 13.05.2014 03:18, Steven D'Aprano wrote: Armin Ronacher is an extremely experienced and knowledgeable Python developer, and a Python core developer. He might be wrong, but he's not *obviously* wrong. He's correct about file name encodings. Which can be fixed really easily wihtout messing everything up (sys.argv binary variant, open accepting binary filenames). But that he suggests that Go would be superior: Which uses an even simpler model than Python 2: everything is a byte string. The assumed encoding is UTF-8. End of the story. Is just a horrible idea. An obviously horrible idea, too. Having dealt with the UTF-8 problems on Python2 I can safely say that I never, never ever want to go back to that freaky hell. If I deal with strings, I want to be able to sanely manipulate them and I want to be sure that after manipulation they're still valid strings. Manipulating the bytes representation of unicode data just doesn't work. And I'm very very glad that some people felt the same way and implemented a sane, consistent way of dealing with Unicode in Python3. It's one of the reasons why I switched to Py3 very early and I love it. Cheers, Johannes -- Wo hattest Du das Beben nochmal GENAU vorhergesagt? Zumindest nicht öffentlich! Ah, der neueste und bis heute genialste Streich unsere großen Kosmologen: Die Geheim-Vorhersage. - Karl Kaos über Rüdiger Thomas in dsa hidbv3$om2$1...@speranza.aioe.org === A Rob 'Commander' Pike will never put utf16 and ebcdic in the same basket, when discussing coding of characters. jmf -- https://mail.python.org/mailman/listinfo/python-list
Re: SQLAlchemy - web framework ?
One of the main parts that is tripping myself up is that I need to consistently import xml files into my database. Looking to find the best support and methodologies to do this, that is one of the reasons I am looking at SqlAlchemy. Sayth -- https://mail.python.org/mailman/listinfo/python-list
Re: SQLAlchemy - web framework ?
flebber flebber.c...@gmail.com writes: One of the main parts that is tripping myself up is that I need to consistently import xml files into my database. XML documents represent a hierarchical tree of data. Relational databases are not good at representing hierarchical documents. So I don't know what you mean by “consistently import xml files into my database”. What are you expecting the result to be? You won't have sensible relational records as a result. At best, you'll have XML blobs in single SQL fields. Looking to find the best support and methodologies to do this, that is one of the reasons I am looking at SqlAlchemy. I've asked you about using Django with SQLAlchemy; it's not clear why you don't think that is suitable. So I have the same question: What makes you think a database API is going to solve the problem, and what makes you think SQLAlchemy in particlar is the right solution? More generally: You appear to have already decided what the solution is, without making clear to us what the problem is. Advice is going to be mis-matched until you tell us more about what problem you're trying to solve. -- \ “The Way to see by Faith is to shut the Eye of Reason.” | `\—Benjamin Franklin | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Fortran
Steven D'Aprano st...@pearwood.info: On Wed, 14 May 2014 07:35:35 +0300, Marko Rauhamaa wrote: I'm having a hard time finding information on how well it performs wrt Java, for example. Did PyPy truly find the Philosophers' Stone? [...] do you mean, how does PyPy compare with insert name of Java compiler here? I don't know. There are some old benchmarks here: http://attractivechaos.wordpress.com/2011/04/25/my-programming-language- benchmarks-plb/ but the person doing the benchmarks is by his own admission not a skilled Python programmer. That's what I'm after. The answer from the page is: Java 1.7 2.6 67.1 6.8 13.4 6.7 314.8 PyPy 19.5 8.5 84.1 4.0 7.3 12.3 236.0 None of the benchmark tests seems all that relevant, but the one that comes closest to being interesting is Column 1: Sudoku. There, Java is an order of magnitude faster (1.7 s vs 19.5 s). When Python equals Java performance, Java will lose its raison-d'être. Marko -- https://mail.python.org/mailman/listinfo/python-list
problems decoding json objects
Hi people! My JSON String: from json.decoder import JSONDecoder myjs = '{AVName:Tamer,ANName:Higazi,AAnschrift:Bauerngasse,AHausnr:1,APLZ:55116,AOrt:Mainz},{KontaktTel:[01234,11223344],{ZahlungsArt:0},{ZugangsDaten:[tamer.hig...@nomail.com,mypass]}' If I try to decode it, with: JSD = JSONDecoder() rsx = JSD.decode(myjs) I get this error message: JSD.decode(myjs) Traceback (most recent call last): File stdin, line 1, in module File /usr/lib64/python2.7/json/decoder.py, line 368, in decode raise ValueError(errmsg(Extra data, s, end, len(s))) ValueError: Extra data: line 1 column 108 - line 1 column 220 (char 107 - 219) How do I solve this problem ?! For any help, thanks Tamer -- https://mail.python.org/mailman/listinfo/python-list
Re: problems decoding json objects
Tamer Higazi th9...@googlemail.com writes: myjs = '{AVName:Tamer,ANName:Higazi,AAnschrift:Bauerngasse,AHausnr:1,APLZ:55116,AOrt:Mainz},{KontaktTel:[01234,11223344],{ZahlungsArt:0},{ZugangsDaten:[tamer.hig...@nomail.com,mypass]}' That's not a valid JSON document. See URL:http://json.org/. You appear to have three documents in a row, separated by commas. Or one malformed document, missing its enclosure. Or something else; that's the trouble with a malformed document, we don't know what it should be. I get this error message: JSD.decode(myjs) Traceback (most recent call last): File stdin, line 1, in module File /usr/lib64/python2.7/json/decoder.py, line 368, in decode raise ValueError(errmsg(Extra data, s, end, len(s))) ValueError: Extra data: line 1 column 108 - line 1 column 220 (char 107 - 219) Right. The document ends there, and the rest of the string is trailing garbage, which is an error. How do I solve this problem ?! Fix the document. Where did it come from? Best, don't put it directly in the Python source code as a string. Ideally, have it as a distinct file, which you can examine in a text editor with JSON highlighting; and run separately through a JSON parser for correctness. -- \ “Isn't it enough to see that a garden is beautiful without | `\ having to believe that there are fairies at the bottom of it | _o__) too?” —Douglas Adams | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
RE: Exception problem with module
I see that you've solved your immediate problem, but you shouldn't call __setattr__ directly. That should actually be written setattr(bar, 'a_new_name', MyError) But really, since bar is (apparently) a module, and it is *bar itself* setting the attribute, the better way is a_new_name = MyError or even from module.foo import MyError as a_new_name Well I am not sure what advantage this has for the user, not my code as I don't advocate the import to begin with it, its fine spelled as it was from where it was... I'll look back at this and see if that resolves the issue as it had manifested. jlc -- https://mail.python.org/mailman/listinfo/python-list
Re: problems decoding json objects
On Wed, May 14, 2014 at 3:36 AM, Tamer Higazi th9...@googlemail.com wrote: myjs = '{AVName:Tamer,ANName:Higazi,AAnschrift:Bauerngasse,AHausnr:1,APLZ:55116,AOrt:Mainz},{KontaktTel:[01234,11223344],{ZahlungsArt:0},{ZugangsDaten:[tamer.hig...@nomail.com,mypass]}' Following up on Ben's comment, what did you expect? With my Python hat on, I'd say you've got a string representing a tuple of four dictionaries, though my human brain can see past the missing '}' which is supposed to close the second dict. If you add that, it's still not valid JSON (I guess JSON doesn't have tuples). This stuff isn't meant to be typed by humans. Instead computers are supposed to barf it out and munch on it. As Ben indicated, putting it in a string is pointless. Might as well just define the dictionaries yourself. not-gonna-mention-eval-ly, y'rs Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: problems decoding json objects
Ben Finney b...@benfinney.id.au writes: Tamer Higazi th9...@googlemail.com writes: How do I solve this problem ?! Fix the document. Where did it come from? If you're the one typing raw JSON into your program: Fix that. Don't type raw JSON. JSON is an object serialisation format; it's foolish to type it yourself. You should only be generating it from a known-debugged JSON library, or reading it as input from some other generator. If you want to define an object in a Python literal, type Python code. Skip Montanaro s...@pobox.com writes: This stuff isn't meant to be typed by humans. Instead computers are supposed to barf it out and munch on it. As Ben indicated, putting it in a string is pointless. It didn't even occur to me that the programmer would have typed this in manually. Good catch, Skip. -- \ “Why doesn't Python warn that it's not 100% perfect? Are people | `\ just supposed to “know” this, magically?” —Mitya Sirenef, | _o__) comp.lang.python, 2012-12-27 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
python3; ftplib: TypeError: Can't convert 'bytes' object to str implicitly
This is the code I run (python 3.3) host = ... user = ... passwd = ... from ftplib import FTP ftp = FTP(host, user, passwd) ftp.mkd(b'NewDir') ftp.rmd(b'NewDir') This is the traceback Traceback (most recent call last): File ftp-problem, line 9, in module ftp.mkd(b'NewDir') File /usr/lib/python3.3/ftplib.py, line 612, in mkd resp = self.voidcmd('MKD ' + dirname) TypeError: Can't convert 'bytes' object to str implicitly The problem is that I do something like this in a backup program. I don't know the locales that other people use. So I manipulate all file and directory names as bytes. Am I doing something wrong? -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: New to Python. For in loops curiosity
In article 2f08e970-1334-4e7f-ba84-14869708a...@googlegroups.com, Leonardo Petry leonardo.petry...@gmail.com wrote: Basically my question is: Why is python not treating the contents of [a file] as one long string and looping each character? Because whoever designed the original file object decided that the right way to iterate over a file is line by line. In Python (although, at this level of explanation, I could be describing pretty much any language which has iterators), there is an iterator protocol which implements two ideas: 1) There's a method to call to get the next item. 2) There's a way for that method to signal that you've reached the end. Exactly what the next item means is up to whoever implements the iterator. In this case, it was decided that the most convenient thing would be for item to mean line. If you really want to iterate over a file character-by-character, it's easy enough to write an adapter. Something like this (untested): def getchar(f): for line in f: for c in line: yield c Of course, if the native file iterator was character-by-character, then if you wanted it line-by-line, you would have to write the inverse, a function which accumulates characters until it sees a newline, and then returns that. Neither one is fundamentally better, or more correct than the other. One may just be more convenient for a particular use case. -- https://mail.python.org/mailman/listinfo/python-list
Re: problems decoding json objects
In article mailman.9998.1400063958.18130.python-l...@python.org, Skip Montanaro s...@pobox.com wrote: I guess JSON doesn't have tuples JSON has sequences, which both Python lists and tuples serialize as (losing the distinction between them). In the other direction, JSON sequences typically unpack as lists, but I think that's just convention. There might be json packages which unpack them as tuples. -- https://mail.python.org/mailman/listinfo/python-list
Re: problems decoding json objects
On Wed, 14 May 2014 10:36:11 +0200, Tamer Higazi wrote: Hi people! My JSON String: from json.decoder import JSONDecoder myjs = '{AVName:Tamer,ANName:Higazi,AAnschrift:Bauerngasse,AHausnr:1,APLZ:55116,AOrt:Mainz}, {KontaktTel:[01234,11223344],{ZahlungsArt:0},{ZugangsDaten: [tamer.hig...@nomail.com,mypass]}' If I try to decode it, with: JSD = JSONDecoder() rsx = JSD.decode(myjs) I get this error message: JSD.decode(myjs) Traceback (most recent call last): File stdin, line 1, in module File /usr/lib64/python2.7/json/decoder.py, line 368, in decode raise ValueError(errmsg(Extra data, s, end, len(s))) ValueError: Extra data: line 1 column 108 - line 1 column 220 (char 107 - 219) How do I solve this problem ?! For any help, thanks Try doing a manual inspection of your json string. It appears to contain several objects, but they're not contained within an outer object or an array. If you want a list of data objects, you need to put [] round them. If you want them to be dictionary elements, you need to wrap them with {} and put identifiers in. If you want a single dictionary, you need to remove most of the { and }. In addition, one of the objects doesn't appear to be terminated. {AVName:Tamer,ANName:Higazi,AAnschrift:Bauerngasse,AHausnr:1,APLZ:55116,AOrt:Mainz}, {KontaktTel:[01234,11223344] ** missing '}' ??? ** , {ZahlungsArt:0}, {ZugangsDaten:[tamer.hig...@nomail.com,mypass]} Depending how I correct the json string, I can create different values for rsx: (1) a list of 4 dictionaries: $ ./jsonerr.py [{u'APLZ': u'55116', u'ANName': u'Higazi', u'AHausnr': u'1', u'AVName': u'Tamer', u'AAnschrift': u'Bauerngasse', u'AOrt': u'Mainz'}, {u'KontaktTel': [u'01234', u'11223344']}, {u'ZahlungsArt': u'0'}, {u'ZugangsDaten': [u'tamer.hig...@nomail.com', u'mypass']}] (2) a single dictionary: $ ./jsonerr.py {u'APLZ': u'55116', u'KontaktTel': [u'01234', u'11223344'], u'ZugangsDaten': [u'tamer.hig...@nomail.com', u'mypass'], u'ANName': u'Higazi', u'AHausnr': u'1', u'AVName': u'Tamer', u'AAnschrift': u'Bauerngasse', u'AOrt': u'Mainz', u'ZahlungsArt': u'0'} (3) an object with 4 subsidiary objects: $ ./jsonerr.py {u'Misc data': {u'ZahlungsArt': u'0'}, u'Name and Addr': {u'APLZ': u'55116', u'ANName': u'Higazi', u'AHausnr': u'1', u'AVName': u'Tamer', u'AAnschrift': u'Bauerngasse', u'AOrt': u'Mainz'}, u'Login info': {u'ZugangsDaten': [u'tamer.hig...@nomail.com', u'mypass']}, u'Telephones': {u'KontaktTel': [u'01234', u'11223344']}} but I have no way of knowing which it is you require. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: problems decoding json objects
You are right! It was all alone my mistake which I recently figured out. Thanks for helping me. Tamer Am 14.05.2014 11:20, schrieb Ben Finney: Tamer Higazi th9...@googlemail.com writes: That's not a valid JSON document. See URL:http://json.org/. -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything you did not want to know about Unicode in Python 3
On Tue, 13 May 2014 10:08:42 -0600, Ian Kelly wrote: On Tue, May 13, 2014 at 5:19 AM, alister alister.nospam.w...@ntlworld.com wrote: I am only an amateur python coder which is why I asked if I am missing something I could not see any reason to be using the shutil module if all that the programm is doing is opening a file, reading it then printing it. is it python that causes the issue, the shutil module or just the OS not liking the data it is being sent? an explanation of why this approach is taken would be much appreciated. No, that part is perfectly fine. This is exactly what the shutil module is meant for: providing shell-like operations. Although in this case the copyfileobj function is quite simple (have yourself a look at the source -- it just reads from one file and writes to the other in a loop), in general the Pythonic thing is to avoid reinventing the wheel. And since it's so simple, it shouldn't be hard to see that the use of the shutil module has nothing to do with the Unicode woes here. The crux of the issue is that a general-purpose command like cat typically can't know the encoding of its input and can't assume anything about it. In fact, there may not even be an encoding; cat can be used with binary data. The only non-destructive approach then is to copy the binary data straight from the source to the destination with no decoding steps at all, and trust the user to ensure that the destination will be able to accommodate the source encoding. Because Python 3 presents stdin and stdout as text streams however, it makes them more difficult to use with binary data, which is why Armin sets up all that extra code to make sure his file objects are binary. I think I understand that in which case I owe Armin an apology, this certainly sounds like a failing in pythons handling of stdout -- Get it up, keep it up... LINUX: Viagra for the PC. -- Chris Abbey -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything you did not want to know about Unicode in Python 3
On Wed, 14 May 2014 10:08:57 +1000, Chris Angelico wrote: On Wed, May 14, 2014 at 9:53 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: With the current system, all of us here are technically violating copyright every time we reply to an email and quote more than a small percentage of it. Oh wow... so when someone quotes heaps of text without trimming, and adding blank lines, we can complain that it's a copyright violation - reproducing our work with unauthorized modifications and without permission... I never thought of it like that. ChrisA I think I could make a very strong case that anything sent to a public forum with the intention of being broadcast has been placed into the public domain by this action. -- Work expands to fill the time available. -- Cyril Northcote Parkinson, The Economist, 1955 -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything you did not want to know about Unicode in Python 3
On Wed, May 14, 2014 at 10:42 PM, alister alister.nospam.w...@ntlworld.com wrote: On Wed, 14 May 2014 10:08:57 +1000, Chris Angelico wrote: On Wed, May 14, 2014 at 9:53 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: With the current system, all of us here are technically violating copyright every time we reply to an email and quote more than a small percentage of it. Oh wow... so when someone quotes heaps of text without trimming, and adding blank lines, we can complain that it's a copyright violation - reproducing our work with unauthorized modifications and without permission... I never thought of it like that. ChrisA I think I could make a very strong case that anything sent to a public forum with the intention of being broadcast has been placed into the public domain by this action. I don't think so. One can reasonably assume that anything sent to a public forum is permissible to read, and to copy verbatim (although there may be presumed limits on the copying, but probably not with python-list). But if I quote your text and edit it, then you would rightly complain, which is not the case with public domain text. The question is whether or not it's fair to try to scare people with that when they repeatedly use buggy software that inserts blank lines everywhere :) In case it's not obvious, I am NOT seriously contemplating pursuing anything like this legally. It's just funny to contemplate. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything you did not want to know about Unicode in Python 3
On 05/13/2014 09:39 AM, Steven D'Aprano wrote: On Tue, 13 May 2014 07:20:34 -0400, Roy Smith wrote: ASCII *is* all I need. You've never needed to copyright something? Copyright © Roy Smith 2014... I know some people use (c) instead, but that actually has no legal standing. (Not that any reasonable judge would invalidate a copyright based on a technicality like that, not these days.) (c) has no standing whatsoever, as it's properly spelled (copr) -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: Need help to write data onto an XML file after reading data from another xml file
On 05/14/2014 02:49 AM, varun...@gmail.com wrote: I try to add an edge with the source id and destination id over a loop but this is the error I am getting. And the range for the for addEdge is something I have no clue about. python export.py --output topology.xml --xml germany50.xml Traceback (most recent call last): File export.py, line 239, in module main(sys.argv[1:]) File export.py, line 234, in main network.addEdge( PHY_LINKS( j , sourcen, destnn, sid, did, cap_bdw) ) File /home/srva/Approach_Read.py, line 89, in addEdge self.nodes[ edge.SourceID ].addInEdge( edge ) IndexError: list index out of range Thanks for posting a complete stack trace, it can be a real help. You still have not shown us the source code. Did you write it yourself, or are you just trying to debug something written by someone else? In particular, the exception occurs in Approach_Read.py. Is that your file, and can you edit it to ferret out the problem? Do you know what attributes are supposed to be of what types? I peaked; I actually took a look at your dropbox files. So I have some comments, though they may not help debug the problem. After all, there are hundreds of lines of code, First, you don't mention the Python version nor the OS you're using. Indirectly, I can surmise Python 2.7 and Linux, but it's much safer to declare such things in the problem descrition. Assuming 2.x, you're using old-style classes. While that might not be a bug, they've been obsolete for at least a decade. You need to derive each of your classes from object. So, you should have for example: class CplexSolver(object): next, you have way too few comments. I can't even tell why you put certain classes and functions in one file, versus others in another file. Next, you don't follow Pep8, or any other reasonable standard, for naming. Thus, I can't tell readily whether a particular name is a class name, an attribute, a method, or whatever. If the code were smaller, I might be willing to work it out, and make myself a crossref, but that's why you should simplify a problem you're asking for help with. If the code is 700 lines, few people are going to be willing to study it unless it's very well commented and easy to follow. You have a name PHY_NETWORK, which being all caps would indicate it's a const, but instead it's actually a class. It has a method addEdge(), which takes an argument edge. But it's not obvious to me what class that is, so I could look up its definition. If you don't know either, you could add a print type(edge) to that method, and see what gets printed just before it gets the exception. That field might happen to be of type PHY_LINKS, in which case we see the initializer has the line self.SourceID = SourceID Unfortunately, we don't know what class that's supposed to be. You're using it like it's an integer, and the integer is apparently outside the range of the list PHY_NETWORK.nodes So you could add a few more print statements, find out the len() of nodes, and the value of SourceID. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: Exception problem with module
On Wed, 14 May 2014 09:21:50 +, Joseph L. Casale wrote: I see that you've solved your immediate problem, but you shouldn't call __setattr__ directly. That should actually be written setattr(bar, 'a_new_name', MyError) But really, since bar is (apparently) a module, and it is *bar itself* setting the attribute, the better way is a_new_name = MyError or even from module.foo import MyError as a_new_name Well I am not sure what advantage this has for the user, not my code as I don't advocate the import to begin with it, its fine spelled as it was from where it was... The advantage for the user is: - it avoids module bar needing to get a reference to itself; - it avoids the distraction of unnecessarily calling a dunder method; - it is idiomatic Python code that should be instantly understandable by any even moderately experienced Python coder; - prevents the reader from puzzling over why the code does something so unusual (but why does he do this...?); - and avoids the inevitable anger and/or contempt when the reader works out that there is no good reason to write such unidiomatic code. One should code as if the next person who reads your program is an easily upset psychotic axe-murderer who knows where you live. You wouldn't condone writing y = x.__add__(1) instead of y = x + 1, you shouldn't condone writing module.__setattr__ directly either. I'll look back at this and see if that resolves the issue as it had manifested. I doubt it. Not unless module bar has done something weird, like define a function called __setattr__ that shadows the actual method and wraps the exception in another object. More likely, I think you'll find that the original MyError doesn't inherit from Exception. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Fortran
Marko Rauhamaa ma...@pacujo.net writes: Alain Ketterlin al...@dpt-info.u-strasbg.fr: The real nice thing that makes Julia a different language is the optional static typing, which the JIT can use to produce efficient code. It's the only meaningful difference with the current state of python. I'm guessing the two main performance roadblocks for Python are: 1. The dot notation is a hash table lookup instead of a fixed offset to a vector. 2. The creation of a class instance generates a set of trampolines for all methods. The trampolines are ordinary fields that can be overridden. Do you suggest this as a checklist to decide whether Python is the appropriate language for a task? (Do you really need any of these? If yes, use python.) Both features are critical to Python's sex appeal; I wouldn't give them up for performance gains. There are cases where performance matters (especially, when it is directly related to your electricity bill). Producing an effective JIT for Python seems like a formidable challenge but not impossible in principle. After all, the developer *could* provide that static typing information in, like, 99.9% of the code. Not 99% of the code; the code that runs 99% of the time. That would be feat worthy of a Millennium Technology Prize. Here is a fairly interesting blog post about what the WebKit developpers do for javascript (including profile-directed type inference, as they call it): https://www.webkit.org/blog/3362/introducing-the-webkit-ftl-jit/ -- Alain. -- https://mail.python.org/mailman/listinfo/python-list
Re: Exception problem with module
On Wed, May 14, 2014 at 11:08 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: One should code as if the next person who reads your program is an easily upset psychotic axe-murderer who knows where you live. You wouldn't condone writing y = x.__add__(1) instead of y = x + 1, you shouldn't condone writing module.__setattr__ directly either. Oddly enough, I was referencing that first half earlier this evening :) There's a difference between x.__add__(1) and x + 1, though. The latter might end up calling (1).__radd__(x), which (obviously) the first won't. I can imagine there might be some use-case where you specifically DON'T want the reflected method to be silently called (maybe for introspection or debugging??). But it falls under code smell, the sort of thing where you absolutely MUST have a comment - like where I have a call to set_foreground(bg), because that could so easily be an error, yet in this case isn't. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Why isn't my re.sub replacing the contents of my MS Word file?
On Tue, 13 May 2014 23:12:40 -0700, wxjmfauth wrote: Le mardi 13 mai 2014 22:26:51 UTC+2, MRAB a écrit : On 2014-05-13 20:01, scottca...@gmail.com wrote: On Tuesday, May 13, 2014 9:49:12 AM UTC-4, Steven D'Aprano wrote: You may have missed my follow up post, where I said I had not noticed you were operating on a binary .doc file. If you're not willing or able to use a full-blown doc parser, say by controlling Word or LibreOffice, the other alternative is to do something quick and dirty that might work most of the time. Open a doc file, or multiple doc files, in a hex editor and *hopefully* you will be able to see chunks of human-readable text where you can identify how en-dashes and similar are stored. I created a .doc file and opened it with UltraEdit in binary (Hex) mode. What I see is that there are two characters, one for ndash and one for mdash, each a single byte long. 0x96 and 0x97. So I tried this: fStr = re.sub(b'\0x96',b'-',fStr) that did nothing in my file. So I tried this: fStr = re.sub(b'0x97',b'-',fStr) which also did nothing. So, for fun I also tried to just put these wildcards in my re.findall so I added |Part \0x96|Part \0x97to no avail. Obviously 0x96 and 0x97 are NOT being interpreted in a re.findall or re.sub as hex byte values of 96 and 97 hexadecimal using my current syntax. So here's my question...if I want to replace all ndash or mdash values with regular '-' symbols using re.sub, what is the proper syntax to do so? Thanks! 0x96 is a hexadecimal literal for an int. Within a string you need \x96 (it's \x for 2 hex digits, \u for 4 hex digits, \U for 8 hex digits). b'0x61' == b'0x61' True b'0x96' == b'\x96' False - Python and the coding of characters is an unbelievable mess. - Unicode a joke. - I can make Python failing with any valid sequence of chars I wish. - There is a difference between look, my code work with my chars and this code is safely working with any chars. jmf 0x96 is not valid ASCII neither is it a valid unicode character in any encoding scheme I am familiar with it is therefore no surprise that python refuses to encode it it looks like this file is in ANSI - ISO-8859-1 regular expressions are probably overkill fro this issue loop through the byte array replace the bytes as needed. -- Under deadline pressure for the next week. If you want something, it can wait. Unless it's blind screaming paroxysmally hedonistic... -- https://mail.python.org/mailman/listinfo/python-list
Re: New to Python. For in loops curiosity
On 5/13/14 11:38 PM, Leonardo Petry wrote: Hi All, So I am starting with python and I have been working on some simple exercises. Here is something I found curious about python loops This loop run each character in a string def avoids(word,letters): flag = True for letter in letters: if(letter in word): flag = False return flag The loop below (at the bottom) runs each line of the file fin = open('wordplay.txt'); user_input = raw_input('Enter some characters: ') count = 0 for line in fin: word = line.strip() if(avoids(word, user_input)): count += 1; This is just too convenient. Basically my question is: Why is python not treating the contents of wordplay.txt as one long string and looping each character? Any comment is greatly appreciate. Thanks Every class can decide for itself how it will behave when iterated over (including deciding whether it can be iterated at all). File objects produce lines, strings produce characters, lists produce elements, dictionaries produce keys. Other objects do more exotic things. You might find this helpful: http://bit.ly/pyiter It's a PyCon talk all about iteration in Python, aimed at new learners. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Need help to write data onto an XML file after reading data from another xml file
That is a very descriptive post. Since its my first time programming I am not aware of many conventions that are being used to name classes. I tried to distinguish them by naming classes in caps. I borrowed some ideas from here and there to come up with the Approach_Read.py file. What I intend to do with that file is basically define classes. I have defined all the classes that are necessary for me. Now, the lower part of the file contains a function readXML or something which I am still working on but as of now it is not relevant. Second file would be the approach file which I have to use once I generate the xml file that I need to use. So, this brings me to the last file which is really messy. All I want to do in the export.py file is that I'd like to pull out some data from the xml file(from the SNDLib website for the sake of topology). Since this xml file contains the source, destination and some other relevant attributes, I read them out of it. Now, I want to use the class PHY_NETWORK to create this topology. The class consists of arguments nodes, edges, etc., Here to add edges between the nodes, I call the method addEdge from the class PHY_NETWORK. But when I do that I get this error 'unicode' object has no attribute 'addInEdge. I'm not sure if I made myself clear. Once the stuff is working, I would like an xml file which looks somewhat like the one below but with attributes we need like the processing, storage and switching power. VNEInstance schema=VNEInstance.xsd version= substrate nodes node capacity=975.4 costs=0.0 id=0 nodeName=0 xCoordinate=54 yCoordinate=41/ node capacity=742.5 costs=0.0 id=1 nodeName=1 xCoordinate=67 yCoordinate=33/ I'm really sorry for the trouble but once I get this thing going then I can move on with the CPLEX solving stuff.Thanks a lot for your help -- https://mail.python.org/mailman/listinfo/python-list
Re: Need help to write data onto an XML file after reading data from another xml file
On Wed, May 14, 2014 at 11:42 PM, varun...@gmail.com wrote: Since its my first time programming I am not aware of many conventions that are being used to name classes. I tried to distinguish them by naming classes in caps. The most commonly followed naming conventions in Python are those mandated for Python's own standard library. The definition of that is in a document called PEP 8: http://www.python.org/dev/peps/pep-0008/ Makes a good read. If you at least mostly follow PEP 8, people on this list will instantly know what's a class and what's not, etc, and it'll make things easier all round. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Using threads for audio computing?
On 12/05/14 07:33, lgabiot wrote: But AFAIK the python GIL (and in smaller or older computers that have only one core) does not permit true paralell execution of two threads. I believe it is quite like the way multiple processes are handled by an OS on a single CPU computer: process A has x CPU cycles, then process B has y CPU cycles, etc... Python threads are native OS threads. The GIL serializes access to the Python interpreter. If your thread is waiting for i/o or running computations in C or Fortran (e.g. with NumPy), it does not need the Python interpreter. Scientists and engineers use Python threads for true parallel processing all the time. The FUD you will find about the GIL is written by people who don't fully understand the issue. So in my case, I must have a way to make sure that: thread 1 (which gets audio from Pyaudio and put() it in the Queue) is not interrupted long enough to miss a sample. Here you are mistaken. The DMA controller takes care of the audio i/o. Your audio acquisition thread is asleep while its buffer fills up. You don't miss a sample because your thread is interrupted. You do, however, have to make sure your thread don't block on the write to the Queue (use block=False in the call to Queue.put), but it is not a GIL issue. In your case you basically have on thread waiting for the DMA controller to fill up a buffer and another doing computations in NumPy. Neither needs the GIL for most of their work. If you are worried about the GIL you can always use processes (multiprocessing, subprocess, or os.fork) instead of threads. Sturla -- https://mail.python.org/mailman/listinfo/python-list
Re: Why isn't my re.sub replacing the contents of my MS Word file?
On Tuesday, May 13, 2014 4:26:51 PM UTC-4, MRAB wrote: 0x96 is a hexadecimal literal for an int. Within a string you need \x96 (it's \x for 2 hex digits, \u for 4 hex digits, \U for 8 hex digits). Yes, that was my problem. Figured it out just after posting my last message. using \x96 works correctly. Thanks! -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything you did not want to know about Unicode in Python 3
On May 13, 2014 6:10 PM, Chris Angelico ros...@gmail.com wrote: On Wed, May 14, 2014 at 9:53 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: With the current system, all of us here are technically violating copyright every time we reply to an email and quote more than a small percentage of it. Oh wow... so when someone quotes heaps of text without trimming, and adding blank lines, we can complain that it's a copyright violation - reproducing our work with unauthorized modifications and without permission... I never thought of it like that. I'd be surprised if this doesn't fall under fair use. -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything you did not want to know about Unicode in Python 3
On 13/05/2014 17:08, Ian Kelly wrote: . And since it's so simple, it shouldn't be hard to see that the use of the shutil module has nothing to do with the Unicode woes here. The crux of the issue is that a general-purpose command like cat typically can't know the encoding of its input and can't assume anything about it. In fact, there may not even be an encoding; cat can be used with binary data. The only non-destructive approach then is to copy the binary data straight from the source to the destination with no decoding steps at all, and trust the user to ensure that the destination will be able to accommodate the source encoding. Because Python 3 presents stdin and stdout as text streams however, it makes them more difficult to use with binary data, which is why Armin sets up all that extra code to make sure his file objects are binary. Doesn't this issue also come up wherever bytes are being read ie in sockets, pipe file handles etc? Some sources may have well defined encodings and so allow use of unicode strings but surely not all. I imagine all of the problems associated with a broken encoding promise for stdin can also occur with sockets other sources ie error messages failing to be printable etc etc. Since bytes in Python 3 are not equivalent to the old str (Python 3 bytes != Python 2 str) using bytes everywhere has its own problems. -- Robin Becker -- https://mail.python.org/mailman/listinfo/python-list
Re: httplib with NETRC authentication
Chris Angelico ros...@gmail.com writes: On Wed, May 14, 2014 at 9:33 AM, pratibha natani en.prati...@gmail.com wrote: I am trying to establish http connection to a gerrit host using netrc authentication. I have a netrc file created with following entries: machine host1.com login name password pass I did a debug and saw that my netrc file is being read correctly. Also in the connection object(after sending request) a header got created with appropriate credentials: 'headers': {'Authorization': 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ='} Still I get 401,Unauthorized in response. Any help would be greatly appreciated! The obvious question is: What *does* work? Does it work when you use wget, or some other application? Then go and look at what that sends for its authentication headers. Tip: It won't be Authorization. Authorization is the appropriate header for basic http authentication: http://tools.ietf.org/html/rfc2617#section-2 Here's a code example for urllib2: https://gist.github.com/kennethreitz/973705#comment-56387 -- akira -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything you did not want to know about Unicode in Python 3
On Wed, May 14, 2014 at 9:30 AM, Robin Becker ro...@reportlab.com wrote: Doesn't this issue also come up wherever bytes are being read ie in sockets, pipe file handles etc? Some sources may have well defined encodings and so allow use of unicode strings but surely not all. I imagine all of the problems associated with a broken encoding promise for stdin can also occur with sockets other sources ie error messages failing to be printable etc etc. Since bytes in Python 3 are not equivalent to the old str (Python 3 bytes != Python 2 str) using bytes everywhere has its own problems. Sockets send and receive bytes, and pipes created by the subprocess module are opened in binary mode. Pipes inherited as stdin are still assumed to be unicode, though. -- https://mail.python.org/mailman/listinfo/python-list
Re: python3; ftplib: TypeError: Can't convert 'bytes' object to str implicitly
Antoon Pardon antoon.par...@rece.vub.ac.be writes: This is the code I run (python 3.3) host = ... user = ... passwd = ... from ftplib import FTP ftp = FTP(host, user, passwd) ftp.mkd(b'NewDir') ftp.rmd(b'NewDir') This is the traceback Traceback (most recent call last): File ftp-problem, line 9, in module ftp.mkd(b'NewDir') File /usr/lib/python3.3/ftplib.py, line 612, in mkd resp = self.voidcmd('MKD ' + dirname) TypeError: Can't convert 'bytes' object to str implicitly The problem is that I do something like this in a backup program. I don't know the locales that other people use. So I manipulate all file and directory names as bytes. Am I doing something wrong? The error message shows that ftplib expects a string here, not bytes. You could use `ftp.mkd(some_bytes.decode(ftp.encoding))` as a workaround. -- akira -- https://mail.python.org/mailman/listinfo/python-list
Re: httplib with NETRC authentication
pratibha natani en.prati...@gmail.com writes: Hi, I am trying to establish http connection to a gerrit host using netrc authentication. I have a netrc file created with following entries: machine host1.com login name password pass I did a debug and saw that my netrc file is being read correctly. Also in the connection object(after sending request) a header got created with appropriate credentials: 'headers': {'Authorization': 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ='} It should be QWxhZGRpbjpvcGVuIHNlc2FtZQ== (note: the second '=') Also, make sure that you use the correct case for the username. Userids might be case sensitive. -- akira -- https://mail.python.org/mailman/listinfo/python-list
Re: httplib with NETRC authentication
On Thu, May 15, 2014 at 1:44 AM, Akira Li 4kir4...@gmail.com wrote: The obvious question is: What *does* work? Does it work when you use wget, or some other application? Then go and look at what that sends for its authentication headers. Tip: It won't be Authorization. Authorization is the appropriate header for basic http authentication: http://tools.ietf.org/html/rfc2617#section-2 *facepalm* Critical reading failure on my part. He did have it right in the first place. Still, I stand by the original statement and (more importantly) the original question. It's just the tip that's wrong. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: python3; ftplib: TypeError: Can't convert 'bytes' object to str implicitly
op 14-05-14 18:24, Akira Li schreef: Antoon Pardon antoon.par...@rece.vub.ac.be writes: This is the code I run (python 3.3) host = ... user = ... passwd = ... from ftplib import FTP ftp = FTP(host, user, passwd) ftp.mkd(b'NewDir') ftp.rmd(b'NewDir') This is the traceback Traceback (most recent call last): File ftp-problem, line 9, in module ftp.mkd(b'NewDir') File /usr/lib/python3.3/ftplib.py, line 612, in mkd resp = self.voidcmd('MKD ' + dirname) TypeError: Can't convert 'bytes' object to str implicitly The problem is that I do something like this in a backup program. I don't know the locales that other people use. So I manipulate all file and directory names as bytes. Am I doing something wrong? The error message shows that ftplib expects a string here, not bytes. You could use `ftp.mkd(some_bytes.decode(ftp.encoding))` as a workaround. Sure but what I like to know: Can this be considered a failing of ftplib. Since python3 generally allows paths to be strings as well as bytes can't we expect the same of ftplib? Especially as I assume that path will be converted to bytes anyway in order to send it over the network. -- Antoon Pardon. -- https://mail.python.org/mailman/listinfo/python-list
Re: python3; ftplib: TypeError: Can't convert 'bytes' object to str implicitly
On 2014-05-14 19:06, Antoon Pardon wrote: op 14-05-14 18:24, Akira Li schreef: Antoon Pardon antoon.par...@rece.vub.ac.be writes: This is the code I run (python 3.3) host = ... user = ... passwd = ... from ftplib import FTP ftp = FTP(host, user, passwd) ftp.mkd(b'NewDir') ftp.rmd(b'NewDir') This is the traceback Traceback (most recent call last): File ftp-problem, line 9, in module ftp.mkd(b'NewDir') File /usr/lib/python3.3/ftplib.py, line 612, in mkd resp = self.voidcmd('MKD ' + dirname) TypeError: Can't convert 'bytes' object to str implicitly The problem is that I do something like this in a backup program. I don't know the locales that other people use. So I manipulate all file and directory names as bytes. Am I doing something wrong? The error message shows that ftplib expects a string here, not bytes. You could use `ftp.mkd(some_bytes.decode(ftp.encoding))` as a workaround. Sure but what I like to know: Can this be considered a failing of ftplib. Since python3 generally allows paths to be strings as well as bytes can't we expect the same of ftplib? Especially as I assume that path will be converted to bytes anyway in order to send it over the network. From studying the code, I see that it uses the Latin-1 encoding. On another note, I find it interesting that the default for the timeout argument uses the 'magic' value -999 rather than, say, None! -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions.
I downloaded the get-pip.py file. I installed it to the same folder on my C drive as the Beautiful Soup one in which the Beautiful Soup 4 downloads was unzipped to. I changed directory to the folder on the Command Prompt, as you instructed in step 2. I input the code to the console you gave on step 3), that returned some code, as quoted below. I then input the code you gave on step 4) but Console seems to reject or not recognise 'pip' as a term. I am sure quoting the actual prompt response can explain things better than I : --- Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\Intel Atomcd c:\Beautiful Soup c:\Beautiful Souppython get-pip.py Downloading/unpacking pip from https://pypi.python.org/packages/py2.py3/p/pip/pi p-1.5.5-py2.py3-none-any.whl#md5=03a932d6f82a3887d8de1cdb837c87ed Installing collected packages: pip Found existing installation: pip 1.5.4 Uninstalling pip: Successfully uninstalled pip Successfully installed pip Cleaning up... c:\Beautiful Souppip install beautifulsoup4 'pip' is not recognized as an internal or external command, operable program or batch file. c:\Beautiful Soup Perhaps I oughtn't have downloaded the pip file to the same directory as the Beautiful Soup ? I will have a try at transferring the file to another folder and running the code you gave again. -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions.
I have input the above code by copy and pasting to the Idle python console, as the python 2.7 command prompt is fussy about the indentation on the eleventh line down, if I then indent it, it replies that the indentation is unnecessary of unexpected, and if I don't it says an indentation is expected. However when I get to the next lines of code - in the Idle prompt re: C:\Users\Intel Atomcd c:\Beautiful Soup c:\Beautiful Soupc:\Python27\python setup.py install Again it does not recognise 'bs4'. I think having used 'Just unzip it' instead of 'WinZip' may have caused this problem, in the first place ,as when I looked at the WinZip version at a local net café, it did have a folder hierarchy, however I wanted, and still want to skimp the £25 fee for WinZip, which nowadays you can't seem to be able to do. I never asked for the darn files to be zipped, so why ought I pay to have them unzipped, being my contention. -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions.
On Wed, May 14, 2014 at 12:58 PM, Simon Evans musicalhack...@yahoo.co.uk wrote: c:\Beautiful Souppip install beautifulsoup4 'pip' is not recognized as an internal or external command, operable program or batch file. c:\Beautiful Soup Perhaps I oughtn't have downloaded the pip file to the same directory as the Beautiful Soup ? I will have a try at transferring the file to another folder and running the code you gave again. No, sounds like a path environment variable issue. The python executable is on your path, but the pip executable is not. The get-pip.py script should have installed it into C:\Python27\Scripts, I think, so either add that directory to your path (you can find instructions for this on the web) or just cd to that directory and run the pip command from there. -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions.
On Wed, May 14, 2014 at 1:28 PM, Simon Evans Again it does not recognise 'bs4'. I think having used 'Just unzip it' instead of 'WinZip' may have caused this problem, in the first place ,as when I looked at the WinZip version at a local net café, it did have a folder hierarchy, however I wanted, and still want to skimp the £25 fee for WinZip, which nowadays you can't seem to be able to do. I never asked for the darn files to be zipped, so why ought I pay to have them unzipped, being my contention. I use 7-zip (www.7-zip.org), which is freely distributed and open source. -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions.
On Thu, May 15, 2014 at 5:33 AM, Ian Kelly ian.g.ke...@gmail.com wrote: I use 7-zip (www.7-zip.org), which is freely distributed and open source. You beat me to the punch. :) Was about to say the exact same thing, so instead I'll second your recommendation. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: PEP 8 : Maximum line Length :
On 5/13/2014 6:55 PM, Ben Finney wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: On Tue, 13 May 2014 04:52:26 -0700, Rustom Mody wrote: What this goes to show is that while 80 is ridiculously low by most displays today, Not for people who like to has two (or three, or four) windows side-by- side. Or multiple views of the same document. There's also the fact that, while the capacity of monitors to display pixels has dramatically increased in recent decades, the capacity of human cognition to scan long lines of text has not increased at all in that time. The 80 character line limit is *not* driven by a limitation of computer technology; it is driven by a limitation of human cognition. For that reason, it remains relevant until human cognition in the general reading population improves. I use the monitor capacity to have 2 or even 3 code windows open side-by-side. Really handy. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything you did not want to know about Unicode in Python 3
On 5/13/2014 8:53 PM, Ethan Furman wrote: On 05/13/2014 05:10 PM, Steven D'Aprano wrote: On Tue, 13 May 2014 10:08:42 -0600, Ian Kelly wrote: Because Python 3 presents stdin and stdout as text streams however, it makes them more difficult to use with binary data, which is why Armin sets up all that extra code to make sure his file objects are binary. What surprises me is how hard that is. Surely there's a simpler way to open stdin and stdout in binary mode? If not, there ought to be. Somebody already posted this: https://docs.python.org/3/library/sys.html#sys.stdin which talks about .detach(). I sent a message to Armin about this. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: PEP 8 : Maximum line Length :
In article a3253d6a-ef89-49d5-b866-8c06a7462...@googlegroups.com, Rustom Mody rustompm...@gmail.com wrote: On Tuesday, May 13, 2014 12:37:24 PM UTC+5:30, Ganesh Pal wrote: Hi Team , what would be the best way to intent the below line . I have few lines in my program exceeding the allowed maximum line Length of 79./80 characters Example 1 : p = Subprocess.Popen(shlex.split(cmd),stdout=subprocess.PIPE,stderr=subprocess.PIPE) First rule of python-list: Pay careful attention to Peter Otten. That said... 80-character limit?! Sheesh! A relic of the days when terminals were ASCII and 80x24 80 character was the hard limit. The soft limit for readability is 60..65 characters. Think about it. Just that a language accepts #define MASK_SEPIA_INTERNAL_BLEEDING_WASHINGTON_DC_BLACK 0x147800fa means that it is a good idea to do so. Groetjes Albert -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert@spearc.xs4all.nl =n http://home.hccnet.nl/a.w.m.van.der.horst -- https://mail.python.org/mailman/listinfo/python-list
Re: Fortran
Ian Kelly ian.g.ke...@gmail.com wrote: Also numba, which is reminiscent of psyco, but with more features and Python 3 support. For numerical computing with NumPy, Numba tends to give performance comparable to -O2 in C. This is because it is very easy to do type inference in most scientific array computing. Numba is still a bit immature, though, compared to e.g. Cython. Sturla -- https://mail.python.org/mailman/listinfo/python-list
Re: PEP 8 : Maximum line Length :
On 05/14/2014 03:53 PM, Albert van der Horst wrote: In article a3253d6a-ef89-49d5-b866-8c06a7462...@googlegroups.com, Rustom Mody rustompm...@gmail.com wrote: On Tuesday, May 13, 2014 12:37:24 PM UTC+5:30, Ganesh Pal wrote: Hi Team , what would be the best way to intent the below line . I have few lines in my program exceeding the allowed maximum line Length of 79./80 characters Example 1 : p = Subprocess.Popen(shlex.split(cmd),stdout=subprocess.PIPE,stderr=subprocess.PIPE) First rule of python-list: Pay careful attention to Peter Otten. That said... 80-character limit?! Sheesh! A relic of the days when terminals were ASCII and 80x24 Which is a relic of the even older punch cards which contained one line of (up to) 80 characters. Gary Herron 80 character was the hard limit. The soft limit for readability is 60..65 characters. Think about it. Just that a language accepts #define MASK_SEPIA_INTERNAL_BLEEDING_WASHINGTON_DC_BLACK 0x147800fa means that it is a good idea to do so. Groetjes Albert -- https://mail.python.org/mailman/listinfo/python-list
Re: PEP 8 : Maximum line Length :
On 15/05/2014 01:15, Gary Herron wrote: Which is a relic of the even older punch cards which contained one line of (up to) 80 characters. Gary Herron I still remember the cry of anguish when the guy in the computer building at (the then) Portsmouth Polytechnic dropped his cardboard box of punch cards that made up his end of course project. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Re: PEP 8 : Maximum line Length :
In article mailman.10026.1400116640.18130.python-l...@python.org, Mark Lawrence breamore...@yahoo.co.uk wrote: I still remember the cry of anguish when the guy in the computer building at (the then) Portsmouth Polytechnic dropped his cardboard box of punch cards that made up his end of course project. That's why you punch sequence numbers in columns 73-80. If the cards get out of order, just run the deck through the sorter. -- https://mail.python.org/mailman/listinfo/python-list
Re: PEP 8 : Maximum line Length :
On Thursday, May 15, 2014 4:23:52 AM UTC+5:30, Albert van der Horst wrote: Rustom Mody wrote: 80-character limit?! Sheesh! A relic of the days when terminals were ASCII and 80x24 80 character was the hard limit. The soft limit for readability is 60..65 characters. Think about it. Just that a language accepts #define MASK_SEPIA_INTERNAL_BLEEDING_WASHINGTON_DC_BLACK 0x147800fa means that it is a good idea to do so. Yes there are fundamental but soft limits, eg http://webtypography.net/2.1.2 And there are (semi)hard technological limits like if you post code longer 65 chars out here it will fold at random unforeseen points. These limits get irrelevant as the technology changes. If any of these has any relation with the magic number '79' I'd be curious to know. Until then may we relegate '79' to quaint historical curiosities like: Continuation in 6th column, Comment is a C in 1st column, 7-72 for code (ALONG WITH ALL CAPS CODE)? -- https://mail.python.org/mailman/listinfo/python-list
Re: PEP 8 : Maximum line Length :
Rustom Mody rustompm...@gmail.com writes: Until then may we relegate '79' to quaint historical curiosities Not until the general capacity of human cognition advances to make longer lines easier to read. We humans may be historical curiosities some day; until then, let's continue to write our code as though humans are the ones who will be reading it. -- \“Stop — Drive sideways.” —detour sign, Kyushu, Japan | `\ | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: PEP 8 : Maximum line Length :
On Wed, 14 May 2014 19:36:13 -0700, Rustom Mody wrote: And there are (semi)hard technological limits like if you post code longer 65 chars out here it will fold at random unforeseen points. These limits get irrelevant as the technology changes. The technological limits may become irrelevant, but the human limits do not. While there are no *hard* limits to readability, both excessively long and excessively short lines are hard to read. Comprehension and reading speed suffers. If any of these has any relation with the magic number '79' I'd be curious to know. 79 is one short of 80, which gives you a margin of error of 1: off-by-one errors won't matter if you aim for 79 characters but miscalculate by one. People repeatedly state that 80 is the old, obsolete hard limit for ancient terminal systems, but the reason terminals standardised on 80 rather than 70 or 90 (or for that matter 300 or 30) is at least in part -- and I maintain a big part -- because of human reading. 60 to 90 characters per line is a comfortable range for human readability, which makes 80 a reasonable compromise that tends towards the upper end but without pushing hard up against it. Keeping the monitor size and character size fixed, it's easy to show *fewer* characters per line if you choose a standard towards the upper end, if you so choose, but impossible to squeeze in more if you choose a standard at the lower end. Just because the monitor (or the standard) *allows* up to 79 characters per line doesn't make it a good idea to regularly use that many. In my experience, given two or three indent levels, reasonably descriptive variable names, decently expressive expressions, I find that 60-70 characters is *typically* enough horizontal space for the average line of code. Long lines are often (not always) a sign that you're doing too much in one line. This isn't Perl, and newlines are a renewable resource. Until then may we relegate '79' to quaint historical curiosities like: Continuation in 6th column, Comment is a C in 1st column, 7-72 for code (ALONG WITH ALL CAPS CODE)? Nope. Because the main driving force for 79 characters is not technology but human reading. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: PEP 8 : Maximum line Length :
On 15/05/2014 03:43, Ben Finney wrote: Rustom Mody rustompm...@gmail.com writes: Until then may we relegate '79' to quaint historical curiosities Not until the general capacity of human cognition advances to make longer lines easier to read. We humans may be historical curiosities some day; until then, let's continue to write our code as though humans are the ones who will be reading it. I thought code was meant to be read by programmers, not humans :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
[issue21470] Better seeding for the random module
Charles-François Natali added the comment: Thanks for the explanations! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21470 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21505] cx_freeze multiprocessing bug
New submission from Shivani: Hey all, I have problem with multiprocessing and cx_freeze.. I am freezing my UI application. i have a line in code::- multiprocessing.set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe')) when a commented out this line, my UI keeps iterating again and again. and when i uncomment it, without throwing any error,UI just stuck in its second phase. and moreover spoiling my unfreezen code olso. What can be the problem with multi processing and cx_freeze relation..? Thanks in Advance. -- components: Tkinter messages: 218503 nosy: shivani priority: normal severity: normal status: open title: cx_freeze multiprocessing bug versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21505 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21486] optimize v4 v6 netmask parsing
Serhiy Storchaka added the comment: With C implementation (issue14373) functools.lru_cache is so fast as manually written specialized code. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21486 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21402] tkinter.ttk._val_or_dict assumes tkinter._default_root exists
Serhiy Storchaka added the comment: This is not so easy, because it does not work with wantobject=False and can not work with future versions of Tk. Actually we should use self.tk instead of _default_root, but this will change the signature of _list_from_layouttuple() and _val_or_dict(). Due to the risk of breaking existing user code which uses these private functions, they should be left with old signature and new functions should be added. -- assignee: - serhiy.storchaka versions: +Python 2.7, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21402 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21488] codecs.encode/decode documentation inconsistency
Nick Coghlan added the comment: Brett, if you granted Berker commit privileges, you forgot to update the developer log and issue tracker... That said, the patch LGTM too. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21488 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21034] Python docs reference the Distribute package which has been deprecated in favor of Setuptools
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +eric.araujo stage: - patch review type: - enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21034 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21031] [patch] Add AlpineLinux to the platform module's supported distributions list
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +brett.cannon, ezio.melotti stage: - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21031 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21027] difflib new cli interface
Changes by Claudiu.Popa pcmantic...@gmail.com: Added file: http://bugs.python.org/file35247/issue21027_1.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21027 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20160] broken ctypes calling convention on MSVC / 64-bit Windows (large structs)
mattip added the comment: Here is a fix for arguments and return values, based on the support in cffi, for python2.7 I added a test in test_win32, removed the too-early attempt to fix in callproc.c, and merged in most of the changes in lib_msvc from cffi's code base. These changes handle the following (in addition to callproc change): - fix rtype handling by converting a return-by-value struct to a pointer-sized int - fix stack byte-size calculation by checking for large pass-by-value structs, incrementing bytes by sizeof(void*) in this case - fix avalue copying by checking for large pass-by-value structs and copying the pointer not the value - fix bogus check for stack buffer 40 bytes A similar patch for 3.4 will be posted soon. Other related issues: http://bugs.python.org/issue11835 -- keywords: +patch nosy: +mattip Added file: http://bugs.python.org/file35248/issue_20160_python2_7.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20160 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20160] broken ctypes calling convention on MSVC / 64-bit Windows (large structs)
mattip added the comment: and here is the promised patch for tip -- Added file: http://bugs.python.org/file35249/issue_20160_tip.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20160 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18492] Allow all resources if not running under regrtest.py
Serhiy Storchaka added the comment: You have convinced me. In general the approach and the patch LGTM. But I agree with Terry that flag support.regrtest_run is redundant, it duplicates a bit of information which provides support.use_resources. Instead we can rewrite support.is_resource_enabled() as return use_resources is None or resource in use_resources Introducing regrtest_run can cause inconsistency between it and use_resources. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18492 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21488] codecs.encode/decode documentation inconsistency
STINNER Victor added the comment: For Python 3.5, I would prefer to patch the code to support keywords instead. -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21488 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21488] codecs.encode/decode documentation inconsistency
STINNER Victor added the comment: I sent a review on Rietveld. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21488 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21488] codecs.encode/decode documentation inconsistency
STINNER Victor added the comment: codecs_decode_encode_kw.patch: Patch for Python 3.5 adding support of keyword arguments on codecs.encode and codecs.decode. -- Added file: http://bugs.python.org/file35250/codecs_decode_encode_kw.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21488 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6895] locale._parse_localename fails when localename does not contain encoding information
Serhiy Storchaka added the comment: For now the output of the code in msg132878 on Ubuntu is empty. May be this issue is outdated. -- nosy: +serhiy.storchaka status: open - pending ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6895 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21495] Sane default for logging config
Vinay Sajip added the comment: Just on backward compatibility grounds, a proposal like this isn't going to be acceptable on python-dev, I believe, and I'm not even sure it's necessary to have such a thing in the stdlib: why not just use the approach you suggested for your own projects, and leave it at that? I've certainly found that preferences for configuration approaches vary a lot across people, and nothing will please everyone :-( Generally, before writing a PEP, ideas are broached on the python-ideas mailing list, then move to the python-dev mailing list when they seem to have enough mileage to do so, and the PEP discussion / life-cycle happens there. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21495 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9266] ctypes ValueError: NULL pointer access on Win7 x64
Changes by Berker Peksag berker.pek...@gmail.com: -- resolution: - out of date stage: - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9266 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21487] Assorted ipaddress performance improvements
Serhiy Storchaka added the comment: Alternative implementations of _count_righthand_zero_bits(): def _count_righthand_zero_bits(number, bits): if not number: return bits return (~number (number-1)).bit_length() or def _count_righthand_zero_bits(number, bits): if not number: return bits return (~(number | -number)).bit_length() -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21487 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21343] os.path.relpath returns inconsistent types
Serhiy Storchaka added the comment: I think this is not a bug and shouldn't be fixed in 2.7. -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21343 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21387] Memory leaks when embedded interpreter is reinitialized
Stefan Krah added the comment: I've run Evgeniy's example under Valgrind and changed it to import various C extensions. Unfortunately they all leak more or less, so perhaps we can revisit this when (if?) the PEP 3121 and PEP 384 changes have been implemented. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21387 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16594] SocketServer should set SO_REUSEPORT along with SO_REUSEADDR when present
Changes by Stefan Krah stefan-use...@bytereef.org: -- nosy: -skrah ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16594 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21423] concurrent.futures.ThreadPoolExecutor should accept an initializer argument
Andreas van Cranenburgh added the comment: Giampaolo, this patch is for ProcessPoolExecutor as well. About keyboard interrupts, if my tests are correct, they work in Python 3.3+ with both multiprocessing and concurrent.futures. (Although for the latter I have to hit ctrl-c twice). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21423 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21331] Reversing an encoding with unicode-escape returns a different result
Serhiy Storchaka added the comment: Sworddragon, try to use content.encode('ascii', 'backslashreplace').decode('unicode-escape'). It is too late to change the unicode-escape encoding. -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21331 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21231] Issue a python 3 warning when old style classes are defined.
Serhiy Storchaka added the comment: I agree that this is not a good idea. Old-style classes are legal in Python 2 and this syntax is legal in Python 3 where it means new-style classes and in most cases there is no difference between new-style and old-style classes. -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21231 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21506] Windows MSI installer should mklink (symlink) python.exe to python2.7.exe
New submission from Ed Morley: A python.org 2.7.6 release of the Windows MSI installer, results in only the following python binaries in the installation directory: C:\Python27\python.exe C:\Python27\pythonw.exe In Mozilla bug https://bugzilla.mozilla.org/show_bug.cgi?id=957721 we would like to be able to force our 'mach' script to use Python2.7 (due to the assorted Python versions present on our CI machines), however doing so via the script shebang line breaks local developer workflows on Windows, since the default Python install doesn't include python2.7.exe and so the binary isn't found. As such, it would be great if python.exe could be symlinked to pythonX.Y.exe (and also I guess pythonX.exe) as part of the Windows installation/build - giving us parity with Unix based platforms. This can be done on Windows using mklink (http://ss64.com/nt/mklink.html), eg: c:\Python27mklink python2.7.exe python.exe symbolic link created for python2.7.exe === python.exe c:\Python27mklink python2.exe python.exe symbolic link created for python2.exe === python.exe c:\Python27dir python* 10/11/2013 19:2426,624 python.exe 14/05/2014 12:04SYMLINK python2.exe [python.exe] 14/05/2014 12:04SYMLINK python2.7.exe [python.exe] 10/11/2013 19:2427,136 pythonw.exe Alternatively, just a plain copy of the binary prior to creating the MSI would be just as helpful for us too. I searched for a while to see if there were any bugs filed for this already, but the closest I could find was: * http://legacy.python.org/dev/peps/pep-0397/ - which is about a smart launcher that uses the shebang lines to run the correct Python version when multiple are installed (and thus is quite a different request to that in this bug). * and https://mail.python.org/pipermail/python-dev/2011-March/108850.html which suggests the idea as in this bug summary here, but it seems like a bug for it was never filed. Many thanks :-) -- components: Build, Installation, Windows messages: 218521 nosy: edmorley, loewis priority: normal severity: normal status: open title: Windows MSI installer should mklink (symlink) python.exe to python2.7.exe type: enhancement versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21506 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21506] Windows MSI installer should mklink (symlink) python.exe to python2.7.exe
Ed Morley added the comment: Meant to add: the ActivePython release does this already - but it would be great if upstream did too. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21506 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4999] multiprocessing.Queue does not order objects
Changes by Jean-Paul Calderone jean-p...@hybridcluster.com: -- nosy: -exarkun ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4999 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4928] Problem with tempfile.NamedTemporaryFile
Changes by Jean-Paul Calderone jean-p...@hybridcluster.com: -- nosy: -exarkun ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4928 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21046] Document formulas used in statistics
Ezio Melotti added the comment: E.g. median([x1, x2, x3, x4, x5]) = x3 median([x1, x2, x3, x4, x5, x6]) = (x3 + x4) / 2 The docs seem to already contain similar examples for some of the functions (e.g. median()), but not for others (e.g. mean()). For these, if the formula can be expressed with a simple Python equivalent (e.g. sum(values) / len(values)), I think it would be reasonable to add it. -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21046 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21507] memory used by frozenset created from set differs from that of frozenset created from other iterable
New submission from Lev Givon: Not sure if this is indicative of a bug, but I noticed that a frozenset created from a set seems to occupy a different amount of memory than a frozenset created from some other iterable. I observed this behavior with Python 2.7.5 and with Python 3.4.0 on Ubuntu 14.04 x86_64: from sys import getsizeof x = range(100) s = set(x) f0 = frozenset(x) f1 = frozenset(s) getsizeof(s) 8424 getsizeof(f0) 8424 getsizeof(f1) 4328 f0==f1 True Original question on StackOverflow available at https://stackoverflow.com/questions/23618259/memory-occupied-by-set-vs-frozenset-in-python-2-7 -- messages: 218524 nosy: lebedov priority: normal severity: normal status: open title: memory used by frozenset created from set differs from that of frozenset created from other iterable type: resource usage versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21507 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21487] Assorted ipaddress performance improvements
Antoine Pitrou added the comment: Good point, this is a much faster implementation. Updated patch (and fixed the implementation to not return more than `bits`). -- Added file: http://bugs.python.org/file35251/ipaddr_perf2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21487 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21507] memory used by frozenset created from set differs from that of frozenset created from other iterable
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21507 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21496] pyvenv activate_this.py
couplewavylines added the comment: run the command directly...would run with the venv's environment: I'm sorry I didn't realize this, the You don’t specifically need to activate an environment... part of the venv docs didn't sink in for me when I read it earlier. So yes, using a subprocess will do what I'm after. I don't know if the subprocess will cover the situation in that link where they're using execfile on activate_this, but I was just trying to find a common-looking use-case for activate_this. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21496 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21402] tkinter.ttk._val_or_dict assumes tkinter._default_root exists
Stephen Paul Chappell added the comment: There is discussion of removing wantobjects in issue3015. If it gets removed, a better patch might be created for future versions of tkinter. However, accessing self.tk would probably be a good replacement for anywhere tkinter._default_root can be found (except in cases where a widget is not given a parent). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21402 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21343] os.path.relpath returns inconsistent types
Matt Bachmann added the comment: Can you help me understand why not? If I give it two unicode strings it sometimes gives me back a unicode and sometimes gives me back a string. In python3 this does what I expect. In python27 I now have to check the type I get back because I cannot be sure what type I will be getting back. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21343 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21488] codecs.encode/decode documentation inconsistency
Brett Cannon added the comment: Nope, I forgot Berker had triage rights but not commit rights. -- assignee: berker.peksag - docs@python ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21488 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21338] Silent mode for compileall
Changes by R. David Murray rdmur...@bitdance.com: -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21338 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21496] pyvenv activate_this.py
Vinay Sajip added the comment: Okay, I'll close this issue. -- resolution: - not a bug status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21496 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21342] multiprocessing RLock and Lock raise incorrect exceptions when releasing an unlocked lock.
R. David Murray added the comment: As a historical note, the docs are probably correct...but at some point relatively recently we fixed the inconsistency in what was raised in the thread and threading modules, but obviously no one noticed that multiprocessing had the same issue. It could be that a comment should be added to the thread/threading code mentioning the multiprocessing clones, and vice versa. Or perhaps the code can be unified? I suspect the clones exist primarily because multiprocessing was originally an external project. -- nosy: +r.david.murray stage: - patch review versions: -Python 2.7, Python 3.2, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21342 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21345] multiprocessing.Pool._handle_workers sleeps too long
R. David Murray added the comment: I'm not that familiar with multiprocessing, but I'd guess it was to avoid burning cpu in a busy-wait (it seems to me that that doesn't matter during finalization, but does during normal running). Maybe it could be changed to an event wait on a shutdown event? -- nosy: +r.david.murray versions: -Python 3.1, Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21345 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21347] Don't use a list argument together with shell=True in subprocess' docs
R. David Murray added the comment: Thanks, Akira. -- nosy: +r.david.murray resolution: - fixed stage: - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21347 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21347] Don't use a list argument together with shell=True in subprocess' docs
Roundup Robot added the comment: New changeset 5ef9a2c711f5 by R David Murray in branch '2.7': #21347: use string not list in shell=True example. http://hg.python.org/cpython/rev/5ef9a2c711f5 New changeset 3b27f3acf0c4 by R David Murray in branch '3.4': #21347: use string not list in shell=True example. http://hg.python.org/cpython/rev/3b27f3acf0c4 New changeset 217006c5455f by R David Murray in branch 'default': Merge: #21347: use string not list in shell=True example. http://hg.python.org/cpython/rev/217006c5455f -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21347 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21506] Windows MSI installer should mklink (symlink) python.exe to python2.7.exe
Zachary Ware added the comment: A similar thought I've had is to add a feature to the PEP397 launcher, allowing it to figure out Python version from a suffix on its executable name and add symlinks to it for each installed version of Python. That way PATH wouldn't need to be modified to make every installed version accessible from a single optionless command. -- nosy: +steve.dower, tim.golden, zach.ware versions: +Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21506 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21508] C API PyArg_ParseTuple doc is innacurate
New submission from Steve: PyArg_ParseTuple is defined as returning an int, but the documentation talks about returning a true/false value, and failling on false. In addition to being inaccurate, considering that most other functions fail on !=0 (true), it can lead to confusion. Doc: int PyArg_ParseTuple(PyObject *args, const char *format, ...) Parse the parameters of a function that takes only positional parameters into local variables. Returns true on success; on failure, it returns false and raises the appropriate exception. -- assignee: docs@python components: Documentation messages: 218536 nosy: Banger, docs@python priority: normal severity: normal status: open title: C API PyArg_ParseTuple doc is innacurate type: enhancement versions: Python 3.3, Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21508 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com