Re: Probability Problem

2006-04-25 Thread Elliot Temple
I think I got it. I noticed my code is essentially the same as Tim  
Peter's (plus the part of the problem he skipped). I read his code 20  
minutes before recreating mine from Alex's hints. Thanks!

def main():
 ways = ways_to_roll()
 total_ways = float(101**10)
 running_total = 0
 for i in range(1000-390+1):
 j = i + 390
 running_total += ways[i] * ways[j]
 print running_total / total_ways**2
 print ways[:10]

def ways_to_roll():
 result = [1]
 for i in xrange(10):
 result = combine([1] * 101, result)
 return result

def combine(a, b):
 results = [0] * (len(a) + len(b) - 1)
 for i, ele in enumerate(a):
 for j, ele2 in enumerate(b):
 results[i+j] += ele * ele2
 return results

main()
# output: 3.21962542309e-05 and
# [1, 10, 55, 220, 715, 2002, 5005, 11440, 24310, 48620]
# 3.21962542309e-05 is 32 out of a million



On Apr 24, 2006, at 9:14 PM, Alex Martelli wrote:

> Elliot Temple <[EMAIL PROTECTED]> wrote:
>
>> On Apr 24, 2006, at 8:24 PM, Alex Martelli wrote:
>>
>>> Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote:
>>>
 In article <[EMAIL PROTECTED]>,
  Elliot Temple <[EMAIL PROTECTED]> wrote:

> Problem: Randomly generate 10 integers from 0-100 inclusive,  
> and sum
> them. Do that twice. What is the probability the two sums are 390
> apart?

 I think the sum would come close to a normal distribution.
>>>
>>> Yes, very close indeed, by the law of large numbers.
>>>
>>> However, very close (in a math course at least) doesn't get the  
>>> cigar.
>>>
>>> You can compute the requested answer exactly with no random number
>>> generation whatsoever: compute the probability of each result from
>>> 0 to
>>> 1000, then sum the probabilities of entries that are exactly 390
>>> apart.
>>
>> That was the plan, but how do I get the probability of any given
>> result? (in a reasonable amount of time)
>>
>> BTW I'm not in a math course, just curious.
>
> OK, I'll trust that last assertion (sorry for the hesitation, but it's
> all too easy to ``help'' somebody with a homework assignment and
> actually end up damaging them by doing it FOR them!-).
>
>
> I'm still going to present this in a way that stimulates thought,  
> rather
> than a solved problem -- humor me...!-)
>
>
> You're generating a uniformly distributed random number in 0..100 (101
> possibilities), 10 times, and summing the 10 results.
>
> How do you get a result of 0?  Only 1 way: 0 at each attempt --
> probability 1 (out of 1010 possibilities).
>
> How do you get a result of 1?  10 ways: 1 at one attempt and 0 at each
> of the others - probability 10 (again in 1010'ths;-).
>
> How do you get a result of 2?  10 ways for '2 at one attempt and 0 at
> each of the others', plus, 10*9/2 ways for '1 at two attempts and 0 at
> each of the others' -- probability 55 (ditto).
>
> ...and so forth, but you'd rather not work it out...
>
>
> So, suppose you start with a matrix of 101 x 10 entries, each of  
> value 1
> since all results are equiprobable (or, 1/1010.0 if you prefer;-).
>
> You want to compute the number in which you can combine two rows.  How
> could you combine the first two rows (each of 101 1's) to make a  
> row of
> 201 numbers corresponding to the probabilities of the sum of two  
> throws?
>
> Suppose you combine the first entry of the first row with each  
> entry of
> the second, then the second entry of the first row with each entry of
> the second, etc; each time, you get a sum (of two rolls) which  
> gives you
> an index of a entry (in an accumulator row starting at all zeros) to
> increment by the product of the entries you're considering...
>
>
> Can you generalize that?  Or, do you need more hints?  Just ask!
>
>
> Alex
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>

-- Elliot Temple
http://www.curi.us/blog/



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


Re: MS VC++ Toolkit 2003, where?

2006-04-25 Thread Fredrik Lundh
Robert Kern wrote:

> Martin v. Löwis wrote:
> > Robert Kern wrote:
> >
> >>Oh, that's right, you need an import library for Python24.dll .
> >
> > That shouldn't be a problem: that library is included with Python.
>
> For mingw, too? I.e. a .a not a .lib?

last time I tinkered with mingw, it could link directly against the DLL
file.  see the last two minutes in "mingw from scratch in 20 minutes"
post:

http://article.gmane.org/gmane.comp.python.general/388046

the MinGW FAQ says that you can use reimp in cases like this:

http://www.mingw.org/mingwfaq.shtml#faq-msvcdll

but that didn't seem to be necessary (I assume reimp or something
is now integrated in mingw, or maybe I have a magic computer...)

however, note that the FAQ entry says that you can use an existing
LIB file as well, so Python's standard import library should work.





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

Re: MS VC++ Toolkit 2003, where?

2006-04-25 Thread Ron Adam
Alex Martelli wrote:
> Ron Adam <[EMAIL PROTECTED]> wrote:
>...
>> I still get the following with the tinyurl link:
>>
>> ~~~
>> The download you requested is unavailable. If you continue to see this
>> message when trying to access this download, go to the "Search for a 
>> Download" area on the Download Center home page.
>> ~~~
>>
>>
>> Pasting the above tinyurl into firefox results in the following link.
>>
>> http://www.microsoft.com/downloads/details.aspx?familyid=272BE09D-40BB-4&d
>> isplaylang=en
>>
>> Which appears to still be truncated. :-/
> 
> True, but here's the kicker: using the full URL, which I just dblchecked
> from Rushby's original message as being (enclosing in <...>)...:

Yes, I tried the full url also, but was hoping I did something wrong. 
Sigh... guess not.

>  49FD-9CB0-4BFA122FA91B&displaylang=en>
> 
> NOW gives me the same error page too.  When Rushby suggested it
> yesterday I immediately used it, and it allowed me to download the
> Toolkit 2003 just fine -- so, I guess Microsoft must have killed that
> possibility shortly thereafter (who said they can't move fast?-).
> 
> As of now, I don't know any more of a URL that's usable to download
> this, therefore:-(

And with a new version of windows due at the end of this year, it's 
likely those who upgrade to Vista, will also need to upgrade to visual 
studio 2005 or later.

I've seen this pattern before.  :-/

Ron

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


Re: python application ideas.

2006-04-25 Thread Tim Parkin
Anthony Greene wrote:
> Hello, I know this isn't really a python centric question, but I'm seeking
> help from my fellow python programmers. I've been learning python for the
> past year and a half, and I still haven't written anything substantial nor
> have I found an existing project which blows my hair back. Python is my
> first language, and I plan on learning lisp within the next week but
> before I do so I'd like to write something meaningful, does anyone have
> any suggestions? Something they always needed, but never got around to
> writing it? Without an imagination you pretty much stagnate your whole
> learning process. Thanks in advance.
> 

How about writing a standalone wiki markup parser? I know a *lot* of
people who would find this useful..

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


Re: MinGW and Python

2006-04-25 Thread Fredrik Lundh
Brian Elmegaard wrote

> > the gcc project is to provide a portable compiler, not one that
> > generates the best code for any given platform. And in that goal, it
> > succeeds remarkably well.
>
> Will a python program be slower on the same machine running windows
> compared to linux?

a better optimizer usually results in programs that run faster, not slower.





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


Re: Why new Python 2.5 feature "class C()" return old-style class ?

2006-04-25 Thread Bengt Richter
On Sun, 23 Apr 2006 22:12:01 GMT, [EMAIL PROTECTED] (Bengt Richter) wrote:
[...]
>(IMO the proper way to indicate the you don't have a tuple is to use None or 
>some other sentinel,
>not abuse a perfectly legal tuple value).
>
> >>> dis.dis(compile('class X:pass','','exec'))
>   1   0 LOAD_CONST   0 ('X')   <<--+-- ought to be 
> LOAD_CONST 0 (None)
Oops, leave the 'X' of course, just replace the next line
>   3 BUILD_TUPLE  0 <<--'
>   6 LOAD_CONST   1 ( "", line 1>)
>   9 MAKE_FUNCTION0
>  12 CALL_FUNCTION0
>  15 BUILD_CLASS
>  16 STORE_NAME   0 (X)
>  19 LOAD_CONST   2 (None)
>  22 RETURN_VALUE
>
>vs code for class x(something):pass
>
> >>> dis.dis(compile('class X(object):pass','','exec'))
>   1   0 LOAD_CONST   0 ('X')
>   3 LOAD_NAME0 (object)
>   6 BUILD_TUPLE  1
>   9 LOAD_CONST   1 ( "", line 1>)
>  12 MAKE_FUNCTION0
>  15 CALL_FUNCTION0
>  18 BUILD_CLASS
>  19 STORE_NAME   1 (X)
>  22 LOAD_CONST   2 (None)
>  25 RETURN_VALUE
>

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


A QFB agent: how to catch C-level crashes and last Python stack ?

2006-04-25 Thread robert
When employing complex UI libs (wx, win32ui, ..) and other extension 
libs, nice "only Python stack traces" remain a myth.

Currently I'm hunting again a rare C-level crash bug of a Python based 
Windows app with rare user reports - and still in the dark (I get 
snippets of machine stack traces / screenshots with random "mem. access 
error" / "python caused the runtime to terminate in an unusual way" / ..)

I'd like to hook a kind of quality feedback agent a C-level to enable 
the user transfer a report (similar to what Mozilla/Netscape has), e.g. 
in a changed python.exe stub. Next to the machine stack/regs it should 
grab the relevant last Python thread stack(s), if any, and maybe other 
useful status and python global vars.
(There are also Python threads going on. )

Is that possible?

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


Re: MS VC++ Toolkit 2003, where?

2006-04-25 Thread Edward Elliott
Alex Martelli wrote:
> OK, I've placed on http://www.aleax.it/Python/ the files that pybench
> writes (with the -file option) for each machines, the names are
> onmbp.txt and onwin2k.txt -- just 20k each (I'm not sure their format is
> documented, but I guess that, worst case, one just needs to study
> pybench's sources).

Nice, thank you.  The files just contain pickled data, but you need pybench
installed to unpickle the classes.  I used the command
  pybench -s win2k.txt -c osx.txt
to compare the data sets.  Here are the results.  Left two columns are
Windows times, right column is change from OS X time.  I resorted the tests
by percentage change (win2k slowest->fastest) to provide a better picture
of what's going on:

PYBENCH 1.0
Benchmark: /home/ed/python-w2k.txt (rounds=10, warp=20)
measured against: /home/ed/python-osx.txt (rounds=10, warp=20)
Tests:  per runper oper.diff

(slower on win2k)
StringMappings: 309.33 ms2.46 us  +112.53%
 ConcatUnicode: 157.47 ms1.05 us   +77.43%
 ConcatStrings: 103.57 ms0.69 us   +44.86%
 DictWithFloatKeys: 169.10 ms0.28 us   +21.52%
 UnicodeProperties:  86.00 ms0.43 us+6.69%
   PythonFunctionCalls:  85.83 ms0.52 us+1.22%
UnicodeSlicing:  85.64 ms0.49 us+0.16%
(faster on win2k)
IfThenElse:  70.38 ms0.10 us-2.45%
SmallLists:  76.98 ms0.30 us-4.44%
CompareUnicode:  85.22 ms0.23 us-4.72%
  StringPredicates:  87.25 ms0.31 us-6.13%
NestedForLoops:  38.47 ms0.11 us-8.07%
CompareInternedStrings:  59.12 ms0.12 us-8.12%
SimpleListManipulation:  41.93 ms0.16 us-8.55%
   CreateStringsWithConcat:  35.02 ms0.18 us-9.16%
TryRaiseExcept:  49.62 ms3.31 us-9.53%
 StringSlicing:  63.61 ms0.36 us-9.77%
   SmallTuples:  68.65 ms0.29 us   -12.77%
 CompareFloatsIntegers:  72.31 ms0.16 us   -13.72%
 Recursion:  45.88 ms3.67 us   -16.20%
 CompareFloats:  51.26 ms0.11 us   -17.05%
CompareStrings:  76.14 ms0.15 us   -17.51%
 PythonMethodCalls:  60.74 ms0.81 us   -17.75%
   CreateUnicodeWithConcat:  90.22 ms0.45 us   -17.76%
  BuiltinFunctionCalls:  39.38 ms0.31 us   -17.79%
 SimpleFloatArithmetic:  57.72 ms0.10 us   -19.44%
  SecondImport:  29.59 ms1.18 us   -19.71%
   CreateInstances:  63.02 ms1.50 us   -21.08%
  SimpleIntFloatArithmetic:  55.92 ms0.08 us   -21.78%
   SimpleComplexArithmetic:  42.40 ms0.19 us   -22.84%
   BuiltinMethodLookup:  78.26 ms0.15 us   -24.54%
 UnicodePredicates:  56.17 ms0.25 us   -24.75%
  SpecialInstanceAttribute: 117.49 ms0.20 us   -24.97%
DictWithStringKeys:  62.30 ms0.10 us   -26.18%
  TupleSlicing:  73.63 ms0.70 us   -26.34%
   NormalInstanceAttribute:  65.19 ms0.11 us   -26.50%
   UnicodeMappings:  65.20 ms3.62 us   -27.68%
   SecondPackageImport:  31.25 ms1.25 us   -28.74%
 SpecialClassAttribute:  65.94 ms0.11 us   -30.30%
   ListSlicing:  50.75 ms   14.50 us   -31.37%
 SecondSubmoduleImport:  39.39 ms1.58 us   -31.98%
SimpleDictManipulation:  37.88 ms0.13 us   -32.24%
  NormalClassAttribute:  66.37 ms0.11 us   -33.40%
  DictCreation:  36.66 ms0.24 us   -34.25%
   DictWithIntegerKeys:  54.73 ms0.09 us   -35.76%
  SimpleLongArithmetic:  27.03 ms0.16 us   -39.80%
 TryExcept:  62.54 ms0.04 us   -42.17%
   SimpleIntegerArithmetic:  42.88 ms0.06 us   -42.52%
   CompareIntegers:  42.81 ms0.05 us   -45.54%
  ForLoops:  25.72 ms2.57 us   -53.99%
  CompareLongs:  25.45 ms0.06 us   -63.04%

Average round time:3847.99 ms  -12.61%


None of these tests look to me like anything virtualization would affect. 
Beyond that, I'm not sure what to make of it.  The fastest gains on win2k
(>39%) seem to come from branching and arithmetic tests.  Maybe the ms
compiler has significantly better branch prediction (might explain why
ForLoops and TryExcept have such large gains while NestedForLoops and
TryRaiseExcept are more modest).  I can't 

Re: Counting elements in a list wildcard

2006-04-25 Thread Iain King

hawkesed wrote:
> If I have a list, say of names. And I want to count all the people
> named, say, Susie, but I don't care exactly how they spell it (ie,
> Susy, Susi, Susie all work.) how would I do this? Set up a regular
> expression inside the count? Is there a wildcard variable I can use?
> Here is the code for the non-fuzzy way:
> lstNames.count("Susie")
> Any ideas? Is this something you wouldn't expect count to do?
> Thanks y'all from a newbie.
> Ed

Dare I suggest using REs?  This looks like something they'de be good
for:

import re

def countMatches(names, namePattern):
  count = 0
  for name in names:
if namePattern.match(name):
  count += 1
  return count

susie = re.compile("Su(s|z)(i|ie|y)")

print countMatches(["John", "Suzy", "Peter", "Steven", "Susie",
"Susi"], susie)


some other patters:

iain = re.compile("(Ia(i)?n|Eoin)")
steven = re.compile("Ste(v|ph|f)(e|a)n")
john = re.compile("Jo(h)?n")


Iain

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


Re: Counting elements in a list wildcard

2006-04-25 Thread John Machin
On 25/04/2006 3:15 PM, Edward Elliott wrote:
>  Phoneme matching seems overly complex and might
> grab things like Tsu-zi.

It might *only* if somebody had a rush of blood to the head and devised 
yet another phonetic key "algorithm". Tsuzi does *not* give the same 
result as any of Suzi, Suzie, Susi, and Susie when pushed through any of 
the following; Soundex, NYSIIS, Metaphone, Dolby, and Caverphone. None 
of them throw away the 'T' sound.

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


Re: Instruction at "0x00FC3D70" use memory address "0x00000000". Can't be "read".

2006-04-25 Thread bruno at modulix
> On Apr 24, 2006, at 5:38 PM, Neil Adams wrote:
> 
>> How do Ifix memory  message Ox033fc512 at Ox can't be read


I think the first think to do would be to read this:
http://www.catb.org/~esr/faqs/smart-questions.html


-- 
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 application ideas.

2006-04-25 Thread bruno at modulix
Tim Parkin wrote:
> Anthony Greene wrote:
> 
>>Hello, I know this isn't really a python centric question, but I'm seeking
>>help from my fellow python programmers. I've been learning python for the
>>past year and a half, and I still haven't written anything substantial nor
>>have I found an existing project which blows my hair back. Python is my
>>first language, and I plan on learning lisp within the next week but
>>before I do so I'd like to write something meaningful, does anyone have
>>any suggestions? Something they always needed, but never got around to
>>writing it? Without an imagination you pretty much stagnate your whole
>>learning process. Thanks in advance.
>>
> 
> 
> How about writing a standalone wiki markup parser? I know a *lot* of
> people who would find this useful..

+1


-- 
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: Multiple hierarchies and method overloading

2006-04-25 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>,
 "Ben Cartwright" <[EMAIL PROTECTED]> wrote:

>Philippe Martin wrote:
>
>> I renamed A_Func(self) to fix that ... but is there a cleaner way around ?
>
>When using multiple inheritence, the order of the base classes matters!

When you have to start worrying about complications like this, isn't 
that a sign that you're taking the whole OO thing a little too seriously?

After all, technology is supposed to _solve_ problems, not create them. 
If the complications of OO are making you lose sight of your original 
problem, then maybe you should put them aside.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can you create an instance of a subclass with an existing instance of the base class?

2006-04-25 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>,
 bruno at modulix <[EMAIL PROTECTED]> wrote:

>Lawrence D'Oliveiro wrote:
>(snip)
>> I think you're taking Python's OO-ness too seriously. One of the 
>> strengths of Python is that it can _look_ like an OO language without 
>> actually being OO.
>
>According to which definition of OO ?

Isn't there one?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multiple hierarchie and method overloading

2006-04-25 Thread bruno at modulix
Philippe Martin wrote:
> Hi,
> 
> 
> 
> 
> I have something like this:
> 
> Class A:
> def A_Func(self, p_param):
>  .
> Class B:
> def A_Func(self):
>  .
> 
> Class C (A,B):
> A.__init__(self)

If that's really your code, you should have an exception right here.
Else, please post real code.


> B.__init__(self)


> .
> 
> self.A_Func() #HERE I GET AN EXCEPTION "... takes at least 2 
> arguments (1
> given).


> 
> I renamed A_Func(self) to fix that ... but is there a cleaner way around ?

Perhaps should you read these texts:

http://diveintopython.org/object_oriented_framework/defining_classes.html
http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm
http://docs.python.org/tut/node11.html


-- 
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: need a thread to keep a socket connection alive?

2006-04-25 Thread Ben Sizer
[EMAIL PROTECTED] wrote:
> the data comming in is alway in 158 bytes though.

And one day it may not. :)  Consider yourself warned! (In a friendly
manner.)

-- 
Ben Sizer

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


Re: Multiple hierarchie and method overloading

2006-04-25 Thread bruno at modulix
Philippe Martin wrote:
> Hi,
> 
> I have something like this:
> 
> Class A:
> def A_Func(self, p_param):
>  .
> Class B:
> def A_Func(self):
>  .
> 
> Class C (A,B):
> A.__init__(self)
> B.__init__(self)
> 
> .
> 
> self.A_Func() #HERE I GET AN EXCEPTION "... takes at least 2 
> arguments (1
> given).

Ho, yes, also: A.A_Func() really takes 2 arguments (self, and p_param).
When called from an instance of A, the first argument (ie: self) will be
automagically feed with the instance itself - but you still have to pass
the second one.

> 
> I renamed A_Func(self) to fix that ... but is there a cleaner way around ?

Yes : passing the second argument.

-- 
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 application ideas.

2006-04-25 Thread momolulu
   That's really the right thing I want to know , I am a Python newbie
,and learn to know that python is very strong ability in large scale
application , as a beginner , what is the first useful and meaningful
widget can we create through Python ?

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


Re: catching doctype using xml.sax -- please

2006-04-25 Thread Diez B. Roggisch
Sakcee wrote:

> Hi
> 
> I would really appreciate if soemone can point me to the direction. how
> can I use xml.sax to catch doctype entities.
> 
> there is a xml.sax.DTDHandler , but how should i use it?

As all other handlers:

XMLReader.setDTDHandler(handler)


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


Re: test assignmet problem

2006-04-25 Thread bruno at modulix
Paolo Pantaleo wrote:
(snip)
> Thnx for the help,
> actually the problme is not solved
> 
> i have [well I want to do...] something like:
> 
> if a=b():
>do stuff with a
> else if a=c():
>do stuff with b

where does this 'b' come from ?

> else:
>do other stuff
> 
> well, two solutions are
> 
> a1=b()
> a2=c()
> 
> if a1:
>do stuff with a1
> else if a2:
>do stuff with a2
> else:
>do other stuff

if the call to b() returns a non-false value, the call to c() is useless.

> 
> the other is
> 
> 
> if b():
>a=b()
>do stuff with a
> else if c():
>a=c()
>do stuff with b
> else:
>do other stuff

You still have useless function calls.

> Even if none is exactly the same about:
>  * the number of times the b() and c() functions are executed
>  * the final value of a
> 
> I think the right one is:
> 
> a=b()
> if a:
>do stuff with a
> else:
>a=c()
>if a=c():
>do stuff with b
>else:
> do other stuff

Almost :

a = b()
if a:
  do_stuff_with_b(a)
else:
  a = c()
  if a:
do_stuff_with_c(a)
  else:
do_other_stuff()


Now there are probably better ways to write this, but this would require
more knowledge about your real code.

-- 
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: Counting elements in a list wildcard

2006-04-25 Thread John Machin
On 25/04/2006 6:26 PM, Iain King wrote:
> hawkesed wrote:
>> If I have a list, say of names. And I want to count all the people
>> named, say, Susie, but I don't care exactly how they spell it (ie,
>> Susy, Susi, Susie all work.) how would I do this? Set up a regular
>> expression inside the count? Is there a wildcard variable I can use?
>> Here is the code for the non-fuzzy way:
>> lstNames.count("Susie")
>> Any ideas? Is this something you wouldn't expect count to do?
>> Thanks y'all from a newbie.
>> Ed
> 
> Dare I suggest using REs?  This looks like something they'de be good
> for:
> 
> import re
> 
> def countMatches(names, namePattern):
>   count = 0
>   for name in names:
> if namePattern.match(name):
>   count += 1
>   return count
> 
> susie = re.compile("Su(s|z)(i|ie|y)")
> 
> print countMatches(["John", "Suzy", "Peter", "Steven", "Susie",
> "Susi"], susie)
> 
> 
> some other patters:
> 
> iain = re.compile("(Ia(i)?n|Eoin)")
> steven = re.compile("Ste(v|ph|f)(e|a)n")

What about Steffan, Etienne, Esteban, István, ... ?

> john = re.compile("Jo(h)?n")
> 

IMHO, the amount of hand-crafting that goes into a *general-purpose* 
phonetic matching algorithm is already bordering on overkill. Your 
method using REs would not appear to scale well at all.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for resources for making the jump from Java to Python easier and more productive

2006-04-25 Thread bruno at modulix
Lawrence D'Oliveiro wrote:
> In article <[EMAIL PROTECTED]>,
>  bruno at modulix <[EMAIL PROTECTED]> wrote:
> 
> 
>>Lawrence D'Oliveiro wrote:
>>
(snip)
>>>I suppose this is an instance of the more general rule: "using OO when 
>>>you don't have to".
>>
>>Lawrence, I'm afraid you're confusing OO with "statically-typed
>>class-based". FWIW, dynamic typing is part of OO since Smalltalk.
> 
> 
> I wasn't talking about dynamic typing, I was talking about subclassing, 
> which is very much a part of OO.

What you wrote implies (well, at least I understand it that way) that
polymorphic dispatch *not* based on subclassing is not OO. Hence my
reaction : the need to use subclassing (inheritance) for subtyping
(polymorphic dispatch) is not a requirement of object orientation and
has never been - it's only a limitation of languages with declarative
static typing (C++, Java, C# etc).

> Unless you subscribe to the "OO is whatever looks like a good 
> programming idea" definition .

Not really !-)



-- 
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: RESOLVED Re: PYTHONPATH

2006-04-25 Thread bruno at modulix
Brian van den Broek wrote:
> Hi all,
> 
> As a fairly new linux user running ubuntu 5.10 I'd had problems
> persistently setting my PYTHONPATH environment variable. bruno and
> Edward got me most of the way (thanks!); I'm posting what worked for
> future googling.
> 
(snip)
> The syntax that worked for me was *almost* what bruno suggested. It
> didn't work here until I used ':' rather than bruno's ';' as the path
> element separator. 

oops, my bad :(
Sorry for the typo - it's of course ':'.

-- 
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: test assignmet problem

2006-04-25 Thread Duncan Booth
bruno at modulix wrote:

> Almost :
> 
> a = b()
> if a:
>   do_stuff_with_b(a)
> else:
>   a = c()
>   if a:
> do_stuff_with_c(a)
>   else:
> do_other_stuff()
> 
> 
> Now there are probably better ways to write this, but this would require
> more knowledge about your real code.

if there are more than a couple of options you can generalise code such as 
this to use a for loop:

for guard, action in [
(b, do_stuff_with_b),
(c, do_stuff_with_c),
]:
if guard():
action(a)
break
else:
do_other_stuff()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multiple hierarchies and method overloading

2006-04-25 Thread bruno at modulix
Lawrence D'Oliveiro wrote:
> In article <[EMAIL PROTECTED]>,
>  "Ben Cartwright" <[EMAIL PROTECTED]> wrote:
> 
> 
>>Philippe Martin wrote:
>>
>>
>>>I renamed A_Func(self) to fix that ... but is there a cleaner way around ?
>>
>>When using multiple inheritence, the order of the base classes matters!
> 
> 
> When you have to start worrying about complications like this, isn't 
> that a sign that you're taking the whole OO thing a little too seriously?
> 
> After all, technology is supposed to _solve_ problems, not create them. 
> If the complications of OO are making you lose sight of your original 
> problem, then maybe you should put them aside.


def fun(arg1, arg2):
  pass

fun()
Traceback (most recent call last):
  File "", line 1, in ?
TypeError: fun() takes exactly 2 arguments (0 given)

If the complication of functions are making you loose sight of your
original problem, then maybe you should put them aside ?-)


-- 
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: The whitespaceless frontend

2006-04-25 Thread bearophileHUGS
Stelios Xanthakis:

>in my opinion nested functions are not so important and I wouldn't spend any 
>time to improve them. Usually you can do anything with classes<

Some people like and use them often (like those ones coming from
Pascal-like languages, etc), some other people (like those coming from
C-like languages like Java) use them rarely and like classes more.
Python can choose to have just one way to solve such problems, or to
support both kinds of people. At the moment I think it tries to please
both kind of programmers.


>'$' being unused seems like a good choice.<

It's less explicit than self. but it's shorter, this improves typing,
and allows to produce more compact code:

return "".join(["Graph(", repr($o), ", ", repr($nodeData), ")"])

Instead of:

return "".join(["Graph(", repr(self.o), ", ", repr(self.nodeData),
")"])

But note that every time you want to add a new piece of syntax you must
think if the same syntax can be more useful for more common tasks (like
string substitution/templating, in this situation).


> - sorry for the delayed reply. Unexpected easter vacation.<

No problem.

Bye,
bearophile

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


Re: The whitespaceless frontend

2006-04-25 Thread Sybren Stuvel
[EMAIL PROTECTED] enlightened us with:
> Some people like and use them often (like those ones coming from
> Pascal-like languages, etc), some other people (like those coming
> from C-like languages like Java) use them rarely and like classes
> more.  Python can choose to have just one way to solve such
> problems, or to support both kinds of people. At the moment I think
> it tries to please both kind of programmers.

If a function X needs a lot of data from the calling function Y, and
it is called only from Y, I tend to implement it as an inner function
of Y. I like classes a lot, but sometimes I simply want the easiest
and cleanest solution.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


OOP / language design question

2006-04-25 Thread cctv . star
I was wondering, why you always have to remember to call bases'
constructors explicitly from the derived class constructor? Why hasn't
this been enforced by the language?

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


Re: python application ideas.

2006-04-25 Thread Daniel Nogradi
> Hello, I know this isn't really a python centric question, but I'm seeking
> help from my fellow python programmers. I've been learning python for the
> past year and a half, and I still haven't written anything substantial nor
> have I found an existing project which blows my hair back. Python is my
> first language, and I plan on learning lisp within the next week but
> before I do so I'd like to write something meaningful, does anyone have
> any suggestions? Something they always needed, but never got around to
> writing it? Without an imagination you pretty much stagnate your whole
> learning process. Thanks in advance.


>That's really the right thing I want to know , I am a Python newbie
> ,and learn to know that python is very strong ability in large scale
> application , as a beginner , what is the first useful and meaningful
> widget can we create through Python ?
>


You guys might find browsing through
http://wiki.python.org/moin/CodingProjectIdeas inspiring.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Probability Problem

2006-04-25 Thread Peter Tillotson
I had a possibly similar problem calculating probs related to premium
bond permutation. With 10^12 memory ran out v quickly. In the end I got
round it by writing a recursive function and quantising the probability
density function.

Elliot Temple wrote:
> Problem: Randomly generate 10 integers from 0-100 inclusive, and sum
> them. Do that twice. What is the probability the two sums are 390 apart?
> 
> I have code to do part of it (below), and I know how to write code to do
> the rest. The part I have calculates the number of ways the dice can
> come out to a given number. The problem is the main loop has 9
> iterations and it takes about 2.5 minutes to begin the 4th one, and each
> iteration is about 101 times longer than the previous one. So:
> 
 x = 2.5 * 101**6
 x /= (60*24*365.25)
 x
> 5045631.5622908585
> 
> It'd take 5,000 millennia. (If my computer didn't run out of memory
> after about 4 minutes, that is.)
> 
> Any suggestions? Either a way to do the same thing much more efficiently
> (enough that I can run it) or a different way to solve the problem.
> 
> Code:
> 
> li = range(101)
> li2 = []
> range101 = range(101)
> for x in xrange(9):
> print "x is %s" % x
> li2 = []
> for y in li:
> for z in range101:
> li2 += [y+z]
> li = li2
> print li.count(800)
> # prints how many ways the dice can add to 800
> 
> 
> This link may help:
> http://www.math.csusb.edu/faculty/stanton/m262/intro_prob_models/calcprob.html
> 
> 
> -- Elliot Temple
> http://www.curi.us/blog/
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OOP / language design question

2006-04-25 Thread Rene Pijlman
[EMAIL PROTECTED]:
>I was wondering, why you always have to remember to call bases'
>constructors explicitly from the derived class constructor? Why hasn't
>this been enforced by the language?

Probably because the language doesn't know whether the subclass wants to
override its base class's constructor, or enhance it.

-- 
René Pijlman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OOP / language design question

2006-04-25 Thread Heiko Wundram
Am Dienstag 25 April 2006 12:34 schrieb [EMAIL PROTECTED]:
> I was wondering, why you always have to remember to call bases'
> constructors explicitly from the derived class constructor? Why hasn't
> this been enforced by the language?

Because sometimes you don't want to call the base classes constructors? The 
Python zen says: "Better explicit than implicit," and in this case it hits 
the nail on the head. Better to see right away what your code does (the 
explicit call to the base class), than to have to work around calling a bases 
constructor if you don't want to call it.

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


Re: OOP / language design question

2006-04-25 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote:

> I was wondering, why you always have to remember to call bases'
> constructors explicitly from the derived class constructor? Why hasn't
> this been enforced by the language?

I have another question for you: why does JAVA enforce that a constructor of
a base-class must be called prior to everything else in the derived class's
constructor? No way to do some computing for parameters that I want to pass
to the parent constructor...


Besides, this automatically base-constructor-calling only happens for the
most trivial of cases - the no-argument-constructors.

Regards,

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


Re: MinGW and Python

2006-04-25 Thread Brian Elmegaard
"Martin v. Löwis" <[EMAIL PROTECTED]> writes:

> It would certainly be possible to distribute a gcc-compiled python.
> However, what is the point in doing so? Cygwin already includes
> a gcc-compiled Python, for Windows:

Interesting.

> That is simply not true. 

Actually, you answered me then too. I misunderstood after reading
http://sebsauvage.net/python/mingw.html.

Is the information on that page not correct? Has it never been? 

> You can build the entire Python interpreter with Cygwin (but you
> don't need to, because there is a precompiled version), and you can
> build extensions for the python.org binary using MingW.

Great, then I tend to agree that there is no reason for building it
with mingw.


-- 
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
http://www.rugbyklubben-speed.dk
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Counting elements in a list wildcard

2006-04-25 Thread Iain King

John Machin wrote:
> On 25/04/2006 6:26 PM, Iain King wrote:
> > hawkesed wrote:
> >> If I have a list, say of names. And I want to count all the people
> >> named, say, Susie, but I don't care exactly how they spell it (ie,
> >> Susy, Susi, Susie all work.) how would I do this? Set up a regular
> >> expression inside the count? Is there a wildcard variable I can use?
> >> Here is the code for the non-fuzzy way:
> >> lstNames.count("Susie")
> >> Any ideas? Is this something you wouldn't expect count to do?
> >> Thanks y'all from a newbie.

snip

> > steven = re.compile("Ste(v|ph|f)(e|a)n")
>
> What about Steffan, Etienne, Esteban, István, ... ?
>

well, obviously these could be included:
"(Ste(v|ph|f)(e|a)n|Steffan|Etienne|Esteban)", but the OP never said he
wanted to translate anything into another language.  He just wanted to
catch variable spellings.

> > john = re.compile("Jo(h)?n")
> >
>
> IMHO, the amount of hand-crafting that goes into a *general-purpose*
> phonetic matching algorithm is already bordering on overkill. Your
> method using REs would not appear to scale well at all.

Iain

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


Re: Looking for resources for making the jump from Java to Python easier and more productive

2006-04-25 Thread ToddLMorgan
Thanks for those ... just by looking at the colour of the links in my
browser I'd only found 4 of those already so I appreciate the heads up
:- )

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


Re: MinGW and Python

2006-04-25 Thread Brian Elmegaard
Robert Kern <[EMAIL PROTECTED]> writes:

> If you meant writing extension modules for Python instead of extending
> distutils, 

I thought about extending distutils to make non-python installers. I
may have misunderstood the answers I got.
http://groups.google.com/group/comp.lang.python/browse_thread/thread/3f721b5a38fbc2d1/7af1aea19aa187b6?lnk=st&q=author%3Aelmegaard+distutils&rnum=1#7af1aea19aa187b6


> mingw for the standard Python distribution. Please see my post in the thread 
> "MS
> VC++ Toolkit 2003, where?".

Thanks, I will.
-- 
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
http://www.rugbyklubben-speed.dk
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MinGW and Python

2006-04-25 Thread Brian Elmegaard
"Fredrik Lundh" <[EMAIL PROTECTED]> writes:

> a better optimizer usually results in programs that run faster, not slower.

Got it the wrong after some editing ;-(
-- 
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
http://www.rugbyklubben-speed.dk
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OOP / language design question

2006-04-25 Thread cctv . star
Diez B. Roggisch wrote:
> I have another question for you: why does JAVA enforce that a constructor of
> a base-class must be called prior to everything else in the derived class's
> constructor?
Well, I can imagine it's done to make sure that the base(s) are
properly constructed. Sound s sensible to me.

> No way to do some computing for parameters that I want to pass
> to the parent constructor...

Try this:

Derived::Dreived() : Base(calcParam1(), calcParam2())
...

> Besides, this automatically base-constructor-calling only happens for the
> most trivial of cases - the no-argument-constructors.

Well, the language can at least ensure that theconstructor is called -
i.e. either call it automatically if it can be called without
parameters, or fail with error.

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


Re: OOP / language design question

2006-04-25 Thread cctv . star

Heiko Wundram wrote:
> Because sometimes you don't want to call the base classes constructors?
Sounds strange to me at the moment, but I'll try to adjust to this
thought.

> Python zen says: "Better explicit than implicit," and in this case it hits
> the nail on the head. Better to see right away what your code does (the
> explicit call to the base class), than to have to work around calling a bases
> constructor if you don't want to call it.
Thanks, that explains it somehow - at least, it's consistent with
explicit "self".
I think I'll need some shift in thinking after C++.

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


Re: OOP / language design question

2006-04-25 Thread Rene Pijlman
[EMAIL PROTECTED]:
>I think I'll need some shift in thinking after C++.

+1 qotw

-- 
René Pijlman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OOP / language design question

2006-04-25 Thread Diez B. Roggisch
> Well, I can imagine it's done to make sure that the base(s) are
> properly constructed. Sound s sensible to me.

It often is - there are popular examples in python where missing a
constructor will cause a program to fail spectacular. But is it _always_ a
sensible thing to do? No. If you only want some code inherited, but set up
the required constraints to do so yourself. Such things can't be expressed
in C++/JAVA, but that doesn't mean they aren't the sensible solution in
some cases.

>> No way to do some computing for parameters that I want to pass
>> to the parent constructor...
> 
> Try this:
> 
> Derived::Dreived() : Base(calcParam1(), calcParam2())
> ...

Oh, I know about that. however, there are limits to this. For example, you
can't do anything that depends on constructors called before in case of
multiple inheritance. And you are forced to create a static method to do
so, which can be viewed as ugly as well.

> Well, the language can at least ensure that theconstructor is called -
> i.e. either call it automatically if it can be called without
> parameters, or fail with error.

Yes, it can do that because of static typing - in fact it will fail on a lot
more of occasions with a compilation error. 

The question here is if you are willing to trade freedom of expressiveness
against the proposed security of static typing. I found that I favor the
former and can live without the latter.

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


Re: Counting elements in a list wildcard

2006-04-25 Thread John Machin
On 25/04/2006 8:51 PM, Iain King wrote:
> John Machin wrote:
>> On 25/04/2006 6:26 PM, Iain King wrote:
>>> hawkesed wrote:
 If I have a list, say of names. And I want to count all the people
 named, say, Susie, but I don't care exactly how they spell it (ie,
 Susy, Susi, Susie all work.) how would I do this? Set up a regular
 expression inside the count? Is there a wildcard variable I can use?
 Here is the code for the non-fuzzy way:
 lstNames.count("Susie")
 Any ideas? Is this something you wouldn't expect count to do?
 Thanks y'all from a newbie.
