Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| developer:python_tips_and_tricks [2025/02/18 20:36] – external edit 127.0.0.1 | developer:python_tips_and_tricks [2025/10/23 22:42] (current) – [Execute actions in a Trigger only on certain days of the week] davel17 | ||
|---|---|---|---|
| Line 237: | Line 237: | ||
| But this still requires that you define the complete possible list of arguments up-front. What if you wanted your method to collect up any additional arguments? For instance, depending on some of the defined parameters, there might be a difference in what other arguments are passed in? | But this still requires that you define the complete possible list of arguments up-front. What if you wanted your method to collect up any additional arguments? For instance, depending on some of the defined parameters, there might be a difference in what other arguments are passed in? | ||
| - | You can do this using *args and %%**kwargs%% in your method definition. In this example, you're allowing the caller to pass in 1 to N number of positional arguments: | + | You can do this using *args and //''< |
| < | < | ||
| Line 300: | Line 300: | ||
| # Here's an example of executing actions only on a weekend | # Here's an example of executing actions only on a weekend | ||
| if date.today().weekday() in WEEKEND: | if date.today().weekday() in WEEKEND: | ||
| - | # It's a week day, so execute actions here | + | # It's a weekend |
| # You could directly execute actions if they' | # You could directly execute actions if they' | ||
| indigo.device.turnOn(12345) | indigo.device.turnOn(12345) | ||