Re: [Tutor] MP3Info class usage

2008-12-18 Thread Gareth at Serif



Todd Zullinger wrote:
> 
> That's hard to guess at.  If you can explain what you have done and
> how you've installed eyeD3, that would help.
> 

I've not installed it, I've just imported it in my main program.  How do you
install eyeD3, there's no installation package?  I read the readme, which
talks about executing 'configure', but that just reports back that it is not
recognized as an internal or external command, operable program or batch
file.

Clearly I'm missing a huge step, can you help me out?
-- 
View this message in context: 
http://www.nabble.com/MP3Info-class-usage-tp20934673p21071143.html
Sent from the Python - tutor mailing list archive at Nabble.com.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] MP3Info class usage

2008-12-18 Thread Todd Zullinger
Gareth at Serif wrote:
> I've not installed it, I've just imported it in my main program.
> How do you install eyeD3, there's no installation package?

What OS are you running?  I can help if you run some sort of *nix
system.  If you're on Windows, then I'll have to pass as I know
nothing about installing python modules on Windows. :)

> I read the readme, which talks about executing 'configure', but that
> just reports back that it is not recognized as an internal or
> external command, operable program or batch file.

Hmm, "... batch file" makes me think this is Windows.

On *nix systems, you run ./configure; make; sudo make install.  The ./
in front of configure tells the shell that the program you are trying
to run is in the current directory.  Otherwise, the shell would look
for configure in your $PATH, which does not include the current
directory.

-- 
ToddOpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~
Mollison's Bureaucracy Hypothesis:
If an idea can survive a bureaucratic review and be implemented it
wasn't worth doing.



pgp8LSNYi8sv7.pgp
Description: PGP signature
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] PyLucene on Python 2.6

2008-12-18 Thread Jose Neto
I don't know if it's off-topic or not. If it is, please forgive me and
ignore this question.
Does anyone know if there is a win32 binary of PyLucene? I tried to compile
the sources, but the python "explodes" in the middle of the compilation.

Log file:
$ make
/cygdrive/f/Python26/python.exe -v -m jcc.__main__ --shared  --jar
lucene-java-2
.4.0/build/lucene-core-2.4.0.jar --jar
lucene-java-2.4.0/build/contrib/snowball/
lucene-snowball-2.4.0.jar --jar
lucene-java-2.4.0/build/contrib/highlighter/luce
ne-highlighter-2.4.0.jar --jar
lucene-java-2.4.0/build/contrib/analyzers/lucene-
analyzers-2.4.0.jar --jar
lucene-java-2.4.0/build/contrib/regex/lucene-regex-2.4
.0.jar --jar
lucene-java-2.4.0/build/contrib/queries/lucene-queries-2.4.0.jar --
jar
lucene-java-2.4.0/build/contrib/instantiated/lucene-instantiated-2.4.0.jar -
-jar build/jar/extensions.jar --package java.lang java.lang.System
java.lang.Run
time --package java.util java.text.SimpleDateFormat --package java.io
java.io.St
ringReader java.io.InputStreamReader java.io.FileInputStream --exclude
org.apach
e.lucene.queryParser.Token --exclude
org.apache.lucene.queryParser.TokenMgrError
 --exclude org.apache.lucene.queryParser.QueryParserTokenManager --exclude
org.a
pache.lucene.queryParser.ParseException --python lucene --mapping
org.apache.luc
ene.document.Document 'get:(Ljava/lang/String;)Ljava/lang/String;' --mapping
jav
a.util.Properties 'getProperty:(Ljava/lang/String;)Ljava/lang/String;'
--sequenc
e org.apache.lucene.search.Hits 'length:()I'
'doc:(I)Lorg/apache/lucene/document
/Document;' --version 2.4.0 --files 2 --build
[...]
import zlib # builtin
# f:\Python26\lib\site-packages\jcc-2.1-py2.6-win32.egg\jcc\python.pyc
matches f
:\Python26\lib\site-packages\jcc-2.1-py2.6-win32.egg\jcc\python.py
import jcc.python # precompiled from
f:\Python26\lib\site-packages\jcc-2.1-py2.6
-win32.egg\jcc\python.pyc
# f:\Python26\lib\platform.pyc matches f:\Python26\lib\platform.py
import platform # precompiled from f:\Python26\lib\platform.pyc
# f:\Python26\lib\string.pyc matches f:\Python26\lib\string.py
import string # precompiled from f:\Python26\lib\string.pyc
import strop # builtin
# f:\Python26\lib\py_compile.pyc matches f:\Python26\lib\py_compile.py
import py_compile # precompiled from f:\Python26\lib\py_compile.pyc
import marshal # builtin
# f:\Python26\lib\traceback.pyc matches f:\Python26\lib\traceback.py
import traceback # precompiled from f:\Python26\lib\traceback.pyc
make: *** [compile] Error 255

