Isn’t that always the case?

 

Right after sending that question out, I had an idea that seems to explain it.

 

First: My attempt to give enough context without too much distraction left an invalid example.

 

In this case, “name” isn’t a string; it is a string contained in a generator (or from a generator, I don’t know which is correct).

 

And, the problem turned out to be the definition of __getitem__.

 

Joe Pizzi

 

From: Joe Pizzi <pizzi.joe@gmail.com>
Sent: Saturday, August 21, 2021 3:57 PM
To: chirp_devel@intrepid.danplanet.com
Subject: Python and slices

 

I’m working the port to Python3. One strangeness I’ve found is that sometimes

name = ‘memory’

for i in memory[:3]:

 

Doesn’t work. I get:

TypeError: int() argument must be a string, a bytes-like object or a number, not ‘NoneType’

 

I must explicitly add the zero:
for i in memory[0:3]:

 

Anybody know why this is? I’ve tried searching, but cannot find anything that states this doesn’t work.

 

Joe Pizzi