Re: [Tutor] Checking for Python version

2009-10-06 Thread Todd Zullinger
Christian Witts wrote:
 Your version will fail if the person is running Python 3.0, 3.1 up
 until the 3.3 series which is not good.  Neater looking (imo) code
 below.

 from sys import version_info, exit

 if version_info[0] == 1 or (version_info[0] == 2 and version_info[1]  4):
exit(Please upgrade to Python 2.4 or greater.)

This would fail on python  2.0, as version_info is not available.  So
you'd want to catch that, if you want to gracefully handle ancient
versions of python.  You could also just compare the version_info
tuple.

This is a bit ugly, but it works at least back to 1.5.2:

import sys

min_version = '2.4'
upgrade_msg = 'Please upgrade to Python %s or greater' % min_version

try:
min = tuple(map(int, min_version.split('.')))
ver = sys.version_info[:3]
if ver  min:
sys.exit(upgrade_msg)
except AttributeError:
sys.exit(upgrade_msg)

I don't have any python 3.x systems to test though.

-- 
ToddOpenPGP - KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~
Suppose I were a member of Congress, and suppose I were an idiot. But,
I repeat myself.
-- Mark Twain



pgpHQ1caffg6U.pgp
Description: PGP signature
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Please use plain text.

2009-04-07 Thread Todd Zullinger
bob gailer wrote:
 Thanks for the request for clarification. By plain text I mean:

 one font and one size that is readable. Most of the emails I
 receive appear the same in font and size, so whatever that is I
 like.

What's readable to you may not be readable to the next person though.
Most likely is that many of the posters here are not sending HTML
formatted mail, and thus their messages don't contain any font or size
information.  That's left up to your mail client and it will use
whatever defaults you have chosen.

 Use of very small or very large font sizes or various fonts / colors
 makes it hard for me to read.

 As I compose this in Thunderbird I see Body Text and Variable Width.
 But I do appreciate code in Fixed Width.

I believe the best answer to this issue is to not send HTML formatted
mail at all.  A truly plain text email contains no markup telling
anyone's email client what fonts to use.  That is something that
rightly belongs to each user, IMO.  Most of the mailing lists I
subscribe to frown upon HTML mail.

I don't worry about it a lot though, as I use a console based email
tool and any HTML messages that are sent are simply dumped as text for
me to read.  (I know many others that direct all HTML mail to
/dev/null.)

-- 
ToddOpenPGP - KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~
I am not young enough to know everything.
-- Oscar Wilde (1854-1900)



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


Re: [Tutor] Please use plain text.

2009-04-06 Thread Todd Zullinger
bob gailer wrote:
 Please use plain text rather than formatted text.

Was sending this request in an html formatted message intentional?  I
don't know about most folks, but I consider plain text to mean a
content-type of text/plain rather than text/html. :)

-- 
ToddOpenPGP - KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~
Unquestionably, there is progress.  The average American now pays out
twice as much in taxes as he formerly got in wages.
-- H. L. Mencken



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


Re: [Tutor] MP3Info class usage

2008-12-20 Thread Todd Zullinger
Terry Carroll wrote:
 On Fri, 19 Dec 2008, Terry Carroll wrote:
 It would be nice if Eyed3, which is not OS-specific, did not have
 such an OS-specific install process.

Perhaps.  But someone who cares about windows support would have to
submit patches.  I don't know if Travis uses windows or not.  I have
submitted a number of patches to eyeD3, but I don't use windows at all
myself.  I can't see spending any time to support a proprietary OS. :)

