[Tutor] append, list and variables
Emile van Sebille
emile at fenx.com
Thu Jul 15 20:58:13 CEST 2010
On 7/15/2010 11:32 AM Mary Morris said...
> Hi,
> I'm working on a program that parses through all of our source code at my
> office and i need to get my code to print a list of the decorators. I used
> a find(@) to locate all the decorators, but I need to assign them to a
> variable somehow to get it to print a list. How do I do this? How do I
> assign a variable to all the indexed strings after the @ symbol?
>
So, decorator lines start with an '@'. Source files end in '.py'.
Pseudo code could be:
----
initialize result container
with each sourcefilename in globbed list:
for eachline in opened(sourcefilename):
if line.startswith('@'):
append [sourcefilename, line] to result
# print it
for eachline in result:
print eachline
----
Hope this gets you going,
Emile
More information about the Tutor
mailing list