print "Music is by blah blah"
music-file = open(file containing the music"
hide(music-file)
thats wat im looking for, something i can hide the opening of files
because if i open that file, Windows Media Player will open and i would
like to hide that. And advise????
To answer the specific question of how to play a music file in Python,
search Google Groups for: pygame.mixer.music.load("music.mp3")
That will bring up a useful thread. Note that you will need to install
a module such as pygame or pymedia; they are not in the standard
library.
In general, I would also recommend some of the many good Python
tutorials. Some are listed here:
http://wiki.python.org/moin/BeginnersGuide
Good luck!
Here are some links that might be of interest:
http://www.win32com.de/index.php?option=com_content&task=view&id=141&Itemid=259
Larry Bates
Guido has said he wants to keep open() around as the way to open a
file-like object, with the theory that in the future open might also
support opening non-files (e.g. urls). So open("C:\file.txt") is still
fine, though isinstance(f, open) is probably not. ;)
STeVe
I think it is more like it is recommended, not just OK.
--
Benji York
As others have noted, "open" is preferred as the method for opening
files, while "file" is the _type_ involved, for testing or subclassing
or what-have-you.
But neither file("C:\file.txt") nor open("C:\file.txt") is actually
correct at all, unless you have strange files whose names start with
ASCII FF characters. '\f' is an escape sequence, equivalent to '\x0c'.
Always use forward slashes ("C:/file.txt") in path names unless you are
passing them to the shell, or use raw strings (r"C:\file.txt") to avoid
mysterious problems with escape sequences.
-Peter
As others have pointed out: your question is pointless as opening a
file doesn't load it or open it in your preferred application.
You are confusing Operating System semantics with Python semantics.
You're probably only asking this question because you've never
actually tried it.
The solution for your problem is to read a beginner's tutorial about
Python.
> or the even hide the whole python window to run in background?? is
> there no module or function i can use????
On windows: use pythonw.exe instead of python.exe.
The whole open()/file() clairification is useful too. The Python docs
for the file() constructor simply state that, "File objects ... can be
created with the built-in constructor file() described in section 2.1,
'Built-in Functions.'"
(http://python.org/doc/2.4.1/lib/bltin-file-objects.html)
That's followed by a footnote that states, "file() is new in Python
2.2. The older built-in open() is an alias for file()."
At first sight, that to me suggests that open() has been somewhat
deprecated by file().
However, the description of many of the file methods on the same page
refers to opening files using open(), e.g.:
"mode: The I/O mode for the file. If the file was created using the
open() built-in function, this will be the value of the mode
parameter."
It all becomes relatively clear in section 2.1, "Built-in Functions"
where the entry for file() states, "The file() constructor is new in
Python 2.2 and is an alias for open(). Both spellings are equivalent.
The intent is for open() to continue to be preferred for use as a
factory function which returns a new file object. The spelling, file is
more suited to type testing (for example, writing 'isinstance(f,
file)')."
I guess that clears it up. Though perhaps the Python doc for the file()
constructor should add that open() is the preferred general-purpose way
to open a file or file-like object?
Thanks again