I was wondering if there is something in python similar to the begin expression in Scheme, and if not how would you write something in python to simulate it.

Recommended Answers

All 3 Replies

What does 'begin' do?

You don't need a begin in Python,:

(if (condition)
  (begin
    (do-something-1)
    (do-something-2))
  do-something-else)
if condition:
    do_something_1
    do_something_2
else:
    do_something_else

Begin:

The <expression>s are evaluated sequentially from left to right, and the value of the last <expression> is returned. This expression type is used to sequence side effects such as input and output.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.