Sponsored Content
Top Forums Programming Populating Lists in Def using Python Post 302869179 by metallica1973 on Tuesday 29th of October 2013 05:54:04 PM
Old 10-29-2013
Populating Lists in Def using Python

Dipping around in python again and need to create a def that will populate a list(content) with the files that os.walk finds from within this directory and then I will re.search through each files looking for content. In learning Python, can someone point me in the right direction. This is what I have so far.

Code:
def list_files ( content=None ):
    if content is None:
        content = []
        for files in os.walk('var/www/html/data/customer/log', topdown=True):
            content.append(files)
            return content

Many thanks in advanced.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

.def file in HP-UX Shell scripting

Hi Pals, I need some information related .def file in HP-Ux shell scripting. What actaully a .def file contains. It is having all definitions of some functions. But what is the relationship between a .def file and shell script. Can anyone give some examples. Thanks in Advance. Best... (1 Reply)
Discussion started by: manu.vmr
1 Replies

2. Shell Programming and Scripting

Populating an Array

Guys, I need to iterate populate an array while going over files in directory. Can someone please tell me syntax I tried this but it isn't working ==> for F in `ls -p "${directory1}" | grep -v "\/"` do cd "${directory2}" cmp "${directory2}"/"${F}" "${directory1}"/"${F}" ... (2 Replies)
Discussion started by: Veenak15
2 Replies

3. Shell Programming and Scripting

Shell Script to Create non-duplicate lists from two lists

File_A contains Strings: a b c d File_B contains Strings: a c z Need to have script written in either sh or ksh. Derive resultant files (File_New_A and File_New_B) from lists File_A and File_B where string elements in File_New_A and File_New_B are listed below. Resultant... (7 Replies)
Discussion started by: mlv_99
7 Replies

4. Programming

populating a JList

Hi, I have to create a JList and the items I need to display are store in HashMap table. What would be the easiest way to populate this JList. Basically the items I want to display/show in the JList are the key values of the HashMap. Thanks in advance for any suggestions. (0 Replies)
Discussion started by: arizah
0 Replies

5. Programming

Python: Compare 2 word lists

Hi. I am trying to write a Python programme that compares two different text files which both contain a list of words. Each word has its own line worda wordb wordc I want to compare textfile 2 with textfile 1, and if there's a word in textfile 2 that is NOT in textfile 1, I want to... (6 Replies)
Discussion started by: Bloomy
6 Replies

6. Homework & Coursework Questions

[Python] Compare 2 lists

Hello, I'm new to the python programming, and I have a question. I have to write a program that prints a receipt for a restaurant. The input is a list which looks like: product1 product3 product8 .... In the other input file there is a list which looks like: product1 coffee 5,00... (1 Reply)
Discussion started by: dagendy
1 Replies

7. Shell Programming and Scripting

Separate Text File into Two Lists Using Python

Hello, I have a pretty simple question, but I am new to Python and am trying to write a simple program. Put simply, I want to take a text file that looks like this: 11111 22222 33333 44444 55555 66666 77777 88888 and produce two lists, one containing the contents of the left column, one the... (0 Replies)
Discussion started by: Tyler_92
0 Replies

8. Programming

Python Concatenating 2 Lists

I am just trying to concatenate two lists together, but I am not sure what is wrong with my code, it won't run. Thank you for any help. #!/usr/bin/python # Takes two lists and returns a list that is the concatenation of both of # them. A = B = def list_concat( A, B): print(A) ... (2 Replies)
Discussion started by: totoro125
2 Replies

9. Homework & Coursework Questions

KLIBC .def file

I am working on klibc. I need to add a new command in kernel. klibc contains a SYSCALLS.def file which declares functions. Where can I find definition of functions declared in .def file? (1 Reply)
Discussion started by: Vasundhara08
1 Replies
PUBTAL(1)						      General Commands Manual							 PUBTAL(1)

NAME
PubTal -- Generate a web site from content and templates, and upload it to its destination SYNOPSIS
updateSite [options] site.config [content-dir | content-type ] [...] uploadSite [options] site.config [destination-dir | destination-file ] [...] DESCRIPTION
This manual page documents briefly the updateSite and uploadSite commands from the PubTal package This manual page was written for the Debian distribution because the original program does not have a manual page. Instead, it has docu- mentation in HTML format; see below. updateSite generates HTML pages starting from a series of content files and templates written in the ZPT language. The command takes a minimum of one parameter, the location of the website configuration file. The updateSite command first reads in the configuration file and so locates the content, template, and destination directories (defaulting to content, template, and dest respectively). If only one parameter is passed to updateSite, it will then find each file under the content directory and build the corresponding output files. If more than one parameter is passed, then each extra parameter is taken as content to build. If the parameter is a directory under the content directory, then any content files in that directory will be built recursively. If the parameter is a file in the content directory (or one of its children), then just that file will be built. Take for example: updateSite new-site/site.config new-site/content/index.txt new-site/content/examples/ This will build the index.txt file into index.html and all content files under content/examples/ will be built into their corresponding output files. uploadSite uploads the generated pages. This takes a minimum of one parameter, the location of the website configuration file. The uploadSite command first reads in the configuration file and so locates the destination directories. If only one parameter is passed to uploadSite, it will then find each file under the destination directory that needs to be uploaded. The logic used to determine whether a file needs to be uploaded is explained in the Uploading section. If more than one parameter is passed, then each extra parameter is taken as destination to upload. If the parameter is a directory under the destination directory then any files in that directory will be considered for upload recursively. If the parameter is a file in the destination directory (or one of its children), then just that file will be considered for upload. Take for example: uploadSite new-site/site.config new-site/dest/index.html new-site/dest/examples/ This will examine the index.html file and all files under dest/examples/ when determining what files to upload. OPTIONS
A summary of options is included below. For a complete description, see the HTML documentation. Options for updateSite -h --help Prints out the help description for the command. -a --all Builds all classes of content, not just content in the "normal" class. --class classParams Builds all classes given as supplied in a comma separated list. --logging Turns on logging. --logfile name Logs to the file "name" (defaults to updateSite.log). --debug Turns on debug logging; implies --logging. --debug-simpletal Turns on debug logging of SimpleTAL, implies --logging. Options for uploadSite -h --help Prints out the help description for the command. -a --all Checks all files are uploaded, not just PubTal generated ones. --force Uploads files even if PubTal thinks they are up-to-date. --dry-run Prints out what would have been done, but takes no action. --logging Turns on logging. --logfile name Logs to the file "name" (defaults to updateSite.log). --debug Turns on debug logging; implies --logging. SEE ALSO
The programs are documented fully by HTML documentation available in /usr/share/doc/pubtal/html. AUTHOR
This manual page was written by Luis Rodrigo Gallardo Cruz rodrigo@nul-unu.com for the Debian system (but may be used by others). Permis- sion is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. PUBTAL(1)
All times are GMT -4. The time now is 03:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy