Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Creating a Tuple made of variable strings

The following code works:

image_files=['imgpy1.png','imgpy2.png']
clip = moviepy.video.io.ImageSequenceClip.ImageSequenceClip(image_files, fps=20)

But I have 200 filenames ‘imgpy1.png’, ‘imgpy2.png’ and so on. How do I create an object called image_files, that contain these file names. I tried to create an array of strings:

flist=[]
flist=list(map(str,flist))
flist.append['imagepy1.png']
flist.append['imagepy2.png']

but that does not work. I get the error message

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Traceback (most recent call last):
  File "C:\Users\vince\image.py", line 53, in <module>
    flist.append['imagepy1.png']
TypeError: 'builtin_function_or_method' object is not subscriptable

I am new to Python and can’t figure out how to get an array or Tuple of strings. I’ve tried for 2-3 hours to non avail, at least 40 different ways including stuff I read online that don’t work on my laptop. In the end, I am only interested in passing an argument to the video function that (1) does not crash the Python interpreter and (2) can be digested by the video function. So far, I am stuck with (1). But in the end I’m looking at solving (2). I don’t care if it’s an array, a list, a Tuple or anything else, as long as it works.

>Solution :

I think append function is not correct.

flist.append('imagepy1.png')   # not brackets
flist.append('imagepy2.png')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading