Something like "do" in python?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
danielrr
Posts: 140
Joined: Mon Mar 04, 2013 4:03 pm

Something like "do" in python?

Post by danielrr » Wed Sep 21, 2022 7:39 pm

I find livecode's "do" command something like magic.
Is there something like it in Python, or JavaScript?

stam
Posts: 2634
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Something like "do" in python?

Post by stam » Wed Sep 21, 2022 7:51 pm

what's magic for me is the [each] iterator... don't think there's anything like it in other languages and it makes such easy work of it...

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9579
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Something like "do" in python?

Post by dunbarx » Wed Sep 21, 2022 9:29 pm

Stam.

And FAST, if you mean in the "Repeat for each..." form.

But just as cool is the "each" local variable, which allows one to, say:

Code: Select all

sort lines of myHugeList by word 3 of each & item 5 of each
Magic, as you say. :wink:

Craig

stam
Posts: 2634
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Something like "do" in python?

Post by stam » Wed Sep 21, 2022 9:39 pm

dunbarx wrote:
Wed Sep 21, 2022 9:29 pm
Stam.

And FAST, if you mean in the "Repeat for each..." form.

But just as cool is the "each" local variable, which allows one to, say:

Code: Select all

sort lines of myHugeList by word 3 and item 5 of each
Magic, as you say. :wink:

Craig
Actually repeat for each is a common pattern across several languages... (and until we get compiled scripts, all of these are faster...)

i meant the second form you mention - also when filtering arrays, so versatile 8)

Code: Select all

filter elements of tArray where each["someKey"] = "xyz"

SparkOut
Posts: 2839
Joined: Sun Sep 23, 2007 4:58 pm

Re: Something like "do" in python?

Post by SparkOut » Wed Sep 21, 2022 9:48 pm

In both javascript and python the "do" equivalent is

Code: Select all

eval()
In both javascript and python this function is discouraged because it can enable arbitrary code to run, which may be a big security risk. The same risk is applicable in LiveCode but I dare say there is a smaller possibility of attack through this vector.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”