How would one make a list of the files in the top directory
using os.walk.
I need to pick a random file from said list.
Thanks.
-- Posted on news://freenews.netfront.net - Complaints to [EMAIL PROTECTED] --
--
http://mail.python.org/mailman/listinfo/python-list
I've used glob.glob to get a list of files in a directory
and now I want to use os.system to execute one of
those files, the problem is that python automatically
puts a escape charater infront of the back slashes
so the os.system gets X:\\\\\\ and is useless,
I think I need to convert my st
> No, it doesn't. Instead of guessing what the cause might be, please show
> us your code and show us the error message you're getting, so that we can
> determine what the cause really is.
Ok, sorry. Heres my code:
import glob
import random
import os
songs = glob.glob('C:\###\###\###\*.mp3')
p
> my guess is that the real problem is that you get back filenames with
> spaces in them, which gets treated as multiple arguments by os.system.
>
> using os.startfile will fix this:
>
> >>> import glob, os, random
> >>> file = random.choice(glob.glob("\\music\\*.mp3"))
> >>> file
> '\\music\\Madr
Well the othe day I was making a program to make a list of all the songs in
certian directorys but I got a problem, only one of the directorys was added
to the list. Heres my code:
import random
import os
import glob
songs = glob.glob('C:\Documents and Settings\Admin\My
Documents\LimeWire\Save
> 1) You need to either use raw string for your pathnames or use forward
> slashes.
> This is because backslash is an escape character to Python and if you get
> any legal escaped sequence (like \n, \t, etc) it won't work as expected.
>
> songs = glob.glob(r'C:\Documents and Settings\Admin\My
>
pretty self-explanatory, here's what I put in:
while stat == 0 :
pgrid#ignore, A pre-defined function
print "what cell do you want?"
varcc = raw_input
grid[varc] = 'O'
And here's what I get back:
Traceback (most recent call last):
File "C:\py_prog\Ti
> Lanny:
>> ...
>> varcc = raw_input
>> grid[varc] = 'O'
>> ...
>> Why can't I put a varible thats an integer instead?
>
> 'varcc' and 'varc' are different names.
>
> 'raw_input' isn't a
I've been thinking about putting together a text based RPG written
fully in Python, possibly expanding to a MUD system. I'd like to know
if anyone feels any kind of need for this thing or if I'd be wasting
my time, and also if anyone would be interested in participating,
because of the highly modul
The answer may be right infront of me but I really can't figure this
out.
I'm trying to build a interactive fiction kind of game, silly I know
but I
am a fan of the genre. I'm trying to build up an index of all the
rooms in
the game from an outside file called roomlist.txt. The only problem is
that
10 matches
Mail list logo