[chirp_devel] Python and slices

Joe Pizzi
Sat Aug 21 14:10:04 PDT 2021


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 at gmail.com> 
Sent: Saturday, August 21, 2021 3:57 PM
To: chirp_devel at 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

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://intrepid.danplanet.com/pipermail/chirp_devel/attachments/20210821/59d8f241/attachment-0001.html 


More information about the chirp_devel mailing list