I'm developing my first "Hello World" on Python! I used to be Visual Basic programmer a long long time ago...
I'm trying to use Namedtuple Collections like below:
#!/usr/bin/env python3
import collections
#Tipo da colecao
File = collections.namedtuple('File',['abspath' ,'basename','filextention','filetype'])
Files = []
Files.append(File('/home/user/teste1.txt', 'teste1.txt','txt',''))
Files.append(File('/home/user/teste2.txt', 'teste2.txt','txt',''))
Files.append(File('/home/user/teste3.txt', 'teste2.txt','txt',''))
for lCtd in range(0,len(Files)):
print(Files[lCtd].abspath,Files[lCtd].basename,Files[lCtd].filextention)
for lCtd in range(0,len(Files)):
#>>>>>How can I do this?!<<<<<
Files[lCtd].filetype = 'A'
If have a best way to do this(or the all code), I'm all ears...
Thanks a lot!
namedtuples are immutable. You could try using a list ofdicts instead, or recordtype. - PGHEfile, notFile,files, notFiles). Uppercase first characters signal a type vs a variable. - CryptoFool