Re: Reusing object methods?

2005-04-30 Thread Axel Straschil
Hello!

Why not:

 class A:
  def a_lengthy_method(self, params):
   # do some work depending only on data in self and params

 class B(A): pass

?

Lg,
AXEL.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Challenge ahead [NEW] for riddle lovers

2005-04-30 Thread Mark T

pythonchallenge [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 For the riddles' lovers among you, you are most invited to take part
 in the Python Challenge, the first python programming riddle on the net.

 You are invited to take part in it at:
 http://www.pythonchallenge.com

Excellent puzzles!  For others like this see http://www.osix.net.  I love 
these things :^)


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


Re: module exports a property instead of a class -- Evil?

2005-04-30 Thread Bengt Richter
On 29 Apr 2005 11:02:59 -0700, gry@ll.mit.edu wrote:

I often find myself wanting an instance attribute that can take on only

without checking deeply, are you not sharing state among all instance?
See following for an alternative way, allowing initialization by a
first assignment of a name sequence, followed by normal operation on
a per instance basis.

a few fixed symbolic values. (This is less functionality than an enum,
since there are no *numbers* associated with the values).  I do want
the thing to fiercely object to assignments or comparisons with
inappropriate values.  My implementation below gets me:

.import mode
.class C(object):
.   status = mode.Mode('started', 'done', 'on-hold')
.
.c=C()
.c.status = 'started'
.c.status = 'stated': #Exception raised
.if c.status == 'done': something
.if c.status == 'stated': #Exception raised
.if c.status.done: something  #simpler and clearer than string compare
.if c.status  'done': something # Mode arg strings define ordering

I would appreciate comments on the overall scheme, as well as about the
somewhat sneaky (I think) exporting of a property-factory instead of a
class.  My intent is to provide a simple clear interface to the client
class (C above), but I don't want to do something *too* fragile or
confusing...
(I'd also welcome a better name than Mode...)

-- mode.py --
class _Mode:  #internal use only, not exported.
def __init__(self, *vals):
if [v for v in vals if not isinstance(v, str)]:
raise ValueError, 'Mode values must be strings'
else:
self.values = list(vals)

def set(self, val):
if val not in self.values:
raise ValueError, 'bad value for Mode: %s' % val
else:
self.state = val

def __cmp__(self, other):
if other in self.values:
return cmp(self.values.index(self.state),
self.values.index(other))
else:
raise ValueError, 'bad value for Mode comparison'

def __getattr__(self, name):
if name in self.values:
return self.state == name
else:
raise AttributeError, 'no such attribute: %s' % name


def Mode(*vals): # *function* returning a *property*, not a class.
m = _Mode(*vals)
def _insert_mode_get(self):
return m
def _insert_mode_set(self, val):
m.set(val)
return property(_insert_mode_get, _insert_mode_set)
---

Not tested beyond what you see ;-)

 state.py 
--
# set up to validate state name strings
namerefcode = compile('a','','eval').co_code
non_name_chars = []
for c in (chr(i) for i in xrange(256)):
try:
if compile(c, '', 'eval').co_code != namerefcode:
non_name_chars.append(c)
except (SyntaxError, TypeError):
non_name_chars.append(c)
non_name_chars = ''.join(non_name_chars)
idem = ''.join([chr(i) for i in xrange(256)])

class Status(object):
def __get__(self, inst, cls=None):
if inst is None: return self
if not '_state' in inst.__dict__:
raise ValueError, 'Uninitialized instance state names'
return inst._state
def __set__(self, inst, value):
if not hasattr(inst, '_state'): inst._state = self.State(*value)
else: inst._state._setv(value)

class State(object):
def __init__(self, *names):
for s in names:
   if s[:1].isdigit() or s!= s.translate(idem, non_name_chars):
raise ValueError, '%r is not a valid name'%s
self._names = list(names)
self._value = names[0]
def _name_ck(self, name):
if name not in self._names:
raise AttributeError(
'Legal names are: %s -- not %r' % (', '.join(map(repr, 
self._names)), name)) 
def __getattr__(self, attr):
if attr.startswith('_'):
return object.__getattribute__(self, attr)
self._name_ck(attr)
return self._value == attr
def _setv(self, value):
self._name_ck(value)
self._value = value
def __cmp__(self, other):
self._name_ck(other)
return cmp(self._names.index(self._value), self._names.index(other))
def __str__(self):
return self._value

def test():
class C(object):
status = Status()
instances = [C(), C(), C()]
nameslist = map(str.split, ['started done on_hold', 'one two three', 'UNK 
running stopped'])
for i, (inst, names) in enumerate(zip(instances, nameslist)):
inst.status = names
inst.status = names[i]
print 'Instance %s names: %r' %(i, inst.status._names)
for i, inst in enumerate(instances):
print i, 'names:',inst.status._names

Re: Python Challenge ahead [NEW] for riddle lovers

2005-04-30 Thread Tim Peters
[Mike Rovner]
 3 IS wrong because if you use any not BIG letter after bodyguard on both
 sides, you get extra 'eCQQmSXK\n' which slow me down for 5 minutes.

Get rid of the newlines first.

On level 7, I'm not sure whether there's something more to do, or
whether I'm looking at a bug in how IE displays .png files.  Using
Windows is good practice in solving maddening riddles every day
wink.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Micro-PEP: str.translate(None) to mean identity translation

2005-04-30 Thread Bengt Richter
On 29 Apr 2005 21:27:18 -0700, M.E.Farmer [EMAIL PROTECTED] wrote:

Bengt Richter wrote:
 Just thought None as the first argument would be both handy and
mnemonic,
 signifying no translation, but allowing easy expression of deleting
characters,
 e.g.,

s = s.translate(None, 'badcharshere')

 Regards,
 Bengt Richter

What's wrong with :

s = s.replace('badchars', )
That's not what translate does with the badchars, which is a set of
characters, each and all of whose instances in the source string
will be deleted from the source string. Something like
   for c in badchars:
  s = s.replace(c,'')

It seems obvious to replace a char ( to me anyway ) with a blank
string, rather than to 'translate' it to None.
I am sure you have a reason what am I missing ?
M.E.Farmer
The first argument is normally a 256-character string that serves as a table
for converting source characters to destination, so s.translate(table, bad)
does something like
s = ''.join([table[ord(c)] for c in s if c not in bad]

  help(str.translate)
 Help on method_descriptor:

 translate(...)
 S.translate(table [,deletechars]) - string
 Return a copy of the string S, where all characters occurring
 in the optional argument deletechars are removed, and the
 remaining characters have been mapped through the given
 translation table, which must be a string of length 256.

So just to delete, you wind up constructinf a table argument that is just 1:1 
as in

  'abcde'.translate(''.join([chr(i) for i in xrange(256)]), 'tbd')
 'ace'

and the answer to the question, What translation does such a table do? is 
None ;-)

Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [wxPython] Many wxPanel forms in 1 wxFrame

2005-04-30 Thread Fabio Pliger

CYBER [EMAIL PROTECTED] ha scritto nel messaggio
news:[EMAIL PROTECTED]
 Is this possible to create 1 wxFrame and
 register more than 1 wxPanel in it.
 And select the one you want to show at the moment ?

 I'm trying to implement a multistep wizard under wxPython.
 I need to be able to hide and show windows inside my
 frame.

 Help :)


Take a look at the wx documentation about wizards... There is a good example
about doing wizards!

F.P.


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


Re: Micro-PEP: str.translate(None) to mean identity translation

2005-04-30 Thread Peter Otten
M.E.Farmer wrote:

 Bengt Richter wrote:
 Just thought None as the first argument would be both handy and
 mnemonic,
 signifying no translation, but allowing easy expression of deleting
 characters,
 e.g.,

s = s.translate(None, 'badcharshere')

 Regards,
 Bengt Richter
 
 What's wrong with :
 
 s = s.replace('badchars', )
 
 It seems obvious to replace a char ( to me anyway ) with a blank
 string, rather than to 'translate' it to None.
 I am sure you have a reason what am I missing ?
 M.E.Farmer

 s = NHoBwA RyAoSuB AsAeHeH AiBtH,A CnRoAwD HyBoAuC HdRoCnH'AtB
 s.translate(None, BADCHARS)
Now you see it, now you don't
 s.replace(BADCHARS, )
NHoBwA RyAoSuB AsAeHeH AiBtH,A CnRoAwD HyBoAuC HdRoCnH'AtB

i. e. you have to replace() for every char in BADCHARS:

 reduce(lambda x, y: x.replace(y, ), BADCHARS, s)
Now you see it, now you don't


+1, btw.

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


Re: Python Challenge ahead [NEW] for riddle lovers

2005-04-30 Thread Mike Rovner
Tim Peters wrote:
[Mike Rovner]
3 IS wrong because if you use any not BIG letter after bodyguard on both
sides, you get extra 'eCQQmSXK\n' which slow me down for 5 minutes.

Get rid of the newlines first.
On level 7, I'm not sure whether there's something more to do, or
whether I'm looking at a bug in how IE displays .png files.  Using
Windows is good practice in solving maddening riddles every day
wink.
There is! That black and white line contains the message.
Mike
--
http://mail.python.org/mailman/listinfo/python-list


Numeric/Numarray equivalent to zip ?

2005-04-30 Thread George Sakkis
What's the fastest and most elegant equivalent of zip() in
Numeric/Numarray between two equally sized 1D arrays ? That is, how to
combine two (N,)-shaped arrays to one (N,2) (or (2,N)) shaped ? I
expect the fastest and the most elegant idiom to be identical, as it is
usually the case in this excellent library, but if not, both would be
useful to know. Thanks,

George

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


Re: Micro-PEP: str.translate(None) to mean identity translation

2005-04-30 Thread Raymond Hettinger
[Bengt Richter]
 Just thought None as the first argument would be both handy and mnemonic,
 signifying no translation, but allowing easy expression of deleting
characters,
 e.g.,

s = s.translate(None, 'badcharshere')

Log a feature request on SF and assignment to me.
I'll put this in for you.


Raymond Hettinger


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


Re: Python Challenge ahead [NEW] for riddle lovers

2005-04-30 Thread Leif K-Brooks
pythonchallenge wrote:
For the riddles' lovers among you, you are most invited to take part
in the Python Challenge, the first python programming riddle on the net.
You are invited to take part in it at:
http://www.pythonchallenge.com
Very neat, I love things like this. Level 5 is maddening. Keep up the 
good work.
--
http://mail.python.org/mailman/listinfo/python-list


Library Naming Conventions.

2005-04-30 Thread chris . lyon
Is there any specific naming convention as to capitalisation?

Cookies versus cgi for example.

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


Writing to log file when script is killed

2005-04-30 Thread Harlin Seritt
I am looking for a way for my script to write to a log file saying
something like this:

I was killed at time.asctime()

I would like to be able to do this if/when the script is killed by
means rather than my own. How in the world would I accomplish this?

Thanks,

Harlin

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


Re: Sorting an Edge List

2005-04-30 Thread Bengt Richter
On Fri, 29 Apr 2005 23:37:39 -0400, Anthony D'Agostino [EMAIL PROTECTED] 
wrote:

I found my old bubble sort solution:


def esort(edges):
while 1:
swaps = 0
for j in range(len(edges)-2):
if edges[j][1] != edges[j+1][0]:
edges[j+1],edges[j+2] = edges[j+2],edges[j+1] # swap
swaps = 1
if swaps == 0: break
return edges

print esort([('A','Y'), ('J','A'), ('Y','J')])
print esort([(5,0), (6, -12), (0,6), (-12, 3)])


The list can be any length and there will always be multiple valid 
solutions, depending on which edge you start with. I'm using this to sort 
edges for mesh subdivision. I just thought there might be a more elegant way 
to write it. 

This is not tested beyond what you see, but it might give some ideas for
what you want to do. I finds separate sequences if you combine the above into
one, e.g.,

 dagostinoedges.py 
---
# I need to sort this list:
# [('A','Y'), ('J','A'), ('Y','J')] like this:
# [('A','Y'), ('Y','J'), ('J','A')].
# 
# Note how the Ys and Js are together. All I need is for the second element of 
# one tuple to equal the first element of the next tuple. Another valid 
# solution is [('J','A'), ('A','Y'), ('Y','J')].
#
import itertools
def connect(edges):
nodes = dict([(e[0], e) for e in edges])
heads = set([e[0] for e in edges])
tails = set([e[1] for e in edges])
starts = heads - tails
out = []
seen = set()
for h in itertools.chain(starts, heads):
curr = nodes[h]
sub = []
while curr not in seen:
sub.append(curr)
seen.add(curr)
curr = nodes.get(curr[1])
if curr is None: break
if sub: out.append(sub)
return out

if __name__ == '__main__':
edges = set([('A','Y'), ('J','A'), ('Y','J'),
(5,0), (6, -12), (0,6), (-12, 3),
('all', 'alone')])
for sub in connect(edges): print sub

Result:

[ 2:54] C:\pywk\clppy24 dagostinoedges.py
[('all', 'alone')]
[(5, 0), (0, 6), (6, -12), (-12, 3)]
[('A', 'Y'), ('Y', 'J'), ('J', 'A')]


Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Challenge ahead [NEW] for riddle lovers

2005-04-30 Thread Dan Bishop
darren kirby wrote:
 quoth the Shane Hathaway:
  pythonchallenge wrote:
   For the riddles' lovers among you, you are most invited to take
part
   in the Python Challenge, the first python programming riddle on
the net.
  
   You are invited to take part in it at:
   http://www.pythonchallenge.com
 
  That was pretty fun.  Good for a Friday.  Too bad it comes to an
abrupt
  temporary end.
 
  Shane
 
  P.S. I hope I didn't hammer your server on step 3.  I was missing
the
  mark. :-)

 You're not the only one. This is where I am currently stuck. It's
starting to
 hurt my head.

 There are 478 results in the form *BBBsBBB* but the thing said
'exactly'
 right, well there are 10 results in the form *sBBBsBBBs*
 None of them seem to work...

The same thing happened to me, but then I figured it out.

Hint: Print all 10 results in a column.

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


How to run a program?

2005-04-30 Thread Sara Khalatbari
I'm writing a code that checks the header of .po file
for syntax errors. I want this program to run
msgfmt.py on the .po file first  then the rest.

How can you write a code that runs another program in
itself?

:),
Sara

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best way to parse file into db-type layout?

2005-04-30 Thread Michael Hoffman
John Machin wrote:
I beg your pardon. How does: Your point addresses the letter rather
than the spirit of the 'law' sound?
Sure, thanks.
Real-world data is not text.
A lot of real-world data is. For example, almost all of the data I deal with
is text.
That's nice. Well I agree with you, if the OP is concerned about embedded
CRs, LFs and ^Zs in his data (and he is using Windows in the latter case),
then he *definitely* shouldn't use fileinput.
And if the OP is naive enough not to be concerned, then it's OK, is
it?
It simply isn't a problem in some real-world problem domains. And if there
are control characters the OP didn't expect in the input, and csv loads it
without complaint, I would say that he is likely to have other problems once
he's processing it.
Except, perhaps, the reason stated in fileinput.py itself: 


Performance: this module is unfortunately one of the slower ways of
processing large numbers of input lines.

Fair enough, although Python is full of useful things that save the
programmer's time at the expense of that of the CPU, and this is
frequently considered a Good Thing.
Let me ask you this, are you simply opposed to something like fileinput
in principle or is it only because of (1) no binary mode, and (2) poor
performance? Because those are both things that could be fixed. I think
fileinput is so useful that I'm willing to spend some time working on it
when I have some.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list


date to digit

2005-04-30 Thread Sara Khalatbari
Is there a program in python that inputs a date  a
time, for example:  “2005-04-17 04:20+”. And
returns a digit, for example: “3501” instead? 

and if there is such program or built-in function, how
can I run it inside a code?

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: date to digit

2005-04-30 Thread [EMAIL PROTECTED]
try time.strptime() , and then time.time() - see documentation
(http://docs.python.org/lib/module-time.html)

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


Re: How to run a program?

2005-04-30 Thread [EMAIL PROTECTED]
please read the documentation for subprocess,
http://docs.python.org/lib/node230.html

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


Re: Library Naming Conventions.

2005-04-30 Thread [EMAIL PROTECTED]
see http://www.python.org/peps/pep-0008.html for naming conventions and
other style issues

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


Re: Best way to parse file into db-type layout?

2005-04-30 Thread John Machin
On Sat, 30 Apr 2005 11:35:05 +0100, Michael Hoffman
[EMAIL PROTECTED] wrote:

John Machin wrote:

 Real-world data is not text.

A lot of real-world data is. For example, almost all of the data I deal with
is text.

OK, depends on one's definitions of data and text. In the domain
of commercial database applications, there is what's loosely called
text: entity names, and addresses, and product descriptions, and the
dreaded free-text note columns -- all of which (not just the
notes) one can end up parsing trying to extract extraneous data
that's been dumped in there ... sigh ...


That's nice. Well I agree with you, if the OP is concerned about embedded
CRs, LFs and ^Zs in his data (and he is using Windows in the latter case),
then he *definitely* shouldn't use fileinput.
 
 And if the OP is naive enough not to be concerned, then it's OK, is
 it?

It simply isn't a problem in some real-world problem domains. And if there
are control characters the OP didn't expect in the input, and csv loads it
without complaint, I would say that he is likely to have other problems once
he's processing it.

Presuming for the moment that the reason for csv not complaining is
that the data meets the csv non-spec and that the csv module is
checking that: then at least he's got his data in the structural
format he's expecting; if he doesn't do any/enough validation on the
data, we can't save him from that.


 Except, perhaps, the reason stated in fileinput.py itself: 
 
 
 Performance: this module is unfortunately one of the slower ways of
 processing large numbers of input lines.
 

Fair enough, although Python is full of useful things that save the
programmer's time at the expense of that of the CPU, and this is
frequently considered a Good Thing.

Let me ask you this, are you simply opposed to something like fileinput
in principle or is it only because of (1) no binary mode, and (2) poor
performance? Because those are both things that could be fixed. I think
fileinput is so useful that I'm willing to spend some time working on it
when I have some.

I wouldn't use fileinput for a commercial data processing exercise,
because it's slow, and (if it involved using the Python csv module) it
opens the files in text mode, and because in such exercises I don't
often need to process multiple files as though they were one file.

When I am interested in multiple files -- more likely a script that
scans source files -- even though I wouldn't care about the speed nor
the binary mode, I usually do something like:

for pattern in args: # args from an optparse parser
for filename in glob.glob(pattern):
for line in open(filename):

There is also an on principle element to it as well -- with
fileinput one has to use the awkish methods like filelineno() and
nextfile(); strikes me as a tricksy and inverted way of doing things.

Cheers,
John

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


Re: Writing to log file when script is killed

2005-04-30 Thread [EMAIL PROTECTED]
If you run on unix you can use the signal module to intercept a kill -
see http://docs.python.org/lib/node368.html for a quick example

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


Re: how can I sort a bunch of lists over multiple fields?

2005-04-30 Thread El Pitonero
googleboy wrote:

 I am reading in a csv file that documents a bunch of different info
on
 about 200 books, such as title, author, publisher, isbn, date and
 several other bits of info too.
 ...
 I really want to be able to sort the list of books based on other
 criterium, and even multiple criteria (such as by author, and then by
 date.)

import string

input = open(r'c:\books.csv', 'r')
records = input.readlines()
input.close()

# assuming first line contains headers
headers = records.pop(0)
records = [x.strip().split(',') for x in records]

# header order
p_headers ='(title, author, publisher, isbn, date, other)'
p_sorts = '(author, title, date, publisher, other, isbn)'

temp_records = []
for r in records:
exec '%(p_headers)s = r' % vars()
exec 't = %(p_sorts)s' % vars()
temp_records.append(t)

temp_records.sort()

sorted_records = []
for t in temp_records:
exec '%(p_sorts)s = t' % vars()
exec 'r = %(p_headers)s' % vars()
sorted_records.append(r)

lines = [headers] + [','.join(x)+'\n' for x in sorted_records]
output = open(r'c:\output.csv', 'w')
output.writelines(lines) 
output.close()

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


Re: Best way to parse file into db-type layout?

2005-04-30 Thread Steve Holden
John Machin wrote:
[...]
I wouldn't use fileinput for a commercial data processing exercise,
because it's slow, and (if it involved using the Python csv module) it
opens the files in text mode, and because in such exercises I don't
often need to process multiple files as though they were one file.
If the process runs once a month, and take ten minutes to process the 
required data, isn't that fast enough. It's unwise to act as though 
slow is an absolute term.

When I am interested in multiple files -- more likely a script that
scans source files -- even though I wouldn't care about the speed nor
the binary mode, I usually do something like:
for pattern in args: # args from an optparse parser
for filename in glob.glob(pattern):
for line in open(filename):
There is also an on principle element to it as well -- with
fileinput one has to use the awkish methods like filelineno() and
nextfile(); strikes me as a tricksy and inverted way of doing things.
But if it happens to be convenient for the task at hand why deny the OP 
the use of a tool that can solve a problem? We shouldn't be so purist 
that we create extra (and unnecessary) work :-), and principles should 
be tempered with pragmatism in the real world.

regards
 Steve
--
Steve Holden+1 703 861 4237  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fwd: how to find the drive in python/cygwin?

2005-04-30 Thread Jason Tishler
Ivan,

On Tue, Apr 26, 2005 at 07:02:48PM -0600, Ivan Van Laningham wrote:
 Use win32api to find drives:
 
 cut here
 #!/usr/bin/python
 # -*- coding: utf-8 -*-
 
 import os
 import os.path
 import win32api
 [snip]

AFAICT, the win32api module has not been ported to Cygwin Python.

Jason

-- 
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fwd: how to find the drive in python/cygwin?

2005-04-30 Thread Ivan Van Laningham
Hi All--

Jason Tishler wrote:
 
 Ivan,
 
 On Tue, Apr 26, 2005 at 07:02:48PM -0600, Ivan Van Laningham wrote:
  Use win32api to find drives:
 
  cut here
  #!/usr/bin/python
  # -*- coding: utf-8 -*-
 
  import os
  import os.path
  import win32api
  [snip]
 
 AFAICT, the win32api module has not been ported to Cygwin Python.
 

I'm not running Cygwin, but Uwin.  I installed regular Python:


Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on
win32
Type help, copyright, credits or license for more information.
 ^Z  


with the win32api that matched.  I have no trouble running it.  Is there
some reason to prefer a Python compiled by the Cygwin tools?

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can .py be complied?

2005-04-30 Thread Steve Holden
John J. Lee wrote:
Steve Holden [EMAIL PROTECTED] writes:
[...]
There's nothing wrong with open source projects catering to a market,
and there's nothing wrong with running open source software on a
proprietary operating system. To behave otherwise might reduce the
growth opportunities for Python and its community.
no-zealotry-please-ly y'rs  - steve
[...]
I'm hesitant to label everybody who disagrees with you (and me) on
that a zealot.  Though I tend to take the same side you do, I'm not
entirely sure it's not just laziness on my part that I think that way.
Seems to me that holding opinions such as it's a bad thing to support
open source software on closed source systems, and you should not do
it, for the common good is far from crazy, even though I don't
currently happen to hold that view.
Well, we appear to agree. Please note I wasn't labelling anyone a 
zealot, simply implying that I didn't want the discussion to descend to 
blind repetitions of principle with no supporting arguments.

I have no problem with others taking a different view from mine on this 
issue, though I reserve the right to disagree with them. My own view is 
that open source (Python included) wouldn't be anywhere near as advanced 
and popular as it is if it hadn't been ported to the majority platform, 
and that this actually positions it better for eventual world domination 
:-). There's a reason Microsoft are fighting Linux with FUD.

Let's also not forget that at PyCon, (I am told) when Jim Hugunin asked 
for a show of hands as to who principally developed for Windows 
platforms, *Guido* raised his hand.

regards
 Steve
--
Steve Holden+1 703 861 4237  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Best way to parse file into db-type layout?

2005-04-30 Thread Michael Hoffman
John Machin wrote:
That's nice. Well I agree with you, if the OP is concerned about embedded
CRs, LFs and ^Zs in his data (and he is using Windows in the latter case),
then he *definitely* shouldn't use fileinput.
And if the OP is naive enough not to be concerned, then it's OK, is
it?
It simply isn't a problem in some real-world problem domains. And if there
are control characters the OP didn't expect in the input, and csv loads it
without complaint, I would say that he is likely to have other problems once
he's processing it.
Presuming for the moment that the reason for csv not complaining is
that the data meets the csv non-spec and that the csv module is
checking that: then at least he's got his data in the structural
format he's expecting; if he doesn't do any/enough validation on the
data, we can't save him from that.
What if the input is UTF-16? Your solution won't work for that. And there
are certainly UTF-16 CSV files out in the wild.
I think at some point you have to decide that certain kinds of data
are not sensible input to your program, and that the extra hassle in
programming around them is not worth the benefit.
There is also an on principle element to it as well -- with
fileinput one has to use the awkish methods like filelineno() and
nextfile(); strikes me as a tricksy and inverted way of doing things.
Yes, indeed. I never use those, and would probably do something akin to what
you are suggesting rather than doing so. I simply enjoy the no-hassle
simplicity of fileinput.input() rather than worrying about whether my data
will be piped in, or in file(s) specified on the command line.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list


Re: interactive web graphics

2005-04-30 Thread Diez B. Roggisch
 
 I'm surprised that Trolltech is allowing Microsoft to get their product
 for free. 

If the free version is used, it's license is GPL. So for commercial apps,
you still need a license (for linux as well)

 I have played with Qt3 somewhat; not sure how their widgetry 
 compares with GTK+, as far as looks are concerned, but much prefer C++.
 Disappointingly, the openGL module for QT failed to work when I ran the
 examples.  I hear VTK is nice. Just checked Google and, sure enough,
 there's a pyVTK.

Dunno why that happened - Qt certainly has gl support.

-- 
Regards,

Diez B. Roggisch
-- 
http://mail.python.org/mailman/listinfo/python-list


Tkinter app=App(root) problem

2005-04-30 Thread snoylr
This is my first day working with Tkinter.  I'm using python2.3 on
WindowsXP. I found this program and entered it.

from Tkinter import *

class App:
def _init_(self,master):
frame = Frame(master)
frame.pack()

self.button = Button(frame, text = Quit, fg = red, command
=frame.quit)
self.button.pack(side=LEFT)

self.hi_there = Button(frame, text = Hello, command =
self.say_hi)
self.hi_there.pack(side=LEFT)

def say_hi(self):
print hi there, everyone!

root = Tk()
app = App(root)
root.mainloop()

When I run the code in IDLE I get the initial frame but no buttons with
the following error:

Traceback (most recent call last):
  File C:\Documents and Settings\INTERNET\Desktop\hello2.py, line 18,
in ?
app = App(root)
TypeError: this constructor takes no arguments

I have also tried to save the program as with a pyw extension.  Nothing
happens when I try to run it with that extension.

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


Re: Python Challenge ahead [NEW] for riddle lovers

2005-04-30 Thread Roel Schroeven
Mike Rovner wrote:
David Murmann wrote:
Shane Hathaway wrote:

That was pretty fun.  Good for a Friday.  Too bad it comes to an abrupt
temporary end.
Shane
P.S. I hope I didn't hammer your server on step 3.  I was missing the
mark. :-)

Interestingly step 3 is actually wrong... there is an additional 
solution, which looks like cqqmsxk. (I don't think that spoils the fun :))
3 IS wrong because if you use any not BIG letter after bodyguard on both 
sides, you get extra 'eCQQmSXK\n' which slow me down for 5 minutes.
Strange: I don't find eCQQmSXK\n, only eCQQmSxK\n. I guess the data has 
been modified in order to get that potential confusion out of the way.

--
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton
Roel Schroeven
--
http://mail.python.org/mailman/listinfo/python-list


Re: date to digit

2005-04-30 Thread Fabio Pliger

Sara Khalatbari [EMAIL PROTECTED] ha scritto nel messaggio
news:[EMAIL PROTECTED]
 Is there a program in python that inputs a date  a
 time, for example:  2005-04-17 04:20+. And
 returns a digit, for example: 3501 instead?

 and if there is such program or built-in function, how
 can I run it inside a code?

Here you go:

 a = time.strptime(2005-04-17 04:20, %Y-%m-%d %H:%M)
 time.mktime(a)
1113704400.0

F.P.




 __
 Do You Yahoo!?
 Tired of spam?  Yahoo! Mail has the best spam protection around
 http://mail.yahoo.com




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


Re: Fwd: how to find the drive in python/cygwin?

2005-04-30 Thread Jason Tishler
Ivan,

On Sat, Apr 30, 2005 at 07:29:32AM -0600, Ivan Van Laningham wrote:
 Jason Tishler wrote:
  On Tue, Apr 26, 2005 at 07:02:48PM -0600, Ivan Van Laningham wrote:
   Use win32api to find drives:
  
   cut here
   #!/usr/bin/python
   # -*- coding: utf-8 -*-
  
   import os
   import os.path
   import win32api
   [snip]
  
  AFAICT, the win32api module has not been ported to Cygwin Python.
  
 
 I'm not running Cygwin, but Uwin.  I installed regular Python:
 
 Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on
 win32
 Type help, copyright, credits or license for more information.
  ^Z  
 
 with the win32api that matched.  I have no trouble running it.  Is
 there some reason to prefer a Python compiled by the Cygwin tools?

It depends on your needs.  If you are looking for a more Unix-like
Python, then the Cygwin version would probably be better.  If
Windows-like, then the native Windows version would probably be better.

The OP seem to be interested in a Cygwin Python solution -- not a
Windows one.  So, I was just clarifying that the win32api module is not
supported under Cygwin Python.

Jason

-- 
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Embedding Flash OCX object

2005-04-30 Thread Kartic
The Great 'Exeem' uttered these words on 4/29/2005 2:11 PM:
Hi All,
I'm trying to find a way to embbed the flash.ocx object in a Windows Python 
application,
I've successfully integrated a flash object with the ocx already installed 
on the system using the Activex Wrapper,
but i would like to embbed it inside my application in order to distribute 
my application without the need for the user to install the flash player.
It would like also to embbed the flash animation inside my application 
without loading it .. i mean directly from the memory.

I've seen that it was possible in C++ or in Delphi, using the 
http://www.flashplayercontrol.com/ .. but don't know how to make it in 
Python.

Any ideas are welcome
Dan. 

Dan,
wxPython has the capability to embed Flash inside a wxPython panel. It 
uses Macromedia's Flash ocx that is installed when installing flash 
player on Windows. And it is pretty nifty; take a look at the demo.

From your message, it is appears you are using win32gui functions but I 
am unable to tell. So using Win32, I do not know how you can do what you 
are trying. But yeah, look into wxPython!

Please let me know if you need more assistance.
Thanks,
-Kartic
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fwd: how to find the drive in python/cygwin?

2005-04-30 Thread Ivan Van Laningham
Hi All--

Jason Tishler wrote:
 
 Ivan,
 
 It depends on your needs.  If you are looking for a more Unix-like
 Python, then the Cygwin version would probably be better.  If
 Windows-like, then the native Windows version would probably be better.
 
 The OP seem to be interested in a Cygwin Python solution -- not a
 Windows one.  So, I was just clarifying that the win32api module is not
 supported under Cygwin Python.
 

Could you clarify?  I always thought that the only thing really
different were the default path assumptions--/ instead of \, and so
on--rather than anything substantive.  I try to use os.path.sep() and
os.path.join(), etc.

What else could bite me?  ;-)

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Killing process

2005-04-30 Thread Peter Hansen
Harlin Seritt wrote:
I think I need something besides TerminateProcess(). Is there anyway
possible to terminate a process by just passing a string value to the
function? Honestly, I am not interesting in terminating a process by
its handle.
This is a bizarre request.  Why can't you just call int() as you did in 
your example to turn the string into a number?  And if you can do that, 
why would you have a problem using the *defined mechanism* to convert 
from a PID to a handle, which is what the Windows API routine to kill 
processes requires?

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


Re: Fwd: how to find the drive in python/cygwin?

2005-04-30 Thread Jason Tishler
Ivan,

On Sat, Apr 30, 2005 at 08:44:55AM -0600, Ivan Van Laningham wrote:
 Jason Tishler wrote:
  I was just clarifying that the win32api module is not supported
  under Cygwin Python.
 
 Could you clarify?  I always thought that the only thing really
 different were the default path assumptions--/ instead of \, and so
 on--rather than anything substantive.  I try to use os.path.sep() and
 os.path.join(), etc.
 
 What else could bite me?  ;-)

Not much -- at least not too hard. :,)  Anyway, only the low level stuff
would be different: Posix versus Win32, shared extensions, etc.  The
high level stuff should be the same -- isn't Python just Python. :,)

Jason

-- 
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter app=App(root) problem

2005-04-30 Thread Steve Holden
[EMAIL PROTECTED] wrote:
This is my first day working with Tkinter.  I'm using python2.3 on
WindowsXP. I found this program and entered it.
from Tkinter import *
class App:
def _init_(self,master):
  ^^
This should be __init__ (the underscores should be doubled). Python 
magic methods are all named in this way.

frame = Frame(master)
frame.pack()
self.button = Button(frame, text = Quit, fg = red, command
=frame.quit)
self.button.pack(side=LEFT)
self.hi_there = Button(frame, text = Hello, command =
self.say_hi)
self.hi_there.pack(side=LEFT)
def say_hi(self):
print hi there, everyone!
root = Tk()
app = App(root)
root.mainloop()
When I run the code in IDLE I get the initial frame but no buttons with
the following error:
Traceback (most recent call last):
  File C:\Documents and Settings\INTERNET\Desktop\hello2.py, line 18,
in ?
app = App(root)
TypeError: this constructor takes no arguments
I have also tried to save the program as with a pyw extension.  Nothing
happens when I try to run it with that extension.
That's not strictly true. Nothing *appears* to happen, because the same 
error message is produced but there's no windows console to display it in.

regards
 Steve
--
Steve Holden+1 703 861 4237  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: large dictionary creation takes a LOT of time.

2005-04-30 Thread Maksim Kasimov
sorry for my question, but i've read the documentation, and can't find 
where is the explanation of how it is exactly works (but of course i do believe 
you). If it is buit in function, can i see the source code of the method to 
find it out?
Kent Johnson wrote:
Maksim Kasimov wrote:
Kent Johnson wrote:
  for line in open(path):
the line of your example raise another question: opened file will be 
read at once time, as method readlines() do, or it will be read line 
by line as method readline() do.

It will be read line by line as readline() does.
as far i know, it is depends on implementation of method __iter__ of 
the object that open() returns, so another question: where i can 
find such an information (about how does such a functions works)?

http://docs.python.org/lib/built-in-funcs.html
http://docs.python.org/lib/bltin-file-objects.html
Kent

--
Best regards,
Maxim Kasimov
mailto: [EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


mbx repair script: Python vs perl

2005-04-30 Thread David Isaac
I'm looking for the Python equivalent of the perl script and module
described at
http://comments.gmane.org/gmane.mail.imap.uw.c-client/707

Any hope?

Thanks,
Alan Isaac


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


Re: [newbie] Embedding Flash OCX object

2005-04-30 Thread Exeem

Kartic,

Thanks for your reply,

I already use the wxPython to embbed my flash animation

###
from wxPython.lib.activexwrapper import MakeActiveXClass

ActiveXWrapper = MakeActiveXClass(flashActiveXLib.ShockwaveFlash, 
eventClass=None, eventObj=self)

Flash = ActiveXWrapper( self, -1, style=wxSUNKEN_BORDER)


It work fine and i can control my flash animation from Python without 
problem..

But the Wrapper need the flash.ock to be installed on the user system in 
order to work,
and i would like to make an executable application that include the 
flash.ocx or load it on startup for
users who doesn't have the flash player installed.
I would like also to be able to load a flash animation from memory and not 
to load it from external file.

Don't know if you understand me.. Take a look at 
http://www.flashplayercontrol.com/ .. I'd like such a solution for Python,
don't know if i can use that dll from Python or make a module myself..

Anyway, thank a lot for your interest

Dan


Kartic [EMAIL PROTECTED] a écrit dans le message 
de news: [EMAIL PROTECTED]
 The Great 'Exeem' uttered these words on 4/29/2005 2:11 PM:
 Hi All,

 I'm trying to find a way to embbed the flash.ocx object in a Windows 
 Python application,
 I've successfully integrated a flash object with the ocx already 
 installed on the system using the Activex Wrapper,
 but i would like to embbed it inside my application in order to 
 distribute my application without the need for the user to install the 
 flash player.
 It would like also to embbed the flash animation inside my application 
 without loading it .. i mean directly from the memory.

 I've seen that it was possible in C++ or in Delphi, using the 
 http://www.flashplayercontrol.com/ .. but don't know how to make it in 
 Python.

 Any ideas are welcome

 Dan.


 Dan,

 wxPython has the capability to embed Flash inside a wxPython panel. It 
 uses Macromedia's Flash ocx that is installed when installing flash player 
 on Windows. And it is pretty nifty; take a look at the demo.

 From your message, it is appears you are using win32gui functions but I am 
 unable to tell. So using Win32, I do not know how you can do what you are 
 trying. But yeah, look into wxPython!

 Please let me know if you need more assistance.

 Thanks,
 -Kartic 


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


Re: Can .py be complied?

2005-04-30 Thread Peter Dembinski
[EMAIL PROTECTED] (John J. Lee) writes:

[snap]

 Until they install the next program that does this.

If we talk about _real_ users from the _real_ world, the most of them
would just kill the app (or what is the name for stopping running
program in w32) when the download begins[1] :)

[1] 'hey, is that a spyware or what?  what takes so darn long?'

-- 
http://www.pdemb.prv.pl 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ron Grossi: God is not a man

2005-04-30 Thread Donald L McDaniel
Johnny Gentile wrote:
 Donald - go away. Far away. Now.
 And, for the last time (hopefully), stop crossposting to
 rec.music.beatles.
 Go sell crazy somewhere else. We're all stocked up.

 Donald L McDaniel wrote:
 AKA wrote:
 Donald L McDaniel [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 MC05 wrote:
 sheltech [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]

 MC05 [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]

 Donald L McDaniel [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]

 4) I doubt seriously whether God plays a guitar, since guitars
 are made by men, for men.  His Son could theoretically play a
 guitar. Perhaps He does. Perhaps He doesn't.  Only the Father
 and His Holy Angels know.

 So then Lucifer was a wicked bass player whose sex and drugs and
 rock n roll alientated the rest of the band and was fired?




 Fired   good one

 Heh.  Can't take credit for an accident.  Your eye is better than
 mine. :)

 The Devil has been fired...by God Himself.  Read the Book of
 Revelation in the New Testament:  Satan's end is clearly outlined
 by the Angel Jesus sent to St. John.  This end is very clear:  he
 will be cast alive into the Lake which burns with fire and
 brimstone, where he will be tormented day and night forever.

 Not only Satan and his angels will be cast into the Lake, but all
 those who follow him and his servants.  I assure you, Satan won't
 be ruling anyone in the Fire.  He will be in just as much torment
 as his followers. Neither will he have any sort of job.

 I strongly advise you to stop making fun of things you have no
 understanding of.  Your eternal destiny depends on the way you
 treat others.

 --
 Donald L McDaniel
 Please reply to the original thread,
 so that the thread may be kept intact.
 ==

 Just imagine if you actually had a coherent thought.

 My Bible tells me that the Truth sounds like foolishness to a
 perishing man. Are you perishing?  God threw out a life-raft for
 you.  Jesus is more than willing to rescue a drowning man.  Go to
 the nearest church(Roman Catholic, Eastern Orthodox), and ask how
 you can be saved from your sin.

 --
 Donald L McDaniel
 Please reply to the original thread,
 so that the thread may be kept intact.
 ==

1) I am posting to a newsgroup on the Microsoft Usenet Server.  It's not my 
fault the demon-lover who posted the original anti-Christian article 
cross-posted to so many newsgroups across so many servers.  Talk to him 
about cross-posting.
1) I will go away, when Christ returns for me.  I hope you are ready for His 
return, else you are in for a living Hell here on the Earth before the REAL 
Hell rises up to swallow you in its Flames.

-- 
Donald L McDaniel
Please reply to the original thread,
so that the thread may be kept intact.
== 


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


Re: mbx repair script: Python vs perl

2005-04-30 Thread Donn Cave
Quoth David Isaac [EMAIL PROTECTED]:
| I'm looking for the Python equivalent of the perl script and module
| described at
| http://comments.gmane.org/gmane.mail.imap.uw.c-client/707
|
| Any hope?

Sure, should be doable, if for some reason you can't just use that.
I personally wouldn't do it exactly that way, rather I would just
read the file directly.

At first you said you were only interested in fixing the header.
This one operates on the rest of the file, and I guess I will assume
that's what you really want.  MBX structure is just a one line message
header before each message, with a message size value among other things.
Readers of this format will add that size value to the current file
offset and expect another header line at that point.  When the data
there isn't a valid header line, they die.  One does not need the
c-client library to do this, but more to the point it isn't what you
want to do, with a damaged file.

Just read the file from one end to the other and find everything that
looks like a header line, and then rewrite the file with adjusted header
lines required so that

- they are in ascending order by ID number
- they have correct sizes.

Donn Cave, [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New Python website

2005-04-30 Thread Kay Schluehr

lpe wrote:
 http://www.pycode.com

 I was kinda suprised when I could not find any good sites with 3rd
 party modules (other than the Vaults of Parnassus, where you must
host
 files elsewhere), so I decided to write one myself :)

Maybe You shot a bit fast? PiPy is good and the Vaults are good. Link
them makes them better, though not very innovative. Someone told me
that I'm on the Web here, am I?

 It is brand new and might still be buggy, but hopefully it will be
 usefull to some people.  Feel free to join and upload any of your
code.
 thanks

When I was younger I found anarchy cool. Now I find it grey.

Ciao,
Kay

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


Re: interactive web graphics

2005-04-30 Thread M.E.Farmer
Blender has nothing to do with Mozilla.
It is a 3d creation suite it contains more things than you would
believe ;)
Blender is deep and wide, so it can be daunting to use at first but
once you have basic 3d concepts under you belt it is playtime.
Blender is the first software package to be bought from a private
company by a community to be put into opensource. Really cool stuff has
been happening ever since they went opensource. The game engine has
taken the longest to put back together, it was removed because of
licensing issues.  So the old game plugin might not be up to date but
it will eventually be revamped when the 'new' game engine is stable.
Until then you might be able to use the old one but I have had many
problems getting it to work reliably on Firefox or Mozilla, it works
well with I.E. but 
Have fun and experiment. 
M.E.Farmer

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


lists in cx_Oracle

2005-04-30 Thread Andrew Dalke
A while back I asked about which Oracle client to use for
MS Windows.  Turns out I also needed one for unix so I followed
people's advice and installed cx_Oracle.

I want to execute a query with an IN in the WHERE clause
and with the parameter taken from a Python variable.  That
is, I wanted something like this to work

id_list = [AB001, AB002, AB003]

c.execute(SELECT s.smiles FROM smiles_database s WHERE 
   s.id IN :id_list, id_list = id_list)

I couldn't get it to work.  It complained

arrays can only be bound to PL/SQL statements

I tried looking at the source code but couldn't figure out
how to do this.  In no small part due to my nearly complete
lack of experience with Oracle or for that matter SQL databases.

My solution was to build a new string to executed but it
wasn't pretty and I needed to explain to my client about
SQL injection; wanted to use repr(a_tuple) which was *almost*
correct.

How do I do what I want to do?

Andrew
[EMAIL PROTECTED]

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


Re: Micro-PEP: str.translate(None) to mean identity translation

2005-04-30 Thread M.E.Farmer
After I re-read your post in daylight and read your followup the Aha!
 hit me .I am a little slow at times. I have always just iterated thru
the badchars and replaced with   . What you suggest would be very
nice indeed!
Thanks for the time and explanation, and you too Peter !

For what it is worth +1 ;)

On another note why is maketrans in the string module
I was a bit lost finding it the first time should it be builtin?
transtable = abcdefg.maketrans(qwertyu)
Probably missing something.
M.E.Farmer

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


Directory in Windows

2005-04-30 Thread custard_pie
Hi,..I tried to list files in a tree directory using os.path.walk. To
avoid dirnames fromm being listed i use the os.path.isdir method.
However, when isdir encounters directories that use spaces in their
name e.q My Documents it doesn;t recognize them as directories.. Is
there any solution to this,..pertaining that I want to keep the naming
of my directories?

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


Re: large dictionary creation takes a LOT of time.

2005-04-30 Thread Kent Johnson
Maksim Kasimov wrote:
sorry for my question, but i've read the documentation, and can't find 
where is the explanation of how it is exactly works (but of course i do 
believe you). If it is buit in function, can i see the source code of 
the method to find it out?

Kent Johnson wrote:
http://docs.python.org/lib/built-in-funcs.html
From the above page:
open(   filename[, mode[, bufsize]])
An alias for the file() function above.
file(   filename[, mode[, bufsize]])
Return a new file object (described in section 2.3.9, ``File Objects'').
http://docs.python.org/lib/bltin-file-objects.html
2.3.9 File Objects
next(  	)
A file object is its own iterator, for example iter(f) returns f (unless f is closed). When a 
file is used as an iterator, typically in a for loop (for example, for line in f: print line), the 
next() method is called repeatedly. This method returns the next input line, or raises StopIteration 
when EOF is hit. etc

or look at Objects/fileobject.c in the source code.
Kent
--
http://mail.python.org/mailman/listinfo/python-list


[Py Windows] User Directory Path

2005-04-30 Thread Zoool
Hi,

Is there a way to know the main directory path of a user session?
I mean the C:\Documents and Settings\username Directory of the user logged 
into a windows session.
In .NET you can do this with a :
System.Environment.GetEnvironmentVariable(HOMEDRIVE)
System.Environment.GetEnvironmentVariable(HOMEPATH)

Maybe it's a stupid question that was already answered.. but can't anything 
on archives..

thanks a lot

Ben 


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


Re: Directory in Windows

2005-04-30 Thread Kent Johnson
custard_pie wrote:
Hi,..I tried to list files in a tree directory using os.path.walk. To
avoid dirnames fromm being listed i use the os.path.isdir method.
However, when isdir encounters directories that use spaces in their
name e.q My Documents it doesn;t recognize them as directories.. Is
there any solution to this,..pertaining that I want to keep the naming
of my directories?
That seems unlikely. For example,
  os.path.isdir(r'D:\My Documents')
True
Can you show the code?
Alternatively you might try os.walk() which is a bit easier to use than os.path.walk() and it gives 
you separate lists for files and directories:

  import os
  for dirpath, dirnames, filenames in os.walk('f:/tutor'):
 ...   for file in filenames:
 ... print os.path.join(dirpath, file)
 ...
f:/tutor\AllTheSame.py
f:/tutor\AppendTimes.bmp
ecc...
Or even easier, use jorendorff's path module which has a walkfiles() method that iterates over files 
directly and gives you path objects to work with:

  import path
  for file in path.path('f:/tutor').walkfiles():
 ...   print file
 ...
f:/tutor\AllTheSame.py
f:/tutor\AppendTimes.bmp
f:/tutor\ArtOfWar.txt
etc...
http://www.jorendorff.com/articles/python/path/
Kent
--
http://mail.python.org/mailman/listinfo/python-list


Re: Writing to log file when script is killed

2005-04-30 Thread Heiko Wundram
Am Samstag, 30. April 2005 14:26 schrieb [EMAIL PROTECTED]:
 If you run on unix you can use the signal module to intercept a kill -
 see http://docs.python.org/lib/node368.html for a quick example

You cannot intercept a kill (that's the whole meaning of SIGKILL, rather than 
SIGTERM)... Read up on UNIX signal handling.

But, for the rest: you could intercept SIGTERM, log a message, and raise a 
SystemExit exception. That should do the trick.

-- 
--- Heiko.
  see you at: http://www.stud.mh-hannover.de/~hwundram/wordpress/


pgpcjkH9bj8ZO.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Directory in Windows

2005-04-30 Thread custard_pie
Here's my code

filelist={}
def listFiles(self, dirName, filesInDir):
for fname in filesInDir:
if os.path.isfile(fname):
key = os.path.join(dirName, fname)
stats = os.stat(fname)
filelist[key] = (stats[stat.ST_MTIME], 
stats[stat.ST_SIZE])
os.path.walk(string.strip(self.path.get()), listFiles, None)
print filelist
===
I change: if not os.path.isdir(fname) to if os.path.isfile(fname)
because some directories are not recognized as directory, and I get an
error message because os.stat is called with the directory as arg. But
even after I change it into isfile(). There are still some
errors,..some images in the subdirectories won't get printed...
Help please

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


Re: User Directory Path

2005-04-30 Thread [EMAIL PROTECTED]
os.getenv or os.envoron, see http://docs.python.org/lib/os-procinfo.html

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


Re: User Directory Path

2005-04-30 Thread Zoool
Thanks a lot,

os.environ[HOMEDRIVE]
os.environ[HOMEPATH]

are what i was looking for 




[EMAIL PROTECTED] [EMAIL PROTECTED] a écrit dans le message de 
news: [EMAIL PROTECTED]
 os.getenv or os.envoron, see http://docs.python.org/lib/os-procinfo.html
 


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


Re: tkinter OptionMenu column break

2005-04-30 Thread Jeff Epler
I don't think that Tk's menus ever use more than one column.  They
certainly don't on Unix.

Jeff


pgpsVnvjgm3Qy.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: [Py Windows] User Directory Path

2005-04-30 Thread Wolfgang Strobl
Zoool polykrom(at)belcenter(dot)com:

Is there a way to know the main directory path of a user session?
I mean the C:\Documents and Settings\username Directory of the user logged 
into a windows session.

 from win32com.shell.shell import SHGetSpecialFolderPath
 from win32com.shell.shellcon import CSIDL_PROFILE
 SHGetSpecialFolderPath(0,shellcon.CSIDL_PROFILE)
u'C:\\Dokumente und Einstellungen\\wolfgang'


-- 
Wir danken für die Beachtung aller Sicherheitsbestimmungen
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: array type casting problem in scipy.interpolate

2005-04-30 Thread bgs
The routine requires real arrays, and you are giving it one complex
one.  It does not know what to do with the complex array.  What are you
expecting it to do?  If you need the real and imaginary parts to be
separately interpolated, then split the complex array into two real
arrays and use the routine twice.

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


Re: Ron Grossi: God is not a man

2005-04-30 Thread Obaid R.
Donald L McDaniel wrote:

 1) I am posting to a newsgroup on the Microsoft Usenet Server.  It's
not my
 fault the demon-lover who posted the original anti-Christian article
 cross-posted to so many newsgroups across so many servers.  Talk to
him
 about cross-posting.
 1) I will go away, when Christ returns for me.  I hope you are ready
for His
 return, else you are in for a living Hell here on the Earth before
the REAL
 Hell rises up to swallow you in its Flames.

 --
 Donald L McDaniel
 Please reply to the original thread,
 so that the thread may be kept intact.
 ==


And the demon lover would be the one who
quotes from the word of God as reported in
your own Bible which proclaims that God is
not a man ... neither the son of man
(Numbers 23: 19)? Is it your contention that
this is demonic truth? See what the world is
comming to?

And it was not I who originally cross-posted
as you claim. I was replying to Mr. Grossi
who did start the cross-posting. Does your
words: the demon-lover who posted the
original anti-Christian article cross-posted
to so many newsgroups across so many servers
apply to him? Here is a quote from the head
of his original post:

From: [EMAIL PROTECTED]
Newsgroups:
Microsoft.public.windowsxp.network_web,rec.music.beatles,rec.music.makers.guitar.acoustic,alt.showbiz.gossip,comp.lang.python



In case you are interested in comparitive
religion then maybe these links might be of
help:


Qur'an:
===
[1] Download a free Qur'an viewer:
http://www.divineislam.co.uk/


Audio:
==
[1] Christ in Islam - Parts 1, 2  3; a lecture by Ahmed Deedat.
http://islam.org/audio/ra622_1.ram

[2] Crucification: Fact or Fiction - Parts 1,  2; a Christain Muslim
debate in the USA with a Christian and Muslim audience in attendence.
http://islam.org/audio/ra622_3.ram

[3] Is the Bible God's Word - Parts 1,  2; a Christian Muslim debate
in the USA with a Christian and Muslim audience in attendence.
http://islam.org/audio/ra622_4.ram

[4] Audio  Video Files; Misc. topics.
http://www.beconvinced.com/SPEECHES.htm


Articles and booklets:
==
[1] Christ In Islam by Sheikh Ahmad Deedat.
http://www.thestraightway.com/literature/0011.html

[2] What Does the Bible Say about Mohammed (PBUH)? by Sheikh Ahmad
Deedat.
http://www.thestraightway.com/literature/0014.html

[3] The God That Never Was by Sheikh Ahmad Deedat.
http://www.thestraightway.com/literature/0016.html

[4] What was the Sign of Jonah? by Sheikh Ahmad Deedat.
http://www.thestraightway.com/literature/0017.html

[5] Who moved the Stone?  by Sheikh Ahmad Deedat.
http://www.thestraightway.com/literature/0018.html

[6] Resurrection or Resuscitation? by Sheikh Ahmad Deedat.
http://www.thestraightway.com/literature/0019.html

[7] Other work by Sheikh Ahmed Deedat. 
http://www.jamaat.net/deedat.htm

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


Re: [newbie] Embedding Flash OCX object

2005-04-30 Thread Kartic
The Great 'Exeem' uttered these words on 4/30/2005 11:37 AM:
Kartic,
Thanks for your reply,
I already use the wxPython to embbed my flash animation
###
from wxPython.lib.activexwrapper import MakeActiveXClass
ActiveXWrapper = MakeActiveXClass(flashActiveXLib.ShockwaveFlash, 
eventClass=None, eventObj=self)

Flash = ActiveXWrapper( self, -1, style=wxSUNKEN_BORDER)

It work fine and i can control my flash animation from Python without 
problem..

But the Wrapper need the flash.ock to be installed on the user system in 
order to work,
and i would like to make an executable application that include the 
flash.ocx or load it on startup for
users who doesn't have the flash player installed.
I would like also to be able to load a flash animation from memory and not 
to load it from external file.

Don't know if you understand me.. Take a look at 
http://www.flashplayercontrol.com/ .. I'd like such a solution for Python,
don't know if i can use that dll from Python or make a module myself..

Anyway, thank a lot for your interest
Dan

Dan,
Ah! I see what you are trying to do. While I don't have a working piece 
of code to share with you, I can give you a few ideas that you could 
consider:

1. Supply the Macromedia OCX with your app. Try to use the wxActivex 
class and if that fails, register your copy of the OCX. You can do this 
either using a batch file invoking regsvr32 or use Win32 to register. 
The flip side: The flash will be loaded from a file rather than memory.

2. Wrap the flashplayercontrol.com's DLL in an Activex control using VB 
and distribute your OCX. And then use wxActivex to access your OCX.

3. Use SWIG to generate Python bindings for the DLL. I have never done 
this and I am sure some of the more erudite members of the newsgroup can 
shed some light.

4. Call the supplied DLL using Ctypes. In this case, you can convert the 
example under the Features link of that site in DLL calls using 
Ctypes. Question: How will that integrate with wx?

Hope that helped a bit.
Thanks,
-Kartic
--
http://mail.python.org/mailman/listinfo/python-list


Re: Directory in Windows

2005-04-30 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], custard_pie
wrote:

 Here's my code
 
 filelist={}
 def listFiles(self, dirName, filesInDir):
   for fname in filesInDir:
   if os.path.isfile(fname):

`fname` contains just the file name without the path to the file.  So this
gives `False` for every file name except if there's a file with the same
name in the current working directory.

   key = os.path.join(dirName, fname)
   stats = os.stat(fname)

Same problem with `stat()`.  Move the assignment to `key` up and use that
to check with `isfile()`/`isdir()` and `stat()`.

   filelist[key] = (stats[stat.ST_MTIME], 
 stats[stat.ST_SIZE])
 os.path.walk(string.strip(self.path.get()), listFiles, None)
 print filelist
 ===

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ron Grossi: God is not a man

2005-04-30 Thread Obaid R.
Larry Bates,



I truly appreciate the dignified tone of your
response. Kindly allow me to respond.


IN SPITE OF THE BIBLE, NOT BECAUSE OF IT?
=


First I do apologize for the earlier long
discourse; I am afraid this might be just as
long. There is much to discuss and I try
to be through.

Having said that, and to respond to your
point, please be informed that I did not take
any scripture out of context so as to reach a
conclusion of my own. If you'd be kind enough
to point out one incident I will promptly
apologize and will take it back.

With that said, I hope you are fair enough to
agree that if someone makes a claim that then
the same person should back that claim up with
proof. That out of context claim you make,
brother, is made without proof.

Please tell us how Christ the man (Acts 2:
22), and the son of man (Luke 9: 58) are
not part of the Christian textual sources
or how they were taken out of context. How
is that when it is proclaimed in the Law
attributed to Almighty God that God is not a
man ... neither the son of man (Numbers 23:
19) that this part of the Law (given Acts 2:22,
and Luke 9: 58) is not applicable to Christ
PBBUH or any other man and son of man from
the beginning of time until the end of time.

You see, Larry, if someone were to write an
essay and post satellite images in support
of the fact that earth is spherical, anyone
defending the false notion that the earth is
flat can simply counter: you are taking
things out of context. But these words will
not do, as any fair person can confirm.
Without proof, a claim is what it is: just a
claim. The burden of proof is on the one who
makes the point to prove it, not on the other
party to refute what was not proven.

In my case, proof was offered in defence of
my assertions from what Christian authorities
themselves regard as Christian textual
sources of divine origin. Does that not carry
enough weight for you so as to be convinced?

If people will read in their textual sources
that God is not a man ... neither the son of
man and *yet* go on to believe in- and even
argue the exact opposite of that- just
because they have an opinion, then what is the
Bible for then? If people are going to believe
that Christ the man (Acts 2:22), and the son
of man (Luke 9: 58) is Almighty God Himself
in spite of Numbers (among others), then what
is the point of these people having textual
sources for their beliefs?

Wouldn't it be better if these people got
together, sat down, and wrote a novel and
made a religion out of it? This is what the
Church of Scientology did. Perhaps then that
novel would agree with their man-made
beliefs, namely that God is a man and is the
son of man in spite of (Numbers 23: 19)?
That God will dwell on the earth in spite
of (1 Kings 8: 27)? That there are other
'Gods' with God and that there is now someone
like unto God in spite of (Isaiah 46:9)? And
so on and so forth?

After all, let's face it, Larry, the novel is
there inside your (plural) head, and it is
from which you are all reading to us that
Christ PBBUH the man and the son of man
is actually God; but whether you realize it
or not, you are doing so in spite of the word
of God as found in the Bible, not because of it.
I truly don't know how to make a mention of
this and not appear like I wish to offend
you, which is truly not my intention, but I
must inform you anyway: does the word anti
ring any bells?


PLURAL GOD?
===


Do you believe that God is one or not? Was it
not Christ PBBUH himself who said that the
Lord our God is one Lord (as opposed to a
tri-une Lord) or was he not? Is there a
single explicit mention of the word Trinity
in the entire encyclopaedia of books called
the Bible? Just one? There is none, can you
believe it?


THE DONKEY RIDE
---

Please read from the New Testament:

... and they sat him thereon. (The Donkey)
(Matthew 21:7)

... and he sat upon him. (The Donkey)
(Mark 11:7)

... and they set Jesus thereon. (The Donkey)
(Luke 19:35)

... Jesus ... sat thereon: (The Donkey)
(John 12:14)


In Is The Bible God's Word[1], Ahmed
Deedat writes:

Could God Almighty have been the author of
this incongruous situation - going out of His
Way to see that all the Gospel writers did
not miss their footing recording of His
son's donkey-ride into the Holy City - and
yet inspiring them to blackout the news
about His son's heavenly flight on the
wings of angels?


I note the exact same amazing situation here. Why is
it so important to have all the Gospels
mention the donkey incident but not have one single
explicit remark anywhere about what effectively will
decide the eternal fate (repeat: eternal
fate) of many: the alleged trinity?
Astonishing, no?


WHY NOT A PENTINITY?



Yes as humans we will never fully understand
the Trinity in this lifetime, but so would
be the case, I put it to you, concerning
dualnity, (as in two) quadrupinity,
pentinity, etc., if there is actually such

Re: Ron Grossi: God is not a man

2005-04-30 Thread Obaid R.
Non-Offensive, Professional Sounding Name


First of all, there was no diatribe, even
when you can claim there was one. Unless of
course you consider the contents of the Bible
from which I quote as such. Seeing that you
claimed that there was no truth in my post, I
was hoping to read proof in support of your
claim. To my disappointment, there was none.
Just a reference to the word Allah made,
alas, in haste.

I wish that you'd considered your words
before you rushed to post. I say that for the
following reason: did you know that there are
around 26 million Christian Arabs living in
the world today? Did you know that their
Arabic Bibles (together with their Arab Jews
brethren) have the word Allah exactly where
the word God appears in your English Bible?

Furthermore, did you know that in Malta, made
up of a population of staunch Catholics,
people use the word Allah for God in their
own language?

Perhaps you'd be interested in reading Who
is Allah?[1] and The Word ALLAH in the
Arabic Bible[2] both essays by Abu Iman 'Abd
ar-Rahman Robert Squires.

And in case you don't believe either of us,
then visit these links from
bible.gospelcom.net showing you how the word
Allah does appear in the Arabic Bible where
the word God appears in the English one.



FROM THE ARABIC BIBLE
=

Genesis 1: 1
In the beginning God created the heavens and the earth.
http://bible.gospelcom.net/bible?passage=GEN+1:1language=arabicversion=IBSshowfn=onshowxref=on


Genesis 1: 8:
And God called the firmament Heaven. And there was evening and there
was morning, a second day.
http://bible.gospelcom.net/bible?passage=GEN+1:8language=arabicversion=IBSshowfn=onshowxref=on


Mark 10: 18
And Jesus said unto him, Why callest thou me good? there is none good
but one, that is, God.
http://bible.gospelcom.net/bible?passage=MARK+10:18language=arabicversion=IBSshowfn=onshowxref=on


John 3: 16
For God so loved the world that he gave his only Son, that whoever
believes in him should not perish but have eternal life.
http://bible.gospelcom.net/bible?passage=JOHN+3:16language=arabicversion=IBSshowfn=onshowxref=on


Luke 3: 38
the son of Enos, the son of Seth, the son of Adam, the son of God.
http://bible.gospelcom.net/bible?passage=LUKE+3:38language=arabicversion=IBSshowfn=onshowxref=on


Mark 1: 14
Now after John was arrested, Jesus came into Galilee, preaching the
gospel of God,
http://bible.gospelcom.net/bible?passage=MARK+1:14language=arabicversion=IBSshowfn=onshowxref=on

Mark 3: 35
Whoever does the will of God is my brother, and sister, and mother.
http://bible.gospelcom.net/bible?passage=MARK+3:35language=arabicversion=IBSshowfn=onshowxref=on





RESOURCES
=

[1] Squires, Robert, Who is Allah? April 30, 2005:
http://www.wol.net.pk/truth/6who.htm
[2] Squires, Robert, The Word ALLAH in the Arabic Bible April 30,
2005: http://www.wol.net.pk/truth/6aib.htm

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


Re: Micro-PEP: str.translate(None) to mean identity translation

2005-04-30 Thread Bengt Richter
On Sat, 30 Apr 2005 08:44:21 GMT, Raymond Hettinger [EMAIL PROTECTED] wrote:

[Bengt Richter]
 Just thought None as the first argument would be both handy and mnemonic,
 signifying no translation, but allowing easy expression of deleting
characters,
 e.g.,

s = s.translate(None, 'badcharshere')

Log a feature request on SF and assignment to me.
I'll put this in for you.

Thanks. It has request ID # 1193128

Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ron Grossi: God is not a man

2005-04-30 Thread Johnny Gentile
From the Book of Armaments:

And Saint Attila raised the hand grenade up on high,
saying, 'Oh, Lord, bless this thy hand grenade that with it thou
mayest blow thy enemies to tiny bits, in thy mercy.' And the Lord
did grin, and people did feast upon the lambs, and sloths, and
carp, and anchovies, and orangutans, and breakfast cereals, and
fruit bats...


 And the Lord spake, saying, 'First shalt thou take out
the Holy Pin. Then, shalt thou count to three, no more, no less.
Three shalt be the number thou shalt count, and the number of the
counting shalt be three. Four shalt thou not count, nor either
count thou two, excepting that thou then proceed to three. Five is
right out. Once the number three, being the third number, be
reached, then lobbest thou thy Holy Hand Grenade of Antioch towards
thou foe, who being naughty in my sight, shall snuff it.'

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


Re: Ron Grossi: God is not a man

2005-04-30 Thread radio913

Johnny Gentile wrote:
 C'mon. Everyone knows God plays a Martin.


But He also has a de Jonge or two...

Also, i've heard that Satan plays an
old, beat up Takamine  it's NEVER in
tune, the action is ultra-high, and 
it buzzes like mad.



Slick

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


Re: [newbie] Embedding Flash OCX object

2005-04-30 Thread Zoool
Thanks Kartic,

Don't know if i have understand everything, but i 'll try using your lights,

To integrate a flash movie using wx, here is a piece of code (the Flash.py 
is auto-generated by makepy.py)

### testFlash.py
from wxPython.wx import *
import os

if wxPlatform == '__WXMSW__':
from wxPython.lib.activexwrapper import MakeActiveXClass
#import win32com.client.gencache
#import win32com.client
import flash

flashControl = flash

class FlashPanel(wxPanel):
def __init__(self, parent, flashFile):
wxPanel.__init__(self, parent, -1)

sizer = wxBoxSizer(wxVERTICAL)

ActiveXWrapper = MakeActiveXClass(flashControl.ShockwaveFlash)
self.Flash = ActiveXWrapper( self, -1)
self.Flash.Movie = os.path.join(os.getcwd(), flashFile)
self.Flash.Menu=False
self.Flash.OnFSCommand = self.OnFSCommand

sizer.Add(self.Flash, 1, wxEXPAND)
self.SetSizer(sizer)
self.SetAutoLayout(True)

EVT_WINDOW_DESTROY(self, self.OnDestroy)

def OnDestroy(self, evt):
if self.Flash:
self.Flash.Cleanup()
self.Flash = None

def OnFSCommand(self, command, *args):

if command==openFile:
self.openFile()
if command==saveFile:
self.saveFile(*args)


def openFile(self):
dlg = wxFileDialog(self, Choose, , , *.*, wxOPEN)
if dlg.ShowModal()==wxID_OK:
filename = dlg.GetFilename()
dirname = dlg.GetDirectory()
f = open(os.path.join(dirname, filename), r)
self.Flash.SetVariable(PyReply, f.read())
f.close()
dlg.Destroy()

def saveFile(self, text):
dlg = wxFileDialog(self, Save As, , , *.*, 
wxSAVE|wxOVERWRITE_PROMPT)
if dlg.ShowModal()==wxID_OK:
filename = dlg.GetFilename()
dirname = dlg.GetDirectory()
f = open(os.path.join(dirname, filename), w)
f.write(text)
f.close()
dlg.Destroy()


if __name__ == '__main__':
class FlashFrame(wxFrame):
def __init__(self):
wxFrame.__init__(self, None, -1, PyFlash -- Simple 
File Viewer, 
size=(550, 400))
self.flashPanel = FlashPanel(self, testFlash.swf)

app = wxPySimpleApp()
frame = FlashFrame()
frame.Show(True)
app.MainLoop()
### Flash.py

# -*- coding: mbcs -*-
# Created by makepy.py version 0.4.8
# By python version 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit 
(Intel)]
# From type library '{D27CDB6B-AE6D-11CF-96B8-44455354}'
# On Tue Mar 16 01:58:37 2004
Shockwave Flash
makepy_version = '0.4.8'
python_version = 0x20303f0

import win32com.client.CLSIDToClass, pythoncom
import win32com.client.util
from pywintypes import IID
from win32com.client import Dispatch

# The following 3 lines may need tweaking for the particular server
# Candidates are pythoncom.Missing and pythoncom.Empty
defaultNamedOptArg=pythoncom.Empty
defaultNamedNotOptArg=pythoncom.Empty
defaultUnnamedArg=pythoncom.Empty

CLSID = IID('{D27CDB6B-AE6D-11CF-96B8-44455354}')
MajorVersion = 1
MinorVersion = 0
LibraryFlags = 8
LCID = 0x0

from win32com.client import DispatchBaseClass
class IShockwaveFlash(DispatchBaseClass):
Shockwave Flash
CLSID = IID('{D27CDB6C-AE6D-11CF-96B8-44455354}')
coclass_clsid = IID('{D27CDB6E-AE6D-11CF-96B8-44455354}')

#default_interface = IShockwaveFlash
#default_source = _IShockwaveFlashEvents

def Back(self):
method Back
return self._oleobj_.InvokeTypes(114, LCID, 1, (24, 0), (),)

def CurrentFrame(self):
method CurrentFrame
return self._oleobj_.InvokeTypes(128, LCID, 1, (3, 0), (),)

def FlashVersion(self):
method FlashVersion
return self._oleobj_.InvokeTypes(132, LCID, 1, (3, 0), (),)

def Forward(self):
method Forward
return self._oleobj_.InvokeTypes(115, LCID, 1, (24, 0), (),)

def FrameLoaded(self, FrameNum=defaultNamedNotOptArg):
method FrameLoaded
return self._oleobj_.InvokeTypes(131, LCID, 1, (11, 0), ((3, 
1),),FrameNum)

def GetVariable(self, name=defaultNamedNotOptArg):
method GetVariable
# Result is a Unicode object - return as-is for this version of 
Python
return self._oleobj_.InvokeTypes(152, LCID, 1, (8, 0), ((8, 
1),),name)

def GotoFrame(self, 

Tripoli: a Python-based triplespace implementation

2005-04-30 Thread Dominic Fox
I have been working on a Python implementation of a modified Tuple
Space (cf Linda, JavaSpaces) that contains only 3-tuples (triples),
and that has operators for copying and moving graphs of triples as
well as sets matching a given pattern. It's called Tripoli, and the
code for it can be found here:

http://www.codepoetics.com/code/tripoli

More explanation of what it is and what it's meant to do can be found
in these three blog posts:

http://codepoetics.com/poetix/index.php?p=110
http://codepoetics.com/poetix/index.php?p=111
http://codepoetics.com/poetix/index.php?p=113 (this post includes some
sample code, that may clarify intended usage somewhat)

At present, a simple XML-RPC server is used to expose a manifold - a
collection of triple spaces - to multiple clients. I will be
supplementing this with something beefier, and more REST-ful, in due
course - probably based on Twisted.

This is code in the very earliest stages of testing and development -
I would very much welcome comments and suggestions from any intrepid
persons who fancy having a play around with it.

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


Re: Data smoothing algorithms? - Thank you all

2005-04-30 Thread Anthra Norell
Thank you all for your solutions! The moving average filter will surely do.
I will take a closer look at SciPy, though. The doc is impressive. I believe
it's curve fitting I am looking for rather than interpolation. There's a
chapter on that too.

Frederic


- Original Message -
From: Larry Bates [EMAIL PROTECTED]
Newsgroups: comp.lang.python
To: python-list@python.org
Sent: Friday, April 29, 2005 9:02 PM
Subject: Re: Data smoothing algorithms?


 Sounds like what you are looking for is spline interpolation.
 Given a set of datapoints is passes spline curves through
 each point giving you smooth transitions.  Did a lot of this
 in Fortran MANY years ago.

 Google turned up:

 http://www.scipy.org/documentation/apidocs/scipy/scipy.interpolate.html

 http://cmp.felk.cvut.cz/~kybic/thesis/pydoc/bigsplines.html

 http://www.mirror5.com/software/plotutils/plotutils.html

 Good Luck
 Larry Bates

 John J. Lee wrote:
  Anthra Norell [EMAIL PROTECTED] writes:
 
 
 Hi,
 
 The following are differences of solar declinations from one day to
 the next, (never mind the unit). Considering the inertia of a
 planet, any progress of (apparent) celestial motion over regular
 time intervals has to be highly regular too, meaning that a plot
 cannot be jagged. The data I googled out of Her Majesty's Nautical
 Almanac are merely nautical precision and that, I suppose, is where
 the jitter comes in. There's got to be algorithms out there to iron
 it out. If it were a straight line, I could do it. But this, over
 the whole year, is a wavy curve, somthing with a dominant sine
 component. Suggestions welcome.
 
 
  The important thing is to have a (mathematical, hopefully) model of
  how you expect the data to vary with time.  Start from there, and
  then, for example, use regression to fit a curve to the data.
 
  The Numerical Recipes (Press et al.) book is popular and IMHO is a
  good place to learn about these things (comes in several language
  flavours, including Fortran and C -- sadly no Python AFAIK), though
  the implementations aren't a great choice for serious production
  use, according to those in the know.
 
  OTOH, there are quick and dirty methods that don't involve any model
  worth speaking of -- and Press et al. covers those too :-)
 
 
  John
 
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: Can .py be complied?

2005-04-30 Thread Mike Meyer
jfj [EMAIL PROTECTED] writes:

 /* small program in C in self extracting archive
   */
 if (have_application (Python)) {
have_python:
system (python.exe my_application.py)
 } else {
printf (This software requires python. Wait until all the
 necessary components are being installed\n);
download_python_from_python_org();
system (install_python.exe);
goto have_python;
 }

Goto. Ugh.

if (!have_application(Python)) {
printf (This software requires python. Wait until all the
 necessary components are being installed\n);
download_python_from_python_org();
system (install_python.exe);
}
system(python.exe my_application.py);

   mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to track down all required shared libraries?

2005-04-30 Thread sdhyok
Recently, I installed many shared libraries to run a program written in
Python.
Now, I am in the situation to run the same program but on several
different machines with the same Linux OS. To avoid the reinstallation,
I like to pack up all shared libraries into a directory. Is there a
good way to track down all shared libraries required to run a Python
program?

Daehyok Shin

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


Re: bytecode non-backcompatibility

2005-04-30 Thread Mike Meyer
Maurice LING [EMAIL PROTECTED] writes:

Python can then have a built-in mechanism to read the description file
and download the source codes and do the standard sudo python
setup.py install to install the library into site-package.
 I don't like this - it would make Python depend on sudo being
 available. I'd rather it not do that, and let each systems
 administrator issue the command according to *their* security policy.

 If you are installing packages into your home directory, then sudo is
 not needed. But if you are installing it for everybody's use, then it
 is necessary. Fink runs using superuser privileges.

No, sudo isn't necessary.  It isn't provided by
default for all Unix installations, so Python would have to add a
dependency on it, which would be a bad thing.

sudo is sufficient. Other means are also sufficient. It would be wrong
for Python to assume a specific Unix security model (i.e. - sudo)
for installations.

mike

-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: array type casting problem in scipy.interpolate

2005-04-30 Thread Alex
On 30 Apr 2005 12:32:31 -0700, bgs [EMAIL PROTECTED] said:
 The routine requires real arrays, and you are giving it one complex
 one.  It does not know what to do with the complex array.  What are you
 expecting it to do?  If you need the real and imaginary parts to be
 separately interpolated, then split the complex array into two real
 arrays and use the routine twice.

Hello,

Thanks for the pointer. I will interpolate the real and imaginary parts
separately then.

Regards,

Alex


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


Re: bytecode non-backcompatibility

2005-04-30 Thread Mike Meyer
Maurice LING [EMAIL PROTECTED] writes:
 So if C extension API (or whatever that is really called) is stable,
 the system admin can just copy all of /sw/lib/python2.3/site-packages
 into /sw/lib/python2.4/site-packages and it should work. From what
 you've said, it seems that this isn't possible.

Correct. This isn't possible. It's not clear it's *desirable*,
either. For one thing, code can fail to port across versions, so
things will break at random (instead of all at once, I admit). For
another, I dislike the idea of a module sitting unupdate for long
periods of time (decades, say). Updating Python provides a good excuse
to update all the python modules, etc.

Now, it would be nice if Python provided an easy way to do the
update. The FreeBSD packaging system happens to provide a way to
automate this process, but it's still not exactly easy.

 So my alternative
 solution is that PyPI have a mechanism to maintain what had been
 installed in the site-package directory and to download the libraries
 and install into the new site-package directory...

PyPI is the wrong place to maintain a record of installed
software. Distutils is the software that does the installing (ok, on
most modules, anyway), and is the software that should record what
packages are installed.

Neither distutils nor PyPI has a download functionality. For that
matter, PyPI doesn't have a hard requirement on listing where a module
comes from. I'd say distutils is the software that should provide it,
so I can say:

   python setup.py install --depends

and get all the dependencies. But that's not at all clear. PyPI will
have to cooperate by providing URLs to packages, instead of to pages.

 mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Numeric/Numarray equivalent to zip ?

2005-04-30 Thread Robert Kern
George Sakkis wrote:
What's the fastest and most elegant equivalent of zip() in
Numeric/Numarray between two equally sized 1D arrays ? That is, how to
combine two (N,)-shaped arrays to one (N,2) (or (2,N)) shaped ? I
expect the fastest and the most elegant idiom to be identical, as it is
usually the case in this excellent library, but if not, both would be
useful to know. Thanks,
Look at combining concatenate(), reshape(), and transpose(). In Scipy, I 
would use hstack() and vstack().

--
Robert Kern
[EMAIL PROTECTED]
In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die.
  -- Richard Harter
--
http://mail.python.org/mailman/listinfo/python-list


Re: Ron Grossi: God is not a man

2005-04-30 Thread Anthra Norell
It must be because there aren't enough real problems that so many people
devote so much energy to inventing so many imaginary ones.

Frederic

(GOD tells me---much against my will; I categorically refuse to be a
prophet!---to throw this piece of  HIS divine wisdom into the melee.)


- Original Message -
From: Obaid R. [EMAIL PROTECTED]
Newsgroups: microsoft.public.windowsxp.network_web,
rec.music.beatles,rec.music.makers.guitar.acoustic,
alt.showbiz.gossip,comp.lang.python
To: python-list@python.org
Sent: Saturday, April 30, 2005 10:39 PM
Subject: Re: Ron Grossi: God is not a man


 Non-Offensive, Professional Sounding Name


 First of all, there was no diatribe, even
 when you can claim there was one. Unless of
 course you consider the contents of the Bible
 from which I quote as such. Seeing that you
 claimed that there was no truth in my post, I
 was hoping to read proof in support of your
 claim. To my disappointment, there was none.
 Just a reference to the word Allah made,
 alas, in haste.

 I wish that you'd considered your words
 before you rushed to post. I say that for the
 following reason: did you know that there are
 around 26 million Christian Arabs living in
 the world today? Did you know that their
 Arabic Bibles (together with their Arab Jews
 brethren) have the word Allah exactly where
 the word God appears in your English Bible?

 Furthermore, did you know that in Malta, made
 up of a population of staunch Catholics,
 people use the word Allah for God in their
 own language?

 Perhaps you'd be interested in reading Who
 is Allah?[1] and The Word ALLAH in the
 Arabic Bible[2] both essays by Abu Iman 'Abd
 ar-Rahman Robert Squires.

 And in case you don't believe either of us,
 then visit these links from
 bible.gospelcom.net showing you how the word
 Allah does appear in the Arabic Bible where
 the word God appears in the English one.



 FROM THE ARABIC BIBLE
 =

 Genesis 1: 1
 In the beginning God created the heavens and the earth.

http://bible.gospelcom.net/bible?passage=GEN+1:1language=arabicversion=IBS
showfn=onshowxref=on


 Genesis 1: 8:
 And God called the firmament Heaven. And there was evening and there
 was morning, a second day.

http://bible.gospelcom.net/bible?passage=GEN+1:8language=arabicversion=IBS
showfn=onshowxref=on


 Mark 10: 18
 And Jesus said unto him, Why callest thou me good? there is none good
 but one, that is, God.

http://bible.gospelcom.net/bible?passage=MARK+10:18language=arabicversion=
IBSshowfn=onshowxref=on


 John 3: 16
 For God so loved the world that he gave his only Son, that whoever
 believes in him should not perish but have eternal life.

http://bible.gospelcom.net/bible?passage=JOHN+3:16language=arabicversion=I
BSshowfn=onshowxref=on


 Luke 3: 38
 the son of Enos, the son of Seth, the son of Adam, the son of God.

http://bible.gospelcom.net/bible?passage=LUKE+3:38language=arabicversion=I
BSshowfn=onshowxref=on


 Mark 1: 14
 Now after John was arrested, Jesus came into Galilee, preaching the
 gospel of God,

http://bible.gospelcom.net/bible?passage=MARK+1:14language=arabicversion=I
BSshowfn=onshowxref=on

 Mark 3: 35
 Whoever does the will of God is my brother, and sister, and mother.

http://bible.gospelcom.net/bible?passage=MARK+3:35language=arabicversion=I
BSshowfn=onshowxref=on





 RESOURCES
 =

 [1] Squires, Robert, Who is Allah? April 30, 2005:
 http://www.wol.net.pk/truth/6who.htm
 [2] Squires, Robert, The Word ALLAH in the Arabic Bible April 30,
 2005: http://www.wol.net.pk/truth/6aib.htm

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

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


ANN: pynetwork 2.25

2005-04-30 Thread bearophileHUGS
Pynetwork is a graph library, my first SourceForge project:

http://sourceforge.net/projects/pynetwork/

It included tests, some demo, some premilinary docs, and some images.
You can see some screenshoots on the SourceForge page for them.
I know about 5-6 other graph libraries for Python, one even in C++
(Boost).

This library is quite fast, and it can be imported with:
import graph
I've designed it inspired by the sets.py standard module, but here
there isn't a frozengraph because I think it's not much useful.
Inside the docstrings there are many definitions that can be used as a
graph theory glossary.

Surely there are some things to be fixed, I'm still improving it.
Beside the demos, I can add a kind of tutorial, and few more classical
algorithms.

Comments, suggestions, bug fixes, collaborations, etc., are surely
appreciated.

I don't know if Python will ever have a graph data structure in the
collections standard library, but I've tried by best so far :-)

Bear hugs,
Bearophile
(Remove HUGS from my address if you want to email me)

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


Re: Best way to parse file into db-type layout?

2005-04-30 Thread John Machin
On Sat, 30 Apr 2005 09:23:16 -0400, Steve Holden [EMAIL PROTECTED]
wrote:

John Machin wrote:
[...]
 
 I wouldn't use fileinput for a commercial data processing exercise,
 because it's slow, and (if it involved using the Python csv module) it
 opens the files in text mode, and because in such exercises I don't
 often need to process multiple files as though they were one file.
 
If the process runs once a month, and take ten minutes to process the 
required data, isn't that fast enough.

Depends: (1) criticality: could it have been made to run in 5 minutes,
avoiding the accountant missing the deadline to EFT the taxes to the
government (or, worse, missing the last train home)?

(2) Many a mickle makes a muckle: the total of all run times could
be such that overnight processing doesn't complete before the day
shift turns up ...

 It's unwise to act as though 
slow is an absolute term.


 When I am interested in multiple files -- more likely a script that
 scans source files -- even though I wouldn't care about the speed nor
 the binary mode, I usually do something like:
 
 for pattern in args: # args from an optparse parser
 for filename in glob.glob(pattern):
 for line in open(filename):
 
 There is also an on principle element to it as well -- with
 fileinput one has to use the awkish methods like filelineno() and
 nextfile(); strikes me as a tricksy and inverted way of doing things.
 
But if it happens to be convenient for the task at hand why deny the OP 
the use of a tool that can solve a problem? We shouldn't be so purist 
that we create extra (and unnecessary) work :-), and principles should 
be tempered with pragmatism in the real world.

If the job at hand is simulating awk's file reading habits, yes then
fileinput is convenient. However if the job at hand involves anything
like real-world commercial data processing requirements then fileinput
is NOT convenient.

Example 1: Requirement is, for each input file, to display name of
file, number of records, and some data totals.

Example 2: Requirement is, if end of file occurs when not expected
(including, but not restricted to, the case of zero records) display
an error message and terminate abnormally.

I'd like to see some code for example 1 that used fileinput (on a list
of filenames) and didn't involve extra (and unnecessary) work
compared to the for filename in alist / f = open(filename) / for line
in f way of doing it.

If fileinput didn't exist, what do you think the reaction would be if
you raised a PEP to include it in the core?

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


Re: Best way to parse file into db-type layout?

2005-04-30 Thread John Machin
On Sat, 30 Apr 2005 14:31:08 +0100, Michael Hoffman
[EMAIL PROTECTED] wrote:

John Machin wrote:

That's nice. Well I agree with you, if the OP is concerned about embedded
CRs, LFs and ^Zs in his data (and he is using Windows in the latter case),
then he *definitely* shouldn't use fileinput.

And if the OP is naive enough not to be concerned, then it's OK, is
it?

It simply isn't a problem in some real-world problem domains. And if there
are control characters the OP didn't expect in the input, and csv loads it
without complaint, I would say that he is likely to have other problems once
he's processing it.
 
 Presuming for the moment that the reason for csv not complaining is
 that the data meets the csv non-spec and that the csv module is
 checking that: then at least he's got his data in the structural
 format he's expecting; if he doesn't do any/enough validation on the
 data, we can't save him from that.

What if the input is UTF-16? Your solution won't work for that. And there
are certainly UTF-16 CSV files out in the wild.

The csv module docs do say that Unicode is not supported.

This does appear to work, however, at least for data that could in
fact be encoded as ASCII:

 import codecs
 j = codecs.open('utf16junk.txt', 'rb', 'utf-16')
 rdr = csv.reader(j, delimiter='\t')
 rows = list(rdr)

The usual trick to smuggle righteous data past the heathen (recode as
UTF-8, cross the border, decode) should work. However the OP's data is
coming from an MF, not from Excel save as Unicode text (which
produces a tab-delimited .txt file -- how do you get a UTF-16 CSV
file?) and if it's not in ASCII it may have a bit more chance of being
in EBCDIC than UTF-16 -- unless MFs have come a long way since I last
had anything to do with them :-)

In any case, my solution was a sketch, and stated to be such. We
don't know, and I suspect the OP doesn't know, exactly (1) what
encoding is being used (2) what the rules are about quoting the
delimiter, and quoting the quote character. It's very possible even if
it's encoded in ASCII and the delimiter is a comma that the quoting
system being used is not the expected Excel-like method but something
else and hence the csv module can't be used.


I think at some point you have to decide that certain kinds of data
are not sensible input to your program, and that the extra hassle in
programming around them is not worth the benefit.

I prefer to decide at a very early point what is sensible input to a
program, and then try to ensure that nonsensible input neither goes
unnoticed nor crashes with an unhelpful message.


 There is also an on principle element to it as well -- with
 fileinput one has to use the awkish methods like filelineno() and
 nextfile(); strikes me as a tricksy and inverted way of doing things.

Yes, indeed. I never use those, and would probably do something akin to what
you are suggesting rather than doing so. I simply enjoy the no-hassle
simplicity of fileinput.input() rather than worrying about whether my data
will be piped in, or in file(s) specified on the command line.

Good, now we're singing from the same hymnbook :-)

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


Re: Trying to write CGI script with python...

2005-04-30 Thread Jason Mobarak
M.E.Farmer wrote:
 I found an excellent example that was posted by the F-bot.
[...]
 try:
 import myscript
 myscript.main()
 except:
 print Content-Type:, text/html
 print
 file = StringIO.StringIO()

Note: it's usually a very bad idea to name -anything- file unless you
intentionally want to clobber the name of the built-in file object.

 traceback.print_exc(file=file)
 print pre
 print cgi.escape(file.getvalue())
 print /pre

  I haven't got access to error logs so I can't look at it that way.
 
 /F

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


Tkinter weirdness item count

2005-04-30 Thread phil
 Using Tkinter Canvas to teach High School Geometry
 with A LOT of success.
Can you post a link to your code.
I'd like to see what you are doing.
Thx,
Alan Isaac
Yes, I will release it open source at the end of may.
There are too many features I want to add to release it now.
Essentially it is a script language for making complex drawings,
rotating objects, plotting simple functions, and with
a dialogue.  Which means you can make a simple concept or
a whole chapter into a lesson.
Eventually I will write a whole course based on Cliff notes
geometry review.
Why, are you a teacher?

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


Re: Ron Grossi: God is not a man

2005-04-30 Thread Nolan Caudill
Donald L McDaniel wrote:
AKA wrote:
Donald L McDaniel [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
MC05 wrote:
sheltech [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
MC05 [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Donald L McDaniel [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
4) I doubt seriously whether God plays a guitar, since guitars
are made by men, for men.  His Son could theoretically play a
guitar. Perhaps He does. Perhaps He doesn't.  Only the Father
and His Holy Angels know.
So then Lucifer was a wicked bass player whose sex and drugs and
rock n roll alientated the rest of the band and was fired?

Fired   good one
Heh.  Can't take credit for an accident.  Your eye is better than
mine. :)
The Devil has been fired...by God Himself.  Read the Book of
Revelation in the New Testament:  Satan's end is clearly outlined by
the Angel Jesus sent to St. John.  This end is very clear:  he will
be cast alive into the Lake which burns with fire and brimstone,
where he will be tormented day and night forever.
Not only Satan and his angels will be cast into the Lake, but all
those who follow him and his servants.  I assure you, Satan won't be
ruling anyone in the Fire.  He will be in just as much torment as
his followers. Neither will he have any sort of job.
I strongly advise you to stop making fun of things you have no
understanding of.  Your eternal destiny depends on the way you treat
others.
--
Donald L McDaniel
Please reply to the original thread,
so that the thread may be kept intact.
==
Just imagine if you actually had a coherent thought.

My Bible tells me that the Truth sounds like foolishness to a perishing man.
Are you perishing?  God threw out a life-raft for you.  Jesus is more than 
willing to rescue a drowning man.  Go to the nearest church(Roman Catholic, 
Eastern Orthodox), and ask how you can be saved from your sin.

So God only likes the Roman Catholic, Eastern Orthodox churches?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Ron Grossi: God is not a man

2005-04-30 Thread Mike brown
Just go away from RMMGA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to track down all required shared libraries?

2005-04-30 Thread Mike Rovner
sdhyok wrote:
Recently, I installed many shared libraries to run a program written in
Python.
Now, I am in the situation to run the same program but on several
different machines with the same Linux OS. To avoid the reinstallation,
I like to pack up all shared libraries into a directory. Is there a
good way to track down all shared libraries required to run a Python
program?
Daehyok Shin
To get executable requirements use ldd.
When python can't load a lib at run-time usually ImportError is raised.
As with other errors you can never know which libs will be dynamically 
required.

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


Re: How to track down all required shared libraries?

2005-04-30 Thread Jeff Epler
One poster suggests 'ldd' for executables.  You can also use this on shared
libraries:
$ ldd /usr/lib/python2.3/lib-dynload/_tkinter.so 
libtix8.1.8.4.so = /usr/lib/libtix8.1.8.4.so (0x009b6000)
libtk8.4.so = /usr/lib/libtk8.4.so (0x00111000)
libtcl8.4.so = /usr/lib/libtcl8.4.so (0x00539000)
libX11.so.6 = /usr/X11R6/lib/libX11.so.6 (0x00a48000)
libpthread.so.0 = /lib/tls/libpthread.so.0 (0x001de000)
libc.so.6 = /lib/tls/libc.so.6 (0x001f)
libdl.so.2 = /lib/libdl.so.2 (0x0052d000)
libm.so.6 = /lib/tls/libm.so.6 (0x00fcf000)
/lib/ld-linux.so.2 = /lib/ld-linux.so.2 (0x00656000)
If you know what shared modules your program uses, you can ldd them all and
find out the set of libraries they are linked to.

Jeff


pgpeC5PdZ34hJ.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Trying to write CGI script with python...

2005-04-30 Thread Steve Holden
Jason Mobarak wrote:
M.E.Farmer wrote:
I found an excellent example that was posted by the F-bot.
[...]
try:
   import myscript
   myscript.main()
except:
   print Content-Type:, text/html
   print
   file = StringIO.StringIO()

Note: it's usually a very bad idea to name -anything- file unless you
intentionally want to clobber the name of the built-in file object.
[...]
In fairness to the effbot I feel duty bound to suggest that the example 
may have been produced before file() was a built-in function. The effbot 
is usually reiable on programming matters.

regards
 Steve
--
Steve Holden+1 703 861 4237  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
--
http://mail.python.org/mailman/listinfo/python-list


compare two voices

2005-04-30 Thread Qiangning Hong
I want to make an app to help students study foreign language.  I want
the following function in it:

The student reads a piece of text to the microphone. The software
records it and compares it to the wave-file pre-recorded by the
teacher, and gives out a score to indicate the similarity between them.

This function will help the students pronounce properly, I think.

Is there an existing library (C or Python) to do this?  Or if someone
can guide me to a ready-to-implement algorithm?

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


Re: Best way to parse file into db-type layout?

2005-04-30 Thread Steve Holden
John Machin wrote:
On Sat, 30 Apr 2005 09:23:16 -0400, Steve Holden [EMAIL PROTECTED]
wrote:

John Machin wrote:
[...]
I wouldn't use fileinput for a commercial data processing exercise,
because it's slow, and (if it involved using the Python csv module) it
opens the files in text mode, and because in such exercises I don't
often need to process multiple files as though they were one file.
If the process runs once a month, and take ten minutes to process the 
required data, isn't that fast enough.

Depends: (1) criticality: could it have been made to run in 5 minutes,
avoiding the accountant missing the deadline to EFT the taxes to the
government (or, worse, missing the last train home)?
Get real: if that's the the timeline you don't need new software, you 
need a new accountant.

(2) Many a mickle makes a muckle: the total of all run times could
be such that overnight processing doesn't complete before the day
shift turns up ...
Again, get real and stop nitpicking.

It's unwise to act as though 
slow is an absolute term.

When I am interested in multiple files -- more likely a script that
scans source files -- even though I wouldn't care about the speed nor
the binary mode, I usually do something like:
for pattern in args: # args from an optparse parser
   for filename in glob.glob(pattern):
   for line in open(filename):
There is also an on principle element to it as well -- with
fileinput one has to use the awkish methods like filelineno() and
nextfile(); strikes me as a tricksy and inverted way of doing things.
But if it happens to be convenient for the task at hand why deny the OP 
the use of a tool that can solve a problem? We shouldn't be so purist 
that we create extra (and unnecessary) work :-), and principles should 
be tempered with pragmatism in the real world.

If the job at hand is simulating awk's file reading habits, yes then
fileinput is convenient. However if the job at hand involves anything
like real-world commercial data processing requirements then fileinput
is NOT convenient.
Yet again, get real. If someone tells me that fileinput  meets their 
requirements who am I (not to mention who are *you*) to say they should 
invest extra effort in solving their problem some other way?

Example 1: Requirement is, for each input file, to display name of
file, number of records, and some data totals.
Example 2: Requirement is, if end of file occurs when not expected
(including, but not restricted to, the case of zero records) display
an error message and terminate abnormally.
Possibly these examples would have some force if they weren't simply 
invented.

I'd like to see some code for example 1 that used fileinput (on a list
of filenames) and didn't involve extra (and unnecessary) work
compared to the for filename in alist / f = open(filename) / for line
in f way of doing it.
If fileinput didn't exist, what do you think the reaction would be if
you raised a PEP to include it in the core?
Why should such speculation interest me?
regards
 Steve
