Initial release of new PythonQt binding

2006-11-15 Thread Florian Link
PythonQt is a dynamic and lightweight script binding of the Qt4 
framework to the Python language.
It can be easily embedded into Qt4 applications and makes any QObject 
derived
object scriptable via Python without the need of wrapper code generation.

The first public beta release is available as source code under the LGPL 
license.
The binding has been used for quite a while in a commercial product
and we are looking for new developers to join the project on Source Forge.

http://pythonqt.sourceforge.net/
http://sourceforge.net/projects/pythonqt/

PA HREF=http://pythonqt.sourceforge.net/;PythonQt 0.9/A - dynamic 
scripting binding of Qt4 to Python (15-11-06)

-- 

Florian Link
MeVis Research
Universitaetsallee 29,  D-28359 Bremen,  Germany
http://www.mevis.de  email: [EMAIL PROTECTED]
voice: +49 421 218 7772,   fax: +49 421 218 4236


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

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Re: refactoring so that multiple changes can be made with one variable?

2006-11-15 Thread Steven D'Aprano
On Tue, 14 Nov 2006 10:41:53 -0500, John Salerno wrote:

 My code is below. For now I'm focusing on the lines where health (and 
 armor) are increased in each character class. Let's say I decided to 
 change the amount of increase in the future. As it is now, I'd have to 
 go to each character class and change the number so that each is still 
 in a good relation to the other (right now: 3, 2, 1; later: perhaps 4, 
 3, 2, 1, if I added a new class -- i.e., change Fighter from 3 to 4, 
 Thief from 2 to 3, in other words increase them all by 1). So instead of 
 changing each one, is there a simple, clean way of just changing a 
 single number so that this change is reflected in all classes? Hope that 
 makes sense.

Cutting your code down to the minimum that exhibits the behaviour you want:

class Character(object):
def __init__(self, name, strength, dexterity, intelligence):
self.name = name
self.health = 10
# and so on...
self.adjust_attributes()
def adjust_attributes(self):
pass


class Fighter(Character):
def adjust_attributes(self):
self.health += 3

class Thief(Character):
def adjust_attributes(self):
self.health += 2

etc.

Sounds like you want some sort of factory function that returns a class:

# WARNING: untested
def make_character_class(name, adjustments):
class klass(Character):
_adjustments = {}
def adjust_attributes(self):
for key, value in self._adjustments.items():
x = getattr(self, key)
setattr(self, key, x + item)
 
setattr(klass, klass.__name__, name)
setattr(klass, klass._adjustments, adjustments)
return klass


And now you use it like this:

Fighter = make_character_class('Fighter', {'health': 3})
Thief = make_character_class('Thief', {'health': 2})

Now you can easily change the adjustments, all in just a few lines.

Here's another idea:

character_adjustments = { 'Fighter': {'health': 3}, 
'Thief': {'health': 2}, 
'Mage': {'intelligence': 3, 'strength': -1}
}

and change the make_character_class factory function above to only take a
single argument, name. Now if you decide you want to *programmatically*
adjust the adjustments, you can do this:

# still untested...
for key in character_adjustments:
for attribute, value in key.items():
# adjust the values to make up for my poor choices
character_adjustments[key][attribute] = value + 1

(but of course you must do this BEFORE creating your character classes!)


And last but most certainly not least, you can separate the adjustment
values into (say) an INI file, read them in at run-time and pass those
values to the factory function above. Then write another function which
walks through the INI file, adjusting the values in place as needed. This
is obviously going to take the most work, so I strongly suggest you don't
go down this path unless you really have to.


-- 
Steven D'Aprano 

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


Re: reduce to be removed?

2006-11-15 Thread Robert Kern
Antoon Pardon wrote:
 On 2006-11-15, Robert Kern [EMAIL PROTECTED] wrote:
 Dustan wrote:

 2. While I haven't taken a good look at NumPy, my intuition tells me it
 won't work with complex data types, which wouldn't work for me at all.

 Am I correct on that second one?
 No. numpy can make arrays of Python objects in addition to arrays of double,
 unsigned int, etc.
 
 Does numpy still gain you much if you have arrays of Python objects?

It depends on what you want out of it. You won't get fast math, but you will get
convenient multidimensional indexing, slicing, stacking, reshaping, and
transposition.

-- 
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco

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


Re: reading csv problem

2006-11-15 Thread [EMAIL PROTECTED]
Thank you.


On Nov 15, 1:33 pm, Cameron Walsh [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] wrote:
  Hello,

  I use csv to take information from file.
  import csv
  reader = csv.reader(open('t.csv'))

  for row in reader:
  print row # it is perfectly OK

  -
  But If I use this code I have problem
  import csv
  reader = csv.reader(open('t.csv'))

  for row in reader:
  print row # it is perfectly OK
  for row in reader:
  print row # it is not printed on the monitor???

  Why does only the first print row work here?

  TIA,
  ajikoeBecause reader is an iterator and has no means of going back to its
 beginning.

 You could make a list out of it:
 lines = list(csv.reader(open('t.csv')))
 for row in lines:
   print row
 for row in lines:
   print row
 
 Hope it helps,
 
 Cameron.

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


Re: Tkinter: Strange behavior using place() and changing cursors

2006-11-15 Thread Eric Brunel
On Tue, 14 Nov 2006 17:45:52 +0100, Mudcat [EMAIL PROTECTED] wrote:
 The problem is I need the ability to change it dynamically. I don't
 want the cursor to be the double_arrow the whole time the mouse hovers
 inside that frame. It's supposed to be a resize arrow when the mouse is
 on the frame border, and regular cursor once it passes to the inner
 part of the frame.

Why don't you create a Frame for the inside with no border, and another  
Frame for the border? This way, you can have a cursor setting for each of  
them, i.e one for the inside and one for the border.

HTH
-- 
python -c print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: FAQ: How do I calculate what quoted strings and numbers mean?

2006-11-15 Thread p . lavarre
 A FAQ that discusses good ways to handle Python-like literals and
 expressions would definitely be a useful addition to the FAQ.  if nobody
 else does anything about it, I'll get there sooner or later.

Thank you.

   eval(source, {'builtins': {}}) works enough like an evaluator of
   literals to ...

 eval(source, {'builtins': {}}) doesn't prevent you from using built-ins,
 though.  it's spelled __builtins__, not builtins:

   eval(len('10'), {builtins: {}})
 2
   eval(len('10'), {__builtins__: {}}
 Traceback (most recent call last):
File stdin, line 1, in module
File string, line 1, in module
 NameError: name 'len' is not defined

Grin.  Indeed, newbie me, I didn't know that either, thank you.

I was happy enough when I saw an improvement like:

 import os
 result = eval(os.system('pwd'))
.../Desktop
 result = eval(os.system('pwd'), {whatever: {}})
Traceback (most recent call last):
  File stdin, line 1, in module
  File string, line 1, in module
NameError: name 'os' is not defined


Now I fear that I must have copied the misspelled builtins from some
page that's still out there somewhere misleading people ...

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


Re: Py3K idea: why not drop the colon?

2006-11-15 Thread Antoon Pardon
On 2006-11-15, Steven D'Aprano [EMAIL PROTECTED] wrote:
 On Tue, 14 Nov 2006 12:01:05 +, Antoon Pardon wrote:

 On 2006-11-13, Ben Finney [EMAIL PROTECTED] wrote:
 Michael Hobbs [EMAIL PROTECTED] writes:

 To be clear, this is the actual thrust of my argument. It seems
 redundant to have *both* line continuations and colons in compound
 statements.

 Why are you trying to remove redundancy?
 
 Why not? My impression is that removing redundancy is considered
 a positive thing here in c.p.l.

 Redundancy in *what*?

Redundancy in whatever proposal the opponent doesn't like.

 Redundancy is not something to be valued for its own sake. It is only
 valuable when it actually gains you something.

In the same way it is not something to be eliminated for its own
sake. But if someone doesn't like a particulare proposal and
the proposal happens to introduce some redundancy then there is
a reasonable chance the proposal will be dismissed by simply
observing that it introduces redundancy.

 The question is not is the colon redundant? but is the colon useful
 despite, or even because, its redundancy?. There are two schools of
 thought:

 (1) Yes, it is useful, *because* of its redundancy -- it helps the human
 reader parse and comprehend the source code.
 Evidence given: usability studies by the ABC project.

I wonder, did this project also studied the readability of:

  if a == b then

 (2) No, it is not useful, because the computer parser doesn't need it.
 Evidence given: it seems to me repeated loudly until our ears bleed.

A pity that no such study seems to exists concerning code that uses
only indentation to mark structure and code that uses indentation
and some kind of delimiter for showing the boundaries of (sub)
structures. Because the evidence for end markers not being usefull
seems to fall in the same category as (2) here above.

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


Re: FAQ: How do I calculate what quoted strings and numbers mean?

2006-11-15 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

 I was happy enough when I saw an improvement like:
 
 import os
 result = eval(os.system('pwd'))
 .../Desktop
 result = eval(os.system('pwd'), {whatever: {}})
 Traceback (most recent call last):
   File stdin, line 1, in module
   File string, line 1, in module
 NameError: name 'os' is not defined

sure, but the os module isn't very far away:

  result = eval(__import__('os').system('pwd'), {whatever: {}})
/home/fredrik

/F

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


Difference

2006-11-15 Thread Hodren Naidoo
Can someone plz tell me the differences between redirect and traverse in
python metadata?
-- 
Regards
Hodren Naidoo

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


Re: Py3K idea: why not drop the colon?

2006-11-15 Thread Christophe
Stephen Eilert a écrit :
 Well, I *hate* underscores with a passion. So it is kinda frustrating
 that I *have* to say __init__. The fact that the coding conventions
 for Python suggest things such as methods_called_this_or_that do not
 help. Everything else seems fine, since if there's voodoo involved, it
 had best be sticking out from the text in big, bloody, blinking, red
 letters.
 
 I know, there's noone preventing me from doing otherwise (except for
 that blasted __init__). I'd like to follow the pack here, tho.
I'm sure a carefully crafted metaclass can be used to automaticaly 
convert any init function to __init__ ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Difference

2006-11-15 Thread Fredrik Lundh
Hodren Naidoo wrote:

 Can someone plz tell me the differences between redirect and traverse in
 python metadata?

it's not clear what you mean by redirect, traverse or python 
metadata, so that's not very likely.

/F

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


Re: CORBA: Fnorb Problems

2006-11-15 Thread rodmc
Thanks the fix you provided me with workds perfectly. 

Best,

rod

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


Re: A question on Encoding and Decoding.

2006-11-15 Thread rbsharp
Hello,
I think this remark is more to the point. In my experience, the general
problem is that python operates with the default encoding ascii as in
sys.getdefaultencoding(). It is possible to set the defaultencoding in
sitecustomize.py, with sys.setdefaultencoding('latin1'). I have placed
sitecustomize.py in Lib/site-packages. It is not possible to set the
encoding once python has started. Setting the encoding only works if
you can bind yourself to this one encoding and is therefore no general
fix.
The only reasonable way to work is to get your strings into unicode
(and sometimes back out again).
If for instance you type:
s = äÄöÖüÜß and then try
us = unicode(s) you will get a traceback identical to yours.
However:
us = unicode(s,'latin1')
will work. If however to try:
print us
you will get another traceback.

try:
 print %r % us
u'\x84\x8e\x94\x99\x81\x9a\xe1'
Even if it is not pretty, at least the program won't crash.
You can get a better result with:
 print us.encode('latin1')
äÄöÖüÜß

The whole topic can get tedious at times, but be assured,
PyExcelerator, for writing, and xlrd for reading Excel files do work,
with unicode, both in the content and in the sheetnames. PyExcelerator
may be able to read Excel Sheets but not nearly as well as xlrd, which
works wonderfully.

regards,
Richard Sharp


Fredrik Lundh wrote:
 kath wrote:

  Also python IDLE is able to output the same character corretly when I
  say print and why not I?

 probably because IDLE's interactive window is Unicode-aware, but your terminal
 is not.
 
 /F

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

Re: Is python for me?

2006-11-15 Thread rodmc
[EMAIL PROTECTED] wrote:

 By large I mean an application with intensive operations, such as a
 fancy GUI maybe a couple of threads, accessing a database, etc.

I am still fairly new to Python, I only started using it at the start
of this year and then stopped for a while. However the project I
undertook at the start of the year built a system using the
technologies above, in addition it used SVG graphics, Jabber Instant
messaging and the windows API. All of these were built within threads
and used a client/server architecture.  I have also built some small
wxPython based GUI's.

Overall I found Python ideal for the task, both in terms of development
time and reliability - although my knowledge of the Windows API was not
what it should have been (I mainly used Linux/Mac OS X user) so I
experienced a few problems. Also there was a lack of good online docs
about Python based Windows API calls.

You can interface to a few databases very easily including MySQL and
SQLite. I have been using the latter recently for my task and it works
very well. Also I have found that using Stackless Python drastically
improves the reliability of thread based applications. Also performance
can be substantially improved by using the Psyco library, although I
have know it to make things worse.

Overall my experience of Python was very positive and this was in no
small part due to the help I received from people here.

I hope this helps.

Best,

Rod

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


Re: Py3K idea: why not drop the colon?

2006-11-15 Thread Steven D'Aprano
On Wed, 15 Nov 2006 08:22:46 +, Antoon Pardon wrote:

 Redundancy is not something to be valued for its own sake. It is only
 valuable when it actually gains you something.
 
 In the same way it is not something to be eliminated for its own
 sake.

On the contrary, redundancy implies more work somewhere: e.g. more work
for the parser, more effort needed by the python-dev crew, bigger
binaries, larger code bases, more complex test suites, slower development,
longer downloads. Whatever the nature of the redundant thing, there will
be a cost to it. If that cost isn't outweighed by some advantage it should
be eliminated merely because it is redundant and therefore a cost we could
do without.

I suppose, theoretically, if you could find some cost-free redundancy,
something that just happened for free, we would have no reason to care
whether it existed or not. But since cost-free redundancies don't exist,
or at least are very rare, we should prefer to remove redundancies UNLESS
they offer some advantage.



-- 
Steven.

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


Re: Py3K idea: why not drop the colon?

2006-11-15 Thread Antoon Pardon
On 2006-11-15, Steven D'Aprano [EMAIL PROTECTED] wrote:
 On Wed, 15 Nov 2006 08:22:46 +, Antoon Pardon wrote:

 Redundancy is not something to be valued for its own sake. It is only
 valuable when it actually gains you something.
 
 In the same way it is not something to be eliminated for its own
 sake.

 On the contrary, redundancy implies more work somewhere: e.g. more work
 for the parser, more effort needed by the python-dev crew, bigger
 binaries, larger code bases, more complex test suites, slower development,
 longer downloads. Whatever the nature of the redundant thing, there will
 be a cost to it. If that cost isn't outweighed by some advantage it should
 be eliminated merely because it is redundant and therefore a cost we could
 do without.

It you want to put it in those terms fine. It doesn't change the fact
that when someone doesn't like some proposal that happens to introduce
redundancy here in c.l.p, there is a reasonable chance that the proposal
will be dismissed with the simple observation that it introduces redundancy
without further reference to possible costs or benefits of the specific
redundancy.

IME there is a lot of redundancy that has benefits. So there is no
reason to dismiss a proposal simply on the grounds that it introduces
some redundancy. Something that seems to happen a lot here.

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


Re: Using signal.alarm to terminate a thread

2006-11-15 Thread Adrian Casey
Nick Craig-Wood wrote:

 Adrian Casey [EMAIL PROTECTED] wrote:
  Adrian Casey [EMAIL PROTECTED] wrote:
  import os, pexpect, threading
  
  def runyes():
  print Running yes command...
  pexpect.run('yes', timeout=5)
  
  t = threading.Thread(target=runyes)
  t.start()
  t.join()
  
  The timeout parameter will not work in this case.  If you run the sample
  code above, it will run forever.
 
 The above runs just fine for me, stopping after 5 seconds.  Did you
 try it?
 
  The 'yes' command presents a class of command which can not be
  easily be handled by pexpect.
 
 Worked for me under Debian/testing.
 
 As far as I know, mixing threads and signals is OK provided the
 parent creates the alarm.
 
 There are so many pitfalls here that I advise you not to try.  From
 the linuxthreads FAQ
 
   J.3: How shall I go about mixing signals and threads in my program?
 
   The less you mix them, the better. Notice that all pthread_*
   functions are not async-signal safe, meaning that you should not
   call them from signal handlers. This recommendation is not to be
   taken lightly: your program can deadlock if you call a pthread_*
   function from a signal handler!
 
   The only sensible things you can do from a signal handler is set a
   global flag, or call sem_post on a semaphore, to record the delivery
   of the signal. The remainder of the program can then either poll the
   global flag, or use sem_wait() and sem_trywait() on the semaphore.
 
   Another option is to do nothing in the signal handler, and dedicate
   one thread (preferably the initial thread) to wait synchronously for
   signals, using sigwait(), and send messages to the other threads
   accordingly.
 
 Note also that the signal can be delivered to any thread which
 complicates things.
 
I'm running Kubuntu 06-06 with python 2.4.3 and the above code runs forever
at 100% cpu utilization.  I shall look into semaphores. However, that means
another thread whose sole purpose is to watch the semaphore.

Thanks for you help.

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


Re: Decimal() instead of float?

2006-11-15 Thread Fredrik Lundh
Steve Holden wrote:

 It /would/ be nice to see Decimal() become the default.  I cannot 
 imagine why in an otherwise human enough language, math wouldn't be 
 included in that without going out of one's way to do it.  :-)

 Speed has a lot to do with it. Have you timed some decimal operations 
 against their floating-point counterparts? It might be possible to build 
 a version of Python that used decimal instead of floating-point but it 
 certainly wouldn't be trivial: consider the use of C language libraries 
 that know nothing of Python's decimal representation.

judging from the various decimal FAQ:s, I think it's a bit naive to 
think that using Decimal instead of float would somehow make everything 
just work:

http://www2.hursley.ibm.com/decimal/decifaq.html
http://effbot.org/pylib/decimal.htm#decimal-faq

(btw, the OP mentioned in private mail that he wanted to store 
geographical coordinates in decimal because floats kept messing things 
up, but given that a 64-bit float can hold enough decimal digits to 
represent a geographical coordinate with sub-millimeter precision on a 
global scale, I'm not sure I buy that argument.  I suspect he was just 
tricked by the usual repr(1.15) != 1.15 issue.  and seriously, under-
standing the various aspects of floats and decimals is utterly trivial 
compared to all the nearly-magical things you need to understand to be 
able to do geographical calculations at a sub-millimeter scale.  heck, 
even sub-kilometer stuff is pretty hard to get right ;-)

/F

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


Problem reading with bz2.BZ2File(). Bug?

2006-11-15 Thread Clodoaldo Pinto Neto
When comparing two files which should be equal the last line is
different:

The first file is a bzip2 compressed file and is read with
bz2.BZ2File()
The second file is the same file uncompressed and read with open()

The first file named file.txt.bz2 is uncompressed with:

$ bunzip2 -k file.txt.bz2

To compare I use this script:
###
import bz2

f1 = bz2.BZ2File(r'file.txt.bz2', 'r')
f2 = open(r'file.txt', 'r')
lines = 0
while True:
   line1 = f1.readline()
   line2 = f2.readline()
   if line1 == '':
  break
   lines += 1
   if line1 != line2:
  print 'line number:', lines
  print repr(line1)
  print repr(line2)
f1.close()
f2.close()
##

The offending file is 5.5 MB. Sorry, i could not reproduce this problem
with a smaller file.
http://fahstats.com/img/file.txt.bz2

Regards, Clodoaldo Pinto Neto

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


Re: Problem reading with bz2.BZ2File(). Bug?

2006-11-15 Thread Fredrik Lundh
Clodoaldo Pinto Neto wrote:

 The offending file is 5.5 MB. Sorry, i could not reproduce this problem
 with a smaller file.

but surely you can post the repr() of the last two lines?

/F

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


Re: Problem reading with bz2.BZ2File(). Bug?

2006-11-15 Thread Clodoaldo Pinto Neto

Fredrik Lundh wrote:
 Clodoaldo Pinto Neto wrote:

  The offending file is 5.5 MB. Sorry, i could not reproduce this problem
  with a smaller file.

 but surely you can post the repr() of the last two lines?

This is the output:

$ python bzp.py
line number: 588317
'\x07'
''

Clodoaldo

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


biopython SProt

2006-11-15 Thread km
Hi all,

Biopython's SProt module doesnt seem to work with current Uniprot KB . 
do anyone have a parser to read Uniprot format files ? 

regards,
KM





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

Re: Problem reading with bz2.BZ2File(). Bug?

2006-11-15 Thread Leo Kislov
Clodoaldo Pinto Neto wrote:
 Fredrik Lundh wrote:
  Clodoaldo Pinto Neto wrote:
 
   The offending file is 5.5 MB. Sorry, i could not reproduce this problem
   with a smaller file.
 
  but surely you can post the repr() of the last two lines?

 This is the output:

 $ python bzp.py
 line number: 588317
 '\x07'
 ''

Confirmed on windows with 2.4 and 2.5:

C:\p\Python24\python.exe bzp.py
line number: 588317
'\x1e'
''

C:\p\Python25\python.exe bzp.py
line number: 588317
'\x1e'
''

Looks like one byte of garbage is appended at the end of file. Please
file a bug report. As a workaround rU mode seems to work fine for
this file.

  -- Leo

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


Re: numpy/scipy: error of correlation coefficient (clumpy data)

2006-11-15 Thread robert
sturlamolden wrote:
 robert wrote:
 
 t = r * sqrt( (n-2)/(1-r**2) )
 
 yet too lazy/practical for digging these things from there. You obviously 
 got it - out of that, what would be a final estimate for an error range of r 
 (n big) ?
 that same const. * (1-r**2)/sqrt(n) which I found in that other document ?
 
 I gave you th formula. Solve for r and you get the confidence interval.
 You will need to use the inverse cumulative Student t distribution.
 
 Another quick-and-dirty solution is to use bootstrapping.
 
 from numpy import mean, std, sum, sqrt, sort
 from numpy.random import randint
 
 def bootstrap_correlation(x,y):
idx = randint(len(x),size=(1000,len(x)))
bx = x[idx] # reasmples x with replacement
by = y[idx] # resamples y with replacement
mx = mean(bx,1)
my = mean(by,1)
sx = std(bx,1)
sy = std(by,1)
r = sort(sum( (bx - mx.repeat(len(x),0).reshape(bx.shape)) *
   (by - my.repeat(len(y),0).reshape(by.shape)), 1) /
 ((len(x)-1)*sx*sy))
#bootstrap confidence interval (NB! biased)
return (r[25],r[975])
 
 
 My main concern is, how to respect the fact, that the (x,y) points may not 
 distribute well along the regression line.
 
 The bootstrap is non-parametric in the sense that it is distribution
 free.
 

thanks for the bootstrap tester. It confirms mainly the r_stderr = 
(1-r**2)/sqrt(n) formula. The assymetry of r (-1..+1) is less a problem.
Yet my main problem, how to respect clumpy distribution in the data points, is 
still the same.
In practice think of a situation where data out of an experiment has an unkown 
damping/filter (or whatever unkown data clumper) on it, thus lots of redundancy 
in effect. 
An extreme example is to just duplicate data:

 x ,y =[0.,0,0,0,1]*10 ,[0.,1,1,1,1]*10
 xx,yy=[0.,0,0,0,1]*100,[0.,1,1,1,1]*100
 correlation(x,y)
(0.25, 0.132582521472, 0.25, 0.75)
 correlation(xx,yy)
(0.25, 0.0419262745781, 0.25, 0.75)
 bootstrap_correlation(array(x),array(y))
(0.148447544378, 0.375391432338)
 bootstrap_correlation(array(xx),array(yy))
(0.215668822617, 0.285633303438)
 

here the bootstrap test will as well tell us, that the confidence intervall 
narrows down by a factor ~sqrt(10) - just the same as if there would be 10-fold 
more of well distributed new data. Thus this kind of error estimation has no 
reasonable basis for data which is not very good.

The interesting task is probably this: to check for linear correlation but 
weight clumping of data somehow for the error estimation.
So far I can only think of kind of geometric density approach...

Or is there a commonly known straight forward approach/formula for this problem?
In this formula which I can remember weakly somehow - I think there were other 
basic sum terms like sum_xxy, sum_xyy,.. in it (which are not needed for the 
formula for r itself )


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


Re: multi split function taking delimiter list

2006-11-15 Thread Paddy

Paddy wrote:

 Paddy wrote:

  [EMAIL PROTECTED] wrote:
 
   Hi, I'm looking for something like:
  
   multi_split( 'a:=b+c' , [':=','+'] )
  
   returning:
   ['a', ':=', 'b', '+', 'c']
  
   whats the python way to achieve this, preferably without regexp?
  
   Thanks.
  
   Martin
 
  I resisted my urge to use a regexp and came up with this:
 
   from itertools import groupby
   s = 'apple=blue+cart'
   [''.join(g) for k,g in groupby(s, lambda x: x in '=+')]
  ['apple', '=', 'blue', '+', 'cart']
  
 
  For me, the regexp solution would have been clearer, but I need to
  stretch my itertools skills.
 
  - Paddy.
 Arghhh!
 No colon!
 Forget the above please.

 - Pad.

With colon:

 from itertools import groupby
 s = 'apple:=blue+cart'
 [''.join(g) for k,g in groupby(s,lambda x: x in ':=+')]
['apple', ':=', 'blue', '+', 'cart']
 

- Pad.

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


Re: refactoring so that multiple changes can be made with one variable?

2006-11-15 Thread Neil Cerutti
On 2006-11-15, Dennis Lee Bieber [EMAIL PROTECTED] wrote:
 On Wed, 15 Nov 2006 18:57:39 +1100, Steven D'Aprano
[EMAIL PROTECTED] declaimed the following in
 comp.lang.python:
 And last but most certainly not least, you can separate the
 adjustment values into (say) an INI file, read them in at
 run-time and pass those values to the factory function above.
 Then write another function which walks through the INI file,
 adjusting the values in place as needed. This is obviously
 going to take the most work, so I strongly suggest you don't
 go down this path unless you really have to.

 Nice to see I wasn't the only one to consider extending to an
 INI file for this G

Coincidentally, I'm just reading The Pragmattic Programmer for
the first time. One of guidelines is to pry the details ut of the
code if they might change. The above advice seems like a perfect
example.

-- 
Neil Cerutti
For those of you who have children and don't know it, we have a
nursery downstairs. --Church Bulletin Blooper
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sqlite3 views, if not exists clause

2006-11-15 Thread Josh
Tim Golden [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

| Not a bug with the sqlite3 api that comes with python 2.5. as such,
| since .execute pretty much passes its parameters through to the database
| engine. Rather, the syntax you're using is a relatively late addition
| to the sqlite libs -- at least it fails on my 3.2.1 version of the
| sqlite3 commmand-line tool, but succeeds on the latest download (3.3.8).
|
| I presume therefore that you build of Python is linked against an
| older version of the sqlite libraries / DLL.

Exactly right. Since the sqlite3 interface hasn't changed, the fix was 
simply to copy the newest sqlite3.dll into the python dll directory. Now I 
no longer have to catch and ignore the already exists exception thrown by 
python. Thanks! 


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


Re: Using signal.alarm to terminate a thread

2006-11-15 Thread Nick Craig-Wood
Adrian Casey [EMAIL PROTECTED] wrote:
  I'm running Kubuntu 06-06 with python 2.4.3 and the above code runs forever
  at 100% cpu utilization.

Interesting... I wonder if that is a fixed bug.

On Debian/etch with python-pexpect 2.1-1 I get

Python 2.4.4c0 (#2, Jul 30 2006, 15:43:58) 
[GCC 4.1.2 20060715 (prerelease) (Debian 4.1.1-9)] on linux2
Type help, copyright, credits or license for more information.
 import os, pexpect, threading
 def runyes():
... print Running yes command...
... pexpect.run('yes', timeout=5)
... 
 t = threading.Thread(target=runyes)
 t.start()
 Running yes command...
t.join()
 
   

Wheras on Ubuntu/dapper with python-pexpect 0.999-5ubuntu2 I get

Python 2.4.3 (#2, Apr 27 2006, 14:43:58) 
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
Type help, copyright, credits or license for more information.
 import os, pexpect, threading
 def runyes():
... print Running yes command...
... pexpect.run('yes', timeout=5)
... 
 t = threading.Thread(target=runyes)
 t.start()
 Running yes command...
t.join()
[never returns]

I'd guess at differences between the pexpect versions.  You could try
the pexpect from debian/testing easily enough I expect.

-- 
Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem reading with bz2.BZ2File(). Bug?

2006-11-15 Thread Clodoaldo Pinto Neto
Leo Kislov wrote:
 Confirmed on windows with 2.4 and 2.5:

 C:\p\Python24\python.exe bzp.py
 line number: 588317
 '\x1e'
 ''

 C:\p\Python25\python.exe bzp.py
 line number: 588317
 '\x1e'
 ''

 Looks like one byte of garbage is appended at the end of file. Please
 file a bug report.

Bug number 1597011

Clodoaldo

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


Re: Python speed on Solaris 10

2006-11-15 Thread Chris Miles
Since my post I have compiled Python 2.4.3 with Sun Studio 11 with 
-fast option (on Solaris 10) which has produced the fastest version of 
Python I've been able to test on this hardware, including the CentOS 
Linux version (which I'm pleased about).

I haven't looked into more optimal gcc build options yet, so that may 
produce a faster build, but I am probably satisfied with what Sun Studio 
has given me for now.

Cheers,
Chris

[EMAIL PROTECTED] wrote:

 I noticed that speed difference, too. After running ./configure, I
 edited the resulting Makefile to pass -march=athlon-mp to the C
 compiler. ./configure seems to ignore CFLAGS, for example, so I just
 edited Makefile to suit my environment. You should set the values
 appropriate for you system, of course.
 
 I've also compiled Python using the Sun Studio compiler. Some tests
 were faster, some tests were slower.

-- 
http://chrismiles.info/

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


Re: Python v PHP: fair comparison?

2006-11-15 Thread walterbyrd
Luis M. González wrote:
 the new crop of web frameworks (Django, Turbo Gears, etc...).

  - Newer versions of mod_python require Apache 2.0, which few hosters
  have

 You can also get alder versions of mod_python. What's the problem?

The problem is that the system requirements for django and turbogears
are sky-high. I think Django requires Apache 2.0 (and maybe mod_python
3.x), and CherryPy (part of turbogears) requires Python 2.4. If you are
developing for a hosted environment, this can be a big problem. Few
enough hosters provide python to begin with, then add to that such
requirements as apache 2.0 - and you left with almost nothing.

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

RE: Python v PHP: fair comparison?

2006-11-15 Thread Demel, Jeff
-Original Message-
Behalf Of walterbyrd

The problem is that the system requirements for django and turbogears
are sky-high. I think Django requires Apache 2.0 (and maybe mod_python
3.x), and CherryPy (part of turbogears) requires Python 2.4. If you are
developing for a hosted environment, this can be a big problem. Few
enough hosters provide python to begin with, then add to that such
requirements as apache 2.0 - and you left with almost nothing.
--


That's true, but I was lucky enough to find webfaction.com for python
hosting, including Django.  Good prices and they know Python.  I think
they used to be python-hosting.com or something.

-Jeff
 

This email is intended only for the individual or entity to which it is 
addressed.  This email may contain information that is privileged, confidential 
or otherwise protected from disclosure. Dissemination, distribution or copying 
of this e-mail or any attachments by anyone other than the intended recipient, 
or an employee or agent responsible for delivering the message to the intended 
recipient, is prohibited. If you are not the intended recipient of this message 
or the employee or agent responsible for delivery of this email to the intended 
recipient, please notify the sender by replying to this message and then delete 
it from your system.  Any use, dissemination, distribution, or reproduction of 
this message by unintended recipients is strictly prohibited and may be 
unlawful.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python v PHP: fair comparison?

2006-11-15 Thread walterbyrd

Larry Bates wrote:

 I'd be surprised if there was more demand for PHP developers
 than Python developers.

Prepare to be surprised. From what I have seen demand for PHP
developers is off-the-scale higher than demand for Python developers.

If you search the job boards, then -IMO- it is only fair to not include
jobs where the language is listed as an also-ran. For example a typical
sys-admin job will list about 24 skills, and python is often  thrown
into the landry list. To my way of thinking, that is not really an ad
for a python developer.

Trying to be as fair as I can be, my research shows that demand for
developers where PHP is the primary is *far* higher than jobs where
Python is the primary skills.

Of course, at best, that only shows the demand part of the equation.
There is also the supply side to consider. From what I have seen for
salary offers for PHP developers, it may be fair to say that PHP
developers are a dime a dozen.

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


Re: Python v PHP: fair comparison?

2006-11-15 Thread walterbyrd

Bjoern Schliessmann wrote:
 walterbyrd wrote:

  - PHP has a lower barrier to entry

 Which kind of barrier do you mean -- syntax, availability, ...?


Putting php into a web-site is as easy as throwing some php code into a
my html file, and maybe giving the file a php extension. I can get php
hosting for $10 a year easy.

This may not be what you want for a major developement project, but the
barrier to entry is very low.

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


How to pass an argument to a python program open in IDLE?

2006-11-15 Thread tony . ha

Hello,

I have open a Python program in the
IDLE, but when I select the run module under run
menu, it
does not allow me to pass an argument
to my Python program! 
How do you pass an argument to a Python
program under the IDLE? Thanks for you help!


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

Re: Python v PHP: fair comparison?

2006-11-15 Thread Paul Boddie
walterbyrd wrote:

 The problem is that the system requirements for django and turbogears
 are sky-high. I think Django requires Apache 2.0 (and maybe mod_python
 3.x), and CherryPy (part of turbogears) requires Python 2.4. If you are
 developing for a hosted environment, this can be a big problem. Few
 enough hosters provide python to begin with, then add to that such
 requirements as apache 2.0 - and you left with almost nothing.

I guessed that this was what you meant by PHP has a lower barrier to
entry, even though others chose to interpret that in the context of
how easy or consistent the technology would seem to be in comparison
with Python. While it's true that PHP seems to be widely available, and
the newcomer can probably get immediate results by just publishing a
few files, the availability of relatively inexpensive virtual server
hosting seems to undermine claims that no-one supports Python together
with a modern selection of server programs.

I've been tempted to get some dynamic hosting at some point, and the
major difference between now and the last time I looked into this
(possibly about three or so years ago), is that back then you had to
spend a fair amount of money to get anything other than an
inconveniently accessible CGI directory requiring a version of
cgipython that could run on the inconveniently chosen version of
FreeBSD so beloved of certain hosting providers. Now, you can get a
virtual server populated with your own GNU/Linux distribution, or if
that sounds like too much work, there's a choice of hosting providers
that support Python plus certain servers out of the box.

Things seem to have moved on, and very much for the better, too.

Paul

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


Re: Python v PHP: fair comparison?

2006-11-15 Thread walterbyrd

Michael Torrie wrote:

 Absolutely false.  Most of my standalone, command-line scripts for
 manipulating my unix users in LDAP are written in PHP, although we're
 rewriting them in python.


I would say that you are one of very few who use PHP for sys-admin
tasks - and even you have switched to Python. In general, it does not
seem to me that PHP has caught on as a sys-admin language.

However, as sys-admin scripting langanges go, I would also say that
Python is far less popular than butt-ugly Perl. Again - just based on
what I've seen.

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


Re: Is python for me?

2006-11-15 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote:
 By large I mean an application with intensive operations, such as a
 fancy GUI maybe a couple of threads, accessing a database, etc.
 

Threads are handled by the OS. GUI are (usually) handled by a
lower-level lib like GTK or such. DB access mostly rely on the
particular RDBMS. So we're left with the application code itself - the
glue between all these componants. There's usually nothing really
intensive here, and I wouldn't bet using C++ instead of Python would
make a huge difference here - wrt/ perceived performances at least.

My 2 cents...
-- 
bruno desthuilliers
python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python v PHP: fair comparison?

2006-11-15 Thread Andy Dingley

walterbyrd wrote:

 I don't know if this is a fair comparison or not.

Who cares?  Anything involving PHP is a billion flies can't be wrong
type of statement.

I agree completely with your observation about PHP's lower cost of
access. This is ostensibly a good thing, but it also means that every
software-ignorant newbie dives straight into PHP and ten minutes later
they're a guru.  The average quality of PHP developers is rock-bottom
and the average quality of PHP code is about the same. I don't like the
language either, but it's the use PHP is put to that spoils most of it,
more than language features itself.

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


Python-2.5.exe?

2006-11-15 Thread Andrew Burton
What Python is best for installing to a USB Drive?  I've actually got 
2.5 on a drive, but I forget which installation package I used.  It 
seems to me that it was an EXE file, but I cannot seem to find one of 
those today.

Can the Python-2.5.msi installation files from python.org be installed 
so as not to touch the registry, to make them portable?

-- 
Andrew Burton
[EMAIL PROTECTED]
http://utilitarian.us - A Guide to Esoteric Technology in Paragon City
http://jarodrussell.livejournal.com/ - Take a guess. ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python v PHP: fair comparison?

2006-11-15 Thread James Cunningham


On 2006-11-15 10:47:07 -0500, Demel, Jeff 
[EMAIL PROTECTED] said:

 [...]
 That's true, but I was lucky enough to find webfaction.com for python
 hosting, including Django.  Good prices and they know Python.  I think
 they used to be python-hosting.com or something.
 
 -Jeff

Dirt-cheap Dreamhost also offers Python with Django (as well as Ruby 
with Rails), though I haven't used those capabilities so I can't judge 
how good the environment is. I suspect it isn't that great. The people 
at Dreamhost are great; the service itself is - at best! - unreliable.

Best,
James

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


python-ldap and Python 2.5 (was: Python 2.5 Core Dump on Solaris 8)

2006-11-15 Thread Michael Ströder
Martin v. Löwis wrote:
 Melissa Evans schrieb:
 
I've modified grappy.py,
http://www.stacken.kth.se/~mattiasa/projects/grappy/, a postfix policy
daemon for greylisting. to use LDAP as a backend instead of SQL (with
python-ldap.)  The daemon runs fine when testing but when I put it under
load it core dumps quickly.  What little analysis I know how to do shows
similar information every time.  Any advice on where to go from here?
 
 It looks like a memory allocation bug, e.g. caused by a double free,
 or possibly a buffer overrun.

Unfortunately the C part of python-ldap is not in a good shape regarding
Python 2.5 since I'm not a C programmer. Release 2.2.0 works only with
Python 2.3.x. and 2.4.x. :-/

But this seems to help (tested on my local system):
http://sourceforge.net/tracker/index.php?func=detailaid=1575329group_id=2072atid=102072

Generally I also asked for help regarding PEP 353 - preparation for
Python 2.5:
http://sourceforge.net/tracker/index.php?func=detailaid=1467529group_id=2072atid=102072

I posted a related message to python-ldap-dev list with some patches:
http://sourceforge.net/mailarchive/forum.php?thread_id=30574782forum_id=4346

During the next days I hope to commit some of the changes I've made
since then. Contributions welcome.

Ciao, Michael.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: jython's future

2006-11-15 Thread Łukasz Langa
Ed Jensen:
 Łukasz Langa [EMAIL PROTECTED] wrote:
   
 Java was at 1.2 (and compiling Hello World took over 5 minutes)
 

 Bullshit.  Complete and utter bullshit.
   

Someone else already gave you the hints on the actual relevance of my 
post but let me show you one more thing:

http://www.flex-compiler.lcs.mit.edu/Harpoon/hypermail/java-dev/0478.html 
(a hint: 373s  5min, actually)

Also, note the date of the post. So, what's your problem, Ed? For the 
matter, you could use some reading: 
http://www.amazon.com/Excuse-Me-Little-Book-Manners/dp/0448425858

Regards,
Łukasz Langa


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

Re: Python-2.5.exe?

2006-11-15 Thread Fredrik Lundh
Andrew Burton wrote:

 What Python is best for installing to a USB Drive?  I've actually got 
 2.5 on a drive, but I forget which installation package I used.  It 
 seems to me that it was an EXE file, but I cannot seem to find one of 
 those today.
 
 Can the Python-2.5.msi installation files from python.org be installed 
 so as not to touch the registry, to make them portable?

python doesn't depend on the registry settings for normal use, so
you can simply install python as usual, copy python25.dll from 
c:\windows\system32 to c:\python25, and then copy (or move) the
entire c:\python25 tree to your USB drive.

/F

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


Re: plasTeX doesn't load LaTeX packages

2006-11-15 Thread Chris Lambacher
On Sat, Nov 11, 2006 at 01:23:30PM +0100, giovanni gherdovich wrote:
 Hello,
 
 first of all:
 Is this the right place to ask plastek-related
 questions?
I would suspect that the plastex-users mailing list would be the right forum
for plasTeX related questions:
http://sourceforge.net/mail/?group_id=120835

There however only appears to be one message in the archives.  Perhaps there
is not yet much of user community.

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


RE: PyWin32-winxptheme and py2exe

2006-11-15 Thread Stefan Schukat
You probably need to include the common Control Manifest to supprt
themes
see in the py2exe\samples\advanced directory for an example how to do
it.

Stefan

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of Andrea Gavana
 Sent: Tuesday, November 14, 2006 10:43 PM
 To: python-list@python.org
 Subject: PyWin32-winxptheme and py2exe
 
 Hi all,
 
I am having some troubles mixing py2exe and winxptheme. 
 Basically, I am using wxPython 2.7.2.0 with Python 2.5, and 
 painting some window background using the UxTheme via 
 winxptheme. This is what I am doing:
 
 hwnd = MyWindow.GetHandle()
 self.hTheme = winxptheme.OpenThemeData(hwnd, Window)
 
 winxptheme.DrawThemeBackground(self.hTheme, dc.GetHDC(), 5, 1,
   (rc.top, rc.left, rc.right, 
 rc.bottom), None)
 
 
 This works very well using python directly, but when I 
 generate and executable file with py2exe, I get this error 
 when executing that last
 line:
 
 TypeError: an integer is required
 
 This is because self.hTheme is *None*. It seems like 
 OpenThemeData can not be initialized in an executable, or at 
 least that I am not able to do it.
 Does anyone have a possible solution to this problem? I have 
 tried all the possibilities with py2exe, meaning bundle=1, 
 bundle=2, bundle=3, compressed=1, compressed=2, every 
 possible combination. But it doesn't work :-(
 
 I attach my setup file, if it can be of any help.
 
 Thank you very much for every pointer.
 
 
 --
 Andrea.
 
 Imagination Is The Only Weapon In The War Against Reality.
 http://xoomer.virgilio.it/infinity77/
 
-- 
http://mail.python.org/mailman/listinfo/python-list


using converters, adapters in sqlite3

2006-11-15 Thread matthewperpick
hello,

i want to make use of sqlite3's adapter and converter capabilities
but my classes are more complex than the point examples in the python
documentation (http://docs.python.org/lib/node347.html), because they
include foreign keys to othe rtables.

I don't want to concatenate those with the class' other data in one
column because then I lose the ability to filter data by FK in my
select queries.

so .. I was hoping someone could show me how to write converters 
adapters that will allow me to each attribute in its own column.

Thanks very much,

Matt

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


Yield

2006-11-15 Thread Mateuszk87
Hi.

may someone explain yield function, please. how does it actually work
and when do you use it?

thanks in forward

mateusz

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


Re: modules and generated code

2006-11-15 Thread J. Clifford Dyer
Nigel Rantor wrote:
 Peter Otten wrote:
 Nigel Rantor wrote:

 Peter Otten wrote:
 Nigel Rantor wrote:

 So, if I have a tool that generates python code for me (in my case,
 CORBA stubs/skels) in a particular package is there a way of 
 placing my
 own code under the same package hierarchy without all the code 
 living in
 the same directory structure.

 http://docs.python.org/lib/module-pkgutil.html

 Yep, looks like that should work, but it doesn't. :-/

 Do you have any idea whether other __init__.py scripts from the same
 logical module will still be run in this case?

 I don't think it will.
 
 Yeah, I am getting that impression. Gah!
 
 The generated code uses its init script to pull in other code.

 You could invoke it explicitly via
 execfile(/path/to/generated/package/__init__.py)
 in the static package/__init__.py.
 
 Hmm, yes, that works. It's not pretty though, it seems to be finding the 
 file relative to the current directory, I suppose writing a bit of code 
 that figures out where this package is located and modifying it won't be 
 too hard.
 
 And, at the risk of being flamed or sounding like a troll, this seems 
 like something that should be easy to do...other languages manage it 
 quite neatly. Up until this point I was really liking my exposure to 
 Python :-/
 
 I wonder if there is any more magic that I'm missing, the thing is the 
 pkgutil method looks exactly like what I want, except for not executing 
 the additional __init__.py files in the added directories.
 
 Thanks for the help so far Peter, if anyone has a prettier solution then 
 I'm all ears.
 
 Cheers,
 
   n
 
 
 
 
 

Maybe I'm missing something obvious, but it sounds like you are 
over-complicating the idea of inheritance.  Do you just want to create a 
subclass of the other class?

Cheers,
Cliff
-- 
http://mail.python.org/mailman/listinfo/python-list


Heap cleanup in python extension

2006-11-15 Thread Alexander Eisenhuth
Hello Together,

Shortly what I'm  doing:
- Extending python with boost.pthon extension
- Using python C-Api for datatypes in the extension
- extension has a thread (that can be stopped/started)
- thread started: extension updates a dict (given as parameter to the 
extension) 
every 20 ms
- the dict looks like:
{int:{int:[float,float,float] int:[float,float,float], ...}}

Now my question:
I create the dict every 20 ms on the heap in the following way:
--
static PyObject*  createPTDict()
{
static int aNumIter = 0;

PyObject* nRetDictPy =  PyDict_New(); // dicto to return
PyObject* nToolIdPy = PyInt_FromLong(1234567);
PyObject* nLedDict =  PyDict_New(); // dict containing 5 key,values

for (int aLedNum=0; aLedNum  5; aLedNum++)
{
PyObject* aLedNumPy = PyInt_FromLong(aLedNum);
PyObject* aLedList = PyList_New(0);
for ( int aXYZ=0; aXYZ  3; aXYZ++)
{
PyObject* aLedPosXYZ = PyFloat_FromDouble(1.0);
PyList_Append(aLedList, aLedPosXYZ);
}
PyDict_SetItem(nLedDict, aLedNumPy, aLedList);
}
PyDict_SetItem(nRetDictPy, nToolIdPy, nLedDict);
aNumIter ++;
return nRetDictPy;
}
--
I give it to python with:
--
PyObject *aKey, *aValue;
int aPos = 0;
PyObject* aNewToolDict = createPTDict();
PyDict_Next(aNewToolDict, aPos, aKey, aValue);

// DictInPython passed prior to extension
PyDict_SetItem(DictInPython, aKey, aValue);
--
And now, what would be a proper way to cleanup the heap?
1) Does PyDict_Clear(aNewToolDict) also decrement the ref counting for the 
containing list, int, ... PyObjects?
2) Do I need to Py_CLEAR( PyObject *o) for every created PyObject?

Thanks a lot for every answer/hint.

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


Editor w. Code Completion for COM-Libs (ActivePython 2.3)

2006-11-15 Thread Udo
Hello,

I'm looking for an Python-editor which supports code completion for
imported COM-Libs. I'm using ActivePython 2.3.
Any hints?

Thanks and kind regards
Udo

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


Re: How to pass an argument to a python program open in IDLE?

2006-11-15 Thread [EMAIL PROTECTED]


On Nov 15, 7:56 am, [EMAIL PROTECTED] wrote:
 Hello,

 I have open a Python program in the IDLE, but when I select the run
 module under run menu, it
 does not allow me to pass an argument to my Python program!
 How do you pass an argument to a Python program under the IDLE? Thanks for
 you help!

I'm using Python on an old Mac with the IDE.  I think my solution would
work.

opt_parser = OptionParser()

def myfunc(argstring):
(self.options,self.args) =
sub_opt_parser.parse_args(argstring.split())
f not self.args: self.args = [default arguments].split()
...

if __name__==__main__:
myfunc(argstring)


This means editing the file every time.  Since I'm on a Mac, I can also
use:
if __name__==__main__:
from EasyDialogs import AskString
args = AskString('Options and Arguments')

myfunc(args)

I'm not sure how easy this is to implement on other platforms

Josh English
[EMAIL PROTECTED]
http://www.spiritone.com/~english

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


Re: Yield

2006-11-15 Thread Fredrik Lundh
Mateuszk87 wrote:

 may someone explain yield function, please. how does it actually work
 and when do you use it?

it returns a value from a function without actually terminating the 
function; when the function is resumed, it'll continue to execute after 
the yield.

a function that contains a yield statement is called a generator, and 
is most often used in a for-in loop, or in other contexts that expect a 
sequence.  the loop is automatically terminated when the function 
returns in a usual way:

  def gen():
... yield 1
... yield 2
... yield 3
...
  for item in gen():
... print item
...
1
2
3
  sum(gen())
6
  [str(i) for i in gen()]
['1', '2', '3']

you can also use the generator by hand; when you call a generator 
function, it returns a special generator object, and then immediately 
suspends itself.  to run the generator, call its next method:

  g = gen()
  g
generator object at 0x00AE64E0
  g.next()
1
  g.next()
2
  g.next()
3

when the generator is exhausted, it raises a StopIterator exception:

  g.next()
Traceback (most recent call last):
   File stdin, line 1, in module
StopIteration

reference information:

 http://effbot.org/pyref/yield.htm

hope this helps!

/F

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


Re: modules and generated code

2006-11-15 Thread Nigel Rantor
J. Clifford Dyer wrote:
 
 Maybe I'm missing something obvious, but it sounds like you are 
 over-complicating the idea of inheritance.  Do you just want to create a 
 subclass of the other class?

Nope, that isn't my problem.

I have an IDL file that is used to generate a set of stub and skeleton 
code that is not human-modifiable.

Eventually I would like to have my IDL in source control and have a 
setup script able to generate my stubs and skels and install them for me.

At the same time I want to produce code that uses this code but in the 
same package.

In Java or Perl I can easily create a couple package/module like this:

package org.mine.package;

[...class definitions...]


and then somewhere else

package org.mine.otherpackage;

[...class definitions...]

These can be compiled into separate Jar files and just work.

Since the python is the final target though I don't want to put it all 
in one directory because then I need to be clever when I regenerate the 
generated code, I don't want old python modules lying around that are no 
longer in the IDL. Blowing the entire generated directory away is the 
best way of doing this, so I don't want my implementation code in there.

Basically, I want the same top-level package to have bits of code in 
different directories, but because Python requires the __init__.py file 
it only picks up the first one in PYTHONPATH.

I'm not sure if that makes sense, my brain is already toast from 
meetings today.

   n





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


Re: Yield

2006-11-15 Thread Fredrik Lundh
Fredrik Lundh wrote:

 reference information:

also see:

http://effbot.org/pyfaq/what-is-a-generator.htm

/F

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


Re: Yield

2006-11-15 Thread Carsten Haese
On Wed, 2006-11-15 at 09:13 -0800, Mateuszk87 wrote:
 Hi.
 
 may someone explain yield function, please. how does it actually work
 and when do you use it?

[There is probably a much better explanation of this somewhere on the
net already, but I feel like writing this out myself.]

yield is a keyword. In simple terms, if yield appears inside a
function, the function becomes a generator that can return multiple
results.

Consider the following trivial example of a function that calculates the
elements of some sequence and prints each one.

def squares(n):
  for i in range(n):
print i**2

Now suppose it turns out that in addition to--or instead of--printing
the elements of this sequence, the caller wants to do something
different with them. You could handle this by building a list, and
return the list to the caller to loop over and operate on as they
choose. But if the list is very big, that's not very memory-efficient if
the caller only needs to operate on one element at a time.

This is where yield comes in. If you write this:

def squares(n):
  for i in range(n):
yield i**2

squares is now a generator function. If you call squares(100), it won't
calculate any sequence elements immediately. It will instead return an
iterator the caller can loop over:

for el in squares(100):
  print el # or do anything else the caller decides

The beauty of this is that you achieve physical separation between
generating elements of a sequence and using them. The generator function
only cares about how to produce the elements, and the caller only cares
about how to use them.

Hope this helps,

Carsten.


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


Re: Yield

2006-11-15 Thread Mateuszk87
thx for the quick answer. i ll have a look.

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


Re: PyWin32-winxptheme and py2exe

2006-11-15 Thread Andrea Gavana
Hi Stefan,

 You probably need to include the common Control Manifest to supprt
 themes
 see in the py2exe\samples\advanced directory for an example how to do
 it.


I am already doing it. In my Setup.py there is a manifest file
embedded in a Python string. Plus, I *also* have a file called
MyExecutable.exe.manifest in the working directory. I have followed
the directions given in py2exe/samples/advanced, but it still doesn't
work. I think it might be a bug in winxptheme/py2exe.

Thank you for every pointer.

Andrea.

Imagination Is The Only Weapon In The War Against Reality.
http://xoomer.virgilio.it/infinity77/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: modules and generated code

2006-11-15 Thread Fredrik Lundh
Nigel Rantor wrote:

 Basically, I want the same top-level package to have bits of code in 
 different directories, but because Python requires the __init__.py file 
 it only picks up the first one in PYTHONPATH.

would a single __init__.py function that does from-import-* on the 
various implementation modules solve your problem?

/F

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


Re: modules and generated code

2006-11-15 Thread Gabriel Genellina

At Wednesday 15/11/2006 14:33, Nigel Rantor wrote:


I have an IDL file that is used to generate a set of stub and skeleton
code that is not human-modifiable.

Eventually I would like to have my IDL in source control and have a
setup script able to generate my stubs and skels and install them for me.

At the same time I want to produce code that uses this code but in the
same package.

[...]
Basically, I want the same top-level package to have bits of code in
different directories, but because Python requires the __init__.py file
it only picks up the first one in PYTHONPATH.


Put both directories in the same package. But this is the obvious 
thing, so maybe I'm missing something.



--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Yield

2006-11-15 Thread John Henry
Thank you.  This is very clear.  I can see that this is useful in lots
of situations.

Fredrik Lundh wrote:
 Mateuszk87 wrote:

  may someone explain yield function, please. how does it actually work
  and when do you use it?

 it returns a value from a function without actually terminating the
 function; when the function is resumed, it'll continue to execute after
 the yield.

 a function that contains a yield statement is called a generator, and
 is most often used in a for-in loop, or in other contexts that expect a
 sequence.  the loop is automatically terminated when the function
 returns in a usual way:

   def gen():
 ... yield 1
 ... yield 2
 ... yield 3
 ...
   for item in gen():
 ... print item
 ...
 1
 2
 3
   sum(gen())
 6
   [str(i) for i in gen()]
 ['1', '2', '3']

 you can also use the generator by hand; when you call a generator
 function, it returns a special generator object, and then immediately
 suspends itself.  to run the generator, call its next method:

   g = gen()
   g
 generator object at 0x00AE64E0
   g.next()
 1
   g.next()
 2
   g.next()
 3

 when the generator is exhausted, it raises a StopIterator exception:

   g.next()
 Traceback (most recent call last):
File stdin, line 1, in module
 StopIteration

 reference information:

  http://effbot.org/pyref/yield.htm
 
 hope this helps!
 
 /F

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


Re: Python v PHP: fair comparison?

2006-11-15 Thread tobiah
I've wrestled with this for quite a while, and I think
that I've come up with a solution.  Let the heavy lifting
of the application be done with a back end python process.
I was thinking that I might use cherrypy to sit there and
wait for requests.

Then, I would have PHP make calls to this back end process
to get the content that it needs.  This could be on any level
from a simple datum from the database, or as complex as
the HTML for the entire web page.  I'm still trying to settle
on a protocol (SOAP, CORBA?) but I think that it should be
at the object level rather than simple posts to cherrypy.

Anyway, even though not all web hosters have a reasonable
python web framework installed, they will almost certainly
allow you to run python programs.  The PHP might eventually
boil down to simple function calls that get content from
the back end.  Let python do all the work:

?php

put_attendee_mailing_info($id);
list_cart_items($id);

?


walterbyrd wrote:
 I don't know if this is a fair comparison or not. Any comments
 appreciated.
 
 - Python is more readable, and more general purpose
 - PHP has awful backward compatibility
 - PHP has a lower barrier to entry
 - Most inexpensive web-hosters support PHP, but not Python
 - PHP has far more pre-writen scripts available
 - Newer versions of mod_python require Apache 2.0, which few hosters
 have
 - There is more demand for PHP developers, than Python developers
 

-- 
Posted via a free Usenet account from http://www.teranews.com

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


lxml/ElementTree and .tail

2006-11-15 Thread Chas Emerick
I looked around for an ElementTree-specific mailing list, but found  
none -- my apologies if this is too broad a forum for this question.

I've been using the lxml variant of the ElementTree API, which I  
understand works in much the same way (with some significant  
additions).  In particular, it shares the use of a .tail attribute.   
I ran headlong into this aspect of the API while doing some DOM  
manipulations, and it's got me pretty confused.

Example:

  from lxml import etree as ET
  frag = ET.XML('aheadbinside/btail/a')
  b = frag.xpath('//b')[0]
  b
Element b at 71cbe8
  b.text
'inside'
  b.tail
'tail'
  frag.remove(b)
  ET.tostring(frag)
'ahead/a'

As you can see, the .tail text is removed as part of the b element  
-- but it IS NOT part of the b element.  I understand the use of  
the .tail attribute given the desire to simplify the API by avoiding  
pure text nodes, but it seems entirely inappropriate for the tail  
text to disappear into the ether when what is technically a sibling  
node is removed.

Performing the same operations with the Java DOM api (crimson, in  
this case it turns out) yields what I would expect (here I'm using  
JPype to access a v1.4.2 JVM through python -- which makes things  
somewhat less painful):

  from jpype import *
  startJVM(getDefaultJVMPath())
  builder = javax.xml.parsers.DocumentBuilderFactory.newInstance 
().newDocumentBuilder()
  xml = java.io.ByteArrayInputStream(java.lang.String 
('aheadbinside/btail/a').getBytes())
  doc = builder.parse(xml)
  a = doc.documentElement
  a.toString()
u'aheadbinside/btail/a'
  b = a.getElementsByTagName('b').item(0)
  a.removeChild(b)
  a.toString()
u'aheadtail/a'

(Sorry for the Java comparison, but that's where I first cut my teeth  
on XML, and that's where my expectations were formed.)

That's a pretty significant mismatch in functionality.  I certainly  
understand the motivations of Mr. Lundh to make the ET API as  
pythonic as possible, but ET's behaviour in this specific context is  
flatly wrong as far as I can see.  I would have expected that a  
removal operation would have appended b's tail text to the text of  
a (or perhaps to the tail text of b's closest preceding sibling)  
-- something that I think I'm going to have to do in order to  
continue using lxml / ElementTree.

I ran this issue past a few people I know who've worked with and  
written about ElementTree, and their response to this apparent  
divergence between the ET DOM API and standard DOM APIs was  
roughly: that's just the way it is.

Comments, thoughts?

Chas Emerick
Founder, Snowtide Informatics Systems
Enterprise-class PDF content extraction

[EMAIL PROTECTED]
http://snowtide.com | +1 413.519.6365


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


Re: Python-2.5.exe?

2006-11-15 Thread Laurent Pointal
Andrew Burton wrote:

 What Python is best for installing to a USB Drive?  I've actually got
 2.5 on a drive, but I forget which installation package I used. 

Maybe this one ? http://www.voidspace.org.uk/python/movpy/

 It 
 seems to me that it was an EXE file, but I cannot seem to find one of
 those today.
 
 Can the Python-2.5.msi installation files from python.org be installed
 so as not to touch the registry, to make them portable?

It seems movpy can install Python2.5 on an USB Key.

A+

Laurent.

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


Will GPL Java eat into Python marketshare?

2006-11-15 Thread walterbyrd
Some think it will.

Up untill now, Java has never been standard across different versions
of Linux and Unix. Some think that is one reason that some developers
have avoided Java in favor of Python. Now that Java has been GPL'd that
might change.

IMO: it won't make much difference. But I don't really know.

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


Re: Python-2.5.exe?

2006-11-15 Thread John Salerno
Fredrik Lundh wrote:

 python doesn't depend on the registry settings for normal use, so
 you can simply install python as usual, copy python25.dll from 
 c:\windows\system32 to c:\python25, and then copy (or move) the
 entire c:\python25 tree to your USB drive.

Is it safe to assume that if you do this, Python first looks in 
C:\Python25 for the dll file, before trying to find the non-existent (on 
the USB drive) C:\Windows\System32?

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


Re: Decimal() instead of float?

2006-11-15 Thread John Salerno
John Machin wrote:

 Here in Austraila, (I expect this is common to most countries), there
 are people who are utterly clueless about elementary data model rules,
 like identification numbers should be kept as strings.

Do you mean that ID numbers that serve as a primary key in a database 
should also be strings?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python v PHP: fair comparison?

2006-11-15 Thread Luis M. González

walterbyrd ha escrito:

 Luis M. González wrote:
  the new crop of web frameworks (Django, Turbo Gears, etc...).
 
   - Newer versions of mod_python require Apache 2.0, which few hosters
   have
 
  You can also get alder versions of mod_python. What's the problem?

 The problem is that the system requirements for django and turbogears
 are sky-high. I think Django requires Apache 2.0 (and maybe mod_python
 3.x), and CherryPy (part of turbogears) requires Python 2.4. If you are
 developing for a hosted environment, this can be a big problem. Few
 enough hosters provide python to begin with, then add to that such
 requirements as apache 2.0 - and you left with almost nothing.

You are right.
Although this is not a problem to me, because I just use bare-bones
mod_python, with no framework on top of it.
Not many people know that mod_python comes with its own built-in
handlers suitable for different programming styles, such as PSP
(similar to php) or publisher (M-V-C style).

Luis

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


Re: Python-2.5.exe?

2006-11-15 Thread Fredrik Lundh
John Salerno wrote:

 python doesn't depend on the registry settings for normal use, so
 you can simply install python as usual, copy python25.dll from 
 c:\windows\system32 to c:\python25, and then copy (or move) the
 entire c:\python25 tree to your USB drive.
 
 Is it safe to assume that if you do this, Python first looks in 
 C:\Python25 for the dll file, before trying to find the non-existent (on 
 the USB drive) C:\Windows\System32?

Python looks for a DLL in the same directory as the EXE before it looks 
anywhere else (this is standard Windows behaviour).

/F

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


Re: Python-2.5.exe?

2006-11-15 Thread Martin v. Löwis
John Salerno schrieb:
 Is it safe to assume that if you do this, Python first looks in
 C:\Python25 for the dll file, before trying to find the non-existent (on
 the USB drive) C:\Windows\System32?

python25.dll is found through mechanisms of the operating system, not
through code in Python. The operating system loads DLLs in the order
specified here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/dynamic-link_library_search_order.asp

As you can see, the directory containing the application is searched first.

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


Re: Will GPL Java eat into Python marketshare?

2006-11-15 Thread Bill

walterbyrd wrote:
 Some think it will.

 Up untill now, Java has never been standard across different versions
 of Linux and Unix. Some think that is one reason that some developers
 have avoided Java in favor of Python. Now that Java has been GPL'd that
 might change.

 IMO: it won't make much difference. But I don't really know.

The change might also provide an opportunity for further expansion of
jython, eating into Java marketshare

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


Re: Decimal() instead of float?

2006-11-15 Thread Terry Reedy

John Salerno [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 John Machin wrote:

 Here in Austraila, (I expect this is common to most countries), there
 are people who are utterly clueless about elementary data model rules,
 like identification numbers should be kept as strings.

 Do you mean that ID numbers that serve as a primary key in a database
 should also be strings?

If you mean user-entered data like social security, phone, account, part, 
or postal code 'numbers' -- as opposed to internal db-generated numbers 
that the user never sees -- this I would presume 'yes'.

tjr



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


java python GPL

2006-11-15 Thread km
Hi all,

what does Java released under GPL mean to python ? 
could it hamper python development on the long run? 

regards,
KM
-- 
http://mail.python.org/mailman/listinfo/python-list

ANN: pyfaq 1.0b1 is now available

2006-11-15 Thread Fredrik Lundh
After incorporating more than 60 comments, adding a bunch of new 
articles, and having made a ludicrous amount of minor edits and
tweaks, I'm happy to announce a first beta release of the new
Python FAQ:

 http://effbot.org/pyfaq/

Many thanks to everyone who's contributed this far!

/F

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


Re: Decimal() instead of float?

2006-11-15 Thread Aahz
In article [EMAIL PROTECTED],
John Salerno  [EMAIL PROTECTED] wrote:
John Machin wrote:

 Here in Austraila, (I expect this is common to most countries), there
 are people who are utterly clueless about elementary data model rules,
 like identification numbers should be kept as strings.

Do you mean that ID numbers that serve as a primary key in a database 
should also be strings?

Depends.  If they are strictly internal, ints are fine.  But if they
interact with the outside world, they should be strings.
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

In many ways, it's a dull language, borrowing solid old concepts from
many other languages  styles:  boring syntax, unsurprising semantics,
few automatic coercions, etc etc.  But that's one of the things I like
about it.  --Tim Peters on Python, 16 Sep 1993
-- 
http://mail.python.org/mailman/listinfo/python-list


wrapping existing instance in new interface

2006-11-15 Thread [EMAIL PROTECTED]
I am writing a class that subclasses datetime.datetime in order to add
a few specialized methods.  So far the __init__ looks like this:

class myDateTime(datetime.datetime):
def __init__(self, time, *args, **kwargs):
if isinstance(time, str):
timeTuple, tzOffset = self.magicMethod(timeStr)
datetime.__init__(self, tzinfo=GenericTZ(tzoffset),
**timeTuple)

I would also like to pass in instances of datetime.datetime and have my
class wrap it in the new interface.  Something like this:

mdt = myDateTime(datetime.datetime.now())

I suppose I could do something like this:

elif isinstance(time, datetime.datetime):
timetuple = time.timetuple()
tzoffset = time.utcoffset()
datetime.__init__(self, tzinfo=GenericTZ(tzoffset),
**timetuple)

However, that feels rather... awkward.  Is there a better/cleaner way?
Perhaps a way to directly wrap my new interface around the passed-in
datetime.datetime instance?

Thanks...

-Ben

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


Re: Will GPL Java eat into Python marketshare?

2006-11-15 Thread Harry George
walterbyrd [EMAIL PROTECTED] writes:

 Some think it will.
 
 Up untill now, Java has never been standard across different versions
 of Linux and Unix. Some think that is one reason that some developers
 have avoided Java in favor of Python. Now that Java has been GPL'd that
 might change.
 
 IMO: it won't make much difference. But I don't really know.
 

Short answer: People use Python instead of Java because people (at
least intelligent people) tend to avoid pain.

Long answer: Changing licenses doesn't magically change Java's
architecture.  It is still a closed world of reinvent-the-wheel,
my-way-or-the-highway.  Which is antithetical to Python's promiscuous
interface-with-anything approach.

-- 
Harry George
PLM Engineering Architecture
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will GPL Java eat into Python marketshare?

2006-11-15 Thread Maurice LING
walterbyrd wrote:
 Some think it will.
 
 Up untill now, Java has never been standard across different versions
 of Linux and Unix. Some think that is one reason that some developers
 have avoided Java in favor of Python. Now that Java has been GPL'd that
 might change.
 
 IMO: it won't make much difference. But I don't really know.
 

I'm hoping for a more optimistic outcome that this may open a 
possibility for tigher interoperability between java programs and python 
programs. That is, run java class files or java codes natively on python 
VM. Is this still a blue sky dream?

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


Re: ANN: pyfaq 1.0b1 is now available

2006-11-15 Thread John Machin
Fredrik Lundh wrote:
 After incorporating more than 60 comments, adding a bunch of new
 articles, and having made a ludicrous amount of minor edits and
 tweaks, I'm happy to announce a first beta release of the new
 Python FAQ:

  http://effbot.org/pyfaq/

 Many thanks to everyone who's contributed this far!


UnicodeDecodeError, UnicodeEncodeError:

I was about to ask mildly the other day whether a c.l.py poster had
RTFFAQ when I thought Hmmm long while since I'd RTFFAQ myself, better
have a peep. Shock/horror; couldn't find UnicodeEncodeError -- why
not? See below:

FAQ: What does 'UnicodeError: ASCII [decoding,encoding] error: ordinal
not in range(128)' mean?

Python:

Python 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] on win32
|  str(u'\xff')
UnicodeError: ASCII encoding error: ordinal not in range(128)

Python 2.3.5 (#62, Feb  8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)]
on win32
|  str(u'\xff')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xff' in
position 0:
ordinal not in range(128)

===

P.S. Great job on the wiki, and yes a search facility a tad smarter
than browser Ctrl-F would be a very good idea!

Cheers,
John

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


Re: Will GPL Java eat into Python marketshare?

2006-11-15 Thread John Bokma
Harry George [EMAIL PROTECTED] wrote:
 
 Short answer: People use Python instead of Java because people (at
 least intelligent people) tend to avoid pain.

Intelligent people don't suffer from fanboy sentiments. They just pick a 
language that works best for them.

-- 
John   MexIT: http://johnbokma.com/mexit/
   personal page:   http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
-- 
http://mail.python.org/mailman/listinfo/python-list


pyRTF and Footers

2006-11-15 Thread E . Doxtator
Hi All

I've been using the pyRTF module to generate some documents that I need
for work.  In general, the module is good, and pretty simple to use.
However, I am running into a problem with footers that doesn't quite
make sense to me.

My question is this:  Is it possible to change the text of a footer
throughout an RTF document?

The data that I am using to produce my document is organized in a
simple header/detail relationship.  The document I want to produce
looks roughly like this:

---
USER001

detail data line 1
detail data line 2
detail data line 3

page footer that says USER001, plus some other information

**page break**

USER002

detail data line 1
detail data line 2
detail data line 3

page footer that says USER002, plus some other information

**page break**

USERnnn

detail data line 1
detail data line 2
detail data line 3

page footer that says USERnnn, plus some other information

END OF DOCUMENT

---

I've gotten everything the way I want, except for the footer.  The
footer appears on the first page, but not on any other page.

The code that generates the footer is (apologies in advance for poor
style):

---

def MakeFooter(self, facilitatir, startDate, endDate, tuID):
   section = Section()

   self.doc.Sections.append( section )

   p = Paragraph(  %s - %s (%s - %s) % ( facilitator, tuID,
startDate, endDate ), LINE )
   p.append( 'Page', PAGE_NUMBER, ' of ', TOTAL_PAGES )
   section.Footer.append( p )

---

The logic that calls MakeFooter is:

---

   tuDoc = MakeTUDoc()
   DR = Renderer()

   for i in range( start, end + 1 ):
  key = Traininguser%03d % ( i )
  tuDoc.MakeFooter( facilitator, startDate, endDate, key )
  tuDoc.MakeHeader( key, module )
   code to populate the document with detail data 

   DR.Write( tuDoc.doc, tuDoc.OpenFile( 'JUNK' ) )

   print( 'DONE!' )

---

(Note:  the MakeHeader() method doesn't put an actual RTF header in the
document-- it just puts text in a Heading1 format into a section at the
top of the page, before the detail data.)

I had a look at the RTF 1.5 specification
(http://www.biblioscope.com/rtf15_spec.htm), and regarding headers and
footers and it's pretty thin.  I didn't see anything in the
specification regarding support for changing footer text throughout the
document.  Nothing in there that said I could do it, either.

Any ideas, anyone?

Thanks in advance.  This is an extremely helpful discussion group.

-Doc

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


Threads and signals

2006-11-15 Thread Chad J. Schroeder
I've run into an opportunity in a Python application using threads and 
signals.
Basically, there is a main process that spawns off a child thread that loops 
forever.
In between iterations, the child thread sleeps for X seconds. All the while, 
the 
main
thread loops forever doing its thing and also sleeps in between iterations (see 
the code
at the end this message). Normally the application would be daemonized before 
the main
process starts up. Hence, during a system shutdown or stoppage of the daemon, 
it's
desired that the daemon catch a few signals (TERM/INT) and perform a few cleanup
routines. According to the Python docs, only the main thread will receive 
signals. The
problem I have, on FreeBSD systems, is that the sleep function in the child 
gets 
interrupted
and the signal never gets handled until the main thread's sleep concludes. It 
works as
expected on a Linux box (main thrd's sleep is interrupted). Sample output from 
multiple
systems is directly below.

Just looking for insight from others in the know.

Thanks,
Chad


Linux 2.6.17

test_bed$ python2.5 ./thrd_test.py
Starting up
MainThread.run(): 14332
MainThread before sleep(15)
ChildThread.run(): 14332
ChildThread before sleep(10)
Received signal 2-- Interrupted here (Ctrl-C), correctly
flag: Trueinterrupts sleep in main thread
flag: False
MainThread after sleep(15)
Shutting down

test_bed$ python2.4 ./thrd_test.py
Starting up
MainThread.run(): 14338
MainThread before sleep(15)
ChildThread.run(): 14338
ChildThread before sleep(10)
Received signal 2 -- Interrupted here (Ctrl-C), correctly
flag: Trueinterrupts sleep in main thread
flag: False
MainThread after sleep(15)
Shutting down
test_bed$

FreeBSD 4.11, 6.1, and 6.2

bash-2.05b# python2.5 ./thrd_test.py
Starting up
MainThread.run(): 65930
ChildThread.run(): 65930
ChildThread before sleep(10)
MainThread before sleep(15)
^CChildThread after sleep(10)  -- Interrupted here (Ctrl-C), but
ChildThread before sleep(10) interrupts the child thrd's sleep
ChildThread after sleep(10)
ChildThread before sleep(10)
Received signal 2-- Main sleep concludes and then 
the
flag: True   signal gets handled
flag: False
MainThread after sleep(15)
Shutting down
bash-2.05b#


#--- CODE BEGIN ---#

#!/usr/bin/env python

import os
import sys
import time
import signal
import threading

def sigHandle(signo, stkframe):
print Received signal , signo
print flag: , mthrd.flag.isSet()
mthrd.flag.clear()
print flag: , mthrd.flag.isSet()

class ChildThread(threading.Thread):

def __init__(self):
threading.Thread.__init__(self)

def run(self):
print ChildThread.run(): , os.getpid()
while (True):
print ChildThread before sleep(10)
time.sleep(10)
print ChildThread after sleep(10)

class MainThread(object):

def __init__(self):
self.flag = threading.Event()
self.cthrd = ChildThread()
self.cthrd.setDaemon(True)

def run(self):
print MainThread.run(): , os.getpid()
self.flag.wait()
self.cthrd.start()
while (self.flag.isSet()):
print MainThread before sleep(15)
time.sleep(15)
print MainThread after sleep(15)
return# or cleanup routine

if __name__ == __main__:

# Normally, the process is daemonized first. That's been
# left out for testing purposes.

signal.signal(signal.SIGINT, sigHandle)
signal.signal(signal.SIGQUIT, sigHandle)
signal.signal(signal.SIGTERM, sigHandle)

mthrd = MainThread()
print Starting up
mthrd.flag.set()
mthrd.run()
print Shutting down

sys.exit(0)

#--- CODE END ---# 

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


Re: another newbie question

2006-11-15 Thread Bruno Desthuilliers
Mary Jane Boholst a écrit :
 Hello everyone,
 I have a question that google couldnt answer for me and thought that the
 brains on here might be able to help.
 I am trying to upload a file to a database

What do you mean upload a file to a database ? I know how to uplaod a 
file (from a web form to a server), I know how to either store metadata 
about a file in a database, I know how to write code that will parse a 
file content to store it into a database, but I have hard time 
understanding exactly what you're trying to do.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python v PHP: fair comparison?

2006-11-15 Thread Bruno Desthuilliers
walterbyrd a écrit :
 Bjoern Schliessmann wrote:
 
walterbyrd wrote:


- PHP has a lower barrier to entry

Which kind of barrier do you mean -- syntax, availability, ...?
 
 
 Putting php into a web-site is as easy as throwing some php code into a
 my html file, and maybe giving the file a php extension. I can get php
 hosting for $10 a year easy.
 
 This may not be what you want for a major developement project,

Not even for a minor one. While one can write not-trivial applications 
in PHP, the kind of work this requires would greatly benefit from a real 
programming language (vs a QD web scripting language).

 but the
 barrier to entry is very low.
 
Ok. This observation is very specific to web development. Python is a 
general purpose programming language. And from this POV, it's IMHO much 
easier to learn. And not only because you don't need Apache to use it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wrapping existing instance in new interface

2006-11-15 Thread Gabriel Genellina

At Wednesday 15/11/2006 19:30, [EMAIL PROTECTED] wrote:


I am writing a class that subclasses datetime.datetime in order to add
a few specialized methods.  So far the __init__ looks like this:

class myDateTime(datetime.datetime):
def __init__(self, time, *args, **kwargs):
if isinstance(time, str):
timeTuple, tzOffset = self.magicMethod(timeStr)
datetime.__init__(self, tzinfo=GenericTZ(tzoffset),
**timeTuple)


(I assume you mean *timeTuple)


I would also like to pass in instances of datetime.datetime and have my
class wrap it in the new interface.  Something like this:

mdt = myDateTime(datetime.datetime.now())

I suppose I could do something like this:

elif isinstance(time, datetime.datetime):
timetuple = time.timetuple()
tzoffset = time.utcoffset()
datetime.__init__(self, tzinfo=GenericTZ(tzoffset),
**timetuple)

However, that feels rather... awkward.  Is there a better/cleaner way?
Perhaps a way to directly wrap my new interface around the passed-in
datetime.datetime instance?


I don't see any other suitable constructor for datetime; perhaps one 
taking a datetime instance would be useful here.
Each individual component (year, month, etc.) is stored by itself, so 
timetuple() isn't complex; apart from the overhead of constructing a 
new object, you get an unneeded extra check of validity.


Another way would be monkey-patching the datetime class adding your 
own methods. This way the new methods would be available on any 
datetime instance - you don't need myDateTime class.
You can move magicmethod into a factory function used to construct 
datetime objects.



--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python deployment options.

2006-11-15 Thread Maurice LING
Cameron Laird wrote:

 In article [EMAIL PROTECTED],
 Richard Charts [EMAIL PROTECTED] wrote:
   .
   .
   .
 
Well on a Win machine, probably.
Almost every Linux machine you come across will have (most likely a
fairly recent build of) python.  For Macs, I'm not so sure but it's
probably closer to Linux than Win.

 
 
 Recent releases of Mac OS build in Python.

Python has been part of Mac OSX since OSX 10.2 (maybe even earlier but 
10.2 is the earliest I've used).

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


Re: pyRTF and Footers

2006-11-15 Thread Gabriel Genellina

At Wednesday 15/11/2006 20:08, [EMAIL PROTECTED] wrote:


I've been using the pyRTF module to generate some documents that I need
for work.  In general, the module is good, and pretty simple to use.
However, I am running into a problem with footers that doesn't quite
make sense to me.


First, I don't use pyRTF. The app sketch and code snippet you have 
posted look reasonable.
At least using Word, you can configure a page footer for each section 
in the document, so I think it should be posible.
If you don't get the output you want, it may be a bug in the module, 
you are using it in the wrong way, the feature is unsupported, etc. 
but most likely not a bug in Python itself. So a better place to ask 
would be... well, it appears there is no better place except asking 
the author directly :)


(BTW, thanks for pointing me towards pyRTF - it may be useful, so 
I'll give it a try...)



--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python v PHP: fair comparison?

2006-11-15 Thread Bruno Desthuilliers
walterbyrd a écrit :
 Larry Bates wrote:
 
 
I'd be surprised if there was more demand for PHP developers
than Python developers.
 
 
 Prepare to be surprised. From what I have seen demand for PHP
 developers is off-the-scale higher than demand for Python developers.

Anyone that knows how to program and understand the http protocol is 
already a PHP developer.

 If you search the job boards, then -IMO- it is only fair to not include
 jobs where the language is listed as an also-ran.

Then you'll find *very* few Python developper jobs.

 For example a typical
 sys-admin job will list about 24 skills, and python is often  thrown
 into the landry list. To my way of thinking, that is not really an ad
 for a python developer.

No, it's an ad for a sys-admin job.

FWIW, I've been hired as a web developer - not as a PHP or Java or 
whatever specific language programmer. Python wasn't even on the landry 
list. Then we had to hire another developer to help me on a Zope-based 
project. We didn't hired a Zope developer, nor even a Python 
developer - we hired a young C/Perl hacker with almost no prior web 
programming knowledge. Why ? Because he obviously was the best 
*programmer* we could find. As a matter of fact, he managed to become a 
productive Zope/Python programmer in less than two weeks.

 Trying to be as fair as I can be, my research shows that demand for
 developers where PHP is the primary is *far* higher than jobs where
 Python is the primary skills.

There are companies that believe that there are such things as PHP 
programmer, Java programmers, etc. And there are companies that know 
  the difference between a programmer and a code-monkey. The first one 
will ask for 10+ years of experience on a techno that is less than 5 
years old. The other will know a good coder when they meet one. Guess 
where are most 'Python programmers' working ?

 Of course, at best, that only shows the demand part of the equation.

Not even.

 There is also the supply side to consider. From what I have seen for
 salary offers for PHP developers, it may be fair to say that PHP
 developers are a dime a dozen.
 

Anyone that knows how to program and understand the http protocol is 
already a PHP developer.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyRTF and Footers

2006-11-15 Thread E . Doxtator

Gabriel Genellina wrote:
 At Wednesday 15/11/2006 20:08, [EMAIL PROTECTED] wrote:

 I've been using the pyRTF module to generate some documents that I need
 for work.  In general, the module is good, and pretty simple to use.
 However, I am running into a problem with footers that doesn't quite
 make sense to me.

 First, I don't use pyRTF. The app sketch and code snippet you have
 posted look reasonable.

Thanks :)

 At least using Word, you can configure a page footer for each section
 in the document, so I think it should be posible.

I edited the document in Word without problems.  I put in several
different footers into my generated RTF document.

 If you don't get the output you want, it may be a bug in the module,
=:-O

 you are using it in the wrong way,

This is a possibility.  I took a look at the raw RTF text, and the
multiple footers are in the text.  I'm going to have to edit the
document with word and compare it to the original to see what the
difference is, I guess.

...the feature is unsupported, etc.

Say it ain't so!

 but most likely not a bug in Python itself.
=:-O

 So a better place to ask  would be... well, it appears there is no better 
 place except asking
 the author directly :)

Anyone got his number?

 (BTW, thanks for pointing me towards pyRTF - it may be useful, so
 I'll give it a try...)

It's very useful.  I can see several applications in my job where I can
use this module.

Thanks

-Doc

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


Re: Python v PHP: fair comparison?

2006-11-15 Thread Bruno Desthuilliers
Michael Torrie a écrit :
 On Tue, 2006-11-14 at 18:55 -0800, Luis M. González wrote:
 
- Python is more readable, and more general purpose

Yes, php is only for web.
 
 
 Absolutely false. 

 From a purely technical POV, you're of course right. But PHP has been 
hacked (nobody in it's own mind would pretend it has ever been 
'designed') for web programming, and since the language by itself is 
totally and definitively braindead, using it for anything else is either 
  masochism or lack of knowledge of better solutions. Heck, even Perl is 
better for pure admin/scripting tasks.

 Most of my standalone, command-line scripts for
 manipulating my unix users in LDAP are written in PHP,

Yuck.

 although we're
 rewriting them in python.
 
 Although I can't think of a single app written in php that's not web-
 based (other than standalone scripts I have written), there are up-to-
 date php bindings for GTK: http://gtk.php.net/

As a matter of fact, while PHP *can* be used for GUI and CLI apps, 
you'll have hard time finding non-web PHP-based projects... OTOH, you'll 
find Python everywhere, from sys-admin scripts to full-blown web 
application servers to rich GUI clients. There must be a reason...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python v PHP: fair comparison?

2006-11-15 Thread Bruno Desthuilliers
walterbyrd a écrit :
 Michael Torrie wrote:
 
 
Absolutely false.  Most of my standalone, command-line scripts for
manipulating my unix users in LDAP are written in PHP, although we're
rewriting them in python.

 
 
 I would say that you are one of very few who use PHP for sys-admin
 tasks - and even you have switched to Python. In general, it does not
 seem to me that PHP has caught on as a sys-admin language.
 
 However, as sys-admin scripting langanges go, I would also say that
 Python is far less popular than butt-ugly Perl. Again - just based on
 what I've seen.

Perl is a scripting language. By 'design'. It's meant to be a better 
sh+sed+awk. Python is a general purpose programming language meant to 
fill the gap between shell scripts and C programs. So Perl is obviously 
a better scripting language than Python. The problem is that QD 
sys-admin scripts tend to become full-blown apps - and then, Perl starts 
to suck.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python v PHP: fair comparison?

2006-11-15 Thread Bruno Desthuilliers
walterbyrd a écrit :
 Luis M. González wrote:
 
the new crop of web frameworks (Django, Turbo Gears, etc...).


- Newer versions of mod_python require Apache 2.0, which few hosters
have

You can also get alder versions of mod_python. What's the problem?
 
 
 The problem is that the system requirements for django and turbogears
 are sky-high. I think Django requires Apache 2.0 (and maybe mod_python
 3.x),  and CherryPy (part of turbogears) requires Python 2.4.

Yes. Neither Apache 2.0 nor mod_python 3.x nor Python 2.4 are really 
bleeding edge, you know.

 If you are
 developing for a hosted environment, this can be a big problem. Few
 enough hosters provide python to begin with, then add to that such
 requirements as apache 2.0 - and you left with almost nothing.

You mean there are web hosting companies that are still using Apache 
1.3.x ?

C'mon, let's be serious. I just ordered a dedibox - a small dedicated 
web server - for my personal use. It's only 30 euros a month, you know...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will GPL Java eat into Python marketshare?

2006-11-15 Thread Matimus

John Bokma wrote:
 Intelligent people don't suffer from fanboy sentiments. They just pick a
 language that works best for them.

Adding to that, they pick the language that works best for them and the
situation. Python has a significant advantage in many applications
because it is dynamic and can be used for rapid development. IMHO,
usually more rapid than Java. Hopefully Java being GPL'd will make it
easier to deploy applications, especially on Linux. There are many
applications where Java has a significant advantage. I plan to make use
of both.

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


Re: Will GPL Java eat into Python marketshare?

2006-11-15 Thread Bruno Desthuilliers
John Bokma a écrit :
 Harry George [EMAIL PROTECTED] wrote:
  
 
Short answer: People use Python instead of Java because people (at
least intelligent people) tend to avoid pain.
 
 
 Intelligent people don't suffer from fanboy sentiments. They just pick a 
 language that works best for them.
 
Which is *exactly* what Harry said...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python v PHP: fair comparison?

2006-11-15 Thread Carl Banks
walterbyrd wrote:
 Trying to be as fair as I can be, my research shows that demand for
 developers where PHP is the primary is *far* higher than jobs where
 Python is the primary skills.

Probably because PHP is so bug-prone and man-inefficient that a small
website occupies a programmer's whole time, whereas a single Python (or
Ruby, or Perl, or even Java) programmer could manage several web sites.

(If by probable I mean wishful thinking, that is :)


Carl Banks

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


Re: pyRTF and Footers

2006-11-15 Thread Gabriel Genellina

At Wednesday 15/11/2006 21:01, [EMAIL PROTECTED] wrote:


 I've been using the pyRTF module to generate some documents that I need
 for work.  In general, the module is good, and pretty simple to use.
 However, I am running into a problem with footers that doesn't quite
 make sense to me.

 So a better place to ask  would be... well, it appears there is 
no better place except asking

 the author directly :)

Anyone got his number?


You could try the address listed in the docs...
I'm trying the examples and Example7 appears to be what you want.


--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Will GPL Java eat into Python marketshare?

2006-11-15 Thread Dan Lenski
walterbyrd wrote:
 Some think it will.

 Up untill now, Java has never been standard across different versions
 of Linux and Unix. Some think that is one reason that some developers
 have avoided Java in favor of Python. Now that Java has been GPL'd that
 might change.

 IMO: it won't make much difference. But I don't really know.

I don't think so.  Java and Python don't really belong to the same
class of programming languages:

C++, Java: strongly typed, statically typed object-oriented programming
languages... minimal runtime means that these languages can be compiled
to native executables easily (yes, Java can now with things like GCJ
and appropriate libraries)

Python, Perl, Ruby: dynamically typed object-oriented programming
languages... lots of runtime intelligence allows you to do things like
create a new class or function at runtime, or look up a symbol based on
a string of its name, or execute a string containing source code (these
things make the language more flexible but pretty hard to compile to
native code without embedding an interpreter)

The mindset required to program effectively in C++ or Java is very
different from that required to program effectively in Python or Perl,
in a way that's quite separate from the syntactical distinctions
between these languages... I think most programmers settle comfortably
into one mindset that fits best with the tasks they do, and try not to
move outside of it.

The ranks of C++ programmers have already been diminished by many of
them jumping to Java, since it offers less complex syntax and better
cross-platform support.  I expect that GPL'ed Java will accelerate the
decline of C++.  But I don't see Java competing directly with Python...

Dan

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


Re: Yield

2006-11-15 Thread dwelch91
Mateuszk87 wrote:
 Hi.
 
 may someone explain yield function, please. how does it actually work
 and when do you use it?
 
 thanks in forward
 
 mateusz
 

http://docs.python.org/ref/yield.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python v PHP: fair comparison?

2006-11-15 Thread Gabriel Genellina
At Wednesday 15/11/2006 21:28, Bruno Desthuilliers wrote:

Michael Torrie a écrit :
  On Tue, 2006-11-14 at 18:55 -0800, Luis M. González wrote:
 
 - Python is more readable, and more general purpose
 
 Yes, php is only for web.
 
  Absolutely false.

  From a purely technical POV, you're of course right. But PHP has been
hacked (nobody in it's own mind would pretend it has ever been
'designed') for web programming, and since the language by itself is
totally and definitively braindead, using it for anything else is either
   masochism or lack of knowledge of better solutions. Heck, even Perl is
better for pure admin/scripting tasks.

Someone here (= at work) needed to write some PDF 
reports, to be run from a bunch of ini-like 
files. Without much research nor analysis nor 
thinking nor approval, he said let's use this 
php library!. Surely the reports came in a few days. But:
- another dependency was added to the project
- the .ini format -which was suposed to be an 
internal implementation detail- is now part of 
the public interfase to the report generator
- a lot of PHP code duplicates the original class hierarchy (in delphi)
- php sucks :)

Of course there are a lot of unrelated issues 
here, but I think that it's such a braindead 
language which turns people into braindead programmers :)


-- 
Gabriel Genellina
Softlab SRL 

__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Python v PHP: fair comparison?

2006-11-15 Thread bruce
interesting ongoing thread...

i've seen a number of these over the years.. my language is better than your
language!!

i'm sure this question on the php list would have findings/results that are
essentially opposite of what is being discussed here!



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of Bruno Desthuilliers
Sent: Wednesday, November 15, 2006 4:35 PM
To: python-list@python.org
Subject: Re: Python v PHP: fair comparison?


walterbyrd a écrit :
 Michael Torrie wrote:


Absolutely false.  Most of my standalone, command-line scripts for
manipulating my unix users in LDAP are written in PHP, although we're
rewriting them in python.



 I would say that you are one of very few who use PHP for sys-admin
 tasks - and even you have switched to Python. In general, it does not
 seem to me that PHP has caught on as a sys-admin language.

 However, as sys-admin scripting langanges go, I would also say that
 Python is far less popular than butt-ugly Perl. Again - just based on
 what I've seen.

Perl is a scripting language. By 'design'. It's meant to be a better
sh+sed+awk. Python is a general purpose programming language meant to
fill the gap between shell scripts and C programs. So Perl is obviously
a better scripting language than Python. The problem is that QD
sys-admin scripts tend to become full-blown apps - and then, Perl starts
to suck.
--
http://mail.python.org/mailman/listinfo/python-list

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


  1   2   >