[Tutor] append, list and variables

Mary Morris marris1031 at gmail.com
Fri Jul 16 17:37:53 CEST 2010


Thanks-that helps a lot.
The only question I have about your pseudocode is what the 'initialize
result container' does.  I'm pretty new to python and scripting in general
so I'm still trying to figure everything out.

On Thu, Jul 15, 2010 at 12:58 PM, Emile van Sebille <emile at fenx.com> wrote:

> 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 at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100716/354645d3/attachment.html>


More information about the Tutor mailing list