And, to be fair, the install process isn't really OS-specific.  It
works on a large number of operating systems -- just not on Windows.

 You know, I just reinstalled Eyed3, and compared the installed
 result to the six files distributed in the zipped tarfile, and
 they're identical except that one file is named __init__.py.in
 instead of __init__.py, and has two doc variables defined with
 templates.
 
 If you want to avoid having to install a Unix-like environment,
 I suggest you just
 
 1) unzip and untar the zipped tarfile,
 2) copy the eyeD3 directory from  eyeD3-0.6.16/src/ to Python's
 Lib/site-packages/ directory
 3) rename __init__.py.in to  __init__.py
 4) (probably cosmetic) in __init__.py, edit the lines:
 
   eyeD3Version = @PACKAGE_VERSION@;
   eyeD3Maintainer = @PACKAGE_BUGREPORT@;
 
 to:
 
   eyeD3Version = 0.6.16;
   eyeD3Maintainer = Travis Shirk tra...@pobox.com;
 
 Someone else will now explain why this is a terrible idea.

I don't think it is a bad idea at all.  I was going to suggest
something similar.  If you do that, you should be able to copy the
src/eyeD3 directory somewhere in your PYTHONPATH and use it just fine.

-- 
ToddOpenPGP - KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~
I like this 'God'; he's so deliciously evil.
-- Stewie Griffin



pgpzJ8ONmIkTV.pgp
Description: PGP signature
___
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


Re: [Tutor] MP3Info class usage

2008-12-15 Thread Todd Zullinger
Gareth at Serif wrote:
 Okay, I've moved over to eyeD3.py... fif nothing else, the
 documentation for it's usage is far superior.
 
 However, I can't get anything to run.  The help gives examples of
 some simple tasks, but as soon as I 'import eyeD3', not even calling
 any functions within it, I start getting errors such as:
 
 In eyeD3.py, the 'from eyeD3.tag import *;' line (and similar)
 didn't work until I removed the 'eyeD3.' part and just imported
 'tag'.

How have you installed eyeD3?  Perhaps there's something wrong with
the installation.  Certainly, 'import eyeD3' should not create any
errors.

 Then in tag.py, some of the class defs complained about undefined
 variables, for example 'def link(self, f, v = ID3_ANY_VERSION)'
 needed to have quotes around 'ID3_ANY_VERSION'.

That's not what you want to do.  ID3_ANY_VERSION is defined in
eyeD3/__init__.py.  If you quote it, you're breaking it.

 I'm baffled that I'm having to jump through so many hoops because I
 imported eyeD3... is this typical?  What have I done wrong?

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

-- 
ToddOpenPGP - KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~
Don't look for me in daylight where robots all assemble.  You'll find
me in my dark world, in my smoke-filled temple.



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


Re: [Tutor] MP3Info class usage

2008-12-10 Thread Todd Zullinger
Gareth at Serif wrote:
 Has anyone any better suggestions for retreiving ID3 tags from an
 MP3 file using python?

I'd recommend eyeD3¹ and/or mutagen² for tag reading.  Both are pretty
easy to use.

¹ http://eyed3.nicfit.net/
² http://code.google.com/p/quodlibet/wiki/Development/Mutagen

-- 
ToddOpenPGP - KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~
A paranoid is someone who knows a little of what's going on.
-- William S. Burroughs



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


Re: [Tutor] Python open of c:\ path Problem

2008-08-23 Thread Todd Zullinger
Kent Johnson wrote:
 The \ character is a special 'escape' character that is used to insert
 non-printing characters into a string. \t represents a single tab
 character, not the two characters \ and t.
 
 To put an actual backslash into a string, you can either double it:
 'c:\\tmp\\junkpythonfile'
 or prefix the string with r to make a 'raw' string, which doesn't have
 any special meaning for \:
 r'c:\tmp\junkpythonfile'

While I don't use Windows myself, I'm believe that you can also use
forward-slashes as the path separator, e.g.: 

junkfile = open('c:/tmp/junkpythonfile','w')

(Pardon me if I'm completely wrong.)

-- 
ToddOpenPGP - KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~
To grasp the true meaning of socialism, imagine a world where
everything is designed by the post office, even the sleaze.
-- P.J. O'Rourke



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