Re: Aproximative string matching

2005-11-21 Thread Tim Heaney
"javuchi" <[EMAIL PROTECTED]> writes:

> I'm searching for a library which makes aproximative string matching,
> for example, searching in a dictionary the word "motorcycle", but
> returns similar strings like "motorcicle".
>
> Is there such a library?

I kind of like the one at 

  http://www.personal.psu.edu/staff/i/u/iua1/python/apse/

which you might use something like

  >>> import Apse
  >>> ap = Apse.Approx('motorcycle', edit=1)
  >>> ap.match(['motorcycle', 'motorcicle', 'motorscooter'])
  ['motorcycle', 'motorcicle']

That page mentions several alternatives, as well.

I hope this helps,

Tim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Native widgets for Python

2005-01-17 Thread Tim Heaney
Stephen Thorne <[EMAIL PROTECTED]> writes:
>
> there's someone writing 'dabo', which is apparently "wxpython but
> more python".

It looks like dabo uses, not replaces, wxPython

  http://dabodev.com/about
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Quote-aware string splitting

2005-04-25 Thread Tim Heaney
"J. W. McCall" <[EMAIL PROTECTED]> writes:
>
> I need to split a string as per string.strip(), but with a
> modification: I want it to recognize quoted strings and return them as
> one list item, regardless of any whitespace within the quoted string.
>
> For example, given the string:
>
> 'spam "the life of brian" 42'
>
> I'd want it to return:
>
> ['spam', 'the life of brian', '42']
>
> I see no standard library function to do this, so what would be the
> most simple way to achieve this?  This should be simple, but I must be
> tired as I'm not currently able to think of an elegant way to do this.
>
> Any ideas?

How about the csv module? It seems like it might be overkill, but it
does already handle that sort of quoting

  >>> import csv
  >>> csv.reader(['spam "the life of brian" 42'], delimiter=' ').next()
  ['spam', 'the life of brian', '42']

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I need some help

2006-07-11 Thread Tim Heaney
"dammix" <[EMAIL PROTECTED]> writes:
>
> I'm completely a newbye, I've started studying python since 3 weeks and
> now I need to write a small program that reads the id3 tags from the
> mp3 contained inside a cd, and then print them into a simple text file,
> I hope it's possible to do this, and I hope you can help me too.

Several different people have written modules to help you read (and
write) ID3 tags.

  http://id3-py.sourceforge.net/
  http://pyid3lib.sourceforge.net/
  http://news.tiker.net/software/tagpy

Pick one you like!

Tim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need a compelling argument to use Django instead of Rails

2006-07-24 Thread Tim Heaney
"Ray" <[EMAIL PROTECTED]> writes:
>
> Can you help me with my argument? 

Well, there is this study suggesting Django outperforms Ruby on Rails

  http://wiki.rubyonrails.com/rails/pages/Framework+Performance

> Meanwhile I think I'll give RoR a try as well.

Good idea. I think Ruby on Rails is terrific. Perhaps you'll think so
too. If not, at least you'll have a better idea of why you don't.

Tim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pasting numpy array into bigger array

2006-07-26 Thread Tim Heaney
"TG" <[EMAIL PROTECTED]> writes:
>
> let's say I have :
>
> from numpy import *
> x = identity(5)
> y = zeros((7,7))
>
> I want to paste x into y, starting at coordinates (1,1) in order to
> change y to something like this :
>
> 0 0 0 0 0 0 0
> 0 1 0 0 0 0 0
> 0 0 1 0 0 0 0
> 0 0 0 1 0 0 0
> 0 0 0 0 1 0 0
> 0 0 0 0 0 1 0
> 0 0 0 0 0 0 0
>
> how would you do that ?

You can use Python slice notation for each dimension

  y[1:6,1:6] = x

In general, I guess you want something like

  y[1:1+x.shape[0], 1:1+x.shape[1]] = x

or

  m, n = 1, 1
  s, t = x.shape
  y[m:m+s, n:n+t] = x

There is a mailing list for numpy

  https://lists.sourceforge.net/lists/listinfo/numpy-discussion

You might have more luck asking your question on there.

I think it's a shame there isn't any free documentation for numpy.

Tim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using SQLite3 with python 2.5 beta

2006-06-22 Thread Tim Heaney
Harold Shore <[EMAIL PROTECTED]> writes:

> From the release notes I read that
>
> "If you're compiling the Python source yourself, note that 
> the source tree doesn't include the SQLite code, only the 
> wrapper module. You'll need to have the SQLite libraries 
> and headers installed before compiling Python, and the build 
> process will compile the module when the necessary headers 
> are available."
>
> I do have SQLite3 installed on my system, but after doing a 
> plain vanilla compilation of the the 2.5 beta and trying 
> the SQLite code given in the release notes I get the message 
> "NameError: name 'sqlite3' is not defined".
>
> I wonder what the requirement means that "when the necessary 
> headers are available"?  How would they need to be made 
> available?
>
> Does anyone have any success with this?

It seems to work okay for me. 

  $ python2.5
  Python 2.5b1 (r25b1:47027, Jun 21 2006, 19:41:51) 
  [GCC 4.0.2 20051125 (Red Hat 4.0.2-8)] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import sqlite3
  >>> sqlite3.sqlite_version
  '3.1.2'

On my system, the header file is

  /usr/include/sqlite3.h

and the library file is

  /usr/lib64/libsqlite3.so

Those are both standard locations, so configure found them on its
own. If they are someplace unusual, you'll have to tell configure
where they are. It's possible you have SQLite3 installed, but you lack
the header. My system uses RPM, so I had to install both sqlite
and sqlite-devel before building Python. The sqlite-devel package
contains the header.

I hope this helps,

Tim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: matplotlib: TypeError: a float is required

2006-09-17 Thread Tim Heaney
Andi Clemens <[EMAIL PROTECTED]> writes:
>
> everytime I try to plot a bar with matplotlib I get the following
> error message:
> Traceback (most recent call last):
>   File "bar_stacked.py", line 13, in ?
> p1 = bar(ind, menMeans,   width, color='r', yerr=womenStd)
>   File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line
> 1641, in bar
> ret =  gca().bar(*args, **kwargs)
>   File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line
> 2485, in bar
> xerr = asarray([xerr]*nbars, Float)
>   File "/usr/lib/python2.4/site-packages/Numeric/Numeric.py", line
> 134, in asarray
> return multiarray.array(a, typecode, copy=0, savespace=savespace)
> TypeError: a float is required
>
>
> So I guess it has something to do with Numeric.py, but I can't figure
> out what the problem is. I tried to google but found nothing...
>
> Anyone has the same problem? I can plot all kinds of graphics with
> matplotlib, but the only type I'm interested in (bars) will not
> work.

It looks like it doesn't like not having xerr set. The documentation
says 

  xerr and yerr, if not None, will be used to generate errorbars on
  the bar chart

implying that if they are None (the default), then no errorbars will
be generated. But that doesn't seem to be the case. When I add an xerr
to both p1 and p2

  p1 = bar(ind, menMeans,   width, color='r', yerr=womenStd,
   xerr=zeros(N))
  p2 = bar(ind, womenMeans, width, color='y',
   bottom=menMeans, yerr=menStd, xerr=zeros(N))

I get the following bar chart

  http://img176.imageshack.us/my.php?image=imagenx6.png

with no errors.

Tim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: matplotlib: TypeError: a float is required

2006-09-17 Thread Tim Heaney
Andi Clemens <[EMAIL PROTECTED]> writes:
>
> THATS IT! Thanks!
> But why are all the examples wrong? Maybe they changed the API?

I think it's a bug. You should report it. Looking at

  http://matplotlib.sourceforge.net/faq.html#BUGREPORT

it seems you can use either the mailing list or sourceforge.

Tim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mp3 file length in time

2006-09-17 Thread Tim Heaney
"Jay" <[EMAIL PROTECTED]> writes:
> Paul Rubin wrote:
>> "Jay" <[EMAIL PROTECTED]> writes:
>> > In python, I know there are a couple of modules for getting id3 info,
>> > but what about the length of an mp3 file in time?  Is there a way to
>> > aquire that info?  Most of my MP3s don't have id3 tags.  I don't care
>> > for them.  But I need to use python to get their file lengths.  How?
>>
>> You have to count the frames.  Lots of mp3 files use variable bit
>> rates, so you can't go by the file length.
>
> Any tips on how to do that?

Just as there are modules to help you read ID3 tags, there are modules
to help you read the data. For example, MAD

  http://www.underbit.com/products/mad/

can be used from Python

  http://spacepants.org/src/pymad/

so that you could get the length of a track in milliseconds with
something like

  import mad
  print mad.MadFile("a_track.mp3").total_time()

There are other modules for other libraries as well.

I hope this helps,

Tim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get computer name

2006-04-29 Thread Tim Heaney
"pitarda" <[EMAIL PROTECTED]> writes:

> How do I get the computer name in python?

You can use the os module to get it from your environment.

  >>> import os
  >>> os.getenv('HOSTNAME')
  'calvin.watterson'

Depending on your operating system, the environment variable you need
might have a different name. For example, I think in Windows you
might try

  >>> os.getenv('COMPUTERNAME')

You can see all of the environment variables currently available with

  >>> os.environ

I hope this helps,

Tim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: graphs and charts

2006-05-23 Thread Tim Heaney
Grant Edwards <[EMAIL PROTECTED]> writes:
>
> On 2006-05-23, Yaron Butterfield <[EMAIL PROTECTED]> wrote:
>
>> What's the best way to on-the-fly graphs and charts using Python?  Or is 
>> Python not really the best way to do this?
>
> I like Gnuplot-py, but I've been a Gnuplot for 15+ years, so
> I'm biased.
>
> http://gnuplot-py.sourceforge.net/

You might also be interested in matplotlib

  http://matplotlib.sourceforge.net/

Here is an example of how I've used it

  http://cablespeed.com/~theaney/mat191/matplotlib.html

Tim
-- 
http://mail.python.org/mailman/listinfo/python-list