Hi everyone
The following code:
scriptPath = os.path.dirname(__file__)
(dirpath, dirnames, filenames) = os.walk(scriptPath)
print 'dirpath\n'
print dirpath
print 'dirnames\n'
pprint.pprint(dirnames)
print 'filenames\n'
pprint.pprint(filnames)
Fails on the os.walk call with the following error:
(dirpath, dirnames, filenames) = os.walk(scriptPath)
ValueError: need more than 1 value to unpack
Any ideas what could be wrong?
Thx & greetings
Dominique
************************************************** ***************************
This e-mail and any files attached are strictly confidential, may be legally
privileged and are intended solely for the addressee. If you are not the
intended recipient please notify the sender immediately by return email and
then delete the e-mail and any attachments immediately.
The views and or opinions expressed in this e-mail are not necessarily the
views of De La Rue plc or any of its subsidiaries and the De La Rue Group
of companies, their directors, officers and employees make no representation
about and accept no liability for its accuracy or completeness.
You should ensure that you have adequate virus protection as the De La Rue
Group of companies do not accept liability for any viruses.
De La Rue plc Registered No.3834125, De La Rue Holdings plc Registered
No 58025 and De La Rue International Limited Registered No 720284 are all
registered in England with their registered office at:
De La Rue House, Jays Close, Viables, Hampshire RG22 4BS
************************************************** *************************** 2 1791
<Do*****************@ch.delarue.comwrites:
(dirpath, dirnames, filenames) = os.walk(scriptPath)
You're supposed to loop over values in different directories, like
this:
for dirpath, dirnames, filenames in os.walk(scriptPath):
... handle dirpath with dirnames and filenames ...
The loop will be executed for each subdirectory (direct and indirect)
of scriptPath.
Hrvoje Niksic wrote:
<Do*****************@ch.delarue.comwrites:
> (dirpath, dirnames, filenames) = os.walk(scriptPath)
You're supposed to loop over values in different directories, like
this:
for dirpath, dirnames, filenames in os.walk(scriptPath):
... handle dirpath with dirnames and filenames ...
The loop will be executed for each subdirectory (direct and indirect)
of scriptPath.
And if you are simply hand-experimenting, try somthing like:
generator = os.walk(scriptPath)
dirpath, dirnames, filenames = generator.next()
...
dirpath, dirnames, filenames = generator.next()
...
--Scott David Daniels Sc***********@Acm.Org This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Marcello Pietrobon |
last post by:
Hello,
I am using Pyton 2.3
I desire to walk a directory without recursion
this only partly works:
def walk_files() :
for root, dirs, files in os.walk(top, topdown=True):
for filename in...
|
by: rbt |
last post by:
More of an OS question than a Python question, but it is Python related
so here goes:
When I do os.walk('/') on a Linux computer, the entire file system is
walked. On windows, however, I can...
|
by: Jim Hubbard |
last post by:
Are you up to speed on the difficulties in using the 1.1 .Net framework?
Not if you are unaware of the 1,596 issues listed at KBAlertz
(http://www.kbalertz.com/technology_3.aspx).
If you are...
|
by: JC - home |
last post by:
Hello..
I've been having some problems for a little while with this which I was
sure I would beat...hmmm.
Anyway, I have a form with two rich textboxes. One at the top which is
to display a...
|
by: KraftDiner |
last post by:
The os.walk function walks the operating systems directory tree.
This seems to work, but I don't quite understand the tupple that is
returned...
Can someone explain please?
for root, dirs,...
|
by: gregpinero |
last post by:
In the example from help(os.walk) it lists this:
from os.path import join, getsize
for root, dirs, files in walk('python/Lib/email'):
print root, "consumes",
print sum(),
print "bytes in",...
|
by: Marcus Alves Grando |
last post by:
Hello list,
I have a strange problem with os.walk and threads in python script. I
have one script that create some threads and consume Queue. For every
value in Queue this script run os.walk()...
|
by: Jeff McNeil |
last post by:
Your args are fine, that's just the way os.path.walk works. If you
just need the absolute pathname of a directory when given a relative
path, you can always use os.path.abspath, too.
A couple...
|
by: Jeff Nyman |
last post by:
Greetings all.
I did some searching on this but I can't seem to find a specific
solution. I have code like this:
=========================================
def walker1(arg, dirname, names):...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |