سؤال

I have trying to translate code from C++ to python and on one line(in for loop), I have:

x -= (t = u/1.0+ MIN(c, EPS)) 

I want to know what the '=' sign after a decrement indicates? how can I translate this line in python

thank u

هل كانت مفيدة؟

المحلول

In c assigments are functions at there own, in Python assignments are expressions. In python this means

t = u/1.0 + min(c, EPS)
x -= t  # same as x = x - t
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top