Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does inspect() think map isn't built in?

Tags:

The following code returns false

import inspect print(inspect.isbuiltin(map)) 

But the map function is listed under "built-in" functions.

Why is it so?

like image 499
Muthuvel Avatar asked Jul 05 '21 08:07

Muthuvel


People also ask

How do I know if my map features have been mapped?

You can view a history of all your edits in your profile on OpenStreetMap.org under 'my edits'. Check other examples of the features you have added or changed and see if they are mapped the same way. You may also want to check the map features or other wiki pages for the correct tags.

Why are the different maps different?

Every one of these maps can be very different: Not everything that is in the data, is also shown on every map. Some features are only shown on specialized maps, some features aren't shown at all and are only used for other applications, e.g. routing.

Why does the map take so long to update?

Sometimes the tiles (map images) are cached and it will take longer for new or changed stuff to appear. Check if the map you are using shows the update interval or actual date and time. When you talk about 'the map', you may mean the 'Mapnik'-layer on OpenStreetMap.org.

Why is my data not showing up in Mapnik?

Assuming that you're worried about the Mapnik view on openstreetmap.org and you've verified that your data has made it into the database (tick the "data" box, for example), you may be suffering from a stale cache in your browser. You can solve this by following these steps:


Video Answer


1 Answers

The inspect.isbuiltin will only

Return true if the object is a built-in function or method.

The map builtin is a class, not a function or method:

>>> map <class 'map'> 

In fact, most "built-in functions" that return iterators are implemented as classes; calling them returns optimised instances instead of re-using some generic iterator class.

>>> zip  # zip iterator "function" is also a class <class 'zip'> >>> map(str, (1, 2, 34))  # map builds instances of map <map object at 0x103fa34f0> 

In addition, keep in mind that the term "built-in" has two meanings in Python:

  • A compiled object, i.e. built into the interpreter.
  • A member of the builtins module, available in every module.

While most builtins are compiled for speed, this is no necessity.

If you want to check whether a name is part of builtins, do so via the module:

>>> import builtins >>> hasattr(builtins, "map") True >>> hasattr(builtins, "sum") True >>> hasattr(builtins, "reduce") False 
like image 98
MisterMiyagi Avatar answered Oct 12 '22 18:10

MisterMiyagi