Regards
Jose
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] sys.path.append

2008-12-18 Thread Andreas Kostyrka
Am Wed, 17 Dec 2008 11:17:14 -0500
schrieb "Kent Johnson" :

> On Wed, Dec 17, 2008 at 10:20 AM, ppaarrkk 
> wrote:
> >
> > I can do this :
> >
>  sys.path.append ( 'C:\dump1' )
> 
> Note you should use raw strings r'C:\dump1' or double backslash
> 'C:\\dump1' because the \ is a string escape character.
> 
> > but not :
> >
>  x = 'C:\dir1'
>  sys.path.append(x)
> 
> That should work fine (other than the single \). What happens when
> you try it?
> 
> > or :
> 
> ??
> 
> > but not :
> 
>  x = ['C:\dir1']
>  sys.path.append(x)
> 
> Here you are appending a list of strings to sys.path, that will not do
> what you want.

The correct thing to do if you want to add a list of paths to sys.path
(btw, that probably is not what you want in real life, but that's a
complete different question.), you should do 

sys.path.extend(x)

which is an efficient way to do

for i in x:
sys.path.append(i)

Or to visualize it with something simpler:

a = [1, 2, 3]
b = [4, 5, 6]
c = 7

a # [1,2,3]
a.append(c)
a # [1,2,3,7]
a.append(b)
a # [1,2,3,7,[4,5,6]]
a.extend(b)
a # [1,2,3,7,[4,5,6],4,5,6]

Basically append just appends it's parameter to the list, and if the
parameter happens to be a list, it appends the list as one item. Extend
on the other hand, appends all iterable items in the parameter to the
list.

Andreas
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to exit program without sys.exit()

2008-12-18 Thread bob gailer

David wrote:

Hi,
I make these silly programs to learn from examples I find on the list. 
I put a couple together just to practice. I have heard it is not a 
good idea to use sys.exit() but I can not figure out how to do it. 
Also any and all comments are welcome. Thanks


Others have made valuable comments. I add:

It is better to use a while loop rather than recursive function calls. 
The logic is a lot easier to follow, and you won't run into the 
recursive depth limit. Also restrict try blocks to just the statement 
likely to raise the error you  are expecting.


def getinfo():
   while True:
   answer = yesno("Enter y to continue, n to exit: y/n >> ")
   if answer == "y":
   getnumber()
   else:
  break

def getnumber():
   num = 0
   while True:
   try:
   num = int(raw_input("Enter a number between 25 and 75: "))
   except ValueError:
   print "Please Enter a number!"
   if 25 < num < 75:
   print "WOW you are smart ", sayit()
   break   

There are a lot more recursive calls that I will not try to "fix". I 
hope you get the idea.


In fact I'd start out with no functions at all - just one program in a 
loop. See what you can accomplish that way, then add functions only as 
needed.


#!/usr/bin/python
import sys
_count = 0

def getinfo():
answer = yesno("Enter y to continue, n to exit: y/n >> ")
if answer == "y":
getnumber()
else:
sys.exit()

def counter():
global _count
_count += 1
return _count

def yesno(question):
responce = None
while responce not in ("y", "n"):
responce = raw_input(question).lower()
return responce

def getnumber():
try:
num = int(raw_input("Enter a number between 25 and 75: "))
if 25 < num < 75:
print "WOW you are smart ", sayit()
except ValueError:
print "Please Enter a number!", getnumber()


def sayit():
print "Your total correct answers is", counter()
again()


def again():
onemore = raw_input("Again? y/n >> " )
if onemore.lower() == "y":
getnumber()
elif onemore.lower() == "n":
getinfo()
else:
sys.exit


def main():
getinfo()

if __name__=="__main__":
main()






--
Bob Gailer
Chapel Hill NC 
919-636-4239


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] PyLucene on Python 2.6

2008-12-18 Thread Chris Calloway

On 12/18/2008 11:03 AM, Jose Neto wrote:

Does anyone know if there is a win32 binary of PyLucene?


http://code.google.com/p/pylucene-win32-binary/downloads/list

--
Sincerely,

Chris Calloway
http://www.secoora.org
office: 332 Chapman Hall   phone: (919) 599-3530
mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor