Grasshopper

algorithmic modeling for Rhino

I have been importing gis data with meerkat. In order to take advantage of the data fields Iv been using python script to make cull patterns for desired attributes. 

something like 

------------

names = x

cull = []

i=0

while i < len(names);

   if names[i] = "bob";

         cull.append[1];

    else;

          cull.append[0];

    i+1

a = cull

--------------

then I pull out all the bob in the list. 

here is my issue. Im using lists that are so big I dont know all the names or data fields in them. 

is there a way for python to tell me all the different items in a list? 

Views: 352

Replies to This Discussion

Hi Nico,

You can use the set class:

names = ["bob", "mike", "bob", "mcneel", "lucky", "mike", "chris", "bob"]
u_namesSet = set(names)
u_names = [name for name in u_namesSet]
print u_names      # ['mcneel', 'chris', 'lucky', 'bob', 'mike']

Much Thanks, this is great

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service