> 
> snip
> 
>>> steven = re.compile("Ste(v|ph|f)(e|a)n")
>> What about Steffan, Etienne, Esteban, István, ... ?
>>
> 
> well, obviously these could be included:
> "(Ste(v|ph|f)(e|a)n|Steffan|Etienne|Esteban)", but the OP never said he
> wanted to translate anything into another language.

Neither did I. But if you have to cope with a practical situation like 
where the birth certificate says István and the job application says 
Steven and the foreman calls him Steve, you won't be stuffing about with 
hand-crafted REs, one per popular given name. Could be worse: the punter 
could have looked up a dictionary and changed his surname from Kovács to 
Smith; believe me -- it happens.

Oh and if you cast your net as wide as the Pacific islands, chuck in 
Sitiveni. That's enough examples. We won't go near Benjamin :-)

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


Re: OOP / language design question

2006-04-25 Thread Duncan Booth
[EMAIL PROTECTED] wrote:

> Heiko Wundram wrote:
>> Because sometimes you don't want to call the base classes constructors?
> Sounds strange to me at the moment, but I'll try to adjust to this
> thought.

It makes sense in more static languages such as C++. The base class is 
initialised by the constructor, so you have to do everything possible to 
ensure that initialisation is done before you actually try to use any part 
of the base class. Weird things can still happen in C++ if you start 
calling methods too soon (e.g. to calculate some of the base constructor's 
parameters): you can find uninitialised member variables and you might not 
get exactly the virtual methods you expected.

Python is more laid back about these things. The object itself already 
exists when __init__ is first called. It already has a type, which 
(unlike C++) isn't going to change part way through. All that is missing 
are a few attributes, and if you try to access them too soon you'll get an 
exception rather than a random value.

It makes sense therefore to give the programmer the scope to override the 
expected sequence of initialisation for those rare cases where it actually 
matters. The programmer also gets enough scope to shoot themselves in the 
foot, but Python programmers are expected to be intelligent enough not to 
do that accidentally.

Usually though, if a subclass doesn't immediately call the base class 
constructors as the first thing it does in __init__ it indicates poor code 
and should be refactored.

BTW, the same arguments apply to destructors: if you have a __del__ method 
and need to call the base __del__ methods you have to do that manually as 
well.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Accessing Parallel Port in Python Error : Priviledged Instruction

2006-04-25 Thread your
type your message here
-- 
http://mail.python.org/mailman/listinfo/python-list


Zope 3

2006-04-25 Thread Derick van Niekerk
I have been developing in PHP for some time now and needed to look into
application frameworks to speed up my development. I was looking into
Horde and CakePHP before I was introduced to Python. I started learing
python and within a few *hours* I already wrote my first small program
and I still use it!

I love Python! Then I was introduced to Zope by freak accident. While
Zope looked like the answer to my dillemma, I still can't get my head
wrapped around it. Is it because I don't know Python well enough? Or is
it just that difficult to learn?

I would like to start my next web project (a database of demographic
info on scientists in Africa)  on Zope 3. Could anybody point me in the
right direction? Where should I start?

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


Re: Hooking things up in GUI application

2006-04-25 Thread sturlamolden

Ryan Ginstrom wrote:

> Apropos recent threads about GUI editors, coming from a Win32/WTL C++
> background, I actually like the idea of being able to (easily) create GUIs
> programmatically.
>
> But I still see a lot of the same tedium: hooking up events to handlers, and
> getting data into and out of dialogs. In C++, this is generally handled
> through code generation and/or macros, but IMO these are brittle and ugly.
>
> So my question: Is there a Pythonic way to make these tedious hookups easier?


If you use PyGTK (it also runs on Windows), you can design the GUI with
GLADE and then use libglade to import the gui as an xml-resource. You
have to write all handlers (you do anyway), but the GUI design becomes
entirely visual and the hookup becomes one single like of code. It
doesn't get easier than that. As a bonus you get an hardware
accelerated GUI (Cairo takes care of that, currently through OpenGL but
a DirectX backend is planned). I.e. a hardware accelerated GUI
represented as an XML resource. Isn't that Microsoft's next 'big thing'
codenamed 'Avalon'? I wonder where they got the idea.

This should illustrate the level of tediousness when using PyGTK:

import pygtk
pygtk.require('2.0')
import gtk
import gtk.glade

class MyGUI:

   def __init__(self):
  win1 = libglade.GladeXML('mygui.glade','window1')
  win1.signal_autoconnect(self)   # hook event handlers, pass any
class or dictionary
  win1.maximize()

   def on_win1_destroy(self):
  gtk.main_quit()

if __name__ == '__main__'
   gui = MyGUI()
   gtk.main()


You cannot make it less tedious in C++. Even if you use Visual Studio
and all sorts of 'wizards' to autogenerate code. Actually, if you do
use C, C++ or Ada, GLADE can autogenerate code just like Visual Studio.
But since an XML resource us much easier to modify and maintain, it is
not recommended.

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


Re: OOP / language design question

2006-04-25 Thread bruno at modulix
Duncan Booth wrote:
(snip)
> Usually though, if a subclass doesn't immediately call the base class 
> constructors as the first thing it does in __init__ it indicates poor code 
> and should be refactored.

Not necessarily. It's a common case to have some computations to do/some
attributes to set in the derived class's __init__ before calling the
superclass's.

-- 
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: OOP / language design question

2006-04-25 Thread bruno at modulix
[EMAIL PROTECTED] wrote:
> I was wondering, why you always have to remember to call bases'
> constructors 


s/constructors/__init__/

the __init__() method is *not* the constructor. Object's instanciation
is a two-stage process:  __new__() is called first, then __init__().


-- 
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: Can you create an instance of a subclass with an existing instance of the base class?

2006-04-25 Thread bruno at modulix
Lawrence D'Oliveiro wrote:
> In article <[EMAIL PROTECTED]>,
>  bruno at modulix <[EMAIL PROTECTED]> wrote:
> 
> 
>>Lawrence D'Oliveiro wrote:
>>(snip)
>>
>>>I think you're taking Python's OO-ness too seriously. One of the 
>>>strengths of Python is that it can _look_ like an OO language without 
>>>actually being OO.
>>
>>According to which definition of OO ?
> 
> 
> Isn't there one?

Your claim that Python "_look_ like an OO language without actually
being OO" implicitely relies on a definition of OO - or is just
meaningless. So I ask you: what definition of OO do you use to support
your claim ?

-- 
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: MinGW and Python

2006-04-25 Thread sturlamolden

Martin v. Löwis wrote:

> - there is no build process available to do that

In MSYS:

$ ./configure --prefix=/c/mingw
$ make
$ make install

This should be obvious to any with Unix experience.

MinGW actually distribute precompiled Python binaries as well (in
MSYS-DTK).

> - people building extensions to Python must be able to do so with
>   Microsoft C++, since some of these extensions are written using MFC.

MinGW can compile MFC. Download Windows Platform SDK and you get the
MFC source.

> - developing Python itself in Visual Studio is quite convenient; in
>   particular, the debugger works "better" than gdb.

Eclipse is an excellent IDE that works with MinGW.

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


PIL / libjpeg install problem

2006-04-25 Thread mikko . koivunen
Hello all,

I am installing the Python Imaging Library (1.1.5). Following the
README that came with PIL sources, I ran "path/to/python setup.py
build_ext -i" which informed me that JPEG support is OK.

However when I run "path/to/python selftest.py" from the same package,
I get an IOError: decoder jpg not available.

This is a RHEL4 server and I am building PIL for a selfcompiled Python
2.3.5 install.

