User:Orso.b.schmid: Difference between revisions
Jump to navigation
Jump to search
(Create user page) |
(comments of list creation) |
||
Line 3: | Line 3: | ||
I am Orso, an Italian Vectorscripter since many years. I feel very comfortable with VS but will now switch over to Python for even more power. | I am Orso, an Italian Vectorscripter since many years. I feel very comfortable with VS but will now switch over to Python for even more power. | ||
I will try to share here comments, problems -and solutions- from the point of view of a non-programmer. --[[User:Orso.b.schmid|Orso.b.schmid]] ([[User talk:Orso.b.schmid|talk]]) 08:13, 17 May 2015 (EDT) | I will try to share here comments, problems -and solutions- from the point of view of a non-programmer. --[[User:Orso.b.schmid|Orso.b.schmid]] ([[User talk:Orso.b.schmid|talk]]) 08:13, 17 May 2015 (EDT) | ||
Open the terminal on your Mac and write | |||
python | |||
== Lists == | |||
Lists are powerful in Python, below some fascinating lists manipulations. They remind me of Applescript: | |||
months = "Jan Feb Mar Apr May Jun Jul" | |||
months = months.split() # no splitter defined and it will use the empty space --> ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'] | |||
months2 = "Jan, Feb, Mar, Apr, May, Jun, Jul" # overwrite a copy | |||
months2.split(', ') # use comma and empty space as splitter --> ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'] | |||
months.append('Jul') # append adds an item to a list --> ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'] | |||
months.pop() # pop fetches the last item of a list --> 'Jul' | |||
', delirious '.join(months) # --> 'Jan, delirious Feb, delirious Mar, delirious Apr, delirious May, delirious Jun, delirious Sep' | |||
'-'.join(months[1:3]) # --> 'Feb-Mar' |
Revision as of 12:54, 17 May 2015
Ciao,
I am Orso, an Italian Vectorscripter since many years. I feel very comfortable with VS but will now switch over to Python for even more power. I will try to share here comments, problems -and solutions- from the point of view of a non-programmer. --Orso.b.schmid (talk) 08:13, 17 May 2015 (EDT)
Open the terminal on your Mac and write
python
Lists
Lists are powerful in Python, below some fascinating lists manipulations. They remind me of Applescript:
months = "Jan Feb Mar Apr May Jun Jul" months = months.split() # no splitter defined and it will use the empty space --> ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'] months2 = "Jan, Feb, Mar, Apr, May, Jun, Jul" # overwrite a copy months2.split(', ') # use comma and empty space as splitter --> ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'] months.append('Jul') # append adds an item to a list --> ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'] months.pop() # pop fetches the last item of a list --> 'Jul' ', delirious '.join(months) # --> 'Jan, delirious Feb, delirious Mar, delirious Apr, delirious May, delirious Jun, delirious Sep' '-'.join(months[1:3]) # --> 'Feb-Mar'