Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Coming from Ruby, I encountered this funny situation in Python.

I was looking how to get first element of an array or get nil if the array is empty.

Python library doesn't provide this kind of functionality.

https://stackoverflow.com/questions/363944/python-idiom-to-r... offers multiple ugly ways of doing it.

For Ruby, we use `.first`.

In Ruby, the standard library is richer. A lot of libraries are "official" because Rails uses it.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: