stevedore 0.15
stevedore 0.15 What is stevedore? Python makes loading code dynamically easy, allowing you to configure and extend your application by discovering and loading extensions (plugins) at runtime. Many applications implement their own library for doing this, using __import__ or importlib. [1]stevedore avoids creating yet another extension mechanism by building on top of [2]setuptools entry points. The code for managing entry points tends to be repetitive, though, so stevedore provides manager classes for implementing common patterns for using dynamically loaded extensions. What's New? * Only log errors from loading plugins if no error handler callback is provided. Installing Visit the [3]stevedore project page for download links and installation instructions. References 1. http://stevedore.readthedocs.org/ 2. http://packages.python.org/distribute/pkg_resources.html#convenience-api 3. http://stevedore.readthedocs.org/ -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
devpi client/server 1.2.2 releases
Hi all, finally i got around to do 1.2.2 releases of the devpi pypi server tools with a few fixes and improvements. See http://doc.devpi.net for docs and instructions and below for the changelog. cheers, holger krekel 1.2.2 devpi-server: - fix issue78: create less directories for pypi package files by splitting the md5 part into two. Avoids TooManyLinks errors in large installations. - fix --stop on windows. Thanks to Christian Ullrich for the PR. - fix issue79: interoperate with pip-1.5 by interpreting accept header as */* as html_preferred. Thanks Richard Jones. - use latest virtualenv-1.11.2 when bootstrapping on jenkins - fix issue89: adapt for bottle changes in 0.12.1. Thanks Alexey Sveshnikov. devpi-client: - depend on pkginfo1.2b1 for wheel metadata reading support, remove twine dependency. Thanks Tres Seaver. - new: also write buildout configuration file with --set-cfg. Thanks Christian Ullrich for the PR. -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)
On 3/30/14 10:22 AM, Steven D'Aprano wrote: In 1991, there was no wireless, no mobile computing, hardly any public Internet outside of the universities. It was before the Eternal September, and only a few years after the Great Renaming. I was using arpanet since the late 1970s. Python had just been released for the first time, and Windows 3.1 hadn't been (although 3.0 had). There was no Netscape, no Mosaic graphical web browsers. Steve Jobs hadn't returned to Apple yet, Apple was still losing money and mind- share, and Google didn't even exist. It was a different era. Command line all the way babe... uuencode uudecode base64 whoohoo. ftp, and all the rest... 1991 is 23 years ago. In computer years, I consider that almost eight generations, about the same as 160 years in human terms. Bologna, Oscar Meyer Bologna, USDA Prime. That's just plain silly. Yes, a lot of things have happened since 1991, but 1991 was yesterday; and in the big scheme of things, not much really has happened (oh, yeah, smaller and faster; Moores law moves forward, so what?) We're still using von Nuemann processors, we're still using all the same stupid programming tricks; the only thing that has changed is that computers use a fraction of the power they did, they are very tiny, and they are very fast. so what? We have unicode! yea. ASCII is dead. Microsoft is dying. Gun/Linux rules. I still program in BASIC at least once a week, and we all still have trouble communicating around the globe. I didn't really start using unicode until about 5 years ago; python has only really used it since python3. right? No. Python 2.2 introduced Unicode. I didn't ask when it was introduced, I asked when it became useful? Python was experimenting with unicode in version 2. It became more fully useful in version 3. I didn't use it in version 2--- way too frustrating. Unicode in python3.x is (mostly) working correctly. Congratulations to all who worked on it, hat is off. The problem with unicode is that it is just a specification. The consortium cannot force or code anything. They control the scripts and make the specifications. It is left to *everyone* else to implement. And not everyone is taking on that task with the same gusto, if you follow my meaning. marcus -- https://mail.python.org/mailman/listinfo/python-list
Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)
On Mon, Mar 31, 2014 at 5:08 PM, Mark H Harris harrismh...@gmail.com wrote: Unicode in python3.x is (mostly) working correctly. Congratulations to all who worked on it, hat is off. The problem with unicode is that it is just a specification. The consortium cannot force or code anything. They control the scripts and make the specifications. It is left to *everyone* else to implement. And not everyone is taking on that task with the same gusto, if you follow my meaning. Considering that Pike's native double-quoted string type stored true Unicode (not UTF-16, not eight-bit, the full Unicode range) back in 1998, you're quite correct in saying that some take on that task with more enthusiasm than others. Of course, that exact same fact does tell against your other and more important point, namely that people were unable to speak non-English to each other until very recently. Good luck. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)
Mark, you are demonstrating a habit of making sweeping pronouncements and assertions; and then, when those statements are challenged, you act as though you never said them. Here's a characteristic example: Mark H Harris harrismh...@gmail.com writes: On 3/30/14 10:22 AM, Steven D'Aprano wrote: Mark H Harris harrismh...@gmail.com writes: I didn't really start using unicode until about 5 years ago; python has only really used it since python3. right? No. Python 2.2 introduced Unicode. I didn't ask when it was introduced, I asked when it became useful? That's clearly not what you asked, in the material you quoted above; and Steven's answer to your actual false assertion is entirely appropriate. There are many other examples in this thread, but I'm not seeking to catalogue them; merely to show an example of what I'm observing. I hope you can see that this behaviour quickly leads many people to quite reasonably disregard your assertions in general, and even to ignore you altogether. Do you think you can tone down the rhetoric and perhaps stand by the statements you actually make? -- \ “Injustice is relatively easy to bear; what stings is justice.” | `\ —Henry L. Mencken | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)
On Monday, March 31, 2014 12:23:55 PM UTC+5:30, Ben Finney wrote: Mark, you are demonstrating a habit of making sweeping pronouncements and assertions; and then, when those statements are challenged, you act as though you never said them. Here's a characteristic example: Mark H Harris writes: On 3/30/14 10:22 AM, Steven D'Aprano wrote: Mark H Harris writes: I didn't really start using unicode until about 5 years ago; python has only really used it since python3. right? No. Python 2.2 introduced Unicode. I didn't ask when it was introduced, I asked when it became useful? That's clearly not what you asked, in the material you quoted above; and Steven's answer to your actual false assertion is entirely appropriate. There are many other examples in this thread, but I'm not seeking to catalogue them; merely to show an example of what I'm observing. I hope you can see that this behaviour quickly leads many people to quite reasonably disregard your assertions in general, and even to ignore you altogether. Do you think you can tone down the rhetoric and perhaps stand by the statements you actually make? I wonder... Is there some Unicode-corollary to Godwin's law? Something like: Whenever people discuss unicode long enough they start talking rubbish. Not very surprising given that unicode is related to human languages and human languages willy-nilly are connected to politics. It would be neat if we could stick to the 'uni(versal)' (aka math, music etc) aspect of unicode more and the 'needs localization' aspect less. -- https://mail.python.org/mailman/listinfo/python-list
Re: checking if two things do not equal None
contact.tri...@gmail.com wrote: if (a, b) != (None, None): or if a != None != b: Preference? Pros? Cons? Alternatives? I couldn't see anyone else give this, but I like if None not in (a, b): pass Jeremy -- https://mail.python.org/mailman/listinfo/python-list
Re: OFF TOPIC Spanish in the USA [was Re: Explanation of this Python language feature?]
On 31/03/2014 05:57, Mark H Harris wrote: On 3/30/14 5:35 AM, Steven D'Aprano wrote: Approximately 5% of the US population either do not speak English at all, or speak it poorly. That includes approximately half a million ASL speakers (American Sign Language, which is not a manual representation of English but an independent language in it's own right), the majority of whom are unable to speak or understand spoken English. Steven, you have trolled us over to the left edge of outer left field all the way back at the fence, dude, seriously--- and then you dropped the ball. Geeeze... error. Is it safe to assume that's a reference from a sport that essentially only gets played in the USA so you have a World Series? -- 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: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)
Unicode... Interesting reading. jmf -- https://mail.python.org/mailman/listinfo/python-list
Re: OFF TOPIC Spanish in the USA
Mark H Harris harrismh...@gmail.com: The main point of the link is the status on English as an official language. 28 out of 50 states have legislated English as the official language; meaning, that you either speak and write English, or you're going to have a really tough time participating in culture, business, government, and recreation. What does official language mean? Finland has two official languages: Finnish and Swedish. It means you are guaranteed to get state services in both languages. At municipal level, you might get guarantees in one or both of the languages depending on census data. In California, OTOH, it's the other way around: English being official means you are guaranteed *not* to get services in languages other than English. If a government social worker speaks Spanish and the customer only knows Spanish, the social worker is not legally allowed to use Spanish to conduct their business. In Finland, no government worker is disallowed from using any language they deem useful in their work. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Examples of modern GUI python programms
Metallicow metaliobovi...@gmail.com wrote: My opinion would be wxPython if not actually using for a mobile, or PySide if you are. Both of these have acceptable licenses if you want to go commercial also without having to pay for commercial library usage. If you are to distribute a program using LGPL software on AppStore or Gopgle Play, then remember that the user must be allowed to relink the program with anpther version of the library. That is an LGPL requirement. I don't see how this requirement can be satisfied in this case. Thus, LGPL on AppStore or Google Play is probably put of the question. At least on iOS, the user cannot change what you put in an App bundle. This excludes wxPython and PySide. Thus, the only viable cross-platform choices are commercial PyQt + commercial Qt or tkinter. In case of iOS, PyObjC is also an option. py2app will also be useful for creating App bundles on iOS. Sturla -- https://mail.python.org/mailman/listinfo/python-list
Re: Examples of modern GUI python programms
On Monday, March 31, 2014 3:48:33 AM UTC-5, Sturla Molden wrote: If you are to distribute a program using LGPL software on AppStore or Gopgle Play, then remember that the user must be allowed to relink the program with anpther version of the library. That is an LGPL requirement. I don't see how this requirement can be satisfied in this case. Thus, LGPL on AppStore or Google Play is probably put of the question. At least on iOS, the user cannot change what you put in an App bundle. This excludes wxPython and PySide. Thus, the only viable cross-platform choices are commercial PyQt + commercial Qt or tkinter. In case of iOS, PyObjC is also an option. py2app will also be useful for creating App bundles on iOS. Sturla The OP didn't exactly detail what exactly was being looked for just python on windows basically. So that part still hasn't been answered... As far as wxPython, that is not LGPL, it is wxPython/wxWidgets which is fine for licensing your compiled app as however you want. Modifications to the library stuff for example is good in the fact with this that most all improvements(to the library-stuff) eventually work their way back in or have to be released GPL v2. One would have to tool through the PySide agreement for their specifics, but as I recall it is exactly the same as Qt is, which makes sense. Riverbank/PyQt is not Qt, they are a separate entity, just to make that clear. The reason PySide was made was because Riverbank didn't want to license their bindings that same as Qt basically. A lot depends on what you intend to do with the app and how many hoops you are willing to jump through license wise. Just because a library is LGPL doesn't mean the authors code has to be depending on the circumstances. That just means usually you have to be able to provide the library code(and your mods to it) used. If the author doesn't care about releasing his/her own source code, then just about any toolkit would be at the same level of python on windows for the most part. It all depends on what the target for the app is. Windows desktop?, Windows Phone?, MSW XBox?, etc... -- https://mail.python.org/mailman/listinfo/python-list
Re: unicode as valid naming symbols
On 27-03-14 17:22, Ian Kelly wrote: On Thu, Mar 27, 2014 at 9:28 AM, Mark H Harris harrismh...@gmail.com wrote: Do you think that the ability to write this would be an improvement? import ⌺ ⌚ = ⌺.╩░ ⑥ = 5*⌺.⋨⋩ ❹ = ⑥ - 1 ♅⚕⚛ = [⌺.✱✳**⌺.❇*❹{⠪|⌚.∣} for ⠪ in ⌺.⣚] ⌺.˘˜¨´՛՜(♅⚕⚛) Steven, you're killing me here; argument by analogy does not work! [ -- 8 -- ] One of the things that Python is widely known for is its readability. Allowing symbols such as √ to denote identifiers may be quite expressive and appreciable to the person writing the code. However it damages readability considerably, as seen in Steven's example above. Personally I'm not interested in having to maintain another programmer's code that arbitrarily uses ⌚ as a timer function, ╩ as intersection or ░ as a matrix constructor. I don't find Steven's example convincing. Sure it can be used in a way that damages readability considerably however lots of things in python can be abused in a way that damages readability considerably. That you are not interested in having to maintain someone's code who would use such symbols is irrelevant. IIRC people have used the exact same kind of argument against decorators and the if-else operator. It seems we are all consenting adults until someone doesn't like the idea how it might influence his job. In that case it shouldn't be allowed. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Python IM server
Hi all, I want to develop a instant message server, simply has user and group entity. Is there any better existing open-source one? Thus I can download and have a look. Thanks. Wesley -- https://mail.python.org/mailman/listinfo/python-list
Line of best fit
I am new to python so apologies for the ignorance with this question. How would I apply a line of best fit to a plot? My data are netCDF4 data files and this is essentially what I have done so far: swh1=netCDF4.Dataset('filename','r') hs1=swh1.variables['hs'] swh2=netCDF4.Dataset('filename'.'r') hs2=swh2.variables['hs'] plt.plot(hs1,hs2,'.') Cheers, Jamie -- https://mail.python.org/mailman/listinfo/python-list
Re: OFF TOPIC Spanish in the USA
On 3/31/14 4:39 AM, Marko Rauhamaa wrote: Mark H Harris harrismh...@gmail.com: The main point of the link is the status on English as an official language. 28 out of 50 states have legislated English as the official language; meaning, that you either speak and write English, or you're going to have a really tough time participating in culture, business, government, and recreation. What does official language mean? Finland has two official languages: Finnish and Swedish. It means you are guaranteed to get state services in both languages. At municipal level, you might get guarantees in one or both of the languages depending on census data. In California, OTOH, it's the other way around: English being official means you are guaranteed *not* to get services in languages other than English. If a government social worker speaks Spanish and the customer only knows Spanish, the social worker is not legally allowed to use Spanish to conduct their business. In Finland, no government worker is disallowed from using any language they deem useful in their work. Can I politely suggest that we just end this discussion? The thread has been properly marked as OFF TOPIC, and it is now squarely in areas that are 1) politically contentious, 2) wildly subjective, 3) none of our areas of expertise. No good can come from continuing. --Ned. Marko -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)
In article lhb0on$pcj$1...@speranza.aioe.org, Mark H Harris harrismh...@gmail.com wrote: On 3/30/14 10:22 AM, Steven D'Aprano wrote: In 1991, there was no wireless, no mobile computing, hardly any public Internet outside of the universities. It was before the Eternal September, and only a few years after the Great Renaming. I was using arpanet since the late 1970s. Python had just been released for the first time, and Windows 3.1 hadn't been (although 3.0 had). There was no Netscape, no Mosaic graphical web browsers. Steve Jobs hadn't returned to Apple yet, Apple was still losing money and mind- share, and Google didn't even exist. It was a different era. Command line all the way babe... uuencode uudecode base64 whoohoo. Remember when btoa/atob came out? You got 32 bits of data in just 5 characters. Win! Waiting for btou :-) Unicode in python3.x is (mostly) working correctly. Congratulations to all who worked on it, hat is off. The problem with unicode is that it is just a specification. The consortium cannot force or code anything. They control the scripts and make the specifications. It is left to *everyone* else to implement. My first introduction to unicode was a monster i18n makeover on a large C++ codebase. For reasons I no longer remember, we ended up settling on utf-8 for native strings (with, of course, our own string class), but we were also using some library which was utf-16 internally (ICU4C, I think?). So, we were constantly transcoding all over the place. What a mess. -- https://mail.python.org/mailman/listinfo/python-list
Re: Line of best fit
In article 0fb15100-15e8-46d6-a38f-b187c7012...@googlegroups.com, Jamie Mitchell jamiemitchell1...@gmail.com wrote: I am new to python so apologies for the ignorance with this question. How would I apply a line of best fit to a plot? Python has nothing built-in which does that, but there are plenty of add-on modules which do those sorts of things. One popular one is statsmodels (http://statsmodels.sourceforge.net/) plt.plot(hs1,hs2,'.') Please tell us more about the environment you're working in. I'm guessing from the fact that you're calling plt.plot(), that you've already got some add-on modules loaded. Pandas, maybe? -- https://mail.python.org/mailman/listinfo/python-list
Re: OFF TOPIC Spanish in the USA [was Re: Explanation of this Python language feature?]
On Mon, Mar 31, 2014 at 11:41 PM, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Mon, 31 Mar 2014 16:44:56 +1100, Chris Angelico ros...@gmail.com declaimed the following: official language, and pick up any government form - something fairly important, like applying for a passport or something. How many Passport is a Federal form, not under State control. Ehh, sorry, bad example then. (I'm not a Merkin, so I don't know what you suffer under.) Pick something that is state-controlled instead. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Examples of modern GUI python programms
On 31 Mar 2014 00:21, D. Xenakis gouzouna...@hotmail.com wrote: ... Snip ... What i need is to develop an android looking program (entirelly in python) for windows, but dunno if this is possible (most propably is), and which tool between those would help me most: tkinter - wxpython - pyqt - pygtk . Any examples and suggestions are most welcome. While I've not used it much Kivy could be useful if you want it to look Android like, with the added benefit that you can build for android as well. -- https://mail.python.org/mailman/listinfo/python-list
Re: Line of best fit
None of these are in the standard library but why re-invent the wheel? Using numpy: http://docs.scipy.org/doc/numpy/reference/generated/numpy.polyfit.html scipy: http://docs.scipy.org/doc/scipy-0.13.0/reference/generated/scipy.stats.linregress.html statsmodels: http://statsmodels.sourceforge.net/devel/examples/notebooks/generated/ols.html On Mon, Mar 31, 2014 at 1:29 PM, Jamie Mitchell jamiemitchell1...@gmail.com wrote: I am new to python so apologies for the ignorance with this question. How would I apply a line of best fit to a plot? My data are netCDF4 data files and this is essentially what I have done so far: swh1=netCDF4.Dataset('filename','r') hs1=swh1.variables['hs'] swh2=netCDF4.Dataset('filename'.'r') hs2=swh2.variables['hs'] plt.plot(hs1,hs2,'.') Cheers, Jamie -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Python IM server
Hi, I want to develop a instant message server, simply has user and group entity. Is there any better existing open-source one? Take a look at XMPP[0]. There are some Python libraries[1]. [0] https://en.wikipedia.org/wiki/XMPP [1] http://xmpp.org/xmpp-software/libraries/ -- Opt out of global data surveillance programs like PRISM, XKeyscore and Tempora. https://prism-break.org -- https://mail.python.org/mailman/listinfo/python-list
Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)
On 2014-03-30, Rhodri James rho...@wildebst.org.uk wrote: On Sun, 30 Mar 2014 11:44:13 +0100, Steven D'Aprano Among fans of the British writer Terry Pratchett, the usual term is Merkins. Including among Merkin fans. Many of whom even know what a merkin is, and use the term anyway. As much as I'd rather not be called a Merkin, one can't really get mad at Terry Pratchett fans... -- Grant Edwards grant.b.edwardsYow! I'm also against at BODY-SURFING!! gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Code style query: multiple assignments in if/elif tree
Call this a code review request, if you like. I'm wondering how you'd go about coding something like this. Imagine you're in a train, and the brakes don't apply instantly. The definition, in the interests of passenger comfort, is that the first second of brake application has an acceleration of 0.2 m/s/s, the next second has 0.425 m/s/s, and thereafter full effect of 0.85 m/s/s. You have a state variable that says whether the brakes have just been applied, have already been applied for at least two seconds, or haven't yet been applied at all. Problem: Work out how far you'll go before the brakes reach full power, and how fast you'll be going at that point. Here's how I currently have the code. The variable names are a tad long, as this was also part of me teaching my brother Python. # Already got the brakes fully on if mode==Brake2: distance_to_full_braking_power, speed_full_brake = 0.0, curspeed # The brakes went on one second ago, they're nearly full elif mode==Brake1: distance_to_full_braking_power, speed_full_brake = curspeed - 0.2125, curspeed - 0.425 # Brakes aren't on. else: distance_to_full_braking_power, speed_full_brake = (curspeed - 0.1) + (curspeed - 0.4125), curspeed - 0.625 # If we hit the brakes now (or already have hit them), we'll go another d meters and be going at s m/s before reaching full braking power. But I don't like the layout. I could change it to a single assignment with expression-if, but that feels awkward too. How would you lay this out? (Note that the else case could have any of several modes in it, so I can't so easily use a dict.) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Code style query: multiple assignments in if/elif tree
Chris Angelico ros...@gmail.com: Call this a code review request, if you like. I'm wondering how you'd go about coding something like this. As a simple layout question, I'd do it like this: if mode == Brake2: # Already got the brakes fully on distance_to_full_braking_power = 0.0 speed_full_brake = curspeed elif mode == Brake1: # The brakes went on one second ago, they're nearly full distance_to_full_braking_power = curspeed - 0.2125 speed_full_brake = curspeed - 0.425 else: # Brakes aren't on. distance_to_full_braking_power = (curspeed - 0.1) + (curspeed - 0.4125) speed_full_brake = curspeed - 0.625 # If we hit the brakes now (or already have hit them), we'll go another # d meters and be going at s m/s before reaching full braking power. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Code style query: multiple assignments in if/elif tree
On Tue, Apr 1, 2014 at 2:40 AM, Marko Rauhamaa ma...@pacujo.net wrote: As a simple layout question, I'd do it like this: if mode == Brake2: # Already got the brakes fully on distance_to_full_braking_power = 0.0 speed_full_brake = curspeed elif mode == Brake1: # The brakes went on one second ago, they're nearly full distance_to_full_braking_power = curspeed - 0.2125 speed_full_brake = curspeed - 0.425 else: # Brakes aren't on. distance_to_full_braking_power = (curspeed - 0.1) + (curspeed - 0.4125) speed_full_brake = curspeed - 0.625 # If we hit the brakes now (or already have hit them), we'll go another # d meters and be going at s m/s before reaching full braking power. No particular advantage over the current version - it doesn't simplify it any, all you've done is break it across more lines. (The unpacking may not be ideal; as I said, this was a vehicle for teaching oddments of Python, so I used multiple assignment partly for the sake of using it.) Incidentally, if you want to see the code in context, it's here: https://github.com/Rosuav/runningtime/blob/master/runningtime.py ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Code style query: multiple assignments in if/elif tree
On Monday, March 31, 2014 9:33:54 PM UTC+5:30, Chris Angelico wrote: On Tue, Apr 1, 2014 at 2:40 AM, Marko Rauhamaa wrote: As a simple layout question, I'd do it like this: if mode == Brake2: # Already got the brakes fully on distance_to_full_braking_power = 0.0 speed_full_brake = curspeed elif mode == Brake1: # The brakes went on one second ago, they're nearly full distance_to_full_braking_power = curspeed - 0.2125 speed_full_brake = curspeed - 0.425 else: # Brakes aren't on. distance_to_full_braking_power = (curspeed - 0.1) + (curspeed - 0.4125) speed_full_brake = curspeed - 0.625 # If we hit the brakes now (or already have hit them), we'll go another # d meters and be going at s m/s before reaching full braking power. No particular advantage over the current version - it doesn't simplify it any, all you've done is break it across more lines. Not answering your original question but the above comment Your version was sufficiently garbled indentation-wise (it may give you sweet pleasure to know my 'client' is GG) that I gave up on reading it. Marko's version was clear enough that it seems to match your spec [Ive not really verified it word for word... Just sayin'] On the whole I prefer multiple assignments. Maybe in this case use small variable names with separate(d) explanatory comments?? -- https://mail.python.org/mailman/listinfo/python-list
Re: Code style query: multiple assignments in if/elif tree
On Tue, Apr 1, 2014 at 3:20 AM, Rustom Mody rustompm...@gmail.com wrote: On the whole I prefer multiple assignments. Maybe in this case use small variable names with separate(d) explanatory comments?? Shorter variable names would certainly be the more normal, heh. I let my brother do that part of the typing, picking names and so on. Better for teaching to let the victi-- err, the student have the power to choose. :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: checking if two things do not equal None
I couldn't see anyone else give this, but I like if None not in (a, b): I did. I am now considering: if None not in (a,b): or if (a is not None) and (b is not None): However, I decided to just turn the two parameters into one (sequence), since they were logically grouped anyhow. -- https://mail.python.org/mailman/listinfo/python-list
Re: unicode as valid naming symbols
On Mon, Mar 31, 2014 at 3:55 AM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: On 27-03-14 17:22, Ian Kelly wrote: On Thu, Mar 27, 2014 at 9:28 AM, Mark H Harris harrismh...@gmail.com wrote: Do you think that the ability to write this would be an improvement? import ⌺ ⌚ = ⌺.╩░ ⑥ = 5*⌺.⋨⋩ ❹ = ⑥ - 1 ♅⚕⚛ = [⌺.✱✳**⌺.❇*❹{⠪|⌚.∣} for ⠪ in ⌺.⣚] ⌺.˘˜¨´՛՜(♅⚕⚛) Steven, you're killing me here; argument by analogy does not work! [ -- 8 -- ] One of the things that Python is widely known for is its readability. Allowing symbols such as √ to denote identifiers may be quite expressive and appreciable to the person writing the code. However it damages readability considerably, as seen in Steven's example above. Personally I'm not interested in having to maintain another programmer's code that arbitrarily uses ⌚ as a timer function, ╩ as intersection or ░ as a matrix constructor. I don't find Steven's example convincing. Sure it can be used in a way that damages readability considerably however lots of things in python can be abused in a way that damages readability considerably. That you are not interested in having to maintain someone's code who would use such symbols is irrelevant. IIRC people have used the exact same kind of argument against decorators and the if-else operator. It seems we are all consenting adults until someone doesn't like the idea how it might influence his job. In that case it shouldn't be allowed. That was an exaggeration on my part. It wouldn't affect my job, as I wouldn't expect to ever actually have to maintain anything like the above. My greater point though is that it damages Python's readability for no actual gain in my view. There is nothing useful you can do with a name that is the U+1F4A9 character that you can't do just as easily with alphanumeric identifiers like pile_of_poo (or куча_фекалий if one prefers; that's auto-translated, so don't blame me if it's a poor translation). The kinds of symbols that we're talking about here aren't part of any writing systems, and so to incorporate them in *names* as if they were is an abuse of Unicode. I don't think the comparisons to decorators and the if-else operator are apt. First, because while those may degrade readability, they do so in a constrained way. A decorator application is just the @ symbol and an identifier. The if-else is just three expressions separated by keywords. In the case of arbitrary Unicode identifiers, we're talking about approximately doubling the number of different characters (out of a continuously growing set) that could be used, many of which are easily confused with other characters. Of course the potential for confusion already exists, but that's no justification for aggravating it. Second, at least in the case of decorators, while I don't dispute that they can harm readability, I think that in the majority of cases they actually help it. That's because the @ syntax placed before a function or class clearly denotes that the construct is being decorated by something. The alternative to the syntax is to place an assignment like f = decorate(f) *after* the definition, where it is much less prominent. That the reader then potentially has to go figure out what the decorator does is true regardless of whether the @ syntax is used or not. I'm unable to imagine any case where an arbitrary Unicode identifier would actually improve readability. Finally, in my experience the consenting adults line is usually used in the context of program or library design. I don't believe it's appropriate when discussing the design of the language itself, which should be kept as clean as possible. The logical conclusion of that would be Lisp-like macros where every user ends up with their own unique and incompatible version of the language, because we're all consenting adults here, right? -- https://mail.python.org/mailman/listinfo/python-list
Re: unicode as valid naming symbols
On 2014-03-31 11:40, Ian Kelly wrote: There is nothing useful you can do with a name that is the U+1F4A9 character that you can't do just as easily with alphanumeric identifiers like pile_of_poo (or куча_фекалий if one prefers; that's auto-translated, so don't blame me if it's a poor translation). The kinds of symbols that we're talking about here aren't part of any writing systems, and so to incorporate them in *names* as if they were is an abuse of Unicode. It does get more complex though, when you could have things like 黄金屎 = \U0001f4a9 Like you, I don't expect to ever encounter something like this in the wild, but they are indeed symbols used in a writing system. :-) -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: unicode as valid naming symbols
On Mon, Mar 31, 2014 at 12:02 PM, Tim Chase python.l...@tim.thechases.com wrote: On 2014-03-31 11:40, Ian Kelly wrote: There is nothing useful you can do with a name that is the U+1F4A9 character that you can't do just as easily with alphanumeric identifiers like pile_of_poo (or куча_фекалий if one prefers; that's auto-translated, so don't blame me if it's a poor translation). The kinds of symbols that we're talking about here aren't part of any writing systems, and so to incorporate them in *names* as if they were is an abuse of Unicode. It does get more complex though, when you could have things like 黄金屎 = \U0001f4a9 Like you, I don't expect to ever encounter something like this in the wild, but they are indeed symbols used in a writing system. :-) That's already a legal identifier, though. The constituent ideographs are categorized as Letter, Other, not symbols. -- https://mail.python.org/mailman/listinfo/python-list
Re: checking if two things do not equal None
On 31/03/14 19:28, Abe wrote: I couldn't see anyone else give this, but I like if None not in (a, b): I did. I am now considering: if None not in (a,b): or if (a is not None) and (b is not None): That's just if not (a is None or b is None): but you seem to have found your way. However, I decided to just turn the two parameters into one (sequence), since they were logically grouped anyhow. -- https://mail.python.org/mailman/listinfo/python-list
Re: unicode as valid naming symbols
Op 31-03-14 19:40, Ian Kelly schreef: On Mon, Mar 31, 2014 at 3:55 AM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: On 27-03-14 17:22, Ian Kelly wrote: On Thu, Mar 27, 2014 at 9:28 AM, Mark H Harris harrismh...@gmail.com wrote: Do you think that the ability to write this would be an improvement? import ⌺ ⌚ = ⌺.╩░ ⑥ = 5*⌺.⋨⋩ ❹ = ⑥ - 1 ♅⚕⚛ = [⌺.✱✳**⌺.❇*❹{⠪|⌚.∣} for ⠪ in ⌺.⣚] ⌺.˘˜¨´՛՜(♅⚕⚛) Steven, you're killing me here; argument by analogy does not work! [ -- 8 -- ] One of the things that Python is widely known for is its readability. Allowing symbols such as √ to denote identifiers may be quite expressive and appreciable to the person writing the code. However it damages readability considerably, as seen in Steven's example above. Personally I'm not interested in having to maintain another programmer's code that arbitrarily uses ⌚ as a timer function, ╩ as intersection or ░ as a matrix constructor. I don't find Steven's example convincing. Sure it can be used in a way that damages readability considerably however lots of things in python can be abused in a way that damages readability considerably. That you are not interested in having to maintain someone's code who would use such symbols is irrelevant. IIRC people have used the exact same kind of argument against decorators and the if-else operator. It seems we are all consenting adults until someone doesn't like the idea how it might influence his job. In that case it shouldn't be allowed. That was an exaggeration on my part. It wouldn't affect my job, as I wouldn't expect to ever actually have to maintain anything like the above. My greater point though is that it damages Python's readability for no actual gain in my view. There is nothing useful you can do with a name that is the U+1F4A9 character that you can't do just as easily with alphanumeric identifiers like pile_of_poo (or куча_фекалий if one prefers; that's auto-translated, so don't blame me if it's a poor translation). The kinds of symbols that we're talking about here aren't part of any writing systems, and so to incorporate them in *names* as if they were is an abuse of Unicode. Your argument doesn't has much weight. First of all it can be used for just restricting names to the ascii range. Second of all I think a good chosen symbolic name can be more readable than a name in a character set you are not familiar with. A good chosen symbol will evoke a meaning with a lot of people. A name in a character set you are not familiar with is just gibberish to you. I don't think the comparisons to decorators and the if-else operator are apt. I didn't make such a comparison. I just noted the arguments against were similar. First, because while those may degrade readability, they do so in a constrained way. A decorator application is just the @ symbol and an identifier. And if abused, can totally change the working of your function. There is no guarantee that the function returned, has any relation with the original function. If that can't be a night mare for readability, I don't know what is. The if-else is just three expressions separated by keywords. Yes but if used unrestrained in arbitrary expressions will make those expressions hard to understand. In the case of arbitrary Unicode identifiers, we're talking about approximately doubling the number of different characters (out of a continuously growing set) that could be used, many of which are easily confused with other characters. Of course the potential for confusion already exists, but that's no justification for aggravating it. So what if we double the number of different characters? I don't care about the number of them, I care about how meaningful they are. And as you say confusion is already possible. A good programmer knows how to deal with such a possible confusion, that the number of cases increases, doesn't need to be a problem for those that care about this. Second, at least in the case of decorators, while I don't dispute that they can harm readability, I think that in the majority of cases they actually help it. But that is not a fair comparison now, is it. What you are doing here is comparing actual use, to a worst case doom scenario. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: unicode as valid naming symbols
On 3/31/2014 1:40 PM, Ian Kelly wrote: Second, at least in the case of decorators, while I don't dispute that they can harm readability, I think that in the majority of cases they actually help it. That's because the @ syntax placed before a function or class clearly denotes that the construct is being decorated by something. The alternative to the syntax is to place an assignment like f = decorate(f) *after* the definition, where it is much less prominent. Plus, it means writing and reading the name 3 times instead of 1. This is not much of an issue for 'f', but it is for names like 'modify_x07_with_qz46pt'. Names like this occur when interfacing to external systems that dictate the names needed (as when interfacing Python to Objective-C on Macs). -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Examples of modern GUI python programms
Metallicow metaliobovi...@gmail.com wrote: One would have to tool through the PySide agreement for their specifics, but as I recall it is exactly the same as Qt is, which makes sense. According to their web page, PySide is only LGPL. Qt is LGPL or commercial. Just because a library is LGPL doesn't mean the authors code has to be depending on the circumstances. That just means usually you have to be able to provide the library code(and your mods to it) used. No, that would be MPL (Mozilla Public License). Many believe LGPL implies the same freedom as MPL. It does not. LGPL also means you also have to give the user a means to relink the program with a different version of the library. That is a less known restriction of LGPL. Usually this is done by providing the LGPL library as a DLL. But a DLL is actually not sufficient, in case a different version of the library breaks the application binary interface (ABI). In case of ABI breakage, LGPL means the user be given access to the program source code to recompile and relink the program. Because of the closed nature of app bundles on iOS, the user cannot do anything with an .so or .dylib file. Thus, the DLL solution to LGPL infestation is not possible on iOS, even if it were sufficient. MPL is basically a version og LGPL that has removed the requirement to make relinkage possible. That is e.g. why a library like Eigen is released as MPL instead of LGPL. Sturla -- https://mail.python.org/mailman/listinfo/python-list
Re: unicode as valid naming symbols
On 3/31/2014 3:31 PM, Antoon Pardon wrote: Op 31-03-14 19:40, Ian Kelly schreef: First, because while those may degrade readability, they do so in a constrained way. A decorator application is just the @ symbol and an identifier. And if abused, can totally change the working of your function. There is no guarantee that the function returned, has any relation with the original function. If that can't be a night mare for readability, I don't know what is. This is a matter of the wrapping function, not the decorator syntax abbreviation. @twist_the_function_meaning def f: return clear_expression is no worse in this regard than the written out form def f: return clear_expression f = twist_the_function_meaning(f) -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Code style query: multiple assignments in if/elif tree
On Mon, 31 Mar 2014 17:29:54 +0100, Chris Angelico ros...@gmail.com wrote: On Tue, Apr 1, 2014 at 3:20 AM, Rustom Mody rustompm...@gmail.com wrote: On the whole I prefer multiple assignments. Maybe in this case use small variable names with separate(d) explanatory comments?? Shorter variable names would certainly be the more normal, heh. I let my brother do that part of the typing, picking names and so on. Better for teaching to let the victi-- err, the student have the power to choose. :) Not just more normal, but more readable too. The trouble with your original example was that the lines were too long (even ignoring the trouble line-wrapping caused in your post) to take in with only a couple of eye movements along the line. That makes a really quite surprising difference to the comprehensibility of the whole thing. -- Rhodri James *-* Wildebeest Herder to the Masses -- https://mail.python.org/mailman/listinfo/python-list
Re: unicode as valid naming symbols
Terry Reedy tjre...@udel.edu: @twist_the_function_meaning def f: return clear_expression is no worse in this regard than the written out form def f: return clear_expression f = twist_the_function_meaning(f) I don't remember feeling the need for either. I have written wrappers of all sorts, but somehow that pattern just feels alien to me so far. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)
On Mon, 31 Mar 2014 07:08:24 +0100, Mark H Harris harrismh...@gmail.com wrote: On 3/30/14 10:22 AM, Steven D'Aprano wrote: In 1991, there was no wireless, no mobile computing, hardly any public Internet outside of the universities. It was before the Eternal September, and only a few years after the Great Renaming. I was using arpanet since the late 1970s. I was using JANet since the early 80s, and I'm by no means the oldest person here. I should stop playing that card if I were you. I didn't really start using unicode until about 5 years ago; python has only really used it since python3. right? No. Python 2.2 introduced Unicode. I didn't ask when it was introduced, I asked when it became useful? No you didn't. You even quoted yourself as not saying it, just in case you weren't clear about that. And since you're so experienced, you should recognise this sound: *plonk* -- Rhodri James *-* Wildebeest Herder to the Masses -- https://mail.python.org/mailman/listinfo/python-list
Re: OFF TOPIC Spanish in the USA [was Re: Explanation of this Python language feature?]
On Mon, 31 Mar 2014 06:23:46 +0100, Mark H Harris harrismh...@gmail.com wrote: The main point of the link is the status on English as an official language. 28 out of 50 states have legislated English as the official language; meaning, that you either speak and write English, or you're going to have a really tough time participating in culture, business, government, and recreation. That few? I'm surprised. Presumably the other states don't have any contention for the status of official language? I'm also surprised that you aren't surprised that over half the states feel the need to specify an official language. One might wonder why... -- Rhodri James *-* Wildebeest Herder to the Masses -- https://mail.python.org/mailman/listinfo/python-list
Re: Code style query: multiple assignments in if/elif tree
On 3/31/14 12:03 PM, Chris Angelico wrote: Incidentally, if you want to see the code in context, it's here: https://github.com/Rosuav/runningtime/blob/master/runningtime.py ChrisA I know you didn't ask about these aspects, but they jumped out at me: tabs for indentation instead of spaces, and docstring-style comments in places that aren't docstrings. These seem like unusual choices. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list
Re: OFF TOPIC Spanish in the USA [was Re: Explanation of this Python language feature?]
On 3/31/2014 4:47 PM, Rhodri James wrote: On Mon, 31 Mar 2014 06:23:46 +0100, Mark H Harris harrismh...@gmail.com wrote: The main point of the link is the status on English as an official language. 28 out of 50 states have legislated English as the official language; meaning, that you either speak and write English, or you're going to have a really tough time participating in culture, business, government, and recreation. Perhaps the link was https://en.wikipedia.org/wiki/Languages_of_the_United_States#Official_language_status That few? I'm surprised. Presumably the other states don't have any contention for the status of official language? The modern 'English primary' movement, with its first state success in 1981, was a reaction to the 'Spanish co-equal' movement of the 1970s. Without state-by-state data on the push for legislation, I see no clear pattern in the list of which states have such a law. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Code style query: multiple assignments in if/elif tree
On Tue, Apr 1, 2014 at 8:42 AM, Ned Batchelder n...@nedbatchelder.com wrote: On 3/31/14 12:03 PM, Chris Angelico wrote: Incidentally, if you want to see the code in context, it's here: https://github.com/Rosuav/runningtime/blob/master/runningtime.py ChrisA I know you didn't ask about these aspects, but they jumped out at me: tabs for indentation instead of spaces, and docstring-style comments in places that aren't docstrings. These seem like unusual choices. Tabs instead of spaces? They're plenty common enough, but I am *not* getting into that debate now. The file's perfectly consistent - aside from inside strings, all indentation is done with tabs, one per level. How do you go about doing multi-line comments? I know I've seen other code using triple-quoted strings for long comments before. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Code style query: multiple assignments in if/elif tree
Chris Angelico ros...@gmail.com writes: How do you go about doing multi-line comments? I know I've seen other code using triple-quoted strings for long comments before. Just use a sequence of one-line comments:: # Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut a # sapien tempor, suscipit orci sed, elementum nisl. Suspendisse at # lacus ut diam dignissim lobortis ac vitae augue. # # Phasellus bibendum neque a justo vulputate, quis accumsan quam # egestas. Etiam aliquet blandit ante sit amet cursus. A decent code editor (e.g. Emacs, Vim) will allow manipulation of a sequence of one-line comments in Python's comment style, and allow treating it as a paragraphs for purposes such as re-wrapping the lines. I agree with others that triple-quoted strings are best reserved for string literals (including docstrings), not comments. -- \ “Alternative explanations are always welcome in science, if | `\ they are better and explain more. Alternative explanations that | _o__) explain nothing are not welcome.” —Victor J. Stenger, 2001-11-05 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Code style query: multiple assignments in if/elif tree
On Tue, Apr 1, 2014 at 9:57 AM, Ben Finney ben+pyt...@benfinney.id.au wrote: Chris Angelico ros...@gmail.com writes: How do you go about doing multi-line comments? I know I've seen other code using triple-quoted strings for long comments before. Just use a sequence of one-line comments:: # Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut a # sapien tempor, suscipit orci sed, elementum nisl. Suspendisse at # lacus ut diam dignissim lobortis ac vitae augue. # # Phasellus bibendum neque a justo vulputate, quis accumsan quam # egestas. Etiam aliquet blandit ante sit amet cursus. A decent code editor (e.g. Emacs, Vim) will allow manipulation of a sequence of one-line comments in Python's comment style, and allow treating it as a paragraphs for purposes such as re-wrapping the lines. I agree with others that triple-quoted strings are best reserved for string literals (including docstrings), not comments. Fair enough. I can't remember where (or when!) it was that I learned triple-quoted strings were appropriately abused as comments, so I've just done a quick re-layout into hash comments. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Line of best fit
Roy Smith r...@panix.com wrote: Please tell us more about the environment you're working in. I'm guessing from the fact that you're calling plt.plot(), that you've already got some add-on modules loaded. Pandas, maybe? Probably matplotlib.pyplot -- https://mail.python.org/mailman/listinfo/python-list
Re: unicode as valid naming symbols
On Mon, Mar 31, 2014 at 1:31 PM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: Op 31-03-14 19:40, Ian Kelly schreef: That was an exaggeration on my part. It wouldn't affect my job, as I wouldn't expect to ever actually have to maintain anything like the above. My greater point though is that it damages Python's readability for no actual gain in my view. There is nothing useful you can do with a name that is the U+1F4A9 character that you can't do just as easily with alphanumeric identifiers like pile_of_poo (or куча_фекалий if one prefers; that's auto-translated, so don't blame me if it's a poor translation). The kinds of symbols that we're talking about here aren't part of any writing systems, and so to incorporate them in *names* as if they were is an abuse of Unicode. Your argument doesn't has much weight. First of all it can be used for just restricting names to the ascii range. I disagree. Non-ASCII written names are useful to anybody who prefers not to do all their programming in English. Second of all I think a good chosen symbolic name can be more readable than a name in a character set you are not familiar with. A good chosen symbol will evoke a meaning with a lot of people. A name in a character set you are not familiar with is just gibberish to you. Well, this is the path taken by APL. It has its supporters. It's not known for being readable. I don't think the comparisons to decorators and the if-else operator are apt. I didn't make such a comparison. I just noted the arguments against were similar. That's the comparison to which I was referring. First, because while those may degrade readability, they do so in a constrained way. A decorator application is just the @ symbol and an identifier. And if abused, can totally change the working of your function. There is no guarantee that the function returned, has any relation with the original function. If that can't be a night mare for readability, I don't know what is. As Terry Reedy noted, this has nothing to do with the decorator syntax, so it isn't much of an argument against having such syntax. The if-else is just three expressions separated by keywords. Yes but if used unrestrained in arbitrary expressions will make those expressions hard to understand. I don't disagree. I hardly ever use it myself, certainly only if it can fit comfortably into one line, which is rare. But it's still quite limited in syntactic scope. In the case of arbitrary Unicode identifiers, we're talking about approximately doubling the number of different characters (out of a continuously growing set) that could be used, many of which are easily confused with other characters. Of course the potential for confusion already exists, but that's no justification for aggravating it. So what if we double the number of different characters? I don't care about the number of them, I care about how meaningful they are. And as you say confusion is already possible. A good programmer knows how to deal with such a possible confusion, that the number of cases increases, doesn't need to be a problem for those that care about this. So tell me then, how would you deal with it? In the case of script identifiers, it's often not hard to discern from context whether a particular character is e.g. a Latin h or a Cyrillic һ. Assuming the original author wasn't being intentionally obfuscatory, if the rest of the identifier is Cyrillic then the character is probably also Cyrillic. If it's a one-character identifier, then hopefully the rest of the module is consistent and you can guess from that. If the identifier in question is just one symbol though, then you have a lot less context. Second, at least in the case of decorators, while I don't dispute that they can harm readability, I think that in the majority of cases they actually help it. But that is not a fair comparison now, is it. What you are doing here is comparing actual use, to a worst case doom scenario. I contend that there is no scenario with arbitrary Unicode identifiers where readability is improved. -- https://mail.python.org/mailman/listinfo/python-list
Re: Code style query: multiple assignments in if/elif tree
On 03/31/2014 04:12 PM, Chris Angelico wrote: On Tue, Apr 1, 2014 at 9:57 AM, Ben Finney ben+pyt...@benfinney.id.au wrote: Chris Angelico ros...@gmail.com writes: How do you go about doing multi-line comments? I know I've seen other code using triple-quoted strings for long comments before. Just use a sequence of one-line comments:: # Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut a # sapien tempor, suscipit orci sed, elementum nisl. Suspendisse at # lacus ut diam dignissim lobortis ac vitae augue. # # Phasellus bibendum neque a justo vulputate, quis accumsan quam # egestas. Etiam aliquet blandit ante sit amet cursus. A decent code editor (e.g. Emacs, Vim) will allow manipulation of a sequence of one-line comments in Python's comment style, and allow treating it as a paragraphs for purposes such as re-wrapping the lines. I agree with others that triple-quoted strings are best reserved for string literals (including docstrings), not comments. Fair enough. I can't remember where (or when!) it was that I learned triple-quoted strings were appropriately abused as comments, so I've just done a quick re-layout into hash comments. Personally, I use the sequence of one-line comments. But, hey, Guido [1] himself likes the triple-quoted string as comment feature [2], so feel free to use it yourself if you like. -- ~Ethan~ [1] https://mail.python.org/pipermail/python-dev/2013-March/124947.html [2] https://mail.python.org/pipermail/python-ideas/2009-October/006204.html -- https://mail.python.org/mailman/listinfo/python-list
Re: Code style query: multiple assignments in if/elif tree
On Tue, 01 Apr 2014 10:12:38 +1100, Chris Angelico wrote: [...] I agree with others that triple-quoted strings are best reserved for string literals (including docstrings), not comments. Fair enough. I can't remember where (or when!) it was that I learned triple-quoted strings were appropriately abused as comments, so I've just done a quick re-layout into hash comments. Probably here :-) But note the emphasis on abused. The only time I would use triple- quoted strings as comments is if I wanted to quickly comment out a section of code: do_this() do_that() ''' def do_something_else(): Docstring pass do_something_else() ''' do_more() do_less() sort of thing. (Note the cunning use of ''' instead of .) But I wouldn't leave it like that in production code. It's *tempting* to use to mark out a large block of text, and I wouldn't say that doing so was wrong, but it's a bit different, and programmers are very like cats: they don't like different. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Line of best fit
On Mon, 31 Mar 2014 04:29:15 -0700, Jamie Mitchell wrote: I am new to python so apologies for the ignorance with this question. How would I apply a line of best fit to a plot? That depends on what software you are using to generate the plot. I see you have this line of code: plt.plot(hs1,hs2,'.') but you haven't told us what plt is, where it comes from, or anything needed for us to answer your question. So, start by telling us what plt is, and we may be able to tell you whether or not it supports lines of best fit. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Python IM server
在 2014年3月31日星期一UTC+8下午8时37分32秒,Lutz Horn写道: Hi, I want to develop a instant message server, simply has user and group entity. Is there any better existing open-source one? Take a look at XMPP[0]. There are some Python libraries[1]. [0] https://en.wikipedia.org/wiki/XMPP [1] http://xmpp.org/xmpp-software/libraries/ -- Opt out of global data surveillance programs like PRISM, XKeyscore and Tempora. https://prism-break.org I am looking at telepathy, empathy. Currently instant message is urgent, but needs voice/video call in the future. For instant message, I have user-to-user and user-to-group cases. Don't know if it suits well. -- https://mail.python.org/mailman/listinfo/python-list
Re: Examples of modern GUI python programms
On Monday, March 31, 2014 3:16:16 PM UTC-5, Sturla Molden wrote: According to their web page, PySide is only LGPL. Qt is LGPL or commercial. Licensing PySide has been published as a response to the lack of suitably licensed Qt bindings for Python. PySide is licensed under the LGPL version 2.1 license, allowing both Free/Open source software and proprietary software development. Read the legal definition of/and proprietary, then go consult a lawyer. That is caught as an exception/addition to the LGPL in the wording. I don't think anyone pressing the issue would get very far at all, unless there is a real good reason your own non-library source should be disclosed. Are there any legal precedents yet? If you didn't pay for it, or don't have a class action suit, or is of national security, then good luck. So, yes, PySide is acceptable also in certain situations you don't have to disclose own source. May need to consult with Qt personally on the matter if a Qt license is actually needed for your particular project, but in plain legal wording of the LGPL/Qts/PySides agreements, no, it is not but there are a few rules that have been layed out you will need to follow if you don't have a Qt license. Anywho, here is some infos detailing a bit more commonly asked situations on their forums regarding PySide. http://qt-project.org/wiki/About-PySide http://qt-project.org/forums/viewthread/34770 If you do have a Qt license, then the rules change a bit more in your favor at levels of what you can ignore, that others can't legally. A couple of our team members has a license to cover the stuff we do, so I don't worry about it much. The majority of it is open anyway, but pity those who expect everything for free. *I can hear it now* boo hoo pdf format is finally free and open after all these years of adobe's money*grubbin*making. geez... Lesson is: Any software/hardware dev should be familiar with the licensing terms of the toolkits they intend to use. There are always hoops to jump through for Free-Types. Everyone needs to eat also, because as of this writing Money has yet to be abolished in this needy world of ours. And also it seems to fuel development in certain cases also. I often find the writings on the GPL pages about stuff related similarly to sound like a Richard being a crybaby at times, even tho I do respect him for his views he tries to emboss on everyone to create a not-exactly-freeier-but-just-more-open overall software society. If everyone had a flat wallet, then this idea would work out nicely. If I ever write a printer driver, I will make sure I license it GPL and personally send him a copy to inspect, believe me. Maybe when the next raspberry pi revision comes out he'll send 1000's of them out for free also to his supporters and developers also, but I somehow doubt it. http://www.gnu.org/philosophy/proprietary.html Anyhow, this should hopefully be enough infos for the OP to get a general idea of what toolkit would be needed for whatever project is in mind. As I say ,If not satisfied, contact sales. They are always reassuring to sound the least. -- https://mail.python.org/mailman/listinfo/python-list
Re: unicode as valid naming symbols
I personally believe that it becomes hard to have even a programming language overcome cultural learning styles, and programmatic differences, because of nurture vs nature. We can all program something which results in a similar return value, but overcoming the nurturing the internet provides, becomes an imperative. I'll just offer a reference to avoid personal mistakes in explaining something that relates to how programmers/computer scientists/electrical engineers approach their end results, and why those end results may still differ in the mentality of the individual, or group, outcome of developing A.I. systems: http://en.wikipedia.org/wiki/Ethnolinguistics http://en.wikipedia.org/wiki/Cognitive_anthropology http://en.wikipedia.org/wiki/Cognitive_science The latter probably explains what I mean in more depth than the two formers. On Mon, Mar 31, 2014 at 8:47 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On Mon, Mar 31, 2014 at 1:31 PM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: Op 31-03-14 19:40, Ian Kelly schreef: That was an exaggeration on my part. It wouldn't affect my job, as I wouldn't expect to ever actually have to maintain anything like the above. My greater point though is that it damages Python's readability for no actual gain in my view. There is nothing useful you can do with a name that is the U+1F4A9 character that you can't do just as easily with alphanumeric identifiers like pile_of_poo (or куча_фекалий if one prefers; that's auto-translated, so don't blame me if it's a poor translation). The kinds of symbols that we're talking about here aren't part of any writing systems, and so to incorporate them in *names* as if they were is an abuse of Unicode. Your argument doesn't has much weight. First of all it can be used for just restricting names to the ascii range. I disagree. Non-ASCII written names are useful to anybody who prefers not to do all their programming in English. Second of all I think a good chosen symbolic name can be more readable than a name in a character set you are not familiar with. A good chosen symbol will evoke a meaning with a lot of people. A name in a character set you are not familiar with is just gibberish to you. Well, this is the path taken by APL. It has its supporters. It's not known for being readable. I don't think the comparisons to decorators and the if-else operator are apt. I didn't make such a comparison. I just noted the arguments against were similar. That's the comparison to which I was referring. First, because while those may degrade readability, they do so in a constrained way. A decorator application is just the @ symbol and an identifier. And if abused, can totally change the working of your function. There is no guarantee that the function returned, has any relation with the original function. If that can't be a night mare for readability, I don't know what is. As Terry Reedy noted, this has nothing to do with the decorator syntax, so it isn't much of an argument against having such syntax. The if-else is just three expressions separated by keywords. Yes but if used unrestrained in arbitrary expressions will make those expressions hard to understand. I don't disagree. I hardly ever use it myself, certainly only if it can fit comfortably into one line, which is rare. But it's still quite limited in syntactic scope. In the case of arbitrary Unicode identifiers, we're talking about approximately doubling the number of different characters (out of a continuously growing set) that could be used, many of which are easily confused with other characters. Of course the potential for confusion already exists, but that's no justification for aggravating it. So what if we double the number of different characters? I don't care about the number of them, I care about how meaningful they are. And as you say confusion is already possible. A good programmer knows how to deal with such a possible confusion, that the number of cases increases, doesn't need to be a problem for those that care about this. So tell me then, how would you deal with it? In the case of script identifiers, it's often not hard to discern from context whether a particular character is e.g. a Latin h or a Cyrillic һ. Assuming the original author wasn't being intentionally obfuscatory, if the rest of the identifier is Cyrillic then the character is probably also Cyrillic. If it's a one-character identifier, then hopefully the rest of the module is consistent and you can guess from that. If the identifier in question is just one symbol though, then you have a lot less context. Second, at least in the case of decorators, while I don't dispute that they can harm readability, I think that in the majority of cases they actually help it. But that is not a fair comparison now, is it. What you are doing here is comparing
Re: unicode as valid naming symbols
This brings us into a juxtaposition between how cultures have tried to hybridize their mentalities, into more of an empathic means of communication via a formulatic set of coding, and the philosophy thereof, and, 3D renderings of what we visualize, and how we come to the conclusions of these philosophies of what we want to accomplish within the technological age we live within. Maybe not the best way I could explain it, but it has a bunch of fancy words in it. -- https://mail.python.org/mailman/listinfo/python-list
Re: Examples of modern GUI python programms
Caveat emptor(I have a copy of Latin For Idiots). When you get through with refining, in whatever language, the open source/proprietary app you're developing, is there anyway you can say for sure how many people's work went into things under different licenses accompanying what you may have copy and pasted into it, and neither can the individuals who developed the systems they designed, and threw a license on it? *Standing on the shoulder's of giants can still be unsteady ground.* -- https://mail.python.org/mailman/listinfo/python-list
Re: Code style query: multiple assignments in if/elif tree
On Tue, 01 Apr 2014 01:33:09 +1100, Chris Angelico wrote: Call this a code review request, if you like. I'm wondering how you'd go about coding something like this. I wouldn't. I'd start off by analysing the problem, and putting it into the simplest format possible, and *then* start writing code if and only if needed. See below. The first mistake of computational mathematics is to do the computation before the mathematics, and the Holy Grail is to avoid the computation altogether. Imagine you're in a train, and the brakes don't apply instantly. The definition, in the interests of passenger comfort, Ah, you're using comfort in the modern sense, i.e. what people used to call discomfort :-P The scenario you describe has (effectively) infinite rate-of-change-of- acceleration, often called jerk. (A jerk is a rapid change in acceleration.) Human comfort is (within reasonable limits) more affected by jerk than acceleration. The passengers will feel three quite distinctive jerks, one when the brakes are first applied (which is probably reasonable), then one at 1s, then again at 2s. That's not comfortable by any stretch of the imagination. is that the first second of brake application has an acceleration of 0.2 m/s/s, the next second has 0.425 m/s/s, and thereafter full effect of 0.85 m/s/s. In mathematics, this is called hybrid function, and is usually written like this: g(t) for t 0 f(t) = { 42 for t == 0 h(t) for t 0 or something similar. (The opening brace { ought to be large enough to cover all three lines, and there is no closing brace.) In your case, you have three constant functions. You have a state variable that says whether the brakes have just been applied, have already been applied for at least two seconds, or haven't yet been applied at all. I wouldn't model it that way. Especially since you've missed at least one state :-) I'd model the acceleration as a function of time, otherwise you have to convert a time into a state. Nevertheless, if you insist, we can use a state variable instead: 0 for state == BRAKES NOT APPLIED YET accel = { 0.2 for state == BRAKES ON FOR BETWEEN 0 AND 1 SECOND 0.425 for STATE == BRAKES ON FOR BETWEEN 1 AND 2 SECOND 0.85 for state == BRAKES ON FOR MORE THAN 2 SECONDS Implied, but not stated, is that once the train stops, acceleration also goes to zero -- the train does not start moving backwards. Haskell has nifty pattern-matching syntax for this that looks quite close to the mathematical hybrid function syntax, but in Python, we're limited to explicitly using an if. If I were coding this, and I'm not, I'd wrap it in a function. One advantage of a state variable rather than a continuous time function is that we can do this: def accel(state): return {NO_BRAKING: 0.0, LOW_BRAKING: 0.2, MID_BRAKING: 0.425, HIGH_BRAKING: 0.85}[state] which is simple enough to skip using a function in the first place, and just use the dict lookup directly. But for a more general question you'll want acceleration as a function of time. If you prefer if...elif over a dict, I'd still hide it in a function. Problem: Work out how far you'll go before the brakes reach full power, and how fast you'll be going at that point. Given that problem, we actually only care about LOW_BRAKING and MID_BRAKING. The problem becomes quite simple: At t=0, the train is travelling at u m/s and the brakes are applied with acceleration of 0.2m/s^2 for one second, then 0.425m/s^2 for an additional one second. What is the speed of the train after those two seconds, and the distance travelled. This becomes a simple question for the four standard equations of motion: (1) v = u + at (2) s = 1/2(u + v)t (3) s = ut + 1/2(at^2) (4) v^2 = u^2 + 2as Only (1) and (3) are needed. The distance travelled in the first second is: s1 = u - 0.1 m and the speed of the train at that time becomes: v = u - 0.2 m/s Applying this for the second second gives: s2 = (u - 0.2) - 0.2125 m v = (u - 0.2) - 0.425 m/s and the total distance: s = s1 + s2 No programming required, just a calculator :-) Given that solving the entire problem is barely five lines, writing code to do so is probably unnecessary. The only thing I haven't done is check that the train isn't travelling so slowly that it comes to a complete halt within two seconds. I leave that as an exercise. (Hint: if the final speed is negative, the train came to a halt.) Here's how I currently have the code. The variable names are a tad long, as this was also part of me teaching my brother Python. Whatever you used to post this, ate the indentation. # Already got the brakes fully on if mode==Brake2: distance_to_full_braking_power, speed_full_brake = 0.0, curspeed # The brakes went on one second ago, they're nearly full elif mode==Brake1: distance_to_full_braking_power,
Re: Code style query: multiple assignments in if/elif tree
On Tue, Apr 1, 2014 at 3:26 PM, Steven D'Aprano st...@pearwood.info wrote: On Tue, 01 Apr 2014 01:33:09 +1100, Chris Angelico wrote: Call this a code review request, if you like. I'm wondering how you'd go about coding something like this. I wouldn't. I'd start off by analysing the problem, and putting it into the simplest format possible, and *then* start writing code if and only if needed. See below. The first mistake of computational mathematics is to do the computation before the mathematics, and the Holy Grail is to avoid the computation altogether. Fair enough. :) Imagine you're in a train, and the brakes don't apply instantly. The definition, in the interests of passenger comfort, Ah, you're using comfort in the modern sense, i.e. what people used to call discomfort :-P The scenario you describe has (effectively) infinite rate-of-change-of- acceleration, often called jerk. (A jerk is a rapid change in acceleration.) Human comfort is (within reasonable limits) more affected by jerk than acceleration. The passengers will feel three quite distinctive jerks, one when the brakes are first applied (which is probably reasonable), then one at 1s, then again at 2s. That's not comfortable by any stretch of the imagination. It actually is a smooth increase in deceleration, but I'm operating the simulator on a 1s period, so it's actually an average across the first second, and an average across the next second... is that the first second of brake application has an acceleration of 0.2 m/s/s, the next second has 0.425 m/s/s, and thereafter full effect of 0.85 m/s/s. ... so really, it's seeking upward from 0 to 0.85 according to some curve, the details of which I'm not familiar with, but in terms of 1s average accelerations, it's those figures. Actually even 1s resolution is more than we need; the overall purpose is to get a calculated time in minutes, so calculating to sub-second resolution (when, in reality, this is trying to predict what a human will do) is massive overkill. You have a state variable that says whether the brakes have just been applied, have already been applied for at least two seconds, or haven't yet been applied at all. I wouldn't model it that way. Especially since you've missed at least one state :-) I'd model the acceleration as a function of time, otherwise you have to convert a time into a state. Nevertheless, if you insist, we can use a state variable instead: 0 for state == BRAKES NOT APPLIED YET accel = { 0.2 for state == BRAKES ON FOR BETWEEN 0 AND 1 SECOND 0.425 for STATE == BRAKES ON FOR BETWEEN 1 AND 2 SECOND 0.85 for state == BRAKES ON FOR MORE THAN 2 SECONDS Implied, but not stated, is that once the train stops, acceleration also goes to zero -- the train does not start moving backwards. Just been applied is poorly named; that's the state where the brakes have been applied for 1 second so far. The other state (brakes not applied yet) could be looking at powering (which follows a similar curve in the opposite direction) or cruising (which has acceleration of 0.0 m/s/s). Haskell has nifty pattern-matching syntax for this that looks quite close to the mathematical hybrid function syntax, but in Python, we're limited to explicitly using an if. If I were coding this, and I'm not, I'd wrap it in a function. One advantage of a state variable rather than a continuous time function is that we can do this: def accel(state): return {NO_BRAKING: 0.0, LOW_BRAKING: 0.2, MID_BRAKING: 0.425, HIGH_BRAKING: 0.85}[state] That could be done, but with .get() to allow a default. I may well do that. Problem: Work out how far you'll go before the brakes reach full power, and how fast you'll be going at that point. Given that problem, we actually only care about LOW_BRAKING and MID_BRAKING. The problem becomes quite simple: Right. The other state is zero distance and zero loss of speed. At t=0, the train is travelling at u m/s and the brakes are applied with acceleration of 0.2m/s^2 for one second, then 0.425m/s^2 for an additional one second. What is the speed of the train after those two seconds, and the distance travelled. This becomes a simple question for the four standard equations of motion: (1) v = u + at (2) s = 1/2(u + v)t (3) s = ut + 1/2(at^2) (4) v^2 = u^2 + 2as Only (1) and (3) are needed. Okay, what's u here? Heh. The distance travelled in the first second is: s1 = u - 0.1 m and the speed of the train at that time becomes: v = u - 0.2 m/s Applying this for the second second gives: s2 = (u - 0.2) - 0.2125 m v = (u - 0.2) - 0.425 m/s and the total distance: s = s1 + s2 No programming required, just a calculator :-) Given that solving the entire problem is barely five lines, writing code to do so is probably unnecessary. This is one small part of a larger piece of code (which, in this
Re: Python IM server
I want to develop a instant message server, simply has user and group entity. Is there any better existing open-source one? Thus I can download and have a look. You can take a look at Twisted Words (https://twistedmatrix.com/trac/wiki/TwistedWords). -- https://mail.python.org/mailman/listinfo/python-list
Re: Examples of modern GUI python programms
On Sunday, March 30, 2014 7:16:07 PM UTC-4, D. Xenakis wrote: Id like to ask.. do you know any modern looking GUI examples of windows software written in python? Something like this maybe: http://techreport.com/r.x/asus-x79deluxe/software-oc.jpg (or hopefully something like this android look: http://chromloop.com/wp-content/uploads/2013/07/Skype-4.0-Android-screenshot.jpg). What i need is to develop an android looking program (entirelly in python) for windows, but dunno if this is possible (most propably is), and which tool between those would help me most: tkinter - wxpython - pyqt - pygtk . I just know wxPython, so I'll discuss that. I'm pretty sure you could achieve either of those with wxPython, but it isn't really set up to look like that (modern looking in your words) by default. wxPython is set up to look *native* for each platform it runs on. On WinXP, for example, toolbars and buttons generally have system gray backgrounds, but some widgets can be changed, some can't. There are custom widgets that are more flexible though are not native. You could cleverly simulate these sorts of looks with creative use of library-included custom widgets, a few of your own custom widgets possibly, black backgrounds, drawing on a DC directly to the screen, image backgrounds, and a few other things (basically creating your own skin). The harder one is probably the first one you linked--the other, Skype on Android, is mostly just big fluffy images. Probably the first 90% of that is pretty easy and the last 10% might be somewhat difficult, but not too bad. It would be fun to try. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python IM server
hint: Tkinter server db update the tkinter apps, with the new data, after moving a line down On Tue, Apr 1, 2014 at 1:06 AM, Miki Tebeka miki.teb...@gmail.com wrote: I want to develop a instant message server, simply has user and group entity. Is there any better existing open-source one? Thus I can download and have a look. You can take a look at Twisted Words ( https://twistedmatrix.com/trac/wiki/TwistedWords). -- https://mail.python.org/mailman/listinfo/python-list -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com http://www.hitwebdevelopment.com* -- https://mail.python.org/mailman/listinfo/python-list
Re: Code style query: multiple assignments in if/elif tree
On Tue, Apr 1, 2014 at 3:26 PM, Steven D'Aprano wrote: Haskell has nifty pattern-matching syntax for this that looks quite close to the mathematical hybrid function syntax, but in Python, we're limited to explicitly using an if. If I were coding this, and I'm not, I'd wrap it in a function. One advantage of a state variable rather than a continuous time function is that we can do this: def accel(state): return {NO_BRAKING: 0.0, LOW_BRAKING: 0.2, MID_BRAKING: 0.425, HIGH_BRAKING: 0.85}[state] Neat I would put the dict in a variable. And those _BRAKINGs are GALLing me! breaking = {NO:0.0, LOW:0.2, MID:0.425:, HIGH:0.85} def accel(state): return breaking[state] Irony In using Haskell, I often wish for dicts especially python's nifty dict-literals /Irony -- https://mail.python.org/mailman/listinfo/python-list
[issue21104] Read from file aborted
Changes by Alex Grinko nitrog...@gmail.com: -- resolution: - works for me status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21104 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21108] Add examples for importlib in doc
Changes by Ned Deily n...@acm.org: -- nosy: +brett.cannon, eric.snow, ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21108 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1191964] asynchronous Subprocess
Changes by Glenn Linderman v+pyt...@g.nevcal.com: -- nosy: +v+python ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1191964 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21085] compile error Python3.3 on Cygwin
dellair jie added the comment: Yes, my pleasure. After configure on Cygwin, there is pyconfig.h generated, variables are as following: /* #undef HAVE_SIGTIMEDWAIT */ /* #define HAVE_SIGWAITINFO 1 */ The error disappeared once changed HAVE_SIGWAITINFO to undef. However, it encountered another issue mentioned here: http://bugs.python.org/issue13756 The patches provided seem only for 3.2.2, not sure if it is ok to apply them directly on 3.3.2? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21085 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21109] tarfile: Traversal attack vulnerability
New submission from Daniel Garcia: The application does not validate the filenames inside the tar archive, allowing to extract files in arbitrary path. An attacker can craft a tar file to override files. I've view this vulnerability in libtar: http://lwn.net/Vulnerabilities/587141/ I've checked that python tarfile doesn't validate the filenames so python tarfile is vulnerable to this attack. -- components: Library (Lib) files: prevent-tar-traversal-attack.diff keywords: patch messages: 215222 nosy: Daniel.Garcia priority: normal severity: normal status: open title: tarfile: Traversal attack vulnerability type: security versions: Python 3.5 Added file: http://bugs.python.org/file34676/prevent-tar-traversal-attack.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21109 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21109] tarfile: Traversal attack vulnerability
Daniel Garcia added the comment: The solution in the patch is based on the gnutar solution to this, removing the prefix when extracting and adding. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21109 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21109] tarfile: Traversal attack vulnerability
Ned Deily added the comment: Setting as release blocker pending evaluation. -- keywords: +security_issue nosy: +benjamin.peterson, georg.brandl, larry, lars.gustaebel, ned.deily priority: normal - release blocker stage: - test needed 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/issue21109 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21109] tarfile: Traversal attack vulnerability
Christian Heimes added the comment: It's a known and well-documented behavior of the tar module: https://docs.python.org/2.7/library/tarfile.html#tarfile.TarFile.extractall -- nosy: +christian.heimes ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21109 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21109] tarfile: Traversal attack vulnerability
STINNER Victor added the comment: It's a known and well-documented behavior of the tar module Would it possible to disable this behaviour by default, and only enable ti explicitly? The tar command line program has for example the -P / --absolute-paths option. -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21109 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21110] Slowdown and high memory usage when adding a new module in embedded Python 3.4 on 64bit Windows
New submission from MrValdez: The example in the Extending Embedded Python (https://docs.python.org/3/extending/embedding.html#extending-embedded-python) takes up a lot of memory and slow downs the computer. I am using Windows 7 64bit, Python 3.4 64bit and gcc (rubenvb-4.8.0) 4.8.0. Solution: Apparently, you need to add this to your C program: #define HAVE_SSIZE_T I found the solution at (https://forums.embarcadero.com/message.jspa?messageID=581594). The page said that when adding the above, this ensures that the type Py_ssize_t becomes __int64 instead of int. Expected: The programmer should not see a simple program (that came from the main documentation, no less) causing slowdowns and high memory usage. The 64bit version of the Python installer was downloaded so the programmer should, at least, not need to know that they need this flag. Can the Python.h in the 64 bit builds automatically set the flag? Or, if this isn't feasible, add a note to the documentation that this flag exist. -- components: Windows messages: 215227 nosy: MrValdez priority: normal severity: normal status: open title: Slowdown and high memory usage when adding a new module in embedded Python 3.4 on 64bit Windows type: performance versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21110 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21110] Slowdown and high memory usage when adding a new module in embedded Python 3.4 on 64bit Windows
Changes by STINNER Victor victor.stin...@gmail.com: -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21110 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20968] mock.MagicMock does not mock __truediv__
Johannes Baiter added the comment: Sorry for commenting so late, I submitted a version of the patch with unit tests roughly two weeks ago, I just forgot to mention it in a comment. Hereby fixed :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20968 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21082] os.makedirs(exist_ok=True) is not thread-safe: umask is set temporary to 0, serious security problem
Serhiy Storchaka added the comment: See also issue19930. Behaviors of os.makedirs() and pathlib.Path.mkdir() are different. pathlib.Path.mkdir() (as the mkdir command) creates parent directories with default mode, and os.makedirs() - with specified mode. -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21082 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21044] tarfile does not handle file .name being an int
Serhiy Storchaka added the comment: Does tarfile work with bytes file names? I think a test should explicitly test file objects with str, bytes and int name and file objects without name in all write modes (w, w:gz, w|gz, etc). -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21044 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21044] tarfile does not handle file .name being an int
Changes by Serhiy Storchaka storch...@gmail.com: -- stage: patch review - test needed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21044 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17846] Building Python on Windows - Supplementary info
Kathleen Weaver added the comment: Patch from comments on March 29 -- Added file: http://bugs.python.org/file34677/win.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17846 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21085] compile error Python3.3 on Cygwin
dellair jie added the comment: Applied the patch 0001-CYGWIN-issue13756-Python-make-fail-on-cygwin.patch in case: http://bugs.python.org/issue13756 The build failed with parser module: building 'parser' extension gcc -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I./Include -I. -IInclude -I/cygdrive/c/temp/Python-3.3.2/Include -I/cygdrive/c/temp/Python-3.3.2 -c /cygdrive/c/temp/Python-3.3.2/Modules/parsermodule.c -o build/temp.cygwin-1.7.17-i686-3.3/cygdrive/c/temp/Python-3.3.2/Modules/parsermodule.o gcc -shared -Wl,--enable-auto-image-base build/temp.cygwin-1.7.17-i686-3.3/cygdrive/c/temp/Python-3.3.2/Modules/parsermodule.o -L. -L/usr/local/lib -lpython3.3m -o build/lib.cygwin-1.7.17-i686-3.3/parser.dll build/temp.cygwin-1.7.17-i686-3.3/cygdrive/c/temp/Python-3.3.2/Modules/parsermodule.o: In function `parser_sizeof': /cygdrive/c/temp/Python-3.3.2/Modules/parsermodule.c:371: undefined reference to `__PyNode_SizeOf' collect2: ld returned 1 exit status Could anyone shed some lights please? Br, Li -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21085 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17846] Building Python on Windows - Supplementary info
Kathleen Weaver added the comment: New readme.txt patch -- Added file: http://bugs.python.org/file34678/winreadme.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17846 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19655] Replace the ASDL parser carried with CPython
Eli Bendersky added the comment: Attaching patch that implements this. To make it easier, the patch only replaces the ASDL parser - not touching anything else and leaving the output intact. With this patch applied, when the Makefile is rerun it regenerates the actual AST code in: Include/Python-ast.h Python/Python-ast.c However, as the new parser generates exactly the same files, the code above is identical to the originals (hg diff shows nothing). In practice this means that no one building Python should notice this change, unless she's playing with the ASDL input file itself. The Makefile will not even regenerate these files unless the parser or the ASDL file were modified. I have some additional ideas - to be delayed for subsequent patches: 1. The existing Spark-based parser didn't have tests, but my parser does. I'll do something similar to test_tools.py, as Benjamin suggested (to test the parser only in source builds). 2. The code of asdl_c.py could be modernized and be made even cleaner. 3. The same is true of the generated C code for the AST. -- keywords: +patch Added file: http://bugs.python.org/file34679/new-asdl-parser.issue19655.1.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19655 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20375] ElementTree: Document handling processing instructions
Eli Bendersky added the comment: The patch appears to contain code (tests) along with the documentation. Is this intended? This issue is not tagged properly if it is. I'd suggest to split them to separate patches. -- versions: +Python 3.5 -Python 2.7, Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20375 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21109] tarfile: Traversal attack vulnerability
Serhiy Storchaka added the comment: Yes, this behavior is documented, but still it is desirable to fix it. The tar utility has a lot of switches which controls extracting and by default it prevents three ways of attack (absolute names, '..' and symlinks), but there are other possible ways of attack. This is complex issue and I'm working on it. See also issue19974. In any case we should be very careful because every protection against attack changes a behavior (which can be safe if you know what you do), so perhaps we should add parameters which controls behavior. This is possible only in new Python version. -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21109 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21111] PyLong_AsUnsignedLongAndOverflow does not exist
New submission from Hristo Venev: It could set *overflow to -1 on negative value and to 1 on overflow. And PyLong_AsUnsignedLongLongAndOverflow. -- components: Extension Modules messages: 215236 nosy: h.venev priority: normal severity: normal status: open title: PyLong_AsUnsignedLongAndOverflow does not exist versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21028] ElementTree objects should support all the same methods as Element objects
Eli Bendersky added the comment: Raymond, you are right that the APIs presented by Element and ElementTree are somewhat different. As Stefan mentioned, they were really meant to represent different things, but with time some convenience features crept in and made the difference somewhat more moot. Note that some methods/functions in ET give you the root element directly, rather than the tree. For example the XML function, or fromstring function. Also, the tree implements the iter() method, which is morally equivalent to Element.iter() on the root node. However, the tree (unlike Element) is not iterable. Element implements __getitem__, the tree does not. Currently, the first code snippet in the official documentation shows: import xml.etree.ElementTree as ET tree = ET.parse('country_data.xml') root = tree.getroot() Which makes the distinction between the tree and its root. Whether this is a great API (making tree and root distinct), I can't say, but we can't change it now. Do you have concrete suggestions? Make the tree iterable? Add all element methods to the tree, implicitly forwarding to the root? Improve documentation? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21028 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21111] PyLong_AsUnsignedLongAndOverflow does not exist
Changes by Mark Dickinson dicki...@gmail.com: -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21101] Extend the PyDict C API to handle cases where the hash value is known
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21101 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21109] tarfile: Traversal attack vulnerability
R. David Murray added the comment: Note that any issues here should also be considered for zipfile and shutil. (Well, shutil can just use the other two once the security is available.) See issue 20907. -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21109 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21112] 3.4 regression: unittest.expectedFailure no longer works on TestCase subclasses
New submission from William Schwartz: In Python 2.7 and 3.3, decorating a unittest.TestCase subclass with unittest.expectedFailure caused test discover to skip the decorated test case. Python 3.4 apparently ignores the decorator when applied to classes. The attached file when run with Python 2.7.6 on Mac OS X produces the following output $ python -m unittest discover F. == FAIL: test_fails (test.TestControl) -- Traceback (most recent call last): File /Users/schwartz_w/Documents/testtest/test.py, line 9, in test_fails self.assertFalse(True) AssertionError: True is not false -- Ran 2 tests in 0.000s FAILED (failures=1) When run with Python 3.4.0 produces the following output. ~/Documents/testtest $ python3 -m unittest discover F.F. == FAIL: test_fails (test.TestControl) -- Traceback (most recent call last): File /Users/schwartz_w/Documents/testtest/test.py, line 9, in test_fails self.assertFalse(True) AssertionError: True is not false == FAIL: test_fails (test.TestTreatment) -- Traceback (most recent call last): File /Users/schwartz_w/Documents/testtest/test.py, line 9, in test_fails self.assertFalse(True) AssertionError: True is not false -- Ran 4 tests in 0.001s FAILED (failures=2) The expectedFailure decorator when applied to a class should either skip the class or run all of its tests and check that they failed for consistency with how expectedFailure applies to test methods. -- components: Library (Lib) files: test_expectedFailure.py messages: 215240 nosy: William.Schwartz priority: normal severity: normal status: open title: 3.4 regression: unittest.expectedFailure no longer works on TestCase subclasses type: behavior versions: Python 3.4 Added file: http://bugs.python.org/file34680/test_expectedFailure.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21112 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21112] 3.4 regression: unittest.expectedFailure no longer works on TestCase subclasses
Changes by Ezio Melotti ezio.melo...@gmail.com: -- components: +Tests keywords: +3.4regression nosy: +ezio.melotti, michael.foord, pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21112 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21113] Error usage of class.__bases__()
New submission from Lotus Qin: function in urllib.request.build_opener() def isclass(obj): return isinstance(obj, type) or hasattr(obj, __bases__) should it be `obj` or `obj.__class__`? cause in the man of 3.4, there is only `class.__bases__`, but the code there may function like `instance.__bases__`. === # my code behave like this: cookie = http.cookiejar.CookieJar() cookie_handler = urllib.request.HTTPCookieProcessor(cookie) opener = urllib.request.build_opener(cookie_handler) # the variable `skip` in `build_opener` will be empty cause `isclass(obj)` always return false. cookie_handler.__bases__ AttributeError: 'HTTPCookieProcessor' object has no attribute '__bases__' cookie_handler.__class__.__bases__ (class 'urllib.request.BaseHandler',) -- components: Library (Lib) messages: 215241 nosy: ZealotuS priority: normal severity: normal status: open title: Error usage of class.__bases__() type: behavior versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21113 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21113] Error usage of class.__bases__
Changes by Lotus Qin qinzi...@gmail.com: -- title: Error usage of class.__bases__() - Error usage of class.__bases__ ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21113 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21109] tarfile: Traversal attack vulnerability
Christian Heimes added the comment: Don't forget about SUID and SGID, too. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21109 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21082] os.makedirs(exist_ok=True) is not thread-safe: umask is set temporary to 0, serious security problem
Changes by jan matejek jmate...@suse.cz: -- nosy: +matejcik ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21082 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21112] 3.4 regression: unittest.expectedFailure no longer works on TestCase subclasses
Changes by Berker Peksag berker.pek...@gmail.com: -- keywords: +patch nosy: +berker.peksag Added file: http://bugs.python.org/file34681/issue21112.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21112 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21085] compile error Python3.3 on Cygwin
Martin v. Löwis added the comment: dellair jie: please focus on one issue at a time. The issue you reported here is the compile error with si_band; I will not discuss any other problems you bring up in this issue. Note that editing pyconfig.h is not a solution. It's a generated file, so it must not be edited. To diagnose this further, add the -dD option to the preprocessor output of signalmodule.c, i.e. run gcc -dD -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include-DPy_BUILD_CORE -E ./Modules/signalmodule.c and attach the resulting file (or else study the output yourself). BTW, please also understand that Python 3.3 is no longer maintained; it would be good if you could run this porting project on Python 3.4 instead. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21085 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20668] Remove dependency on tests.txt when running test_asyncio suite
Vajrasky Kok added the comment: Thanks for committing my patch, Yury. But you forgot to remove Lib/test/test_asyncio/tests.txt. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20668 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20668] Remove dependency on tests.txt when running test_asyncio suite
Roundup Robot added the comment: New changeset bf661f72aaab by Victor Stinner in branch '3.4': Issue #20668: Remove tests.txt of test_asyncio http://hg.python.org/cpython/rev/bf661f72aaab New changeset a76e459e09be by Victor Stinner in branch 'default': (Merge 3.4) Issue #20668: Remove tests.txt of test_asyncio http://hg.python.org/cpython/rev/a76e459e09be -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20668 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21108] Add examples for importlib in doc
Brett Cannon added the comment: While I'm totally happy to add examples on usage, it is probably best to put them at the end of the class-level docs instead of trailing after the last method of the class. That way someone reading about what the class does can also see examples of how to use it. Another point is that SourceFileLoader.load_module() is documented as deprecated as of Python 3.4 and so promoting it in an example is not good. Now that module creation has been broken out separately this create a module from a file path approach is becoming more and more difficult. If we care to continue to support this use case we will probably need to come up with a function(s) to make it easier and toss something up on PyPI that is Python 2.7-3.5 compatible. -- versions: +Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21108 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21085] compile error Python3.3 on Cygwin
dellair jie added the comment: Martin, Certainly running on 3.4 now. The output of the command is attached. Will try to look into it tomorrow if no immediate follow up post. Br, Li -- Added file: http://bugs.python.org/file34682/signalmodule.output.txt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21085 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com