Libjpeg and libjpeg-devel are installed via RPM.

Any help appreciated.

Full error here:

Failure in example: _info(Image.open("Images/lena.jpg"))
from line #24 of selftest.testimage
Exception raised:
Traceback (most recent call last):
  File "./doctest.py", line 499, in _run_examples_inner
exec compile(source, "", "single") in globs
  File "", line 1, in ?
  File "./selftest.py", line 21, in _info
im.load()
  File "PIL/ImageFile.py", line 180, in load
d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
  File "PIL/Image.py", line 328, in _getdecoder
raise IOError("decoder %s not available" % decoder_name)
IOError: decoder jpeg not available
1 items had failures:
   1 of  55 in selftest.testimage
***Test Failed*** 1 failures.
*** 1 tests of 55 failed.

-- 
Mikko Koivunen

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


Re: Zope 3

2006-04-25 Thread bruno at modulix
Derick van Niekerk wrote:
> I have been developing in PHP for some time now and needed to look into
> application frameworks to speed up my development. I was looking into
> Horde and CakePHP before I was introduced to Python. I started learing
> python and within a few *hours* I already wrote my first small program
> and I still use it!
> 
> I love Python! Then I was introduced to Zope by freak accident. While
> Zope looked like the answer to my dillemma, I still can't get my head
> wrapped around it. Is it because I don't know Python well enough? Or is
> it just that difficult to learn?

Zope is a world in itself - and is certainly not the simplest tool to
learn (nor the most pythonic). You may want to consider other options
like Django, Pylon or Turbogears.

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: Parsing XML/XSLT

2006-04-25 Thread Stefan Behnel
veracon wrote:
> I'm looking to use XML and XSLT for templates in a system I'm writing,
> however I'm not really sure which parser is the "best". Basically,
> which library has the most features, and which is the most supported?

lxml arguably has the most features by now, as it is based on libxml2 and
libxslt (libexslt support is in SVN) and wraps most of their features into
easy-to-use Python APIs.

At least lxml's API is also arguably the most supported as it mostly
compatible to ElementTree (which made it into Python 2.5).

http://codespeak.net/lxml

Beware though, I'm somewhat biased as I'm one of the authors.

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


Re: MinGW and Python

2006-04-25 Thread sturlamolden

Robert Kern wrote:

> - gcc does not optimize particularly well.

That is beyond BS. The more recent gcc releases optimize as well as any
commercial compiler. GCC 4 may even optimize better than MSVC.

GCC is the compiler used to build the Linux kernel and MacOSX. If it
can deal with this I say it can handle Python as well. My guess is you
will not notice any performance difference for the Python interpreter.
Doesn't Python run well on Linux? GCC is used to build Python on Linux.
MinGW is GCC. MinGW on Windows creates the same binary code as GCC on
Linux.

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


Re: How to search HUGE XML with DOM?

2006-04-25 Thread Stefan Behnel
Sullivan WxPyQtKinter wrote:
> My search needs:
> 1. Search and return all the record (an element) with specific id.
> 2. Search and return all the record whose child nodes has a specific id
> or attribute.

Try lxml, which is based on the libxml2 library. The current SVN version has
support for xml:id through the XMLDTDID function. It simply returns an XML
tree and an ID dictionary.

http://codespeak.net/lxml

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


Re: OOP / language design question

2006-04-25 Thread Carl Banks
[EMAIL PROTECTED] wrote:
> Heiko Wundram wrote:
> > Because sometimes you don't want to call the base classes constructors?
> Sounds strange to me at the moment, but I'll try to adjust to this
> thought.

In Java and C++, classes have private members that can only be accessed
by the class itself (and, in C++, friends).  In those languages, a base
constructor needs to be called to initialize the base class's private
members.

Python has no private members (except for the double underscore
thingies, which aren't that common).  Unlike C++ and Java, the derived
class's __init__ can usually initialize all the base class's members,
and it's occasionally useful to do so.

I would agree it's a mistake to not call the base class's __init__
unless you're doing it deliberately.  If you want a tool to catch those
mistakes, have a look at pychecker.  It can inform you whenever the
base class __init__ is not called.

(However, I totally disagree that it's a good idea to always call it
first, though.  I've written base class __init__s that expected the
subclass to provide initialization methods, and some of those methods
needed some subclass members to exist before they were called.)

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


Re: MinGW and Python

2006-04-25 Thread sturlamolden

Robert Kern wrote:

> Dunno. Depends on the machine. Depends on the program. Depends on how the
> interpreter and any extension modules and underlying libraries were built.
> Depends on which Linux and which Windows.
>
> I'm sorry, but your question is a non sequitur. I don't understand its 
> relevance
> to this thread.


The relevance: Python is built with GCC on Linux. Do you or do you not
see a performance hit on Linux?

MinGW is GCC. Will you get a performance hit when building Python with
MinGW?

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


Re: need a thread to keep a socket connection alive?

2006-04-25 Thread nephish
yeah, he he

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


Re: OOP / language design question

2006-04-25 Thread Duncan Booth
bruno at modulix wrote:

> Duncan Booth wrote:
> (snip)
>> Usually though, if a subclass doesn't immediately call the base class
>> constructors as the first thing it does in __init__ it indicates poor
>> code and should be refactored.
> 
> Not necessarily. It's a common case to have some computations to
> do/some attributes to set in the derived class's __init__ before
> calling the superclass's.
> 

I did only say 'usually'. Can you actually think of any good examples where 
you have to set a derived attribute before you can call the base class 
constructor? I can't, which is why I was a bit vague.

The base class is unlikely to depend on the derived class attributes, and 
unless it does there should be no reason which you can't just call the base 
__init__ straight away. Perhaps if the base __init__ calls an overridden 
method, but at that point it sounds to me like something wants refactoring.

I can think that you might have to do some computations to calculate 
parameters for the base __init__, but that is a separate issue.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MinGW and Python

2006-04-25 Thread sturlamolden

I forgot to mention that C libraries built with Visual C++ and MinGW
are binary compatible. MinGW can link libararies and object files from
Visual C++. Although Python may be build with Visual C++, you can still
compile and link your C extensions with MinGW.

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


RE: MinGW and Python

2006-04-25 Thread Ames Andreas
> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED]
> g] On Behalf Of sturlamolden
> Sent: Tuesday, April 25, 2006 2:27 PM
> Subject: Re: MinGW and Python
> 
> 
> Robert Kern wrote:
> 
> > - gcc does not optimize particularly well.
> 
> That is beyond BS. The more recent gcc releases optimize as 
> well as any
> commercial compiler. GCC 4 may even optimize better than MSVC.

Not to talk of standard compliance (msvc-c99 anyone?).


cheers,

aa

-- 
Andreas Ames | Programmer | Comergo GmbH |
Voice:  +49 69 7505 3213 | ames AT avaya . com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OOP / language design question

2006-04-25 Thread Carl Banks

bruno at modulix wrote:
> [EMAIL PROTECTED] wrote:
> > I was wondering, why you always have to remember to call bases'
> > constructors
>
> 
> s/constructors/__init__/
>
> the __init__() method is *not* the constructor. Object's instanciation
> is a two-stage process:  __new__() is called first, then __init__().
> 

You know, Python's __init__ has almost the same semantics as C++
constructors (they both initialize something that's already been
allocated in memory, and neither can return a substitute object).  I
actually think constructors are misnamed in C++, they should be called
initializers (and destructors finalizers).  The only thing is that C++
doesn't always call operator new when constructing objects, whereas
Python always calls __new__, so you can put some initialization in
__new__ if you want.

Other than that I'd say that Python __init__ is analogous to Java and
C++ constructors, but is not a constructor because C++ and Java
constructors are not constructors. :)  And Java has pointers, not
references. :)

A-rose-by-any-other-name-ly yr's,

Carl Banks

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


Re: python application ideas.

2006-04-25 Thread Fredrik Lundh
"momolulu" wrote:

>   That's really the right thing I want to know , I am a Python newbie
> ,and learn to know that python is very strong ability in large scale
> application , as a beginner , what is the first useful and meaningful
> widget can we create through Python ?

What makes you think that the first "useful and meaningful widget" is the
same thing for everyone ?

The first thing I built as a Python beginner was a high-volume fault-tolerant
distributed image production system for heterogenous environments.  The
most recent thing I built is a small script that takes an infogami comment
and reposts it as an article.

What kind of applications and systems do you usually work on ?

 



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


EuroPython 2006: Call for papers

2006-04-25 Thread Armin Rigo
Hi all,

A shameless plug and reminder for EuroPython 2006 (July 3-5):

* you can submit talk proposals until May 31st.

* there is a refereed papers track; deadline for abstracts: May 5th.
  See the full call for papers below.


A bientot,

Armin Rigo & Carl Friedrich Bolz




   EuroPython 2006
   CERN, Geneva, 3-5 July

   Refereed Track: Call for Paper

 http://www.europython.org


EuroPython is the only conference in the Python world that has a
properly prestigious peer-reviewed forum for presenting technical and
scientific papers. Such papers, with advanced and highly innovative
contents, can equally well stem from academic research or industrial
research. We think this is an important function for EuroPython, so we
are even making some grants available to help people with travel costs.

For this refereed track, we will be happy to consider papers in subject
areas including, but not necessarily limited to, the following:

* Python language and implementations
* Python modules (in the broadest sense)
* Python extensions
* Interoperation between Python and other languages / subsystems
* Scientific applications of Python
* Python in Education
* Benchmarking Python

We are looking for Python-related scientific and technical papers of
advanced, highly innovative content that present the results of original
research (be it of the academic or "industrial research" kind), with
proper attention to "state of the art" and previous relevant
literature/results (whether such relevant previous literature is itself
directly related to Python or not).

We do not intend to let the specific subject area block a paper's
acceptance, as long as the paper satisfies other requirements:
innovative, Python-related, reflecting original research, with proper
attention to previous literature.

Abstracts
=

Please submit abstracts of no more than 200 words to the refereeing
committee. You can send submissions no later than 5 May 2006. We shall
inform you whether your paper has been selected no later than 15 May
2006. For all details regarding the submission of abstracts, please see
the EuroPython website (http://www.europython.org).  Papers

If your abstract is accepted, you must submit your corresponding paper
before 17 June 2006. You should submit the paper as a PDF file, in A4
format, complete, "stand-alone", and readable on any standards-compliant
PDF reader (basically, the paper must include all fonts and figures it
uses, rather than using external pointers to them; by default, most
PDF-preparation programs typically produce such valid "stand-alone" PDF
documents).

Refereeing
==

The refereeing committee, selected by Armin Rigo, will examine all
abstracts and papers. The committee may consult external experts as it
deems fit. Referees may suggest or require certain changes and editing
in submissions, and make acceptance conditional on such changes being
performed. We expect all papers to reflect the abstract as approved and
reserve the right, at our discretion, to reject a paper, despite having
accepted the corresponding abstract, if the paper does not substantially
correspond to the approved abstract.

Presentation


The paper must be presented at EuroPython by one or more of the
authors. Presentation time will be either half an hour or an hour,
including time for questions and answers, depending on each paper's
details, and also on the total number of papers approved for
presentation.

Proceedings
===

We will publish the conference's proceedings in purely electronic
form. By presenting a paper, authors agree to give the EuroPython
conference non-exclusive rights to publish the paper in electronic forms
(including, but not limited to, partial and total publication on web
sites and/or such media as CDROM and DVD-ROM), and warrant that the
papers are not infringing on the rights of any third parties. Authors
retain all other intellectual property rights on their submitted
abstracts and papers excepting only this non-exclusive license.

Subsidised travel
=

We have funds available to subsidise travel costs for some presenters
who would otherwise not be able to attend EuroPython. When submitting
your abstract, please indicate if you would need such a subsidy as a
precondition of being able to come and present your paper. (Yes, this
possibility does exist even if you are coming from outside of
Europe. Papers from people in New Zealand who can only come if their
travel is subsidised, for example, would be just fine with us...).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OOP / language design question

2006-04-25 Thread Duncan Booth
Carl Banks wrote:

> You know, Python's __init__ has almost the same semantics as C++
> constructors (they both initialize something that's already been
> allocated in memory, and neither can return a substitute object). 

There is a significant difference: imagine B is a base type and C a 
subclass of B:

When you create an object of type C in Python, while B.__init__ is 
executing self is an object of type C (albeit without all the attributes 
you expect on your C).

In C++ when the B() constructor is executing the object is an object of 
type B. It doesn't become a C object until the C() constructor is 
executing.

In other words, the object is constructed in Python before any __init__ is 
called, but in C++ it isn't constructed until after all the base class 
constructors have returned.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python application ideas.

2006-04-25 Thread RK
I need a python source code diagrammer that actually works
out-of-the-box to explore all the code already written out there.

something like SmallWorlds was to java before they got rid of it.

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


RE: Hooking things up in GUI application

2006-04-25 Thread Ryan Ginstrom
> Behalf Of sturlamolden
> If you use PyGTK (it also runs on Windows), you can design 
> the GUI with
> GLADE and then use libglade to import the gui as an xml-resource.

Yes, I've tried something similar with wxGlade. Nice, but it doesn't seem to
remove the most tedious work -- hooking up handlers (although it does help
here, at the cost of some behind-the-scenes magic), and getting data into and
out of GUI widgets. That's the kind of boilerplate code that makes GUI
development a pain in my opinion -- the actual GUI design/layout isn't so
bad, especially with the spacer layout concept.

--
Regards,
Ryan Ginstrom


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


MySQLdb "begin()" -

2006-04-25 Thread shearichard
Hi - Feeling a bit weird about this but I cannot find the 'begin'
method on a connection object of MySQLdb. Can anyone explain why ?

I'm using version 1.2.0 which is pretty recent and I've read that
'begin' should be a method of connection but it's not there ! Feeling
pretty puzzled !

Below are the details of what I see ...


>>> import MySQLdb
>>> c= MySQLdb.Connect(host='localhost', user='a',passwd='b', db='c',compress=1)
>>> c.begin()
Traceback (most recent call last):
  File "", line 1, in ?
AttributeError: 'Connection' object has no attribute 'begin'
>>> o=MySQLdb
>>> o.__version__
'1.2.0'
>>> o.__revision__
'1.37'
>>> o.apilevel
'2.0'


Be interested in any comments.

regards

Richard.

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


Re: Zope 3

2006-04-25 Thread Benji York
bruno at modulix wrote:
> Zope is a world in itself - and is certainly not the simplest tool to
> learn (nor the most pythonic).

Those statements apply more to Zope 2 than Zope 3 (and Zope 2 is moving 
more and more toward Zope 3 these days).  One of Zope 3's main goals was 
to focus on the Python programmer as a primary target.  That being said 
there /are/ some powerful and novel concepts used in Z3 (the component 
framework).

> You may want to consider other options like Django, Pylon or Turbogears.

It's true that Z3 is not currently focused very well on the 
"middle-class" developer.  It's more of an industrial-strength kind of 
thing, but considerable thought has been given lately on how to build 
bridges so everyone can benefit without being full-time Zope masters.

Toward that end, I wrote a little quick start guide that might help the 
OP: http://www.benjiyork.com/quick_start
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python on Nintendo DS

2006-04-25 Thread Richard Tew
An update to my Python on Nintendo DS efforts.

Summary:
- Working bug free port of Python for the Nintendo DS.
- Programmers wanted to help write extensions to expose the DS hardware
  to Python.
- Stackless Python supported, but not bug free.

When I last worked on it, it had several remaining bugs including a
broken zipimport, unreliability due to limited stack space and more.

I spent a statutory holiday on it and located and fixed all the bugs,
including the allocation of stack space and the problems with zipimport
(due to a misunderstanding about what seek function API I should
respect).  As it stands now, it seems pretty bug free.

Python itself running on the Nintendo DS with no access to the hardware
features (graphics, microphone, speakers, touchscreen) is not much use.
 As a text-based calculator it serves one purpose I guess. But to
really serve as a useful tool on the DS, it needs to expose these
pieces of hardware.  SDL is one option, as there is a reportedly buggy
port of SDL for the DS, and ideally as PyGame is based on SDL, a port
of that would hopefully be straightforward.

If anyone has an experience writing extension modules in C, and with
programming the DS hardware in C, and wishes to help flesh out some
form of library codebase to make this a useful port of Python, please
let me know! :)

Also, I switched to the Stackless Python code base.   The tasklet
scheduler locks up if invoked, but I haven't had the chance to look
into this yet.  But given that tasklets run and switch in the limited
scenarios I have tried, fixing the scheduler should be a matter of
time.

Richard

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


I have problems with creating the classic game Wumpus. the file: http://esnips.com/webfolder/b71bfe95-d363-4dd3-bfad-39999a9e36d0

2006-04-25 Thread conny . ledin
Im trying to create a version of the game Wumpus. Mine is called
Belzebub. But im STUCK! And its due tuesday 2 maj. Im panicing! Can
some one help me??
here is the file:
http://esnips.com/webfolder/b71bfe95-d363-4dd3-bfad-3a9e36d0

What i have the biggest problems with now is between line 8 and 23. How
i can move the character trough the game. Other parts of the game that
have with the movement to do is between line 83-114 and 123-143.

This is part of the spec:
"The player walks around in the hallways, finds and tries to kill
Wumpus (Belzebub). The game finishes when the player or Belzebub dies.
 The player has bombs which he can shoot. When he shoots he can
controll th ebombs for three moves, north, south, east or west three
times. If he is not careful he can shoot himself, ex first move: north.
second move south.
 Let every room be represented by the object room. In the object,
information of what exists in the room is stored. (Belzebub,
teleporters, fire traps, acid traps or nothing). and where the halways
leads. (north hallway leads to room 17, the east to room 2 etc.).
Create a list of room objects to represent the hallways (every room
have has a number).
 The content of the rooms shall be randomized in the beginning of
the program. Aproximatly 20% of the rooms should contain traps, 30%
should contain teleporters and in one of the rooms is Belzebub. One
room can not contain more than one danger, no traps and teleporters
together etc.
 Teleporters transports the player from one room to another random
room. If the player encounters a trap o Belzebub he is killed and GAME
OVER.
 The halways should also be randomized in the beginning of the
program. Like this:

* Create a list with all the room numbers and shuffle it so all of the
rooms is in a mixed order. ex. [5 2 12 18 9 1 3 6 14 19 11 7 17 4 20 16
10 15 8 13]

* Connect the rooms in east-west direction so that the east hallway
from room 5 leads to room 2 and the west hallway from room to leads
back to room 5 etc. The last room in the lest should be connected with
the first.

* Shuffle a new list and do the same thing in north-south direction.

once again the file:
http://esnips.com/webfolder/b71bfe95-d363-4dd3-bfad-3a9e36d0

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


I have problems with creating the classic game Wumpus. the file: http://esnips.c

2006-04-25 Thread connyledin
Im trying to create a version of the game Wumpus. Mine is called 
Belzebub. But im STUCK! And its due tuesday 2 maj. Im panicing! Can 
some one help me??
here is the file:
http://esnips.com/webfolder/b71bfe95-d363-4dd3-bfad-3a9e36d0

What i have the biggest problems with now is between line 8 and 23. 
How i can move the character trough the game. Other parts of the game 
that have with the movement to do is between line 83-114 and 123-143.

This is part of the spec:
"The player walks around in the hallways, finds and tries to kill 
Wumpus (Belzebub). The game finishes when the player or Belzebub dies.
 The player has bombs which he can shoot. When he shoots he can 
controll th ebombs for three moves, north, south, east or west three 
times. If he is not careful he can shoot himself, ex first move: 
north. second move south.
 Let every room be represented by the object room. In the object, 
information of what exists in the room is stored. (Belzebub, 
teleporters, fire traps, acid traps or nothing). and where the 
halways leads. (north hallway leads to room 17, the east to room 2 
etc.). Create a list of room objects to represent the hallways (every 
room have has a number). 
 The content of the rooms shall be randomized in the beginning of 
the program. Aproximatly 20% of the rooms should contain traps, 30% 
should contain teleporters and in one of the rooms is Belzebub. One 
room can not contain more than one danger, no traps and teleporters 
together etc. 
 Teleporters transports the player from one room to another 
random room. If the player encounters a trap o Belzebub he is killed 
and GAME OVER.
 The halways should also be randomized in the beginning of the 
program. Like this:

* Create a list with all the room numbers and shuffle it so all of 
the rooms is in a mixed order. ex. [5 2 12 18 9 1 3 6 14 19 11 7 17 4 
20 16 10 15 8 13]

* Connect the rooms in east-west direction so that the east hallway 
from room 5 leads to room 2 and the west hallway from room to leads 
back to room 5 etc. The last room in the lest should be connected 
with the first.

* Shuffle a new list and do the same thing in north-south direction.

Once again the file: http://esnips.com/webfolder/b71bfe95-d363-4dd3-
bfad-3a9e36d0





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


Re: Multiple hierarchies and method overloading

2006-04-25 Thread Philippe Martin
Well, the whole point was to clean up my code:

Actually this is what I have:

Class A:
def A_Func(self, p_param):
 .
Class B:
def A_Func(self):
 .

Class C (A,B):
A.__init__(self)
B.__init__(self)

Class D (A,B):
A.__init__(self)
B.__init__(self)


Where A is a wxWidget class and B a "Common/utility" class which I wanted to
factorize (and yes, inheritance was not mandatory here, just simpler)

My common class does have an A_Func(self) while wxWidget an A_Func(self,
p_param) ==> I actually got the error calling A_Func(self) as it was
checked against A_Func(self, p_param).

Regards,

Philippe







Lawrence D'Oliveiro wrote:

> In article <[EMAIL PROTECTED]>,
>  "Ben Cartwright" <[EMAIL PROTECTED]> wrote:
> 
>>Philippe Martin wrote:
>>
>>> I renamed A_Func(self) to fix that ... but is there a cleaner way around
>>> ?
>>
>>When using multiple inheritence, the order of the base classes matters!
> 
> When you have to start worrying about complications like this, isn't
> that a sign that you're taking the whole OO thing a little too seriously?
> 
> After all, technology is supposed to _solve_ problems, not create them.
> If the complications of OO are making you lose sight of your original
> problem, then maybe you should put them aside.

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


Re: Multiple hierarchie and method overloading

2006-04-25 Thread Philippe Martin
Thanks,

I'll try that.

Philippe


Ben Cartwright wrote:

> Philippe Martin wrote:
>> I have something like this:
>>
>> Class A:
>> def A_Func(self, p_param):
>>  .
>> Class B:
>> def A_Func(self):
>>  .
>>
>> Class C (A,B):
>> A.__init__(self)
>> B.__init__(self)
>>
>> .
>>
>> self.A_Func() #HERE I GET AN EXCEPTION "... takes at least 2
>> arguments (1
>> given).
>>
>>
>> I renamed A_Func(self) to fix that ... but is there a cleaner way around
>> ?
> 
> When using multiple inheritence, the order of the base classes matters!
>  E.g.:
> 
>   class A(object):
>   def f(self):
>   print 'in A.f()'
>   class B(object):
>   def f(self):
>   print 'in B.f()'
>   class X(A, B):
>   pass
>   class Y(B, A):
>   pass
> 
>   >>> x = X()
>   >>> x.f()
>   in A.f()
>   >>> y = Y()
>   >>> y.f()
>   in B.f()
> 
> If you want to call B.f() instead of A.f() for an X instance, you can
> either rename B.f() like you've done, or do this:
> 
>   >>> B.f(x)
>   in B.f()
> 
> --Ben

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


