Re: On Lists and Iterables
John Lenton schreef op 15-12-2017 13:02: On 15 December 2017 at 10:40, Xen wrote: Zipping by definition produces a list of tuples No it's not I was talking about the semantical definition, not implementation details. That's how it was defined in python 2, yes. The definition changed for 3. No, the implementation changed, and they just changed the "definition" to follow the implementation. Just because a "book" requires paper, and you decide that paper is wasteful, and hence only produce paperless books, doesn't change the definition of a book. And then you say : oh those are not books, because they use paper. This is _more_ friendly, because in 2 you could very easily inadvertently use up a lot more memory "Rule of Economy Developers should value developer time over machine time, because machine cycles today are relatively inexpensive compared to prices in the 1970s. This rule aims to reduce development costs of projects." You still don't understand it do you. Python is a high-productivity language. It's not C. I think I have to stop posting here for a while... The whole idea of Python was to be friendly to the programmer, not to the computer. Changing definitions of stuff in order to be able to have a more efficient implementation is not Python. That's selling out. 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. Yes, so you make the developer spend more time, and the computer less. If this was about C I could understand your statement, even though I would disagree with it (because I don't like C that much). But this is about Python okay. Developer ease and productivity was at the central core of this language. Now you are corrupting it in order to be more efficient. That's what we generally call a "hack". You expose an implementation detail that really has no significant cultural or language-based meaning. What does a "zip" object mean? Nothing, it's just an intermediate stage. In a makefile, this would be an .INTERMEDIATE step. So you choose efficiency over elegance, thinking basically in the C mindset and unpythonizing python ;-). :( :-/. -- 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: Detecting the init system in use
On 13/12/17 17:57, Robie Basak wrote: > 2) Come up with and agree on some other universal way for testing for > systemd and make that work everywhere. Then we can SRU that test to MAAS > in Trusty, and fix any other packages in Trusty affected by the > behaviour change of the original test. Possibly too simplistic, but /sbin/init itself may be a target for a test: On a 14.04 system: $ file /sbin/init /sbin/init: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=7a4c688d009fc1f06ffc692f5f42ab09e68582b2, stripped On a 16.04 system: $ file /sbin/init /sbin/init: symbolic link to /lib/systemd/systemd Other "pure-systemd" systems (e.g. Arch) use a symlink similar to 16.04 so this should work with later Ubuntu releases too: $ file /sbin/init /sbin/init: symbolic link to ../lib/systemd/systemd J -- 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: On Lists and Iterables
On 16/12/17 15:13, Xen wrote: > Python is a high-productivity language. > > It's not C. > > I think I have to stop posting here for a while... > I've only been vaguely following this thread as it doesn't appear to be related to Ubuntu Development, but it seems to me you're annoyed that you started learning Python2 before finding out that it is being replaced by Python3. This isn't an Ubuntu problem - you started learning the wrong language version in the first place: https://wiki.python.org/moin/Python2orPython3 If you have an issue with the _language syntax_ then you're definitely on the wrong list. J -- 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: On Lists and Iterables
As J Fernyhough notes elsewhere in the thread, this is not the list to quibble about Python 3. Though, as John Lenton notes, there are excellent reasons for most of the changes in Python 3, which of course has a different leading version number precisely because it is not backward compatible. See e.g. this piece on the critical need for Python 3, and the benefits of it. E.g. Why Python 3 exists https://snarky.ca/why-python-3-exists/ For more on the rationale for changes related to iterators see http://portingguide.readthedocs.io/en/latest/iterators.html But it is very much appropriate for this list to help developers port packages so they can continue to be supported in future Ubuntu versions after Python 2 is demoted. And you should be pleased to learn that often all you have to do is use the 2to3 or futurize tools to automatically port your code to Python 3. After doing so you can take advantage of the cleaner and more efficient Python 3 world. It is of course a hassle to do so, but it is a one-time cost, with many benefits. For example here I port your one-line Python 2 script that uses zip. $ cat porting_example.py print zip(["a","b"], ["c","d"]) $ python porting_example.py [('a', 'c'), ('b', 'd')] $ 2to3 porting_example.py > porting_example.patch $ cat porting_example.patch --- porting_example.py (original) +++ porting_example.py (refactored) @@ -1 +1 @@ -print zip(["a","b"], ["c","d"]) +print(list(zip(["a","b"], ["c","d"]))) $ patch -b < porting_example.patch # -b saves original as porting_example.py.orig $ cat porting_example.py print(list(zip(["a","b"], ["c","d"]))) $ python3 porting_example.py [('a', 'c'), ('b', 'd')] See docs at http://python3porting.com/2to3.html Porting Python 2 Code to Python 3 — Python 3.6.1rc1 documentation https://docs.python.org/3/howto/pyporting.html Neal McBurnett http://neal.mcburnett.org/ On Fri, Dec 15, 2017 at 11:40:14AM +0100, Xen wrote: > 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: On Lists and Iterables
On 16/12/17 15:13, Xen wrote: > Python is a high-productivity language. > > It's not C. > > I think I have to stop posting here for a while... > I've only been vaguely following this thread as it doesn't appear to be related to Ubuntu Development, but it seems to me you're annoyed that you started learning Python2 before finding out that it is being replaced by Python3. This isn't an Ubuntu problem - you started learning the wrong language version in the first place: https://wiki.python.org/moin/Python2orPython3 If you have an issue with the _language syntax_ then you're definitely on the wrong list. J signature.asc Description: OpenPGP digital signature -- 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