Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!
Active reading.
Source Link
Peter Mortensen

Substr() normally (i.e. PHP, and Perl) works this way:

s = Substr(s, beginning, LENGTH)

So the parameters are beginningbeginning and LENGTHLENGTH.

But Python's behaviour is different,different; it expects beginning and one after END (!). This is difficult to spot by beginners. So the correct replacement for Substr(s, beginning, LENGTH) is

s = s[ beginning : beginning + LENGTH]

Substr() normally (i.e. PHP, Perl) works this way:

s = Substr(s, beginning, LENGTH)

So the parameters are beginning and LENGTH

But Python's behaviour is different, it expects beginning and one after END (!). This is difficult to spot by beginners. So the correct replacement for Substr(s, beginning, LENGTH) is

s = s[ beginning : beginning + LENGTH]

Substr() normally (i.e. PHP and Perl) works this way:

s = Substr(s, beginning, LENGTH)

So the parameters are beginning and LENGTH.

But Python's behaviour is different; it expects beginning and one after END (!). This is difficult to spot by beginners. So the correct replacement for Substr(s, beginning, LENGTH) is

s = s[ beginning : beginning + LENGTH]
the second index is the first position which is not contained in the result (one after the end).
Source Link
Community Bot

Substr() normally (i.e. PHP, Perl) works this way:

s = Substr(s, beginning, LENGTH)

So the parameters are beginning and LENGTH

But Python's behaviour is different, it expects beginning and one after END (!). This is difficult to spot by beginners. So the correct replacement for Substr(s, beginning, LENGTH) is

s = s[ beginning : beginning + LENGTH]

Substr() normally (i.e. PHP, Perl) works this way:

s = Substr(s, beginning, LENGTH)

So the parameters are beginning and LENGTH

But Python's behaviour is different, it expects beginning and END (!). This is difficult to spot by beginners. So the correct replacement for Substr(s, beginning, LENGTH) is

s = s[ beginning : beginning + LENGTH]

Substr() normally (i.e. PHP, Perl) works this way:

s = Substr(s, beginning, LENGTH)

So the parameters are beginning and LENGTH

But Python's behaviour is different, it expects beginning and one after END (!). This is difficult to spot by beginners. So the correct replacement for Substr(s, beginning, LENGTH) is

s = s[ beginning : beginning + LENGTH]
Seanog

Substr() normally (i.e. PHP, Perl) works this way:

s = Substr(s, beginning, LENGTH)

So the parameters are beginning and LENGTH

But Python's behaviour is different, it expects beginning and END (!). This is difficult to spot by beginners. So the correct replacement for Substr(s, beginning, LENGTH) is

s = s[beginning,s[ beginning+LENGTH]beginning : beginning + LENGTH]

Substr() normally (i.e. PHP, Perl) works this way:

s = Substr(s, beginning, LENGTH)

So the parameters are beginning and LENGTH

But Python's behaviour is different, it expects beginning and END (!). This is difficult to spot by beginners. So the correct replacement for Substr(s, beginning, LENGTH) is

s = s[beginning, beginning+LENGTH]

Substr() normally (i.e. PHP, Perl) works this way:

s = Substr(s, beginning, LENGTH)

So the parameters are beginning and LENGTH

But Python's behaviour is different, it expects beginning and END (!). This is difficult to spot by beginners. So the correct replacement for Substr(s, beginning, LENGTH) is

s = s[ beginning : beginning + LENGTH]
Source Link
Michał Leon
Loading
lang-py