I'll visit that channel when back from vacation for sure.
To do what you want you could use list comprehensions or the filter(function, sequence) function:
List comprehension:
links = ["https://securesite.com", "http://unsecuresite.com", "https://sec2.com", "http://unsec2.com"]
[url for url in links if not url.startswith("https")]
>>> ['http://unsecuresite.com', 'http://unsec2.com']
filter() + lambda: links = ["https://securesite.com", "http://unsecuresite.com", "https://sec2.com", "http://unsec2.com"]
filter(lambda url: not url.startswith("https"), links)
['http://unsecuresite.com', 'http://unsec2.com']
I'd go with the list comprehension, from your use of map i'd guess you'd go with the filter ;)Of course you'd replace the url.startswith with whatever your criteria is.
Ah, that's kinda what i expected. Suddenly the two languages look fairly similar, no? :)
Also, list comprehension doesn't look bad to me. It's just a slightly weird and more verbose syntax of doing map, while filter does an in-place operation.
> 1. there are too many non-obvious ways to do simple things
To a person who learned Lisp first your pythonish ways would be similarly non-obvious. Obviousness depends always on previous knowledge and you seem to know a lot about python; and as such expect things to operate like there.
Consider how confused a foreigner would be when he hears the word "bowling" and does not know about the sport and thinks it has to do with bowls.
> map is short for "apply function to every item" not "filter out an item" - i hate doing "go over every item in a list and execute a function that returns the item if it is not 'dogfood' and return that new list, overwriting the original one" when all i want is "delete 'dogfood' from my list"
But that is what filter does. Literally, there is no other way to implement this, unless you're operating with linked lists, which are not arrays. Filter is a map with a negated search func - wait, i'm an idiot. it should've been grep. But yeah, filter is just a grep with a negated search function.
Let me ask you a question though. In Perl, if i have a list of objects representing links and i want to remove all SSL links, i can do this: How would i implement this in python? Does array.remove() accept lambdas as parameter? Or would i need to go another way?> At the end of the day i will still try to find and fix bugs in other peoples perl code, curse frequently
Good luck and hop by on IRC! It will increase your curse frequency a LOT. (Until you meet mst and start to pick things up from him.)