-1

For instance, can someone please explain to me the purpose of the asterisk in line 2 below?

m = Basemap(projection='merc', llcrnrlon=lon.min(), urcrnrlon=lon.max(), llcrnrlat=lat.min(), urcrnrlat=lat.max())
x, y = m(*np.meshgrid(lat,lon))
sls37
  • 1
  • 3

2 Answers2

2

It means it will "expand" a collection in its individual elements.

So, suppose a function needs many arguments, and you have these arguments in a collection. Since you could not pass the collection itself (which would count as a single argument), you use the * so the collection is expanded and passed as its individual arguments to the function.

heltonbiker
  • 26,657
  • 28
  • 137
  • 252
0

from the documentation:

An asterisk * denotes iterable unpacking. Its operand must be an iterable. The iterable is expanded into a sequence of items, which are included in the new tuple, list, or set, at the site of the unpacking.

John Anderson
  • 35,991
  • 4
  • 13
  • 36
  • Note the bullet point in the "Answer Well-Asked Questions" section of [How to Answer](https://stackoverflow.com/help/how-to-answer) re: questions which "...have already been asked and answered many times before". – Charles Duffy Dec 17 '18 at 01:51
  • Thank you to the two that answered my question. I saw the other posted questions already which did not clearly answer what I was specifically asking. The Stack Overlords may do as they wish with my question now. – sls37 Dec 17 '18 at 01:58