--
Steve Holden+1 703 861 4237  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Challenge ahead [NEW] for riddle lovers

2005-04-30 Thread Dan Bishop

Shane Hathaway wrote:
 pythonchallenge wrote:
  For the riddles' lovers among you, you are most invited to take
part
  in the Python Challenge, the first python programming riddle on the
net.
 
  You are invited to take part in it at:
  http://www.pythonchallenge.com

 That was pretty fun.  Good for a Friday.  Too bad it comes to an
abrupt
 temporary end.

They've added at least one more level since yesterday.  Unfortunately,
I'm stuck on it.

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


Re: compare two voices

2005-04-30 Thread Jeremy Bowers
On Sat, 30 Apr 2005 20:00:57 -0700, Qiangning Hong wrote:

 I want to make an app to help students study foreign language.  I want the
 following function in it:
 
 The student reads a piece of text to the microphone. The software records
 it and compares it to the wave-file pre-recorded by the teacher, and gives
 out a score to indicate the similarity between them.
 
 This function will help the students pronounce properly, I think.

Do you have any idea what it takes to compare two voices in a
*meaningful* fashion? This is a serious question. I can't guarantee
there is no app to help with this, but if it does exist, it either costs a
lot of money, or will be almost impossible to use for what you want
(boiling two voice samples down to a speaker-independent single similarity
number... the mind boggles at the possible number of ways of defining that).
Quite possibly both.

If you *do* know something about the math, which, by the way, is graduate
level+, then you'd do better to go look at the open source voice
recognition systems and ask on those mailing lists. 

No matter how you slice it, this is not a Python problem, this is an
intense voice recognition algorithm problem that would make a good PhD
thesis. I have no idea if it has already been done and you will likely get
much better help from such a community where people might know that. I am
aware of the CMU Sphinx project, which should get you started Googling.
Good luck; it's a great idea, but if somebody somewhere hasn't already
done it, it's an extremely tough one.

(Theoretically, it's probably not a horrid problem, but my intuition leads
me to believe that turning it into a *useful product*, that corresponds to
what humans would say is similar, will probably be a practical
nightmare. Plus it'll be highly language dependent; a similarity algorithm
for Chinese probably won't work very well for English and vice versa. All
this, and you *could* just play the two sounds back to the human and let
their brain try to understand it... ;-) )

Waiting for the message pointing to the Sourceforge project that
implemented this three years ago... 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: pynetwork 2.25

2005-04-30 Thread Kay Schluehr

[EMAIL PROTECTED] wrote:
 Pynetwork is a graph library, my first SourceForge project:

 http://sourceforge.net/projects/pynetwork/

 It included tests, some demo, some premilinary docs, and some images.
 You can see some screenshoots on the SourceForge page for them.
 I know about 5-6 other graph libraries for Python, one even in C++
 (Boost).

What is wrong with the other librarys that they can't be approved?

Kay

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


[ python-Feature Requests-1191699 ] make slices pickable

2005-04-30 Thread SourceForge.net
Feature Requests item #1191699, was opened at 2005-04-28 08:44
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1191699group_id=5470

Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Sebastien de Menten (sdementen)
Assigned to: Nobody/Anonymous (nobody)
Summary: make slices pickable

Initial Comment:
As suggested  by the summary, provide pickability of 
slices by default.
Currently one has to use copy_reg module to register 
slices as pickables.

--

Comment By: Raymond Hettinger (rhettinger)
Date: 2005-04-30 07:32

Message:
Logged In: YES 
user_id=80475

Use cases?

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1191699group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1193061 ] Python and Turkish Locale

2005-04-30 Thread SourceForge.net
Bugs item #1193061, was opened at 2005-04-30 20:37
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1193061group_id=5470

Category: Unicode
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: S.Ça#287;lar Onur (caglar)
Assigned to: M.-A. Lemburg (lemburg)
Summary: Python and Turkish Locale

Initial Comment:
On behalf of this thread;

http://mail.python.org/pipermail/python-dev/2005-April/052968.html

As described in
http://www.i18nguy.com/unicode/turkish-i18n.html [ How
Applications Fail With Turkish Language
] , Turkish has 4 i in their alphabet. 

Without --with-wctype-functions support Python convert
these characters locare-independent manner in
tr_TR.UTF-8 locale. So all conversitons maps to i or
I which is wrong in Turkish locale. 

So if Python Developers will remove the wctype
functions from Python, then there must be a
locale-dependent upper/lower funtion to handle these
characters properly.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1193061group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Feature Requests-1191699 ] make slices pickable

2005-04-30 Thread SourceForge.net
Feature Requests item #1191699, was opened at 2005-04-28 13:44
Message generated for change (Comment added) made by sdementen
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1191699group_id=5470

Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Sebastien de Menten (sdementen)
Assigned to: Nobody/Anonymous (nobody)
Summary: make slices pickable

Initial Comment:
As suggested  by the summary, provide pickability of 
slices by default.
Currently one has to use copy_reg module to register 
slices as pickables.

--

Comment By: Sebastien de Menten (sdementen)
Date: 2005-04-30 18:02

Message:
Logged In: YES 
user_id=820079

Use case for pickable slices. 
Let A be a numeric array of size M x N. We want to consider 
sub-arrays in this array like A[:4, :] (the first 4 lines of the 
array). 
If we want to store both the array and the information of 
sub-arrays structures, we need to store slices (we can also 
store start/end indices of the array ... but this is call a slice 
so it would be better to have pickable slices). 
 
In fact, whenever one wants to write generic algorithm 
working on sublist of lists or subarrays of arrays or 
sub-items of collection of items, it is nicer to use slice 
objects explicitly and so store them also explicitly. 
 

--

Comment By: Raymond Hettinger (rhettinger)
Date: 2005-04-30 12:32

Message:
Logged In: YES 
user_id=80475

Use cases?

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1191699group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1193099 ] Embedded python thread crashes

2005-04-30 Thread SourceForge.net
Bugs item #1193099, was opened at 2005-04-30 12:03
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1193099group_id=5470

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: ugodiggi (ugodiggi)
Assigned to: Nobody/Anonymous (nobody)
Summary: Embedded python thread crashes

Initial Comment:
The following code crashes about 1/3 of the times. 

My platform is Python 2.4.1 on WXP (I tried the release
version from the msi and the debug version built by me). 
I can reproduce the same behavior on another wxp
system, under python 2.4. 

The crash happens (in the python thread) while the main
thread is in Py_Finalize. 
I traced the crash to _Py_ForgetReference(op) in
object.c at line 1847, where I have op-_ob_prev == NULL. 

The open file seems to be the issue, since if I remove
all the references to the file I cannot get the program
to crash.

Cheers and ciao 

Ugo 

// TestPyThreads.cpp
// 
#include windows.h // Sleep
#include Python.h 

int main() 
{ 
PyEval_InitThreads(); 
Py_Initialize(); 
PyGILState_STATE main_restore_state =
PyGILState_UNLOCKED; 
PyGILState_Release(main_restore_state); 

// start the thread 
{ 
PyGILState_STATE state =
PyGILState_Ensure(); 
int trash = PyRun_SimpleString( 
import thread\n 
import time\n 
def foo():\n 
  f =
open('pippo.out', 'w', 0)\n 
  i = 0;\n 
  while 1:\n 
f.write('%d\n'%i)\n 
time.sleep(0.01)\n 
i += 1\n 
t =
thread.start_new_thread(foo, ())\n 
); 
PyGILState_Release(state); 
} 

// wait 300 ms 
Sleep(300); 

PyGILState_Ensure(); 
Py_Finalize(); 
return 0; 
} 
 


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1193099group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Feature Requests-1193128 ] 'str'.translate(None) = identity translation

2005-04-30 Thread SourceForge.net
Feature Requests item #1193128, was opened at 2005-04-30 13:31
Message generated for change (Settings changed) made by bokr
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1193128group_id=5470

Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Bengt Richter (bokr)
Assigned to: Raymond Hettinger (rhettinger)
Summary: 'str'.translate(None) = identity translation

Initial Comment:
This feature would permit passing None as the first
argument to str.translate in place of  an identity
translation
table like ''.join([[chr(i) for i in xrange(256)])

This should be handy for deleting characters, e.g., as in

 s = s.translate(None, delchars)

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1193128group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1193180 ] Strange os.path.exists() results with invalid chars

2005-04-30 Thread SourceForge.net
Bugs item #1193180, was opened at 2005-04-30 23:13
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1193180group_id=5470

Category: Windows
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Daniele Varrazzo (dvarrazzo)
Assigned to: Nobody/Anonymous (nobody)
Summary: Strange os.path.exists() results with invalid chars

Initial Comment:
Hi,

when there are invalid chars in a filename, os.path.exists
() behaves oddly, returning True.

The bug appears on win32 system, not on unix ones. 
Thus is probably related to some weird windows api call 
and doesn't maybe worth fixing.

Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 
32 bit (Intel)] on win32
Type help, copyright, credits or license for more 
information.
 import os
 f = file(a_b, w)
 f.close()
 os.listdir(.)
['a_b']
 os.path.exists(ab)
True
 os.path.exists(ab)
True

And, even more strange...

 os.path.exists(a)
True
 os.path.exists(a)
False

Better answers would have been:
  * False
  * raise ValueError


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1193180group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1193190 ] MACOSX_DEPLOYMENT_TARGET checked incorrectly

2005-04-30 Thread SourceForge.net
Bugs item #1193190, was opened at 2005-04-30 20:15
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1193190group_id=5470

Category: Distutils
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Bob Ippolito (etrepum)
Assigned to: Bob Ippolito (etrepum)
Summary: MACOSX_DEPLOYMENT_TARGET checked incorrectly

Initial Comment:
MACOSX_DEPLOYMENT_TARGET should be checked to be = 
the configure time value (or not set).  Currently, it checks for 
equality.

For example, this is necessary in order to use a Python built for Mac 
OS X 10.3 but build an extension with features specific to Mac OS X 
10.4.

Backport candidate to 2.4, patches attached.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1193190group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >