Isaac274 Isaac274 - 3 months ago 34
Python Question

Python3 wifi module returns object, not list of wifi networks

I just installed the wifi library, and started following the guide here, but when I type

>>> from wifi import Cell, Scheme
>>> Cell.all('wlan0')

The output I get isn't a list, but an object:

<map object at 0x7ff23b40e588>

I'm using Python 3.4 on Ubuntu 14.04, and this does seem to work with Python 2.7, which is fine, but I'd prefer to use 3.4. How do I get the output to be a list? I presume it's just a case of different Python versions handling output differently.

Edit: I've just started trying to figure it out again, and now when I do

from wifi import Cell

I get this:

ImportError: cannot import name Cell

I'm really confused.

Edit again:

Never mind, that was me being stupid. I made a program called to test it, forgetting about the whole idea of modules in Python.


The all method of Cell returns a map(...). In Python 2.x this will automatically return a list, but Python 3.x returns a map object (an iterator) which can be converted into a list by calling list on it.

So you can see the full list of wifi networks by calling list on the returned object:

>>> list(Cell.all('wlan0'))