Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78643
| References | (8 earlier) <CALwzid=zLF1bUcJ9U31YJJjQ4gRTjE2NGFe8Pv5FwgprpazrGA@mail.gmail.com> <mailman.14564.1412280412.18130.python-list@python.org> <542ddce8$0$12985$c3e8da3$5496439d@news.astraweb.com> <mailman.14568.1412304280.18130.python-list@python.org> <542e5677$0$2916$c3e8da3$76491128@news.astraweb.com> |
|---|---|
| Date | 2014-10-03 18:09 +1000 |
| Subject | Re: How to show a dictionary sorted on a value within its data? |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14572.1412323799.18130.python-list@python.org> (permalink) |
On Fri, Oct 3, 2014 at 5:55 PM, Steven D'Aprano <steve@pearwood.info> wrote: >> which return non-list iterables. There's no really convenient equivalent >> to the map() usage of "call this function with each of these args, and >> discard the return values", as it looks very odd to do a list comp for >> nothing: > > map doesn't discard the return values. It accumulates them in a list, or > yields them in a list comp. Sure, but I've seen it used in various places to call functions where you don't care about the return values. Technically it's identical to the list comp, but somehow it's seen as less of an abuse. >> Short of borrowing Pike's automap syntax: >> >> print(list_of_strings[*]) > > you mean something like this perhaps? > > print(*list_of_strings, sep='\n') Well, no. In that one specific example, it happens to be possible to pass all the args to one print() call and get the same effect, but imagine some function that doesn't have that particular feature. (I just used print for simplicity.) >> there's really not much that's better than the original map() call. On >> the other hand, there aren't actually all that many times when I've >> needed to do this, and the simple for loop generally suffices: >> >> for x in list_of_strings: print(x) > > Exactly. Yeah. That's the normal way to do things. I'm not entirely sure why I keep seeing map() for that; there's probably a justification in functional programming languages, or something. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to show a dictionary sorted on a value within its data? cl@isbd.net - 2014-10-01 10:58 +0100
Re: How to show a dictionary sorted on a value within its data? Peter Otten <__peter__@web.de> - 2014-10-01 12:24 +0200
Re: How to show a dictionary sorted on a value within its data? cl@isbd.net - 2014-10-01 11:45 +0100
Re: How to show a dictionary sorted on a value within its data? Joel Goldstick <joel.goldstick@gmail.com> - 2014-10-01 06:56 -0400
Re: How to show a dictionary sorted on a value within its data? cl@isbd.net - 2014-10-01 13:16 +0100
Re: How to show a dictionary sorted on a value within its data? Peter Otten <__peter__@web.de> - 2014-10-01 13:12 +0200
Re: How to show a dictionary sorted on a value within its data? Travis Griggs <travisgriggs@gmail.com> - 2014-10-01 21:57 -0700
Re: How to show a dictionary sorted on a value within its data? cl@isbd.net - 2014-10-02 10:40 +0100
Re: How to show a dictionary sorted on a value within its data? Marko Rauhamaa <marko@pacujo.net> - 2014-10-02 14:17 +0300
Re: How to show a dictionary sorted on a value within its data? Rustom Mody <rustompmody@gmail.com> - 2014-10-02 10:46 -0700
Re: How to show a dictionary sorted on a value within its data? Grant Edwards <invalid@invalid.invalid> - 2014-10-02 14:05 +0000
Re: How to show a dictionary sorted on a value within its data? cl@isbd.net - 2014-10-02 17:33 +0100
Re: How to show a dictionary sorted on a value within its data? Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-02 13:15 -0600
Re: How to show a dictionary sorted on a value within its data? Grant Edwards <invalid@invalid.invalid> - 2014-10-02 19:36 +0000
Re: How to show a dictionary sorted on a value within its data? Dan Stromberg <drsalists@gmail.com> - 2014-10-02 13:06 -0700
Re: How to show a dictionary sorted on a value within its data? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-10-03 09:16 +1000
Re: How to show a dictionary sorted on a value within its data? Chris Angelico <rosuav@gmail.com> - 2014-10-03 12:44 +1000
Re: How to show a dictionary sorted on a value within its data? Steven D'Aprano <steve@pearwood.info> - 2014-10-03 07:55 +0000
Re: How to show a dictionary sorted on a value within its data? Chris Angelico <rosuav@gmail.com> - 2014-10-03 18:09 +1000
Re: How to show a dictionary sorted on a value within its data? Chris Angelico <rosuav@gmail.com> - 2014-10-03 07:01 +1000
Re: How to show a dictionary sorted on a value within its data? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-10-01 11:27 +0100
Re: How to show a dictionary sorted on a value within its data? Joel Goldstick <joel.goldstick@gmail.com> - 2014-10-01 06:37 -0400
Re: How to show a dictionary sorted on a value within its data? cl@isbd.net - 2014-10-01 13:19 +0100
csiph-web