Re: MySQLdb "begin()" -

2006-04-25 Thread Geoffrey Clements
<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi - Feeling a bit weird about this but I cannot find the 'begin'
> method on a connection object of MySQLdb. Can anyone explain why ?
>
> I'm using version 1.2.0 which is pretty recent and I've read that
> 'begin' should be a method of connection but it's not there ! Feeling
> pretty puzzled !
>

What exactly do you expect a begin method to do?  Have you read this:
http://www.python.org/dev/peps/pep-0249/

-- 
Geoff 


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


Re: Hooking things up in GUI application

2006-04-25 Thread sturlamolden

Ryan Ginstrom wrote:
> > Behalf Of sturlamolden
> > If you use PyGTK (it also runs on Windows), you can design
> > the GUI with
> > GLADE and then use libglade to import the gui as an xml-resource.
>
> Yes, I've tried something similar with wxGlade. Nice, but it doesn't seem to
> remove the most tedious work -- hooking up handlers (although it does help
> here, at the cost of some behind-the-scenes magic),

It does, there is just *one* line of code for hooking up all the
handlers:

   win.signal_autoconnect(something)

That is one line of code for the entire window, not one line of code
for every widget in the window. Even if your window contains 100
widgets (buttons, sliders, menus, etc), this hooks up the handlers for
every one of them. You just call .signal_autoconnect once. This single
line of code does the job of all the message map macros you would write
in MFC, Fox and wxWidgets. signal_autoconnect does what it says, it
autoconnects the signal handlers. How can that be tedious?

Here is an advice: just be lazy. In particular:

* Don't create write a dictionary mannually and feed it to
signal_autoconnect. Many tutorials do that. It is silly: it is tedious,
it is superfluous bloat, and the job has in fact aldready been done.
Write a class instead. Guido has made sure every class has a
dictionary. Just make sure you have class methods with names
corresponding to the signals. Pass a class reference to
signal_autoconnect.

* Don't grab references for every widget out of the xml. I've seen done
that in many tutorials too. It is silly. Just ask the xml for a
reference when you need one. The xml resources will store the widget
references for you, you don't need to save them anywhere else. Storing
a hundred widget references as class variables is tedious and
superfluous work, and does not do anything except bloating and slowing
your code.


> and getting data into and out of GUI widgets.

It does not save you the job of writing the GUI handlers! It saves you
the job of coding the  GUI (delegate that job to a graphical designer!)
and hooking up the handlers. But you still need to *write* the
handlers.


> That's the kind of boilerplate code that makes GUI
> development a pain in my opinion -- the actual GUI design/layout isn't so
> bad, especially with the spacer layout concept.

At least you get the GUI design out of the rest of your code. The
application logic still need to be there.

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


Re: MinGW and Python

2006-04-25 Thread Alex Martelli
sturlamolden <[EMAIL PROTECTED]> wrote:

> Robert Kern wrote:
> 
> > Dunno. Depends on the machine. Depends on the program. Depends on how
> > the interpreter and any extension modules and underlying libraries were
> > built. Depends on which Linux and which Windows.
> >
> > I'm sorry, but your question is a non sequitur. I don't understand its
> > relevance to this thread.
> 
> The relevance: Python is built with GCC on Linux. Do you or do you not
> see a performance hit on Linux?
> 
> MinGW is GCC. Will you get a performance hit when building Python with
> MinGW?

I cannot predict this, though it would be great if somebody who does
have both VS2003 and mingw could give it a try.

What I did just post on another thread over the last couple of days is
about MacOSX, which also uses gcc: 14% faster pybench using Python 2.4.3
under Win2000 under Parallels Workstation beta, compared to 2.4.3
Universal directly on MacOSX -- the standard build of 2.4.3 in either
cause, i.e., the one built with MS compilers on Windows, vs the one
built with Apple's gcc on MacOSX.


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


Re: MinGW and Python

2006-04-25 Thread Alex Martelli
sturlamolden <[EMAIL PROTECTED]> wrote:

> Robert Kern wrote:
> 
> > - gcc does not optimize particularly well.
> 
> That is beyond BS. The more recent gcc releases optimize as well as any
> commercial compiler. GCC 4 may even optimize better than MSVC.
> 
> GCC is the compiler used to build the Linux kernel and MacOSX. If it
> can deal with this I say it can handle Python as well. My guess is you
> will not notice any performance difference for the Python interpreter.

That is quite possible, of course: if, for example, the 14% speed
difference I measured with pybench is representative, then you might not
notice it because human beings have a hard time noticing time
differences of that magnitude.  But it might still be there, easy to
measure, even though not to notice.

At the same time, if the 14% slowdown is representative, then it's not
true that the compiler responsible for it "optimizes as well" as the
other; indeed, "does not optimize particularly well", under such a
hypothesis, would be far from a "beyond BS" assertion.


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


Re: Hooking things up in GUI application

2006-04-25 Thread sturlamolden

Ryan Ginstrom wrote:

> Yes, I've tried something similar with wxGlade.

But GLADE is not wxGlade :-)

wxGlade is a GUI designer for wxWidgets and wxPython. It looks a bit
like GLADE on the surface, but does not share any code with GLADE.

GLADE is a GUI designer for GTK, gtkmm, Mono, GNOME and PyGTK.

http://glade.gnome.org/
http://www.pygtk.org/
http://www.mapr.ucl.ac.be/~gustin/win32_ports/

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


Re: OOP / language design question

2006-04-25 Thread Carl Banks
Duncan Booth wrote:
> In other words, the object is constructed in Python before any __init__ is
> called, but in C++ it isn't constructed until after all the base class
> constructors have returned.

That's true.  Good point.


Carl Banks

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


Re: python application ideas.

2006-04-25 Thread Thomas Bartkus
"Anthony Greene" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello, I know this isn't really a python centric question, but I'm seeking
> help from my fellow python programmers. I've been learning python for the
> past year and a half, and I still haven't written anything substantial nor
> have I found an existing project which blows my hair back. Python is my
> first language, and I plan on learning lisp within the next week but
> before I do so I'd like to write something meaningful, does anyone have
> any suggestions? Something they always needed, but never got around to
> writing it? Without an imagination you pretty much stagnate your whole
> learning process. Thanks in advance.

Just what is it, other than programming, that you have expertise in?
What kind of problems do you know how to solve?

> Without an imagination you pretty much stagnate your whole
> learning process.

So true!  Unfortunately, no one can provide you with one.
You have to develop that yourself.

Tis the conundrum of programming in general.  If all you know how to do is
write code - then you truly have nothing to do.  What *other* interests do
you have?  Hobbies? Job Skills?
What *does* "blow your hair back" ;-)

That's where your programming ideas need to come from.
Thomas Bartkus




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


Re: Zope 3

2006-04-25 Thread Steve Juranich
Derick van Niekerk wrote:

> I love Python! Then I was introduced to Zope by freak accident. While
> Zope looked like the answer to my dillemma, I still can't get my head
> wrapped around it. Is it because I don't know Python well enough? Or is
> it just that difficult to learn?

I've been hacking Python now for 6 years.  I just picked up Zope last month
and found the learning curve to be quite steep.  It's not just you. 
There's a lot of stuff there.

> I would like to start my next web project (a database of demographic
> info on scientists in Africa)  on Zope 3. Could anybody point me in the
> right direction? Where should I start?

After you look through the tutorial (which is simply a Zope product you can
add from the main page of the ZMI (Zope Management Interface), have a peek
at the Zope book
(http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/view).  Don't
worry about the version (2.6) of the book.  It's the latest they have (I
think they're working on a new one for z3).  You can skip the bits about
DTML, but keep them handy.

You should also take a look at the Zope user list:
http://mail.zope.org/mailman/listinfo/zope

Hope this all helps.
-- 
Steve Juranich
Tucson, AZ
USA

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


Re: OOP / language design question

2006-04-25 Thread bruno at modulix
Duncan Booth wrote:
> bruno at modulix wrote:
> 
> 
>>Duncan Booth wrote:
>>(snip)
>>
>>>Usually though, if a subclass doesn't immediately call the base class
>>>constructors as the first thing it does in __init__ it indicates poor
>>>code and should be refactored.
>>
>>Not necessarily. It's a common case to have some computations to
>>do/some attributes to set in the derived class's __init__ before
>>calling the superclass's.
>>
> 
> 
> I did only say 'usually'. Can you actually think of any good examples where 
> you have to set a derived attribute before you can call the base class 
> constructor? 

class Base(object):
  def __init__(self, arg1):
self.attr1 = arg1
self.dothis()

  def dothis(self):
return self.attr1

class Derived(Base):
  def __init__(self, arg1, arg2=0):
self.attr2 = arg2
Base.__init__(self, arg1)

  def dothis(self):
return self.attr1 + self.attr2

(snip)

> Perhaps if the base __init__ calls an overridden 
> method, but at that point it sounds to me like something wants refactoring.

Why so ? This is a well-known pattern (template method). I don't see
what's wrong with it.

> I can think that you might have to do some computations to calculate 
> parameters for the base __init__, but that is a separate issue.


-- 
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: Zope 3

2006-04-25 Thread bruno at modulix
Benji York wrote:
> bruno at modulix wrote:
> 
>> Zope is a world in itself - and is certainly not the simplest tool to
>> learn (nor the most pythonic).
> 
> 
> Those statements apply more to Zope 2 than Zope 3 (and Zope 2 is moving
> more and more toward Zope 3 these days).  One of Zope 3's main goals was
> to focus on the Python programmer as a primary target.  That being said
> there /are/ some powerful and novel concepts used in Z3 (the component
> framework).

While it's true that Zope3 is more 'python-programmer oriented' than
Zope2 - and probably much safer wrt/ developper's sanity -, it's still a
world on it's own, it's still a complex framework, and it's still not
very pythonic (IMHO based on 2+ years experience with Zope2, with or
without the CMF, and some time spent evaluating Zope3).

>> You may want to consider other options like Django, Pylon or Turbogears.
> 
> 
> It's true that Z3 is not currently focused very well on the
> "middle-class" developer. 

That's an understatement !-)

> It's more of an industrial-strength kind of
> thing, but considerable thought has been given lately on how to build
> bridges so everyone can benefit without being full-time Zope masters.
> 
> Toward that end, I wrote a little quick start guide that might help the
> OP: http://www.benjiyork.com/quick_start


-- 
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


How do I open a mysql database with python

2006-04-25 Thread Moishy Gluck
How do I open a mysql database with python. I nead a module that is
compatible with windows, and will be on any regular server I singup
with. if you could give me some documentation on the module that would
be good also.

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


Re: Zope 3

2006-04-25 Thread bruno at modulix
Steve Juranich wrote:
> Derick van Niekerk wrote:
(snip)
>>I would like to start my next web project (a database of demographic
>>info on scientists in Africa)  on Zope 3. Could anybody point me in the
>>right direction? Where should I start?
> 
> 
> After you look through the tutorial (which is simply a Zope product you can
> add from the main page of the ZMI (Zope Management Interface), have a peek
> at the Zope book
> (http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/view). 

Actually, the OP was asking about Zope3, which is a *very* different beast.

-- 
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: Hooking things up in GUI application

2006-04-25 Thread Ryan Ginstrom
> Behalf Of sturlamolden
> Ryan Ginstrom wrote:
> 
> > Yes, I've tried something similar with wxGlade.
> 
> But GLADE is not wxGlade :-)

Yes, I'm just saying that I've done something similar to your example. In
fact, wxCard also does this auto-generation of handlers. That's a start, but
it's still auto-generated code -- XML doesn't save you from that -- and it
doesn't do the meaty stuff. (I chose wxWidgets over GTK because, despite
GTK-Wimp, I think wxWidgets' support on Windows is better.)

There are many philosophies to GUI design, and mine problably isn't the best,
but I actually like having my design in the code. I think it saves a layer of
abstraction, it's easier to test/modularize, and still doesn't prevent you
from separating the GUI layer from the business logic, especially in a
language like Python.

But I don't want to argue this point, just state that this isn't the problem
I want to solve. I really liked the idea of KVO/KVC in Cocoa that James
Stroud mentioned. That is what I am after, or something like that. If there
isn't anything like that, I think that it might be worthwhile to port it to
Python in some form. It seems at first glance that it would be fairly easy to
do. 

--
Regards,
Ryan Ginstrom

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


Re: How do I open a mysql database with python

2006-04-25 Thread sturlamolden
http://sourceforge.net/projects/mysql-python

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


Re: FOUNDIT (was Re: massive threading performance)

2006-04-25 Thread Paul Sijben
Lawrence D'Oliveiro wrote:
> In article <[EMAIL PROTECTED]>,
>  Paul Sijben <[EMAIL PROTECTED]> wrote:
> 
>> I found that the problem was caused by the sending thread not giving
>> control back quickly enough to the receiving thread.
>>
>> Also in going through the code I found an old self.s.setblocking(0)call
>> that was no longer relevant. Removing that solved my problem.
>>
>> Something that took 20 seconds now takes just 1.
> 
> You might also find that it goes still faster if you forego threading 
> and use a select.select loop.

thanks for that. I will have to try it.
-- 
http://mail.python.org/mailman/listinfo/python-list


How do I set the __debug__ flag in a win32com server?

2006-04-25 Thread ago
Hi all,

When I use my win32com.server object from an excel client, the python
process running the server always has __debug__==True. When using a
python client the __debug__ flag for the server is determined by the
client (i.e. if I start the client with 'python -o client.py' then
__debug__ == False both for the server and the client). But when
running it from excel I cannot do that. Registering the com server with
debug=false does not seem to have anything to do with the __debug__
flag. Is it possible to change the flag at all?

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


Re: Coming from delphi - looking for an IDE - willing to spend money

2006-04-25 Thread RunLevelZero
Check out SciTE.  It is from the creator of Scintilla and it's great.
It's not a full IDE but with python you'll learn you really don't need
it, at least IMHO.  It's fast and works on windows and Linux.
http://www.scintilla.org/SciTE.html

I would also checkout WingIDE.  Its one of the best, again IMHO.  If
you write open source apps you can have the IDE for free although they
do ask to take a look at your source code and that you have a web page
up for it.  I believe those are the only requirements.  If you don't
have your project to that stage yet, they will give you a 6 month
license to get it there.
http://wingware.com

Wing IDE Professional v. 2.x $179.00 $295.00 $395.00
Wing IDE Personal v. 2.x   $35.00   $60.00   $80.00

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


Re: Zope 3

2006-04-25 Thread Egon Frerich
What is pythonic? See:

http://faassen.n--tree.net/blog/view/weblog/2005/08/06/0

bruno at modulix schrieb am 25.04.2006 17:10:

> Benji York wrote:
>> bruno at modulix wrote:
>>
>>> Zope is a world in itself - and is certainly not the simplest tool to
>>> learn (nor the most pythonic).
>>
>> Those statements apply more to Zope 2 than Zope 3 (and Zope 2 is moving
>> more and more toward Zope 3 these days).  One of Zope 3's main goals was
>> to focus on the Python programmer as a primary target.  That being said
>> there /are/ some powerful and novel concepts used in Z3 (the component
>> framework).
> 
> While it's true that Zope3 is more 'python-programmer oriented' than
> Zope2 - and probably much safer wrt/ developper's sanity -, it's still a
> world on it's own, it's still a complex framework, and it's still not
> very pythonic (IMHO based on 2+ years experience with Zope2, with or
> without the CMF, and some time spent evaluating Zope3).
> 
>>> You may want to consider other options like Django, Pylon or Turbogears.
>>
>> It's true that Z3 is not currently focused very well on the
>> "middle-class" developer. 
> 
> That's an understatement !-)
> 
>> It's more of an industrial-strength kind of
>> thing, but considerable thought has been given lately on how to build
>> bridges so everyone can benefit without being full-time Zope masters.
>>
>> Toward that end, I wrote a little quick start guide that might help the
>> OP: http://www.benjiyork.com/quick_start
> 
> 

-- 
Egon Frerich, Freudenbergstr. 16, 28213 Bremen

E-Mail: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MinGW and Python

2006-04-25 Thread Scott David Daniels
sturlamolden wrote:
> Robert Kern wrote:
>> - gcc does not optimize particularly well.
> That is beyond BS. 

> The more recent gcc releases optimize as well as any
> commercial compiler. 

   This is an outrageous claim.  Having worked a bit doing
compilers, I no of no commercial compiler that would have
a leg to stand on if it claimed it optimized "as well as
any commercial compiler."

   There are compilers and compiler experts out there in the
weeds that can (and regularly do) compile the hell out of code.
I took classes from one of these guys, and now he works in a
little company that does exactly that for particular customers
and problems.

   Uncle Timmy, used to work for some of the places that employed
some of these experts.  There is no "fully optimized state" for
compiled code (if the resultant instruction stream is greater
than a few hundred instructions); everyone approximates optimization.
It is almost inevitably a grey trade-off of compile time to speed
of resulting code over certain distributions of problems.

   To say "gcc does a credible job of optimization" would not be
outrageous.  To say "gcc optimization beats tool X on benchmark Y
on hardware Z by 1.237%" is a claim that could be made supportably,
but it would probably have to be accompanied with "using optimization
switches gcc-W for gcc and X-W for tool X."

   I expect gcc does a reasonably good job of optimization, but the
best optimizers (as far as I know) are done by a relatively small
number of people who fully understand the workings of the optimizer
and its current workload, the workings of the hardware in question
as well, and have chosen a portion of that workload to become expert
in.  Gcc does not have that expertise available to support people
to do things like that (nor does it need to).  They don't need (or
want) to become wed to one architecture, but to do the best optimization
you must at some point get married.

The gcc team does a great job at what they do; blind defense of them
discredits the good work they do.

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Hooking things up in GUI application

2006-04-25 Thread sturlamolden

Ryan Ginstrom wrote:

> But I don't want to argue this point, just state that this isn't the problem
> I want to solve. I really liked the idea of KVO/KVC in Cocoa that James
> Stroud mentioned. That is what I am after, or something like that. If there
> isn't anything like that, I think that it might be worthwhile to port it to
> Python in some form. It seems at first glance that it would be fairly easy to
> do.


I must admit I don't know the KVO/KVC in Cocoa so I had to look it up.
It seems they are accessing widget property values through text strings
called 'key values'.

In Python we have dictionaries, and dictionaries have 'keys' and
'values'. So it should be trvial to make a system where widget
attribute values gets stored in a dictionary. One would just have to
subclass the Python dictionary in order to send an update signal
whenever an item is written to.

In PyGTK we can create and access a label (static text) like this:

label = gtk.Label(str)
label.set_text(str)
str = label.get_text()

With 'KVC' (key value controller) design it could perhaps be changed
to:

label = gtk.Label(str)
label['text'] = str
str = label['text']

It does not save any lines of code. But it adds the possibility of
checking if a widget has an attribute through the 'in' operator. E.g.
to make everything red,

for widget in wigets:
   if 'color' in widget:
  widget['color'] = 0xFF

I am not sure how useful this would be.

Then there are 'properties', as one can find in Hejlsberg's creations
Delphi and C#. This is possible too, using Python properties, which is
merely a copy of Delphi properties. Then would have something like

label.text = str
str = labe.text

Still the amount of code remains the same. But perhaps the property
solution is the more readable. I don't know. I guess it is a matter of
taste.

http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/index.html#//apple_ref/doc/uid/1107i
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/WhatAreBindings.html


I don't use Wimp. These days, GTK looks good on Windows without Wimp.
But yes, GTK apps do get their own 'personality' (aka look and feel).
But so does many Windows applications. Microsoft Office has it's own
widget set, so does Mozilla, SPSS, LabView, Matlab, Internet Explorer,
etc. There is really not a consistent widget set, not even on Windows.
MFC/ATL/WTL use Windows GDI controls, C# use .NET/GDI+ controls, .NET
2.0 has controls slightly different from those in .NET 1.1 (e.g. menus
and toolbars), Visual Basic 6 had ActiveX controls that were similar
but not identical to GDI controls, Delphi (VCL) has its own controls,
so does Qt and FOX. The GUI consistency on Windows is an illusion. I am
not worried about the minor differences between GTK and GDI as long as
my program looks good.

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


Re: Zope 3

2006-04-25 Thread Steve Juranich
bruno at modulix wrote:

> Actually, the OP was asking about Zope3, which is a *very* different
> beast.

Okay, so my ignorance is showing (/me pauses to stuff it back where it
belongs).  So is there some big master diff, along the lines of "What's new
in Python X.X" that I could look at to get an idea of what z3 has that 2.9
(which I'm currently still cutting my teeth on) doesn't?  I've looked at
the documentation on the main Zope page (zope.org) and all of the documents
I've seen are apparently geared towards Zope 2.X.  Where are the Zope3
docs?

Thanks.

-- 
Steve Juranich
Tucson, AZ
USA

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


Tkinter: Dynamic entry widget

2006-04-25 Thread Arne
Hello !

I want to create entry widgets dynamically.
var = ["one", "two", "three"]
i=0
for x in var:
textbox = "t_", x
textbox = entry(frame)
textbox.grid(row=4+i, column=0)
i = i + 1
This works ok. On the window are the entries like I want.

When I want to get to entered data from the entry widget. I am not able to 
get them.
The statement: t_one.get()
dosent work. I am getting an error message that t_one is not global defined.

How can I do this?

Arne


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


Dell Support Web Site Automation.

2006-04-25 Thread S. D. Rose
Hello all.  Awhile back I was playing with win32all package to get system 
information from the Dell PCs.  However, I'm using a win32 program, bginfo, 
to get the information on the PC and insert it into a MySQL database.  Of 
the fields I'm recording, I am saving the system serial number.

I was wondering if it's possible, or highly involved, to have a list of 
serial numbers and have a python script iterate thru and go on-line and 
automate the Support.Dell.Com website, inserting the serial number and 
choosing System Details, to be able to get the out-of-warranty date and 
maybe other information I can't get using bginfo or win32all.

Thanks for your help!
-Dave 



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


Re: MinGW and Python

2006-04-25 Thread Edward Elliott
Alex Martelli wrote:
> At the same time, if the 14% slowdown is representative, then it's not
> true that the compiler responsible for it "optimizes as well" as the
> other; indeed, "does not optimize particularly well", under such a
> hypothesis, would be far from a "beyond BS" assertion.

Maybe someone with access to Windows and some free time could compare
pybench compiled under msvc and mingw.  The best way to test the compiler
is to eliminate all other variables.

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


Re: MinGW and Python

2006-04-25 Thread Edward Elliott
Alex Martelli wrote:
> about MacOSX, which also uses gcc: 14% faster pybench using Python 2.4.3

this is the second time I've seen that 14% figure.  OOC, where does it come
from?  the data sets you posted show an average 12.6% speedup.  14 is an
odd way to round. :)

I don't think it's very useful to talk about average speedups from a
benchmark of equally-weighted feature tests.  the data shows wildly varying
differences in performance for each test.  a real-world application could
be much slower or much faster on either platform depending on its feature
mix.  not the type of thing that's amenable to expression as a single
value.

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


  1   2   3   >