For Dynamo specific workflows with Python have a look around the forum.
I noticed it might be useful to gather some Python related posts in one thread to make it easy to get started with some basic understanding (and also for a consultation ease purpose). This is still a work in progress and there might be some slight inconsistencies. Feel free to add your own links or Python related comments, or to PM me on anything that should be revised. This first post relates naturally to tips for LEARNING PYTHON:
http://dynamoprimer.com/en/09_Custom-Nodes/9-4_Python.html
htt…
For more general code introduction take a look at something like the Harvard CS50 videos online.
When working with Strings (Text Values) you can use Regular Expressions to ‘sense’ their structure.
A regular expression (shortened as regex or regexp), sometimes referred to as rational expression, is a sequence of characters that specifies a match pattern in text. Usually such patterns are used by string-searching algorithms for "find" or "find and replace" operations on strings, or for input validation. Regular expression techniques are developed in theoretical computer science and formal language theory.
The concept of regular expressions began in the 1950s, when the American mathematician...
import re
input_list = IN[0] # List of strings
result = [] # Output
for item in input_list:
# Use regular expression to find the pattern of sequential numbers or letters after the initial 'C'
match = re.search(r'C[A-Za-z0-9]+', item)
if match:
result.append(match.group())
OUT = result
1 Like