Python 3 support

Funcy works with python 3 as of version 0.9. However, it has slightly different interface. It follows python 3 convention of “iterator by default” for utilities like map(), filter() and such. When funcy has two versions of utility (list and iterator) they are named like keep() and ikeep() in python 2 and lkeep() and keep() in python 3. You can look up a full table of differently named functions below.

Writing cross-python code

You can do that two ways: writing python 2 code that works in python 3 or vice versa. You can import python 2 or 3 style functions from funcy.py2 or funcy.py3:

from funcy.py2 import whatever, you, need

# write python 2 style code here
from funcy.py3 import whatever, you, need

# write python 3 style code here

You can even import map(), imap(), filter(), ifilter(), zip() and izip().

Full table of python dependent function names

Python 2 / list Python 2 / iterator Python 3 / list Python 3 / iterator
map() imap() lmap() map()
filter() ifilter() lfilter() filter()
zip() (built-in) izip() lzip() zip() (built-in)
remove() iremove() lremove() remove()
keep() ikeep() lkeep() keep()
without() iwithout() lwithout() without()
concat() iconcat() lconcat() concat()
cat() icat() lcat() cat()
flatten() iflatten() lflatten() flatten()
mapcat() imapcat() lmapcat() mapcat()
distinct() idistinct() ldistinct() distinct()
split() isplit() lsplit() split()
split_at() isplit_at() lsplit_at() split_at()
split_by() isplit_by() lsplit_by() split_by()
partition() ipartition() lpartition() partition()
chunks() ichunks() lchunks() chunks()
partition_by() ipartition_by() lpartition_by() partition_by()
reductions() ireductions() lreductions() reductions()
sums() isums() lsums() sums()
juxt() ijuxt() ljuxt() juxt()
where() - - where()
pluck() - - pluck()
invoke() - - invoke()
- izip_values() - zip_values()
- izip_dicts() - zip_dicts()

Table Of Contents

Previous topic

Welcome to funcy documentation!

Next topic

Extended predicate/mapper semantics

This Page