Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
map function
#6
In Python, using a map for it isn't very appropriate. map() is good for mapping from some values to some other values. print() returns None, so you're not really mapping to anything.

Another way to look at it is that map() is a functional idea, and in functional programming side-effects are evil.

If you simply call list() on the generator returned by map(), you'll get the output. But as you can tell by the code, it's just not ideal. Your code makes it look like you want a list, when you don't, and creating that list means you'll be using memory that you don't need to occupy.
Reply


Messages In This Thread
map function - by landlord1984 - Jan-26-2017, 11:44 PM
RE: map function - by micseydel - Jan-26-2017, 11:55 PM
RE: map function - by landlord1984 - Jan-27-2017, 12:24 AM
RE: map function - by micseydel - Jan-27-2017, 12:39 AM
RE: map function - by landlord1984 - Jan-27-2017, 12:46 AM
RE: map function - by micseydel - Jan-27-2017, 01:05 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020