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




_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to