Re: On Lists and Iterables
On 15 December 2017 at 10:40, Xenwrote: > > Zipping by definition produces a list of tuples No it's not. That's how it was defined in python 2, yes. The definition changed for 3. This is _more_ friendly, because in 2 you could very easily inadvertently use up a lot more memory than you were wanting to. If all you wanted was to loop over things, zip (and dict's keys and values and items, and range) now do the right thing. If you actually wanted the list you pass it to list(), and make your wants explicit. -- Ubuntu-devel-discuss mailing list Ubuntu-devel-discuss@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss
Re: Python2 demotion (moving from main to universe) in progress
On Fri, Dec 15, 2017 at 03:38:20AM +0100, Xen wrote: > Colin Watson schreef op 09-12-2017 13:51: > > Even as somebody generally very sympathetic to the needs of > > localisation, I've got this wrong because Python 2 had just too many > > ways to make mistakes in this area. > > So you are basically saying that you still don't agree but you have somehow > accepted your own fallibility in that something you like is wrong and > something you dislike is right. No - you're putting words in my mouth that are the opposite of what I'm saying. Kindly don't reply to try to convince me otherwise. In general, I dislike programming idioms that are too easy to get wrong. > I happen to know the % operator ;-). > > It is ridiculous that you cannot use it for binary-only text, or what I > would call just byte strings. You can use the % operator on bytes, as of Python 3.5. Please spend more time checking the assertions you make. It's the much newer "format" method that still isn't supported on bytes, and from https://bugs.python.org/issue3982#msg268160 it sounds like that's intentional and well-founded. https://docs.python.org/3/whatsnew/3.5.html#whatsnew-pep-461 (Python 3.5 is in Ubuntu 16.04; while some people may care, I'm not personally especially interested in earlier versions of Python 3 at this point, although I've been using it on and off since 3.2 or so.) While I know there are exceptions, some mentioned in that issue link above, on the whole my impression is that old Python code isn't likely to be using str.format very much anyway, since it's a relatively modern innovation compared to Python 2; it was introduced in 2.6. > This example really says it all: > > Python 2: b'Content-length: {}\r\n'.format(length) > > Python 3: b''.join([b'Content-length: ', (bytes if bytes is str else > str)(length).encode('ascii'), b'\r\n']) > > Or well, that is 2<>3 compatible code. Sure, if you work at it you can always construct unnecessarily complicated examples. "bytes if bytes is str else str" is strictly identical to "str", on both Python 2 and 3. (Glyph is an extremely experienced and competent developer, so I'm sure this was just an oversight.) But you can just do this instead, which in fact is roughly what Twisted, the source of the above comment, now does: Python 2/3: b'Content-Length: %d\r\n' % length (As mentioned above, str.format was new in Python 2.6, so this is just a return to the status quo ante for bytes.) > So if this person does keep maintaining this project and it gets some > traction, you could have a 'supported' python 2 interpretor being callable > by "python2" or "python2.7" or even "python2.8" for some time to come. > > If more people rally around that you could even have an unofficial > 'official' Python 2.8 specification ;-). > > Of which Tauthon would then be one interpreter ;-). > > You could then move Tauthon (package "tauthon") to universe around the time > that you would move python 2.7 out of it. If it turns out that the maintainer of Tauthon builds a sustained track record of doing a good job with it, then I'd support it being available in Ubuntu. There's still quite a while until Python 2.7 is in any danger of being removed from Ubuntu, so there's time for them to develop such a track record. (I don't think we should hold back other packaged libraries to support it, though; for example, Django 2.0 dropped support for Python 2. So it might be that Tauthon users would end up in practice with an Ubuntu-packaged interpreter and then using packages from PyPI in a virtualenv for most things that aren't in the standard library, or something like that. That would possibly work well enough; the audience for something like Tauthon probably also wants to stick with old library versions as well, at least until they can upgrade in a tightly-controlled fashion.) -- Colin Watson [cjwat...@ubuntu.com] -- Ubuntu-devel-discuss mailing list Ubuntu-devel-discuss@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss
On Lists and Iterables
I am just posting this so I don't have to save the text. 2.7: type(zip(["a","b"], ["c","d"])) 3 : type(zip(["a","b"], ["c","d"])) 3 : zip(["a","b"], ["c","d"]) 2.7: zip(["a","b"], ["c","d"]) [('a', 'c'), ('b', 'd')] 3 : list(zip(["a","b"], ["c","d"])) [('a', 'c'), ('b', 'd')] I don't even know what Iterables are. I just know that I can't print them directly. Python is supposed to be a beginner-friendly language. But this is incomprehensible. Zipping by definition produces a list of tuples, I mean zipping a list by definition creates a list of tuples, not a "zip" object. The whole semantic definition of "zip" is to take 2 (or more) lists, then create tuples out of every matched list element, and return those as a new list. Not to be left in some intermediate stage which is somehow more efficient to the interpreter or something. That would be like calling Set.difference and then getting a Difference object instead of a Set. Just an example of a user-unfriendly change. I already know someone is going to say "No it's not." and then leave it at that. About the above. Regards. -- Ubuntu-devel-discuss mailing list Ubuntu-devel-discuss@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss
Re: Python2 demotion (moving from main to universe) in progress
Daniel Watkins schreef op 15-12-2017 0:05: On Thu, Dec 14, 2017 at 11:45:23PM +0100, Xen wrote: The move towards Python 3 was forced, it didn't come natural for anyone. Nope, I have preferred Python 3 since ~3.3, and the transition has happened over _more than a decade_. So you waited till 3.3 until the language was "better" for you, that means at that point it was marginally better, with more to come later down the road. It took 4 years for a version to arise that you liked better. But there are 3 aspects here: - self-convincing because you see no future in the alternative (self-deluding) - lack of context for proper comparison (newcomers) - technical reasons. I argue that for the old established programmers now moving to, or "liking", python 3, nr. 1 is a larger component than technical reasons. I don't know if the community is split around the lowlevel part, where those who have to write lowlevel libraries hate on (or hate) python 3, and those that don't have to love it because they only benefit from the new features. The Tauthon guy actually professes to favour Python 3 technically. Not practically, but ideally. I don't know his reasons, but let's just believe him for a second. Let's believe he likes the str/bytes thing better because that's the only significant difference between his Tauthon and Python 3. There are computer games in which you see the same thing. Starcraft II is a game that superseded Starcraft I but the interesting part is money. The professionals moved to SC II because that's where the tournaments were. After a while they all got bored and the viewers also got bored because it was a game that was boring to watch, so they went back to SC I, but they really can't, because there are no tournaments anymore for it. The "future" is SC II but for them it is empty, and the past is hard to revive. This then finds a lot of people complaining about those "Korean gamers" who "refuse to move on" despite "SC II being a better game". New people however are appalled by the amount of _work_ you have to do to play the game, in the sense of micro-management and keyboard use (the old game). So *new people* are biased to like SC I ... I mean II, because they are lazy and spoiled and don't know better but these are also the people that more easily get bored. The game means much less to them etc. Their love is superficial. They are the smartphone generation. Back in the 90s my friend who was into BSD liked to complain about Windows lovers who professed "It just works!" -- but he knew that for his use case, it limited him. He knew that it would someday bite them. If you always have your food handed to you, you don't need to know how to grow it yourself. But when the time comes that you may want to move somewhere where you need to do this, your lack of experience will keep you immobile and paralyzed because you can only operate in a world where everything is done for you. Some of Python 3's improvements fall into that category, "It works" but you don't know how and you don't need to do anything for it, and only later down the road you find that you are limited in what you can do (as a newcomer) because you don't have the expertise to work around the difficulties in getting "ordinary" stuff to work. You, as a seasoned programmer, knows how to do this. The new generation will be clueless. You only have this frame of reference because you experienced the old; you have the knowhow that comes with it. New people will find barriers in their use of the system that does not impede them as long as they are doing their "walled garden thing" and actually, perhaps greatly, increases their productivity as long as they stick within that garden. But stepping outside of that, it's impossible for them. (I experience plenty of young people who are _afraid_ of computers, even those that are interested in becoming more experts). I have a friend who is afraid to open a PuTTY session. He thinks the world will explode if he does something like that. Back in my day, this _never_ happened. These people only know Windows or the Mac and have no way to look into system internals. They barely know DOS of course, and have no reason to ever have learned BAT shell scripting. PowerShell is even more a threatening thing. (Bash is more accessible than PowerShell imo). If they program it is Python or PHP; with PHP still being reasonably raw, but Python 3 an abstraction. I learned Turbo Assembler on a 80286. I am not that old. But most people experience a mental block these days because they are only used to their walled gardens. Python 3 is a step up in walled-gardenness from Python 2. Now personally I am not completely anathema to *learning* Python 3. Now for instance I ran into Python 3's "UserDict" and then found to my slight dismay that it didn't exist in Python 2. Now I am actually happy about that in the sense that I