Sponsored Content
Top Forums Programming Populating Lists in Def using Python Post 302869191 by targzeta on Tuesday 29th of October 2013 07:07:03 PM
Old 10-29-2013
Basically os.walk returns a tuple (dirpath, dirnames, filenames). So, if you want the full path of every files, you have to join dirpath and filename:
Code:
content = []
for root, dirs, files in os.walk("/tmp", topdown=False):
    for name in files:
        content.append(os.path.join(root, name))

Emanuele

Note: if your directory doesn't have subdirs, you can also use os.listdir.
 

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
IO::All::HTTP(3pm)					User Contributed Perl Documentation					IO::All::HTTP(3pm)

NAME
IO::All::LWP - Extends IO::All to HTTP URLs SYNOPSIS
use IO::All; $content < io('http://example.org'); # GET webpage into scalar io('http://example.org') > io('index.html'); # GET to file "hello " > io('http://example.org/index.html'); # PUT webpage # two ways of getting a page with a password: $content < io('http://me:secret@example.org'); $content < io('http://example.org')->user('me')->password('secret'); DESCRIPTION
This module extends IO::All for dealing with HTTP URLs. Note that you don't need to use it explicitly, as it is autoloaded by IO::All whenever it sees something that looks like an HTTP URL. The SYNOPSIS shows some simple typical examples, but there are many other interesting combinations with other IO::All features! For example, you can get an HTTP URL and write the content to a socket, or to an FTP URL, of to a DBM file. METHODS
This is a subclass of IO::All::LWP. The only new method is "http", which can be used to create a blank IO::All::HTTP object; or it can also take an HTTP URL as a parameter. Note that in most cases it is simpler just to call io('http://example.com'), which calls the "http" method automatically. OPERATOR OVERLOADING
The same operators from IO::All may be used. < GETs an HTTP URL; > PUTs to an HTTP URL. SEE ALSO
IO::All, IO::All::LWP, LWP. AUTHORS
Ivan Tubert-Brohman <itub@cpan.org> and Brian Ingerson <ingy@cpan.org> COPYRIGHT
Copyright (c) 2007. Ivan Tubert-Brohman and Brian Ingerson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See <http://www.perl.com/perl/misc/Artistic.html> perl v5.10.0 2007-03-29 IO::All::HTTP(3pm)
All times are GMT -4. The time now is 11:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy