Re: Best IDE?

2006-10-16 Thread limodou
On 10/14/06, Fulvio <[EMAIL PROTECTED]> wrote:
> ***
> Your mail has been scanned by InterScan MSS.
> ***
>
>
> On Friday 13 October 2006 23:17, limodou wrote:
> > hope you try it.
>
> If you'll manage for macro recording, playing back and from file then I'll be
> yours :)
>
> F
>
I'll add this funcationality at 3.6 version. And I want to release 3.5
as soon as I can.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a question about s[i:j] when i is negative

2006-10-16 Thread [EMAIL PROTECTED]

dracula571 wrote:
> s[i:j] slice of s from i to j (3), (4)
>
> (3)
> If i or j is negative, the index is relative to the end of the string:
> len(s) + i or len(s) + j is substituted. But note that -0 is still 0.
>
>
> (4)
> The slice of s from i to j is defined as the sequence of items with
> index k such that i <= k < j. If i or j is greater than len(s), use
> len(s). If i is omitted or None, use 0. If j is omitted or None, use
> len(s). If i is greater than or equal to j, the slice is empty.
>
> i can't follow (3) very well.
> for example:k = [1,2,3,4,5]
> k[-1:2]=[]
> k[-5:2]=[1,2]
> but k[-6:2] = [1,2]
> why k[-6:2] is [1,2]not [].

Because 6 is greater then len(k), so when you ask
for i=-6, you get i=-5 instead. And relative -5 is actually
absolute 0 which is less than 2, so you do not get an
empty slice.

> i do follow (3),to make i positive by
> plusing len(k) twice.But the result is not what i expect.why,or did i
> misunderstand the rule of (3).

See (4).

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


Re: Python component model

2006-10-16 Thread Ilias Lazaridis

Peter  Wang wrote:
> Ilias Lazaridis wrote:
> > looks interesting.
>
> Thanks!
>
> > what about persistency?
>
> Um... what about it?

"
As far as I can see, there's no persistency binding available.

Is one planned?
"
http://groups.google.com/group/comp.lang.python/msg/dbdaedc68eee653a

.

--
http://lazaridis.com

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


Scope of decorator argument

2006-10-16 Thread Gregor Horvath
Hi,

this:

class base(object):
@adecorator(xy)
def edit(self):
print "edit"

class child(base):
xy = 3


obviously fails because "xy" is not bound at class creation time of the
base object.

One solution could be delegation:

class base(object):
@classmethod
def edit(self):
print "do the real work here"

class child(object):
xy = 3
mybase = base

@adecorator(xy)
def edit(self, *args, **kwargs):
self.mybase.edit(*args, **kwargs)

But then I have the ugly boiler plate delegation code in child.

Is there any other solution, probably with metaclasses ?

-- 
  Servus, Gregor
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-16 Thread Ilias Lazaridis
Terry Reedy wrote:
> "Ilias Lazaridis" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > I share the infrastructure which I use:
> >
> > http://dev.lazaridis.com/base
>
> But not quite yet, it appears. "A public release is planned shortly"

Thank you for you comment.

You are right.

I've not yet selected the license yet (this case is quite complex):

http://case.lazaridis.com/wiki/License

But I've placed a BSD2 license to the existent files:

http://dev.lazaridis.com/base/browser/infra

.

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


Re: a question about s[i:j] when i is negative

2006-10-16 Thread Fredrik Lundh
dracula571 wrote:

> but k[-6:2] = [1,2]
> why k[-6:2] is [1,2]not [].i do follow (3),to make i positive by
> plusing len(k) twice.

twice?



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


a question about s[i:j] when i is negative

2006-10-16 Thread dracula571
s[i:j] slice of s from i to j (3), (4)

(3)
If i or j is negative, the index is relative to the end of the string:
len(s) + i or len(s) + j is substituted. But note that -0 is still 0.


(4)
The slice of s from i to j is defined as the sequence of items with
index k such that i <= k < j. If i or j is greater than len(s), use
len(s). If i is omitted or None, use 0. If j is omitted or None, use
len(s). If i is greater than or equal to j, the slice is empty.

i can't follow (3) very well.
for example:k = [1,2,3,4,5]
k[-1:2]=[]
k[-5:2]=[1,2]
but k[-6:2] = [1,2]
why k[-6:2] is [1,2]not [].i do follow (3),to make i positive by
plusing len(k) twice.But the result is not what i expect.why,or did i
misunderstand the rule of (3).

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


Re: COM Error -- Urgent help

2006-10-16 Thread M�ta-MCI
Hi!


.func(  is not defined...


@-salutations
-- 
Michel Claveau



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


Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocksin python

2006-10-16 Thread Hendrik van Rooyen
 "Bruno Desthuilliers" <[EMAIL PROTECTED]> wrote:
> Kay Schluehr wrote:
> > Bruno Desthuilliers wrote:
> >
> >> Just for the record : Ruby's code-blocks (closures, really) come from
> >> Smalltalk, which is still the OneTrueObjectLanguage(tm).
> >
> > IsTheOneTrueObjectLanguage(tm)ReallyCamelCased?
> >
> ThatsAGoodQuestion.
>
>
DoYouMeanIsTheIdentifierTheOneTrueObjectLanguage(tm)CamelCasedOrIsTheObjectObjec
tBoundToIdentifierTheOneTrueObjectLanguage(tm)CamelCasedOrYetSomethingElse?

IAmGladToSeeThisSterlingAttemptAtMinimisingTheEncodingSpaceAsTheSpaceCharacterNe
verImpartedAnyInformationAnywayHendrik

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


Re: Output from subprocess.Popen()

2006-10-16 Thread Fredrik Lundh
Clodoaldo Pinto Neto wrote:

> But I still don't understand what is happening. The manual says that
> when shell=True the executable argument specifies which shell to use:

no, it says that when shell=True, it runs the command "through" the 
default shell.  that is, it hands it over to the shell for execution, 
pretty much as if you'd typed it in yourself.

> To make my confusion bigger, in Fedora sh is just a link to bash:

that only means that the programs share the same binary, not that they 
necessarily have exactly the same behaviour:

$ man bash

   ...

   INVOCATION

   ...

   If bash is invoked with the name sh, it tries to mimic the
   startup behavior of historical versions of sh as closely as
   possible, while conforming to the POSIX standard as well.

   ...



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


Re: OT: What's up with the starship?

2006-10-16 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> I admit I am totally flmmexed by your answer.
> What does when the bug was introduced have to do with
> anything?

oh, I thought your main concern was whether the packages available had 
been compromised, and that you asked if that was the reason an advisory
was released last week.

if someone has developed an exploit for the vulnerability, chances are 
that they'd attack more than just a single obscure and mostly abandoned 
server.



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


COM Error -- Urgent help

2006-10-16 Thread Teja
HI all,

I have a problem in accesing COM objects in threads. To be precise,
lets assume that I have a class GenericFunctions which is defined as
follows:


import win32com.client, pythoncom, thread
ie=win32com.client.Dispatch('internetexplorer.application')
ie.Visible=1


class GenericFunctions:


   def __init__(self):
 print "In Constructor of Generic Functions"


   def MyNavigate(self,dest):
 ie.Navigate(dest)


Now there  is another file Main.py which is defined as follows:


import win32com.client, pythoncom, thread
from GenericFunctions import *
obj = GenericFunctions()


class Mainclass:
   def __init__(self);
print "In Constructor of Main class"


   def threadFunction(self,dest):
pythoncom.CoInitialize()
d=pythoncom.CoGetInterfaceAndReleaseStream(s,
pythoncom.IID_IDispatch)
my_ie=win32com.client.Dispatch(d)
obj.func(dest)  # this is gving an error.
pythoncom.CoUninitialize()


if __name__ == "__main__":


s=pythoncom.CoMarshalInterThreadInterfaceInStream(pythoncom.IID_IDispatch,i­e)

 thread.start_new_thread(self.nav, (s,'www.google.com')


Basically, I want to access object of GenericFunctions class inside
threadFunction(). However I was able to execute
my_ie.Navigate("google.com"). But that was not I wanted. I am not
knowing where the error is
Please let me know the solution ASAP... 


Teja.P

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


Re: Can I set up a timed callback without Tkinter or twisted orsomething?

2006-10-16 Thread Hendrik van Rooyen

<[EMAIL PROTECTED]> wrote:

> 
> Hendrik> is there not something based on signals?  - I seem to recall
> Hendrik> some such thing here in another thread.. ( I am running Linux)
> 
> Have you tried:
> 
> import signal
> help(signal)
> 
> at the interpreter prompt?
> 
> Skip

*blush* - actually, no - I was looking for signals...

- Hendrik

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


[no subject]

2006-10-16 Thread zhaoren liu

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

Re: Plotting histograms

2006-10-16 Thread Theerasak Photha
On 16 Oct 2006 20:49:10 -0700, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> hi, I have some values(say from -a to a) stored in a vector and I want
> to plot a histogram for those values. How can I get it done in python.
> I have installed and imported the Matplotlib package but on executing
> the code
> [N,x]=hist(eig, 10) # make a histogram
>  I am getting an error saying   "NameError: name 'hist' is not
> defined".

Use the statement 'from pylab import *' in the beginning of your program.

Others, of course, may find it more tasteful and Pythonic to do:

[N,x]=pylab.hist(eig, 10)

i.e., prefix it with the package name. Wouldn't want to clutter the
global namespace of your program after all.

Good luck with it then. I think I see a reference to advanced linear
algebra with 'eig' (Eigen-?) and I'm sure you understand that better
than I. :)

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


Re: Plotting histograms

2006-10-16 Thread Robert Kern
[EMAIL PROTECTED] wrote:
> hi, I have some values(say from -a to a) stored in a vector and I want
> to plot a histogram for those values. How can I get it done in python.
> I have installed and imported the Matplotlib package but on executing
> the code
> [N,x]=hist(eig, 10) # make a histogram
>  I am getting an error saying   "NameError: name 'hist' is not
> defined".

I presume what you did was something like this:

   from matplotlib import pylab
   [N,x] = hist(eig, 10)

What you actually want is this:

   from matplotlib import pylab
   [N,x] = pylab.hist(eig, 10)

Or, if you're at the interactive prompt (but remember that it is inadvisable to 
do so in modules):

   from matplotlib.pylab import *
   [N,x] = hist(eig, 10)

You will probably want to review the section of the tutorial on importing 
modules if you don't understand the differences.

-- 
Robert Kern

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

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


Re: wing ide vs. komodo?

2006-10-16 Thread Theerasak Photha
On 13 Oct 2006 17:07:56 -0700, Sandra-24 <[EMAIL PROTECTED]> wrote:
> John Salerno wrote:
> > Just curious what users of the two big commercial IDEs think of them
> > compared to one another (if you've used both).
> >
> > Wing IDE looks a lot nicer and fuller featured in the screenshots, but a
> > glance at the feature list shows that the "personal" version doesn't
> > even support code folding! That's a little ridiculous and makes me have
> > doubts about it.
>
> Well I don't know about the personal edition, but I've used Komodo and
> Wing, and I must say that I chose Wing in the end because it's debugger
> is so much more robust than komodo. I tried remote debugging mod_python
> using komodo, and it just choked. I spent a week trying to get it to
> work. Wing, on the other hand, just worked. I have only the highest
> praise for the Wing IDE Debugger, once you get to know it, it's so much
> more powerful than Komodo's. The time saved over Komodo was well worth
> the money for the professional edition.

Well, the beauty of Python is that even seasoned programmers have told
me that they've only used pdb several times /in their lives/.

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


Plotting histograms

2006-10-16 Thread [EMAIL PROTECTED]
hi, I have some values(say from -a to a) stored in a vector and I want
to plot a histogram for those values. How can I get it done in python.
I have installed and imported the Matplotlib package but on executing
the code
[N,x]=hist(eig, 10) # make a histogram
 I am getting an error saying   "NameError: name 'hist' is not
defined".

Is there any other way to plot histograms over a given range?

thanks

Amit

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


Re: Alphabetical sorts

2006-10-16 Thread Ron Adam
Neil Cerutti wrote:
> On 2006-10-16, Ron Adam <[EMAIL PROTECTED]> wrote:
>> I have several applications where I want to sort lists in
>> alphabetical order. Most examples of sorting usually sort on
>> the ord() order of the character set as an approximation.  But
>> that is not always what you want.
> 
> Check out strxfrm in the locale module.
> 
 a = ["Neil", "Cerutti", "neil", "cerutti"]
 a.sort()
 a
> ['Cerutti', 'Neil', 'cerutti', 'neil']
 import locale
 locale.setlocale(locale.LC_ALL, '')
> 'English_United States.1252'
 a.sort(key=locale.strxfrm)
 a
> ['cerutti', 'Cerutti', 'neil', 'Neil']

Thanks, that helps.

The documentation for local.strxfrm() certainly could be more complete.  And 
the 
name isn't intuitive at all.  It also coorisponds to the C funciton for 
translating strings which isn't the same thing.

For that matter locale.strcoll() isn't documented any better.



I see this is actually a very complex subject.  A littler searching, found the 
following link on Wikipedia.

http://en.wikipedia.org/wiki/Alphabetical_order#Compound_words_and_special_characters

And from there a very informative report:

  http://www.unicode.org/unicode/reports/tr10/


It looks to me this would be a good candidate for a configurable class. 
Something preferably in the string module where it could be found easier.

Is there anyway to change the behavior of strxfrm or strcoll?  For example have 
caps before lowercase, instead of after?


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


Re: python's OOP question

2006-10-16 Thread neoedmund


On Oct 16, 9:01 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
> neoedmund wrote:
> > Bruno Desthuilliers wrote:
> >> neoedmund wrote:
> >> (*PLEASE* stop top-posting - corrected)
> >>> Ben Finney wrote:
>  [Please don't top-post above the text to which you're replying.]
>
>  "neoedmund" <[EMAIL PROTECTED]> writes:
>
> > I'm trying to achieve a higher level of "reusability". Maybe it
> > cannot be done in python? Can anybody help me?
>  What, specifically, are you trying to achieve? What problem needs
>  solving?
> >>> python use multiple inheritance.
> >>> but "inheritance" means you must inherite all methods from super type.
> >>> now i just need "some" methods from one type and "some" methods from
> >>> other types, to build the new type.
> >>> Do you think this way is more flexible than tranditional inheritance?
>
> >> While dynamically adding attributes (and methods - which are attributes
> >> too) is not a problem, I'd second Gregor's anwser : it might be better
> >> to use composition/delegation here.
>
> > Could you show some code to help me know how composition/delegation can
> > be done here? Thanks.About composition/delegation, there's no 
> > "one-size-fits-all" answer, but
> the main idea is to use the magic '__getattr__(self, name)' method.
>
> Now back to your specific case : after a better reading of your original
> question, straight composition/delegation wouldn't work here - at least
> not without modifications to both C1 and C2 (sorry, should have read
> better the first time).
>
> Given the context (ie : "create a new type with methods from type X and
> methods from type Y"), a very simple solution could be:
>
> class C3(object):
> m = C2.m.im_func
> v = C1.v.im_func
>
> FWIW, if you have full control over C1, C2 and C3, you could also just
> 'externalize' the functions definitions:
>
> def v1(self, o):
> return "expected "+o
>
> def v2(self, o):
> return "unexpected "+o
>
> def m2(self):
> """ requires that 'self' has a v(self, somestring) method """
> print self.v("aaa")
>
> class C1(object):
> v = v1
>
> class C2(object):
> v = v2
> m = m2
>
> class C3(object):
> v = v1
> m = m2
>
> The problem (with the whole approach, whatever the choosen technical
> solution) is that if one of theses methods depends on another one (or on
> any other attribute) that is not defined in your new class, you're in
> trouble. This is not such a big deal in the above example, but might
> become much more brittle in real life.
>
> Now we can look at the problem from a different perspective. You wrote:
> """
> but "inheritance" means you must inherite all methods from super type.
> now i just need "some" methods from one type and "some" methods from
> other types, to build the new type.
> """
>
> What is your problem with having the other extra methods too ?
>
> --
> bruno desthuilliers
> python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
> p in '[EMAIL PROTECTED]'.split('@')])"

Bruno , your 2 great and clear samples revealed what method is in
python, which is also I really want to ask. thank you.
So I can reuse a method freely only if it's worth reusing.
For the word "inheritance", in some aspect, meanings reuse the super
class, with the condition: must reuse everything from super class.
It's lack of a option to select which methods are to be reused.
this is something should be improved for general OOP i think.
So to answer " What is your problem with having the other extra methods
too ?",
in real life, a class is not defined so well that any method is needed
by sub-class. so contains a method never to be used is meaningless and
i think something should forbidden.
also, any handy methods in a class can be grabbed out for our reuse. so
we can forgotting the bundering inheritance tree and order.

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

Re: httplib and HTTPS Connections

2006-10-16 Thread runningwild

runningwild wrote:
> Helo,
>
> This is the first time I have cared about httplib's HTTPSConnection.
>
> In the docs I read "Note: HTTPS support is only available if the socket
> module was compiled with SSL support."
>
> Although my small test script "seems" to work when connecting to a
> webserver via HTTPS I am really not sure.
>
> In other words it worked the first time. I never trust anything that
> seems to work right the first time. ;-)
>
> My question is how can I tell if the criteria in the "NOTE:" is met?
> How do I know that the socket module was indeed compled with SSL
> support?
>
> The reason this is important is that I am building a credit card
> payment system.
>
> Here is my little test script
> 
> Python 2.4.3
>
> import httplib
> conn = httplib.HTTPSConnection('**')
> conn.request('GET' '/index.html')
> resp = conn.getresponse()
>
> page = resp.read()
> print page

Quick followup:

I just got off the phone with my sys admin. Python was compiled with
the ssl flag turned on.
ssl does work other applications.

I am assuming we are covered. I just want to be sure.

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


httplib and HTTPS Connections

2006-10-16 Thread runningwild
Helo,

This is the first time I have cared about httplib's HTTPSConnection.

In the docs I read "Note: HTTPS support is only available if the socket
module was compiled with SSL support."

Although my small test script "seems" to work when connecting to a
webserver via HTTPS I am really not sure.

In other words it worked the first time. I never trust anything that
seems to work right the first time. ;-)

My question is how can I tell if the criteria in the "NOTE:" is met?
How do I know that the socket module was indeed compled with SSL
support?

The reason this is important is that I am building a credit card
payment system.

Here is my little test script

Python 2.4.3

import httplib
conn = httplib.HTTPSConnection('**')
conn.request('GET' '/index.html')
resp = conn.getresponse()

page = resp.read()
print page

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


Re: command text parsing and hints displaying on user input.

2006-10-16 Thread Andy
Anybody have an idea on this??
Does Natural Language Processing help in this case?

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


PyGegl

2006-10-16 Thread bearophileHUGS
It looks interesting, PyGegl is a python binding for gegl:
http://ervilha.org/pygegl/

Bye,
bearophile

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


Re: Output from subprocess.Popen()

2006-10-16 Thread Clodoaldo Pinto Neto
Fredrik Lundh wrote:
> [EMAIL PROTECTED] wrote:
>
> > I can't see any obvious way to ask subprocess to use a shell other than
> > the default.
>
> -c ?
>
>  >>> f = Popen(["/bin/bash", "-c", "set|grep IFS"], stdout=PIPE)
>  >>> f.stdout.read()
> "IFS=$' \\t\\n'\n"
>  >>> f = Popen(["/bin/sh", "-c", "set|grep IFS"], stdout=PIPE)
>  >>> f.stdout.read()
> "IFS=' \t\n"

It solves my problem:
>>> f = sub.Popen(['/bin/sh', '-c', 'set|grep IFS'], stdout=sub.PIPE)
>>> f.stdout.read()
"BASH_EXECUTION_STRING='set|grep IFS'\nIFS=' \t\n"
>>> f = sub.Popen(['/bin/bash', '-c', 'set|grep IFS'], stdout=sub.PIPE)
>>> f.stdout.read()
"BASH_EXECUTION_STRING='set|grep IFS'\nIFS=$' \\t\\n'\n"

But I still don't understand what is happening. The manual says that
when shell=True the executable argument specifies which shell to use:

>>> f = sub.Popen('set|grep IFS', shell=True, executable='/bin/sh', 
>>> stdout=sub.PIPE)
>>> f.stdout.read()
"BASH_EXECUTION_STRING='set|grep IFS'\nIFS=' \t\n"
>>> f = sub.Popen('set|grep IFS', shell=True, executable='/bin/bash', 
>>> stdout=sub.PIPE)
>>> f.stdout.read()
"BASH_EXECUTION_STRING='set|grep IFS'\nIFS=' \t\n"

To make my confusion bigger, in Fedora sh is just a link to bash:
$ ll /bin/*sh
-rwxr-xr-x 1 root root  720888 Feb 11  2006 /bin/bash
lrwxrwxrwx 1 root root   4 Aug 28 22:53 /bin/csh -> tcsh
-rwxr-xr-x 1 root root 1175496 Aug 17 13:19 /bin/ksh
lrwxrwxrwx 1 root root   4 Feb 24  2006 /bin/sh -> bash
-rwxr-xr-x 1 root root  349312 Aug 17 15:20 /bin/tcsh
-rwxr-xr-x 1 root root  514668 Feb 12  2006 /bin/zsh

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


doctest quiet again before exit how

2006-10-16 Thread p . lavarre
Looks like every run of doctest after the first is verbose:

$ python2.5 quiet-once.py
(0, 0)
*** DocTestRunner.merge: '__main__' in both testers; summing outcomes.
(0, 0)
*** DocTestRunner.merge: '__main__' in both testers; summing outcomes.
(0, 0)
$
$ cat quiet-once.py
import doctest
print doctest.testmod()
print doctest.testmod()
print doctest.testmod()
$

How do I ask for another quiet run, before exiting the process?

Adding the arg verbose=False to the testmod call doesn't work.

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


Dr. Dobb's Python-URL! - weekly Python news and links (Oct 16)

2006-10-16 Thread Cameron Laird
QOTW:  "Well, I haven't yet seen a definition of 'Integrated Development
Environment' which would exclude Emacs..." - Slawomir Nowaczyk

"Let me tell you: There are times when I'm really glad that as a German,
I'm not supposed to possess any sense of humour at all." - Georg Brandl


Pythoneers will be talking about certification for quite a while:

http://tarekziade.wordpress.com/2006/10/15/marketing-python-is-urgent-part-1-a-python-certification/

http://groups.google.com/group/comp.lang.python/browse_thread/thread/60dae5ab119c4a90/

http://www.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/Zope3SecurityEvaluation

Greg Wilson's "Software Carpentry" is an important resource
(even though I bristle at Greg's bad-mouthing of vi and emacs):
http://www.swc.scipy.org/

The Internet Hosting Cooperative supports "any and every thing
Python":
  http://groups.google.com/group/comp.lang.python/msg/f3c6068b873427bb

Enthought Traits allow powerful GUI technique, and they're more
usefully documented than many realize:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/90e966185e548d51/



Everything Python-related you want is probably one or two clicks away in
these pages:

Python.org's Python Language Website is the traditional
center of Pythonia
http://www.python.org
Notice especially the master FAQ
http://www.python.org/doc/FAQ.html

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

For far, FAR more Python reading than any one mind should
absorb, much of it quite interesting, several pages index
much of the universe of Pybloggers.
http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog
http://www.planetpython.org/
http://mechanicalcat.net/pyblagg.html

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.

http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce

Python411 indexes "podcasts ... to help people learn Python ..."
Updates appear more-than-weekly:
http://www.awaretek.com/python/index.html

Steve Bethard continues the marvelous tradition early borne by
Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim
Lesher of intelligently summarizing action on the python-dev mailing
list once every other week.
http://www.python.org/dev/summary/

The Python Package Index catalogues packages.
http://www.python.org/pypi/

The somewhat older Vaults of Parnassus ambitiously collects references
to all sorts of Python resources.
http://www.vex.net/~x/parnassus/

Much of Python's real work takes place on Special-Interest Group
mailing lists
http://www.python.org/sigs/

Python Success Stories--from air-traffic control to on-line
match-making--can inspire you or decision-makers to whom you're
subject with a vision of what the language makes practical.
http://www.pythonology.com/python/success

The Python Software Foundation (PSF) has replaced the Python
Consortium as an independent nexus of activity.  It has official
responsibility for Python's development and maintenance.
http://www.python.org/psf/
Among the ways you can support PSF is with a donation.
http://www.python.org/psf/donate.html

Kurt B. Kaiser publishes a weekly report on faults and patches.
http://www.google.com/groups?as_usubject=weekly%20python%20patch

Although unmaintained since 2002, the Cetus collection of Python
hyperlinks retains a few gems.
http://www.cetus-links.org/oo_python.html

Python FAQTS
http://python.faqts.com/

The Cookbook is a collaborative effort to capture useful and
interesting recipes.
http://aspn.activestate.com/ASPN/Cookbook/Python

Among several Python-oriented RSS/RDF feeds available are
http://www.python.org/channews.rdf
http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi
http://python.de/backend.php
For more, see
http://www.syndic8.com/feedlist.php?ShowMatch=python&ShowStatus=all
The old Python "To-Do List" now lives principally in a
SourceForge reincarnation.
http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse
http://www.python.org/dev/peps/pep-0042/

The online Python Journal is posted at pythonjournal.cognizor.com.
[EMAIL PROTECT

XLRDError: Can't find workbook in OLE2 compound document

2006-10-16 Thread kath
Hi

XLRDError: Can't find workbook in OLE2 compound document

What does this error means?

When I try to open some excel files using XLRD, I encounter this error.
Not with every excel, but with some file.
Can anybody help me know, what is this error trying say and what I
should do to avoid this.


Traceback (most recent call last):
  File
"D:\PYTHON23\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py",
line 310, in RunScript
exec codeObject in __main__.__dict__
  File "D:\Python23\Testing area\Python and Excel\read_map.py", line
71, in ?
workbook=xlrd.open_workbook(_file[kfp])
  File "D:\PYTHON23\Lib\site-packages\xlrd\__init__.py", line 121, in
open_workbook
logfile=logfile, verbosity=verbosity, pickleable=pickleable,
use_mmap=use_mmap,
  File "D:\PYTHON23\Lib\site-packages\xlrd\__init__.py", line 304, in
__init__
raise XLRDError("Can't find workbook in OLE2 compound document")
XLRDError: Can't find workbook in OLE2 compound document


Thank you.
Regards,
sudhir.

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


Re: Alphabetical sorts

2006-10-16 Thread Leo Kislov


On Oct 16, 2:39 pm, Tuomas <[EMAIL PROTECTED]> wrote:
> My application needs to handle different language sorts. Do you know a
> way to apply strxfrm dynamically i.e. without setting the locale?

Collation is almost always locale dependant. So you have to set locale.
One day I needed collation that worked on Windows and Linux. It's not
that polished and not that tested but it worked for me:

import locale, os, codecs

current_encoding = 'ascii'
current_locale = ''

def get_collate_encoding(s):
'''Grab character encoding from locale name'''
split_name = s.split('.')
if len(split_name) != 2:
return 'ascii'
encoding = split_name[1]
if os.name == "nt":
encoding = 'cp' + encoding
try:
codecs.lookup(encoding)
return encoding
except LookupError:
return 'ascii'

def setup_locale(locale_name):
'''Switch to new collation locale or do nothing if locale
   is the same'''
global current_locale, current_encoding
if current_locale == locale_name:
return
current_encoding = get_collate_encoding(
locale.setlocale(locale.LC_COLLATE, locale_name))
current_locale = locale_name

def collate_key(s):
'''Return collation weight of a string'''
return locale.strxfrm(s.encode(current_encoding, 'ignore'))

def collate(lst, locale_name):
'''Sort a list of unicode strings according to locale rules.
   Locale is specified as 2 letter code'''
setup_locale(locale_name)
return sorted(lst, key = collate_key)


words = u'c ch f'.split()
print ' '.join(collate(words, 'en'))
print ' '.join(collate(words, 'cz'))

Prints:

c ch f
c f ch

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


Re: always raise syntax error!

2006-10-16 Thread Cameron Laird
In article <[EMAIL PROTECTED]>,
Larry Bates  <[EMAIL PROTECTED]> wrote:
>daniel wrote:
.
.
.
>> well, I would say, the reason why I could not position the error code
>> may partly due to the ambiguous message that python provides. the lines
>> that python pointed to contains no error,  I think the error codes must
>> be too far away from there. anyway, I hope python would make more
>> detailed error messages, like c++ compilers do. such as: "missing ;" or
>> "(" not matching...etc.
.
.
.
>Occassionally I will have phantom syntax errors that seem to be
>attributable to non-printing characters in a line.  Other times the
>error is in fact far above the place pointed to by the syntax error.
>Start by commenting out large chunks of code with triple quotes and
>slowly work towards the lines with a problem.
>
>-Larry Bates

I'll reinforce part of this:  if C++ compilers are our standard, 
Python needn't feel shame about its error-reporting.  While I've
long advocated upgrades to Python's diagnostic-reporting, it's
simply not true that Python points to "no error".  Python reports
a syntax error on a particular line only when there's sufficient
reason.  

I recognize a background with C++ will probably necessitate 
accomodation to Python, because the two do NOT employ the same
style for syntax questions.  Please, though, daniel:  don't make
the mistake of thinking Python's syntax is a mystery.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Max-plus library

2006-10-16 Thread Robert Kern
Martin Manns wrote:
> Hello,
> 
> Is there any library that allows employing max-plus dioids in
> python (e.g. based on numpy/scipy)?

Google says "no" and I haven't heard of any, so I imagine that there aren't. 
There might be something buried in some of the control theory packages, but as 
I 
neither know what max-plus dioids are, nor have I any current interest in them, 
I can't give you any better pointers.

-- 
Robert Kern

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

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


Max-plus library

2006-10-16 Thread Martin Manns
Hello,

Is there any library that allows employing max-plus dioids in
python (e.g. based on numpy/scipy)?

The only libraries that I found so far are for Matlab / Octave,
Scilab and Maple:
http://ifatwww.et.uni-magdeburg.de/~stanczyk/mpa/index.php
http://www-rocq.inria.fr/MaxplusOrg/soft.html

Thanks

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


Re: Mail Delivery (failure [EMAIL PROTECTED])

2006-10-16 Thread support
Thank you for your email. This is an automatic acknowledgement, and we will 
process your email in one business day.

To shorten your waiting period until your email is answered manually, you have 
the possibility to find a solution on our webpage i.e.

1.) I am unable to register my program I purchased. What is the problem?
It can be resolved by installing the most current version of our products.
FYI: http://www.pdf-convert.com/faq/register.html

2.) PDF-Convert Software Products FAQS:
http://www.pdf-convert.com/support.htm


Thank you for your support!
PDF-Convert Software
http://www.pdf-convert.com



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


Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-16 Thread jmdeschamps

Bruno Desthuilliers wrote:
> Kay Schluehr wrote:
> > Bruno Desthuilliers wrote:
> >
> >> Just for the record : Ruby's code-blocks (closures, really) come from
> >> Smalltalk, which is still the OneTrueObjectLanguage(tm).
> >
> > IsTheOneTrueObjectLanguage(tm)ReallyCamelCased?
> >
> ThatsAGoodQuestion.
>
> DoYouMeanIsTheIdentifierTheOneTrueObjectLanguage(tm)CamelCasedOrIsTheObjectObjectBoundToIdentifierTheOneTrueObjectLanguage(tm)CamelCasedOrYetSomethingElse?
>
> --
> bruno desthuilliers
> python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
> p in '[EMAIL PROTECTED]'.split('@')])"
youGuysAreAllCrazyOrSomethingNicer(CrazyBeingANiceAttributeHere)(ButIDon'tKnowAboutSyncategoremasLikeParenthesisOrApostrophe)InCamelBackNotationWhichAsNothingToDoWithPolishReverseNotation)ThankYou

Jean-Marc

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


Re: ADO with Python

2006-10-16 Thread Ravi Teja
Ralf wrote:
> Is their anybody with xperience in using the both and can provide me with
> some xamples.

Googling for python ado returns this simple tutorial
http://www.markcarter.me.uk/computing/python/ado.html

COM access in Python is straight forward with win32all.

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


Re: Alphabetical sorts

2006-10-16 Thread Tuomas

My application needs to handle different language sorts. Do you know a 
way to apply strxfrm dynamically i.e. without setting the locale?

Tuomas

Neil Cerutti wrote:
> On 2006-10-16, Ron Adam <[EMAIL PROTECTED]> wrote:
> 
>>I have several applications where I want to sort lists in
>>alphabetical order. Most examples of sorting usually sort on
>>the ord() order of the character set as an approximation.  But
>>that is not always what you want.
> 
> 
> Check out strxfrm in the locale module.
> 
> 
a = ["Neil", "Cerutti", "neil", "cerutti"]
a.sort()
a
> 
> ['Cerutti', 'Neil', 'cerutti', 'neil']
> 
import locale
locale.setlocale(locale.LC_ALL, '')
> 
> 'English_United States.1252'
> 
a.sort(key=locale.strxfrm)
a
> 
> ['cerutti', 'Cerutti', 'neil', 'Neil']
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Output from subprocess.Popen()

2006-10-16 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> I can't see any obvious way to ask subprocess to use a shell other than
> the default.

-c ?

 >>> f = Popen(["/bin/bash", "-c", "set|grep IFS"], stdout=PIPE)
 >>> f.stdout.read()
"IFS=$' \\t\\n'\n"
 >>> f = Popen(["/bin/sh", "-c", "set|grep IFS"], stdout=PIPE)
 >>> f.stdout.read()
"IFS=' \t\n"



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


Re: Need a strange sort method...

2006-10-16 Thread SpreadTooThin

Tim Chase wrote:
> > for example:
> > a = [1,2,3,4,5,6,7,8,9,10] #Although not necessarily in order
> >
> > def cmp(i,j):  #to be defined in this thread.
>
> Well, if you're willing to give up doing it in a cmp() method,
> you can do it as such:
>
>  >>> a.sort()
>  >>> chunk_size = 3
>  >>> [a[i::chunk_size] for i in range(chunk_size)]
> [[1, 4, 7, 10], [2, 5, 8], [3, 6, 9]]
>
> If you need it in a flat list, rather than as a list of
> chunk_size lists (which are handy for iterating over in many
> cases), there are ways of obtaining it, such as the hackish
>
>  >>> sum([a[i::chunk_size] for i in range(chunk_size)], [])
> [1, 4, 7, 10, 2, 5, 8, 3, 6, 9]
>
> There are likely good recipes for flattening a list.  I just
> happen not to have any at my fingertips.
>
> I'm not sure it's possible to do in a cmp() method, given that it
> requires apriori knowledge of the dataset (are the numbers
> contiguous?).  Unless, of course, you have such a list...
>
> However, as a benefit, this method should work no matter what the
> list contains, as long as they're comparable to each other for an
> initial sorting:
>
>  >>> a = [chr(ord('a') + i) for i in range(10)]
>  >>> # a.sort() if it were needed
>  >>> a
> ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
>  >>> sum([a[i::chunk_size] for i in range(chunk_size)], [])
> ['a', 'd', 'g', 'j', 'b', 'e', 'h', 'c', 'f', 'i']
>
>
> -tkc


Yes this is excellent...
Doh... How easy was that! :)
[a[i::chunk_size] for i in range(chunk_size)]

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


Re: Output from subprocess.Popen()

2006-10-16 Thread [EMAIL PROTECTED]
Clodoaldo Pinto Neto wrote:
> Output from the shell:
>
> [EMAIL PROTECTED] teste]$ set | grep IFS
> IFS=$' \t\n'
>
> Output from subprocess.Popen():
>
> >>> import subprocess as sub
> >>> p = sub.Popen('set | grep IFS', shell=True, stdout=sub.PIPE)
> >>> p.stdout.readlines()[1]
> "IFS=' \t\n"
>
> Both outputs for comparison:
> IFS=$' \t\n'
> "IFS=' \t\n"
>
> The subprocess.Popen() output is missing the $ and the last '
>
> How to get the raw shell output from subprocess.Popen()?

You are getting the raw shell output, it's just that subprocess uses
the default shell (/bin/sh) and not your personal shell.  Try running
/bin/sh and run the set|grep command.

I can't see any obvious way to ask subprocess to use a shell other than
the default.
If you need a particular shell, you could use a shell script, e.g.
myscript.sh:
#!/bin/bash
set|grep IFS

and call that with shell=False
p = sub.Popen('/path/to/myscript.sh', stdout=sub.PIPE)

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


Re: Re:RELEASED Python 2.4.4, release candidate 1

2006-10-16 Thread skip

Jonathan> When trying to build 2.4.4c1 with cross-compiling, I get the
Jonathan> following error.

Can you file a bug report on SourceForge please?

Thx,

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


Re: Standard Forth versus Python: a case study

2006-10-16 Thread Elizabeth D Rather
[EMAIL PROTECTED] wrote:
> John you nailed it. I was a big forth fan in the mid-80s but it was
> very clear that you either had to spend a lot of money on proprietary
> systems or do it ALL yourself. Not having any money I was pleased to be
> able to do it all but today, in the age of instant communication and
> collaboration, its not a competitive option in any language. Had forth
> kicked off the open source community about a decade earlier than the
> UNIX folk (in useful terms) I think we'd be living in a much different
> world from a computing perspective. Forth is still cool - but only when
> its for something I wanna do all by myself... :)

Fortunately, modern Forths have quite a lot more functionality than 
mid-80's Forths, in terms of application-relevant features, programming 
aids, more intelligent compilers, OS (e.g. Windows, Unix) compatibility 
and access, etc.  You should really have another look!

Cheers,
Elizabeth

-- 
==
Elizabeth D. Rather   (US & Canada)   800-55-FORTH
FORTH Inc. +1 310-491-3356
5155 W. Rosecrans Ave. #1018  Fax: +1 310-978-9454
Hawthorne, CA 90250
http://www.forth.com

"Forth-based products and Services for real-time
applications since 1973."
==
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: What's up with the starship?

2006-10-16 Thread skip

Shane> I'm trying to understand:

Shane> a) how urgent and/or exploitable this is,

Perhaps not very.  As I indicated in an earlier post, the exploit has been
available since 2001, so it is probably fairly hard to exploit.

Shane> b) how I can check whether a given Python installation (running
Shane>on a server) has been patched, and

If it's running 2.4.4 or 2.5 it should be okay.  If it's running some
earlier version a lot will depend on whether Python was installed by a Linux
distributor (in which case check their version numbers and their release
notes) or installed locally from source.

Shane> c) whether the security advisory downplays the risk more than it
Shane>should, since it appears that many Zope/Plone web servers are
Shane>vulnerable.

I can't pretend to divine the true meaning behind all the wording of the
various security advisories.  You'd have to ask each one of the security
organizations.

Here's one example:

http://secunia.com/advisories/22276/

The application has to work with Unicode on a UCS-4-compiled version of
Python and use the repr() function on such Unicode strings.  Furthermore,
the black hat would have to figure out how to get a suitably crafted Unicode
string into the repr() function at just the right place.

I'm not saying it can't be done, but I think it would be a fairly
challenging undertaking.

Skip


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


Re: ADO with Python

2006-10-16 Thread hg
Ralf wrote:
> Is their anybody with xperience in using the both and can provide me with 
> some xamples.
> 
> Thx a lot
> Ralf 
> 
> 

I suggest you buy the book from Mark Hammond

hg


ex (major cut and paste):

   #
def Get_User_Info_From_DB(self, p_user_id):
try:
#l_query = 'Select Groups.GR_AccessDate from Groups,Members
where Members.GroupId = Groups.GR_GroupId and Members.MemberId = %s;' %
p_user_id
l_query = 'SELECT
Firstname,Lastname,GR_ExpirationDate,GR_AccessDate,GR_CurrentBal,MemberType,MemberDues
FROM MemberTypes,Members,Groups Where (Groups.GR_GroupId =
Members.GroupId) and (MemberTypes.MemberTypeID =
Groups.GR_MembershipType) and (MemberId = %s);' % p_user_id
l_conn = win32com.client.Dispatch(r'ADODB.Connection')
l_DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE='+self.__m_database + ';'
l_conn.Open(l_DSN)
l_recordset = win32com.client.Dispatch(r'ADODB.Recordset')
l_recordset.Open(l_query, l_conn, 1, 3)
l_found_date = False
try:
l_recordset.MoveFirst()
l_exp_date =
l_recordset.Fields.Item('GR_ExpirationDate').Value
l_access_date =
l_recordset.Fields.Item('GR_AccessDate').Value

l_last_name = l_recordset.Fields.Item('Lastname').Value
l_first_name = l_recordset.Fields.Item('Firstname').Value
l_membership_type =
l_recordset.Fields.Item('MemberType').Value
#print 'HERE ', l_recordset.Fields.Item('MemberType').Value
l_val = l_recordset.Fields.Item('MemberDues').Value

l_dues_amount =  '%.02f' % (float(l_val[1])/1.0)


if None == l_access_date:
self.__m_log.Log(  ('DATE IS NOT AVAILABLE FOR USER
ID %s' % p_user_id) )
else:
l_found_date = True
self.__m_log.Log(  ('FOUND NEW DATE IN DATABASE FOR
USER ID %s: %s' % (p_user_id, l_access_date)) )
except:
self.__m_log.Log(  ( 'GET DATE QUERY FAILED ON USER ID
%s' % p_user_id)  )
self.__m_log.Log(traceback.format_exc())
l_conn.Close()

if False == l_found_date:
return None

#print 'IN GET: ACCESS ', l_access_date.Format()
#print 'IN GET: EXP', l_exp_date.Format()
return ( l_exp_date.Format(),l_access_date.Format(),
l_last_name, l_first_name, l_membership_type, l_dues_amount)
except:
self.__m_log.Log(traceback.format_exc())
try:
l_conn.Close()
except:
self.__m_log.Log('Could not close database connection on
retrieval')
self.__m_log.Log(traceback.format_exc())
pass
self.__m_log.Log( ('Fatal error retrieving date from
database for user id %s ' % p_user_id))
return None
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need a strange sort method...

2006-10-16 Thread [EMAIL PROTECTED]

SpreadTooThin wrote:
> SpreadTooThin wrote:
> > Simon Brunning wrote:
> > > On 10/16/06, Simon Brunning <[EMAIL PROTECTED]> wrote:
> > > > >>> a = [1,2,3,4,5,6,7,8,9,10]
> > > > >>> a.sort(key=lambda item: (((item-1) %3), item))
> > > > >>> a
> > > > [1, 4, 7, 10, 2, 5, 8, 3, 6, 9]
> > >
> > > Re-reading the OP's post, perhaps sorting isn't what's required:
> > >
> > > >>> a[::3] + a[1::3] + a[2::3]
> > > [1, 4, 7, 10, 2, 5, 8, 3, 6, 9]
> > >
> > > --
> > > Cheers,
> > > Simon B
> > > [EMAIL PROTECTED]
> > > http://www.brunningonline.net/simon/blog/
> >
>
> > Ok so this is what I got.. but there is an odd side effect:
> >
> > def reslice(series):
> > series.sort()
> > i = 1
> > newseries = series[::3]
> > while(1):
> > c = series[i::3]
> > if len(c) >= 3:
> > newseries = newseries + c
> > else:
> > break
> > i = i + 1
> > return newseries
> >
> > a = [2,1,4,3,6,5,8,7,10,9]
> > b = reslice(a)
> > print b
> > >>> [1, 4, 7, 10, 2, 5, 8, 3, 6, 9, 4, 7, 10]
> >
> > I have one extra 10 that I shouldn't...

Actually, you have an extra 4,7,10.

>
>
> I think my loop termination is incorrect...
> maybe I should just stop when my new series size is the same size as
> the original?

You can do this automatically (and pass the size of the
desired sublist grouping also).

def strange(n,d):
""" n list to sort
d sublist length
"""
LoL = []
for i in xrange(d):
LoL.append(n[i::d])
print LoL
out = []
for i in LoL:
out.extend(i)
return out

a = [1,2,3,4,5,6,7,8,9,10]
b = [1,3,5,7,11,13,17,19,23,29]
c = [1,2,3,4,4,5,6,7,8,9,10]
d = [1,2]

print a
test = strange(a,3)
print test
print

print a
test = strange(a,4)
print test
print

print a
test = strange(a,5)
print test
print

print b
test = strange(b,3)
print test
print

print c
test = strange(c,3)
print test
print

print d
test = strange(d,5)
print test
print

##[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
##[[1, 4, 7, 10], [2, 5, 8], [3, 6, 9]]
##[1, 4, 7, 10, 2, 5, 8, 3, 6, 9]
##
##[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
##[[1, 5, 9], [2, 6, 10], [3, 7], [4, 8]]
##[1, 5, 9, 2, 6, 10, 3, 7, 4, 8]
##
##[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
##[[1, 6], [2, 7], [3, 8], [4, 9], [5, 10]]
##[1, 6, 2, 7, 3, 8, 4, 9, 5, 10]
##
##[1, 3, 5, 7, 11, 13, 17, 19, 23, 29]
##[[1, 7, 17, 29], [3, 11, 19], [5, 13, 23]]
##[1, 7, 17, 29, 3, 11, 19, 5, 13, 23]
##
##[1, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10]
##[[1, 4, 6, 9], [2, 4, 7, 10], [3, 5, 8]]
##[1, 4, 6, 9, 2, 4, 7, 10, 3, 5, 8]
##
##[1, 2]
##[[1], [2], [], [], []]
##[1, 2]

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


Re:RELEASED Python 2.4.4, release candidate 1

2006-10-16 Thread Jonathan Smith
Anthony Baxter wrote:
> On behalf of the Python development team and the Python community, 
> I'm happy to announce the release of Python 2.4.4 (release candidate 1).

When trying to build 2.4.4c1 with cross-compiling, I get the following 
error.

checking for /dev/ptmx... configure: error: cannot check for file 
existence when cross compiling

./config.log:configure:20566: checking for /dev/ptmx
./config.log:configure:20572: error: cannot check for file existence 
when cross compiling

This does not occur with 2.4.3.

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


ADO with Python

2006-10-16 Thread Ralf
Is their anybody with xperience in using the both and can provide me with 
some xamples.

Thx a lot
Ralf 


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


Re: OT: What's up with the starship?

2006-10-16 Thread Shane Hathaway
Fredrik Lundh wrote:
> Shane Hathaway wrote:
> 
>  > I don't know if this concern applies to Starship specifically, but it
>  > seems to apply to thousands of web sites running Python CGIs and
>  > Python web servers.
> 
> so are we seeing thousands of web sites running Python CGIs and web 
> servers being attacked right now?

No, but it often takes a long time for servers to get patched, so the
window for intruders is going to be open for a while.  I'm trying to
understand:

a) how urgent and/or exploitable this is,

b) how I can check whether a given Python installation (running on a
server) has been patched, and

c) whether the security advisory downplays the risk more than it should,
since it appears that many Zope/Plone web servers are vulnerable.

Shane

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


Re: Need a strange sort method...

2006-10-16 Thread Gerard Flanagan

Gerard Flanagan wrote:
> Gerard Flanagan wrote:
> > SpreadTooThin wrote:
> > > I have a list and I need to do a custom sort on it...
> > >
> > > for example:
> > > a = [1,2,3,4,5,6,7,8,9,10] #Although not necessarily in order
> >
> > > 1 4 7 10
> > > 2 5 8
> > > 3 6 9
> > >
> >
> > from math import sqrt
> >
> > for i in range(2,12):
> > seq = range(1,i)
> > numcols = int(sqrt(len(seq)))
> > print columnise(seq, numcols)
> >
>
> should be:
>
>   numcols = int(sqrt(len(seq) + 0.5)
>

Feck! Missing a fecking bracket:

   numcols = int(sqrt(len(seq)) + 0.5)

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


Re: Need a strange sort method...

2006-10-16 Thread Paul Rubin
"SpreadTooThin" <[EMAIL PROTECTED]> writes:
> > I have one extra 10 that I shouldn't...
> 
> I think my loop termination is incorrect...

It looks wrong to me; try your loop on range(20) and see what happens.

> maybe I should just stop when my new series size is the same size as
> the original?

You should make exactly 3 passes.  You might also want to use
list.extend rather than adding lists.  Finally, your function modifies
its input list (by sorting it), which generally is not nice unless the
caller expects it and wants it.  You can save the caller some trouble
by making a sorted copy to work from.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: run subprocess in separate window

2006-10-16 Thread Radek
Hello,

as you can see, I tried subprocess methods. But could not find the
right call.

Radek


[EMAIL PROTECTED] wrote:
> Radek a écrit :
>
> > Hi,
> >
> > I am trying to create GUI launcher of several applications using Python
> > and Tkinter.
> >
> > Currently when using subprocess.Popen("mycommand") all output goes to
> > the stdout of my launcher.
> >
> > For some command line applications I need to launch them so that their
> > output goes into the separate "terminal" window.
> >
> > How can I make it?
> >
> > Thanks,
> >
> > Radek
>
> Hello, have a look at the subprocess module, it might help you get to
> what you want.

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


Re: string splitting

2006-10-16 Thread bearophileHUGS
A pair of solutions:

>>> s = "central_african_republic_province.txt"
>>> s.rsplit("_", 1)[-1].split(".")[0]
'province'
>>> import re
>>> p = re.compile(r"_ ([^_]+) \.", re.VERBOSE)
>>> s = """\
... wisconsin_state.txt
... french_guiana_district.txt
... central_african_republic_province.txt"""
>>> p.findall(s)
['state', 'district', 'province']

Bye,
bearophile

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


Re: OT: What's up with the starship?

2006-10-16 Thread Fredrik Lundh
Shane Hathaway wrote:

 > I don't know if this concern applies to Starship specifically, but it
 > seems to apply to thousands of web sites running Python CGIs and
 > Python web servers.

so are we seeing thousands of web sites running Python CGIs and web 
servers being attacked right now?



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


Re: Need a strange sort method...

2006-10-16 Thread SpreadTooThin

SpreadTooThin wrote:
> Simon Brunning wrote:
> > On 10/16/06, Simon Brunning <[EMAIL PROTECTED]> wrote:
> > > >>> a = [1,2,3,4,5,6,7,8,9,10]
> > > >>> a.sort(key=lambda item: (((item-1) %3), item))
> > > >>> a
> > > [1, 4, 7, 10, 2, 5, 8, 3, 6, 9]
> >
> > Re-reading the OP's post, perhaps sorting isn't what's required:
> >
> > >>> a[::3] + a[1::3] + a[2::3]
> > [1, 4, 7, 10, 2, 5, 8, 3, 6, 9]
> >
> > --
> > Cheers,
> > Simon B
> > [EMAIL PROTECTED]
> > http://www.brunningonline.net/simon/blog/
>

> Ok so this is what I got.. but there is an odd side effect:
>
> def reslice(series):
>   series.sort()
>   i = 1
>   newseries = series[::3]
>   while(1):
>   c = series[i::3]
>   if len(c) >= 3:
>   newseries = newseries + c
>   else:
>   break
>   i = i + 1
>   return newseries
>
> a = [2,1,4,3,6,5,8,7,10,9]
> b = reslice(a)
> print b
> >>> [1, 4, 7, 10, 2, 5, 8, 3, 6, 9, 4, 7, 10]
>
> I have one extra 10 that I shouldn't...


I think my loop termination is incorrect...
maybe I should just stop when my new series size is the same size as
the original?

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


Re: Need a strange sort method...

2006-10-16 Thread Gerard Flanagan

Gerard Flanagan wrote:
> SpreadTooThin wrote:
> > I have a list and I need to do a custom sort on it...
> >
> > for example:
> > a = [1,2,3,4,5,6,7,8,9,10] #Although not necessarily in order
>
> > 1 4 7 10
> > 2 5 8
> > 3 6 9
> >
>
> from math import sqrt
>
> for i in range(2,12):
> seq = range(1,i)
> numcols = int(sqrt(len(seq)))
> print columnise(seq, numcols)
> 

should be:

  numcols = int(sqrt(len(seq) + 0.5)


Gerard

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


Re: Book about database application development?

2006-10-16 Thread Wolfgang Keller
> Developping quality SQLDBMS-based applications requires more than "a
> bit" of SQL knowledge.

No doubt. :-) But my "bit" is enough to get me going and to know where to 
look for further information if I hit a wall. Especially the people on the 
Postgres mailinglists (as well as the excellent documentation of Postgres) 
tend to be very helpful here. :-)
 
>> What I'm interested in is rather how to connect a GUI to a database, with 
>> quite a bit of application logic in between. And how to do it well.
> 
> This is more a general design question than a database-related (or even
> Python-related) one.

The question is specific to database applications in so far as these are 
typically client-server aplications (multiple users working with the same 
data with all the resulting concurrency nightmares), and as the volumes and 
the complexity of the data to be handled are non-trivial.

> The answer starts with forgetting about "connect(ing) a GUI to a database" 
> IMHO 

Well, _somehow_ the GUI _has_ to be connected to the database. ;-)

I didn't say that this would be through a spaghetti-heap of SQL queries 
hard-coded into the GUI event handlers.

> and experience. Might be time to google for MVC... 

I know about the existence of MVC. But what I'm actually missing is a nice 
textbook that teaches how to actually implement it (and other design patterns 
which are useful for database applications) in a real-world application in a 
way that leads to non-ridiculous behaviour of the resulting application when 
it gets actually used.

Preferrably using a language for the examples that's readable for someone who 
has learned programming ages ago with Pascal and is now using Python because 
he _hates_ everything that remotely ressembles to any mutation of 
C(++/#/Java).

Sincerely,

Wolfgang Keller

-- 
My email-address is correct.
Do NOT remove ".nospam" to reply.

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


Re: Need a strange sort method...

2006-10-16 Thread SpreadTooThin

Simon Brunning wrote:
> On 10/16/06, Simon Brunning <[EMAIL PROTECTED]> wrote:
> > >>> a = [1,2,3,4,5,6,7,8,9,10]
> > >>> a.sort(key=lambda item: (((item-1) %3), item))
> > >>> a
> > [1, 4, 7, 10, 2, 5, 8, 3, 6, 9]
>
> Re-reading the OP's post, perhaps sorting isn't what's required:
>
> >>> a[::3] + a[1::3] + a[2::3]
> [1, 4, 7, 10, 2, 5, 8, 3, 6, 9]
>
> --
> Cheers,
> Simon B
> [EMAIL PROTECTED]
> http://www.brunningonline.net/simon/blog/

Ok so this is what I got.. but there is an odd side effect:

def reslice(series):
series.sort()
i = 1
newseries = series[::3]
while(1):
c = series[i::3]
if len(c) >= 3:
newseries = newseries + c
else:
break
i = i + 1
return newseries

a = [2,1,4,3,6,5,8,7,10,9]
b = reslice(a)
print b
>>> [1, 4, 7, 10, 2, 5, 8, 3, 6, 9, 4, 7, 10]

I have one extra 10 that I shouldn't...

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


Re: Need a strange sort method...

2006-10-16 Thread Tim Chase
>>> that's trivial to do with slicing, of course.  what makes you think you
>>> need to do this by calling the "sort" method ?
>>>
>>> 
>> You are of course correct.. There might be a way to do this with
>> slicing 
>> and i % 3
> 
> Slicing will work only with a sorted list.

But modulus arithmetic will only work with contiguous, 
non-repeating numeric sequences...Funky things happen with 
sequences like

[1,2,3,4,4,5,6,7,8,9,10] # "4" appears twice

or

[1,3,5,7,11,13,17,19,23,29]

where the position and the numeric value no longer correlate via 
a simple modulus.

-tkc



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


Re: OT: What's up with the starship?

2006-10-16 Thread skip

rurpy> It seems to have been disscussed publically starting around Oct 6
rurpy> or 7 (I didn't do a though search so this may be wrong.)  It was
rurpy> fixed in Python 2.5 so either it was treated as a ordinary bug
rurpy> with unrecognised security implications, or the developers were
rurpy> aware of the security issues and sat on them.

It was fixed in a checkin on August 21 (rev 51450).  While it's possible in
theory that this was the root of the compromise, the fact that none of the
security memos floating around suggested that it had been exploited gives me
a fairly warm feeling that it wasn't the cause of the starship breakin.
Also, the fact that it has been around, apparently unexploited, since 2001
suggests that it was sufficiently obscure that either a) nobody who knew
about it found a way to take advantage of it, or b) it was only recently
discovered back in August shortly before the problem was fixed in the source
code.

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


Re: string splitting

2006-10-16 Thread rdharles
Much thanks for your replies hiaips & Simon!
R.D.

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


Re: How to send E-mail without an external SMTP server ?

2006-10-16 Thread Grant Edwards
On 2006-10-16, Sybren Stuvel <[EMAIL PROTECTED]> wrote:

>> Yes, I want to find a way to send email without an external
>> smtp server.
>
> You can't. Use a DNS server to find the MX record of the
> destination domain, connect to that SMTP server, then deliver
> the mail.

Or, just send it to a relay server for which you have
privledges. Those are the two choices, and both mean using an
SMTP server.

-- 
Grant Edwards   grante Yow!  Gibble, Gobble, we
  at   ACCEPT YOU...
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to send E-mail without an external SMTP server ?

2006-10-16 Thread Grant Edwards
On 2006-10-16, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On Mon, 16 Oct 2006 17:04:19 +0800, "[EMAIL PROTECTED]"
><[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
>
>> 
>> Yes, I want to find a way to send email without an external smtp server.
>>
>   You're going to have to hit an SMTPd somewhere along
> the route... Many moons ago it was easy to connect directly to
> the recipient's mail server (and even easier to grab any
> server one could find, to send mail to any address).

But those were smtp servers, so I don't see you the OP could
have accomplished his goal unless you set the wayback machine
to pre-Internet days and use the uucp transport mechanism.

> In closing down these "open relays" to block spammers, many
> SMTPd's are now configured to accept "outgoing" mail only from
> hosts that are part of the local network, and to accept
> "incoming" mail only if the recipient is a member of the local
> network. Hence, most client programs are now configured to
> connect to the local ISP server to relay mail.

That local ISP server is also an smtp server.  I haven't heard
of anybody accepting vail via uucp for at least 10 years.  I'm
not saying that such hosts don't exist, but that they're pretty
darned rare.

-- 
Grant Edwards   grante Yow!  Today, THREE WINOS
  at   from DETROIT sold me a
   visi.comframed photo of TAB HUNTER
   before his MAKEOVER!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need a strange sort method...

2006-10-16 Thread Saizan

SpreadTooThin wrote:
> > that's trivial to do with slicing, of course.  what makes you think you
> > need to do this by calling the "sort" method ?
> >
> > 
>
> You are of course correct.. There might be a way to do this with
> slicing 
> and i % 3

Slicing will work only with a sorted list.

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


Re: string splitting

2006-10-16 Thread hiaips

[EMAIL PROTECTED] wrote:
> Hello,
> I have thousands of files that look something like this:
>
> wisconsin_state.txt
> french_guiana_district.txt
> central_african_republic_province.txt
>
> I need to extract the string between the *last* underscore and the
> extention.
> So based on the files above, I want returned:
> state
> district
> province
>
> My plan was to use .split or .find but I can't figure out how locate
> only the last underscore in the filename.
>
> Anyone have any ideas?
>
> Thanks.
> R.D.

Hi,

Try splitting the string on "." and using rfind to find the last
instance of "_".

i.e.,
myStr = "wisconsin_state.txt"
pieces = myStr.split(".")
substr = pieces[0][pieces[0].rfind("_") + 1:]

--hiaips

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


Re: Need a strange sort method...

2006-10-16 Thread Neil Cerutti
On 2006-10-16, Tim Chase <[EMAIL PROTECTED]> wrote:
> If you need it in a flat list, rather than as a list of
> chunk_size lists (which are handy for iterating over in many
> cases), there are ways of obtaining it, such as the hackish
>
> >>> sum([a[i::chunk_size] for i in range(chunk_size)], [])
> [1, 4, 7, 10, 2, 5, 8, 3, 6, 9]
>
> There are likely good recipes for flattening a list.  I just
> happen not to have any at my fingertips.

Actually, there isn't a good recipe in Python for flattening a
list. They all come out tasting like Circus Peanuts (Turkish
Delight for you non-Yanks).

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


Re: string splitting

2006-10-16 Thread Simon Brunning
On 16 Oct 2006 12:12:38 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hello,
> I have thousands of files that look something like this:
>
> wisconsin_state.txt
> french_guiana_district.txt
> central_african_republic_province.txt
>
> I need to extract the string between the *last* underscore and the
> extention.
> So based on the files above, I want returned:
> state
> district
> province
>
> My plan was to use .split or .find but I can't figure out how locate
> only the last underscore in the filename.

>>> spam = 'central_african_republic_province.txt'
>>> spam.split('.')[0].rsplit('_', 1)[-1]
'province'

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: jython and toString

2006-10-16 Thread Walter S. Leipold
toString() isn't supposed to be a static method.  When you call
x.toString(), you're accessing x's non-static version of toString(), which
is inherited from Object. 

-- Walt


ivansh ([EMAIL PROTECTED]) wrote:
> For one java class (Hello) i use another (HelloPrinter) to build the
> string representation of the first one. When i've tried to use this
> from within jython,  HelloPrinter.toString(hello) call gives results
> like Object.toString() of hello has being called. The example below
> shows this behaviour.
> Could somebody explain this?
> 
> // Hello.java
> package jythontest;
> public class Hello {
>   private String name;
>   public Hello(String name)
>   {
>   this.name = name;
>   }
>   public String sayHello()
>   {
>   return "Hello, "+name;
>   }
> }
> 
> // HelloPrinter.java
> package jythontest;
> public class HelloPrinter {
>   public static String toString(Hello h)
>   {
>   return h.sayHello();
>   }
> 
>   public static String toMyString(Hello h)
>   {
>   return h.sayHello();
>   }
> }
> 
> #  calljava.py
> from jythontest import *
> h = Hello("theName")
> print h
> print HelloPrinter.toString(h)
> print HelloPrinter.toMyString(h)
> 
> OUTPUT:
> [EMAIL PROTECTED]   // GOOD
> [EMAIL PROTECTED]   // WRONG
> Hello, theName // GOOD
> 
> 
> Jython 2.1 on java (JIT: null)
> 
> java version "1.5.0_03"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
> Java HotSpot(TM) Server VM (build 1.5.0_03-b07, mixed mode)
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: urllib.urlopen: Errno socket error

2006-10-16 Thread kgrafals
Hi Salvatore,

Even if I catch the exceptions in a loop it goes on forever.

- ken

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


Re: Need a strange sort method...

2006-10-16 Thread SpreadTooThin

Fredrik Lundh wrote:
> SpreadTooThin wrote:
>
> > I have a list and I need to do a custom sort on it...
>
> > Its more like
> > 1 4 7 10
> > 2 5 8
> > 3 6 9
>
> that's trivial to do with slicing, of course.  what makes you think you
> need to do this by calling the "sort" method ?
>
> 

You are of course correct.. There might be a way to do this with
slicing 
and i % 3

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


string splitting

2006-10-16 Thread rdharles
Hello,
I have thousands of files that look something like this:

wisconsin_state.txt
french_guiana_district.txt
central_african_republic_province.txt

I need to extract the string between the *last* underscore and the
extention.
So based on the files above, I want returned:
state
district
province

My plan was to use .split or .find but I can't figure out how locate
only the last underscore in the filename.

Anyone have any ideas?

Thanks.
R.D.

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


Re: OT: What's up with the starship?

2006-10-16 Thread Shane Hathaway
Fredrik Lundh wrote:
> [EMAIL PROTECTED] wrote:
> 
>> Then perhaps you or he could explain it to us less intelligent
>> people in very simple terms?
> 
> the security advisory explains that the cause of the problem is a bug
> in the source code used to implement repr() for 32-bit Unicode strings, 
> on all Python versions from 2.2 and onwards.
> 
> Python 2.2 was released in 2001.

So, are we to infer that Starship was running Python 2.1 or earlier at
the time the server was compromised?  Otherwise I missed your point, sorry.

The vulnerability described by PSF-2006-001 could easily lead to server
compromises.  AFAIK, most Linux distributions enable UCS-4 by default,
and they have done so for years.  To compromise a server using the
PSF-2006-001 vulnerability, an intruder just needs to find a Python CGI
script running on that server that converts some bad input to unicode,
then cause that script to raise an error while processing the request
containing the bad input.  There's a good chance the script will log an
error with the repr() of the bad input, allowing the intruder to mess
with the stack.  If the server is running a distribution-supplied build
of Python, the intruder may be able to inject arbitrary code.

I don't know if this concern applies to Starship specifically, but it
seems to apply to thousands of web sites running Python CGIs and Python
web servers.

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


Re: OT: What's up with the starship?

2006-10-16 Thread rurpy

Fredrik Lundh wrote:
> [EMAIL PROTECTED] wrote:
>
> > Then perhaps you or he could explain it to us less intelligent
> > people in very simple terms?
>
> the security advisory explains that the cause of the problem is a bug
> in the source code used to implement repr() for 32-bit Unicode strings,
> on all Python versions from 2.2 and onwards.
>
> Python 2.2 was released in 2001.

I admit I am totally flmmexed by your answer.
What does when the bug was introduced have to do with
anything?  It is present in contemporary versions of Python.
It "can lead to execution of arbitrary code".  It is important
enough to drive an "emergency" (my term) bug fix python
release.

It seems to have been disscussed publically starting around
Oct 6 or 7 (I didn't do a though search so this may be wrong.)
It was fixed in Python 2.5 so either it was treated as a
ordinary bug with unrecognised security implications,
or the developers were aware of the security issues and
sat on them.

Regardless, I don't see anything in the advisory that either
makes it an unimportant issue, or makes clearly unrelated
to the starship.python.net compromise.

So could you please try to explain again in even simpler 
terms?

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


Re: Need a strange sort method...

2006-10-16 Thread Saizan

SpreadTooThin wrote:
> I have a list and I need to do a custom sort on it...
>
> for example:
> a = [1,2,3,4,5,6,7,8,9,10] #Although not necessarily in order
>
> def cmp(i,j):  #to be defined in this thread.
>
> a.sort(cmp)
>
> print a
> [1,4,7,10,  2,5,8, 3,6,9]
>
> So withouth making this into an IQ test.
> Its more like
> 1 4 7 10
> 2 5 8
> 3 6 9
>
> Read that top to bottom from column 1 to column 4.
> When you get to the bottom of a column move to the next column.
> Get it?
It's a little vague, but i'm supposing that if you have an 11 in a the
order will be:
[1,4,7,10, 2,5,8,11, 3, 6,9]
If this holds then your order is based on x%3. You place first all x
for which x%3 == 1, then x%3 == 2, and last x%3 == 0. And among these
three group you use "natural" order.
 so:
def yourcmp(i,j):
   ri = i%3
   rj = j%3
   if ri == rj: return i.__cmp__(j)
   elif ri == 0: return 1
   elif rj == 0: return -1
   else: return ri.__cmp__(rj)
This works with your example, and with my assumption, feel free to
"optimize" the if/elif block.

However you shuold pay attention to the 0 behavior.
a = range(11)
a.sort(yourcmp)
print a
[1, 4, 7, 10, 2, 5, 8, 0, 3, 6, 9]

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


Re: Need a strange sort method...

2006-10-16 Thread Tim Chase
> for example:
> a = [1,2,3,4,5,6,7,8,9,10] #Although not necessarily in order
> 
> def cmp(i,j):  #to be defined in this thread.

Well, if you're willing to give up doing it in a cmp() method, 
you can do it as such:

 >>> a.sort()
 >>> chunk_size = 3
 >>> [a[i::chunk_size] for i in range(chunk_size)]
[[1, 4, 7, 10], [2, 5, 8], [3, 6, 9]]

If you need it in a flat list, rather than as a list of 
chunk_size lists (which are handy for iterating over in many 
cases), there are ways of obtaining it, such as the hackish

 >>> sum([a[i::chunk_size] for i in range(chunk_size)], [])
[1, 4, 7, 10, 2, 5, 8, 3, 6, 9]

There are likely good recipes for flattening a list.  I just 
happen not to have any at my fingertips.

I'm not sure it's possible to do in a cmp() method, given that it 
requires apriori knowledge of the dataset (are the numbers 
contiguous?).  Unless, of course, you have such a list...

However, as a benefit, this method should work no matter what the 
list contains, as long as they're comparable to each other for an 
initial sorting:

 >>> a = [chr(ord('a') + i) for i in range(10)]
 >>> # a.sort() if it were needed
 >>> a
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
 >>> sum([a[i::chunk_size] for i in range(chunk_size)], [])
['a', 'd', 'g', 'j', 'b', 'e', 'h', 'c', 'f', 'i']


-tkc




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


Re: Alphabetical sorts

2006-10-16 Thread Neil Cerutti
On 2006-10-16, Ron Adam <[EMAIL PROTECTED]> wrote:
>
> I have several applications where I want to sort lists in
> alphabetical order. Most examples of sorting usually sort on
> the ord() order of the character set as an approximation.  But
> that is not always what you want.

Check out strxfrm in the locale module.

>>> a = ["Neil", "Cerutti", "neil", "cerutti"]
>>> a.sort()
>>> a
['Cerutti', 'Neil', 'cerutti', 'neil']
>>> import locale
>>> locale.setlocale(locale.LC_ALL, '')
'English_United States.1252'
>>> a.sort(key=locale.strxfrm)
>>> a
['cerutti', 'Cerutti', 'neil', 'Neil']

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


Re: How to send E-mail without an external SMTP server ?

2006-10-16 Thread Sybren Stuvel
[EMAIL PROTECTED] enlightened us with:
> Yes, I want to find a way to send email without an external smtp server.

You can't. Use a DNS server to find the MX record of the destination
domain, connect to that SMTP server, then deliver the mail.

Sybren
-- 
Sybren Stüvel
Stüvel IT - http://www.stuvel.eu/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ok. This IS homework ...

2006-10-16 Thread Frederic Rentsch
Nick Craig-Wood wrote:
> Frederic Rentsch <[EMAIL PROTECTED]> wrote:
>   
>>  It was called a flow chart. Flow charts could be translated directly 
>>  into machine code written in assembly languages which had labels, tests 
>>  and jumps as the only flow-control constructs. When structured 
>>  programming introduced for and while loops they internalized labeling 
>>  and jumping. That was a great convenience. Flow-charting became rather 
>>  obsolete because the one-to-one correspondence between flow chart and 
>>  code was largely lost.
>> 
>
> The trouble with flow charts is that they aren't appropriate maps for
> the modern computing language territory.
>   
Yes. That's why they aren't used anymore.
> I was born and bred on flow charts and I admit they were useful back
> in the days when I wrote 1000s of lines of assembler code a week.
>
> Now-a-days a much better map for the the territory is pseudo-code.
> Python is pretty much executable pseudo-code anway
>   
Yes. But it's the "executable pseudo code" our friend has problems with. 
So your very pertinent observation doesn't help him. My suggestion to 
use a flow chart was on the impression that he didn't have a clear 
conception of the solution's logic and that the flow chart was a simple 
means to acquire that clear conception. I like flow charts because they 
exhaustively map states and transitions exactly the way they 
connect---solution imaging as it were. If they can help intelligence map 
a territory it is no issue if they don't map it themselves very well.

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


Re: Need a strange sort method...

2006-10-16 Thread Gerard Flanagan

SpreadTooThin wrote:
> I have a list and I need to do a custom sort on it...
>
> for example:
> a = [1,2,3,4,5,6,7,8,9,10] #Although not necessarily in order
>
> def cmp(i,j):  #to be defined in this thread.
>
> a.sort(cmp)
>
> print a
> [1,4,7,10,  2,5,8, 3,6,9]
>
> So withouth making this into an IQ test.
> Its more like
> 1 4 7 10
> 2 5 8
> 3 6 9
>
> Read that top to bottom from column 1 to column 4.
> When you get to the bottom of a column move to the next column.
> Get it?

maybe the columnise function here would help:

http://www.gflanagan.net/site/python/utils/sequtils/

from math import sqrt

for i in range(2,12):
seq = range(1,i)
numcols = int(sqrt(len(seq)))
print columnise(seq, numcols)

[(1,)]
[(1, 2)]
[(1, 2, 3)]
[(1, 3), (2, 4)]
[(1, 3, 5), (2, 4, None)]
[(1, 3, 5), (2, 4, 6)]
[(1, 3, 5, 7), (2, 4, 6, None)]
[(1, 3, 5, 7), (2, 4, 6, 8)]
[(1, 4, 7), (2, 5, 8), (3, 6, 9)]
[(1, 4, 7, 10), (2, 5, 8, None), (3, 6, 9, None)]

--

def chunk( seq, size, pad=None ):
'''
Slice a list into consecutive disjoint 'chunks' of
length equal to size. The last chunk is padded if necessary.

>>> list(chunk(range(1,10),3))
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
>>> list(chunk(range(1,9),3))
[[1, 2, 3], [4, 5, 6], [7, 8, None]]
>>> list(chunk(range(1,8),3))
[[1, 2, 3], [4, 5, 6], [7, None, None]]
>>> list(chunk(range(1,10),1))
[[1], [2], [3], [4], [5], [6], [7], [8], [9]]
>>> list(chunk(range(1,10),9))
[[1, 2, 3, 4, 5, 6, 7, 8, 9]]
>>> for X in chunk([],3): print X
>>>
'''
n = len(seq)
mod = n % size
for i in xrange(0, n-mod, size):
yield seq[i:i+size]
if mod:
padding = [pad] * (size-mod)
yield seq[-mod:] + padding

def columnise( seq, numcols, pad=None ):
'''
>>> columnise(range(1,10),3)
[(1, 4, 7), (2, 5, 8), (3, 6, 9)]
>>> columnise(range(1,9),3)
[(1, 4, 7), (2, 5, 8), (3, 6, None)]
>>> columnise(range(1,8),3)
[(1, 4, 7), (2, 5, None), (3, 6, None)]
'''
return zip( *chunk(seq, numcols, pad) )
---

Gerard

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


Re: Need a strange sort method...

2006-10-16 Thread Simon Brunning
On 10/16/06, Simon Brunning <[EMAIL PROTECTED]> wrote:
> >>> a = [1,2,3,4,5,6,7,8,9,10]
> >>> a.sort(key=lambda item: (((item-1) %3), item))
> >>> a
> [1, 4, 7, 10, 2, 5, 8, 3, 6, 9]

Re-reading the OP's post, perhaps sorting isn't what's required:

>>> a[::3] + a[1::3] + a[2::3]
[1, 4, 7, 10, 2, 5, 8, 3, 6, 9]

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need a strange sort method...

2006-10-16 Thread Fredrik Lundh
SpreadTooThin wrote:

> I have a list and I need to do a custom sort on it...

> Its more like
> 1 4 7 10
> 2 5 8
> 3 6 9

that's trivial to do with slicing, of course.  what makes you think you 
need to do this by calling the "sort" method ?



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


Re: urllib.urlopen: Errno socket error

2006-10-16 Thread Salvatore
Hello,

Try to increase the time out : socket.settimeout(n)
and catch the timeout error when it occurs

Regards



[EMAIL PROTECTED] a écrit :

> Hi,
>
> I'm just trying to read from a webpage with urllib but I'm getting
> IOErrors. This is my code:
>
> import urllib
> sock = urllib.urlopen("http://www.google.com/";)
>
> and this is the error:
>
> Traceback (most recent call last):
>   File "", line 1, in 
> sock = urllib.urlopen("http://www.google.com/";)
>   File "C:\Python25\lib\urllib.py", line 82, in urlopen
> return opener.open(url)
>   File "C:\Python25\lib\urllib.py", line 190, in open
> return getattr(self, name)(url)
>   File "C:\Python25\lib\urllib.py", line 325, in open_http
> h.endheaders()
>   File "C:\Python25\lib\httplib.py", line 856, in endheaders
> self._send_output()
>   File "C:\Python25\lib\httplib.py", line 728, in _send_output
> self.send(msg)
>   File "C:\Python25\lib\httplib.py", line 695, in send
> self.connect()
>   File "C:\Python25\lib\httplib.py", line 679, in connect
> raise socket.error, msg
> IOError: [Errno socket error] (10060, 'Operation timed out')
>
> I'm behind my company's firewall. Would that cause a problem? If it
> does, How do I get around it?

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


Re: Need a strange sort method...

2006-10-16 Thread Simon Brunning
On 16 Oct 2006 11:13:08 -0700, SpreadTooThin <[EMAIL PROTECTED]> wrote:
> I have a list and I need to do a custom sort on it...
>
> for example:
> a = [1,2,3,4,5,6,7,8,9,10] #Although not necessarily in order
>
> def cmp(i,j):  #to be defined in this thread.
>
> a.sort(cmp)
>
> print a
> [1,4,7,10,  2,5,8, 3,6,9]
>
> So withouth making this into an IQ test.
> Its more like
> 1 4 7 10
> 2 5 8
> 3 6 9

>>> a = [1,2,3,4,5,6,7,8,9,10]
>>> a.sort(key=lambda item: (((item-1) %3), item))
>>> a
[1, 4, 7, 10, 2, 5, 8, 3, 6, 9]

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need a strange sort method...

2006-10-16 Thread Paul Rubin
"SpreadTooThin" <[EMAIL PROTECTED]> writes:
> a = [1,2,3,4,5,6,7,8,9,10] #Although not necessarily in order
> 
> def cmp(i,j):  #to be defined in this thread.
> 
> a.sort(cmp)
> 
> print a
> [1,4,7,10,  2,5,8, 3,6,9]

def k(n): return (n-1) % 3, (n-1) // 3
a.sort(key=k)
-- 
http://mail.python.org/mailman/listinfo/python-list


Alphabetical sorts

2006-10-16 Thread Ron Adam

I have several applications where I want to sort lists in alphabetical order. 
Most examples of sorting usually sort on the ord() order of the character set 
as 
an approximation.  But that is not always what you want.

The solution of converting everything to lowercase or uppercase is closer, but 
it would be nice if capitalized words come before lowercase words of the same 
spellings.  And I suspect ord() order may not be correct for some character 
sets.

So I'm wandering what others have done and weather there is something in the 
standard library I haven't found for doing this.

Below is my current way of doing it, but I think it can probably be improved 
quite a bit.

This partial solution also allows ignoring leading characters such as spaces, 
tabs, and underscores by specifying what not to ignore.  So '__ABC__' will be 
next to 'ABC'.  But this aspect isn't my main concern.

Maybe some sort of alphabetical order string could be easily referenced for 
various alphabets instead of having to create them manually?

Also it would be nice if strings with multiple words were ordered correctly.


Cheers,
   _Ron



def stripto(s, goodchrs):
 """ Removes leading and trailing characters from string s
 which are not in the string goodchrs.
 """
 badchrs = set(s)
 for c in goodchrs:
 if c in badchrs:
 badchrs.remove(c)
 badchrs = ''.join(badchrs)
 return s.strip(badchrs)


def alpha_sorted(seq):
 """ Sort a list of strings in 123AaBbCc... order.
 """
 order = ( '0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNn'
   'OoPpQqRrSsTtUuVvWwXxYyZz' )
 def chr_index(value, sortorder):
 """ Make a sortable numeric list
 """
 result = []
 for c in stripto(value, order):
 cindex = sortorder.find(c)
 if cindex == -1:
 cindex = len(sortorder)+ord(c)
 result.append(cindex)
 return result

 deco = [(chr_index(a, order), a) for a in seq]
 deco.sort()
 return list(x[1] for x in deco)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: What's up with the starship?

2006-10-16 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> Then perhaps you or he could explain it to us less intelligent
> people in very simple terms?

the security advisory explains that the cause of the problem is a bug
in the source code used to implement repr() for 32-bit Unicode strings, 
on all Python versions from 2.2 and onwards.

Python 2.2 was released in 2001.



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


Re: set operations on dictionaries?

2006-10-16 Thread Tim Chase
> I understand this point but this is just an argument for
> saying that it should throw an exception when the values don't
> match. It is not an argument for not doing the logical thing
> when they do. In fact in many situations it can be reasonably
> expected that the values will be the same. If not, give an
> error. There is no danger in that. The programmer should know
> whether this is a reasonable expectation in any givn case. (As
> it is at the moment, you get an error even if they match...)

Well, the operation as you describe it is easy enough to implement:

 >>> d1 = {1:42, 2:43, 3:44}
 >>> d2 = {1:42, 2:55, 5:66}
 >>> dict((k,v) for k,v in d1.items() if k in d2)
{1: 42, 2: 43}
 >>> dict((k,v) for k,v in d1.items() if k in d2 and d2[k] == v)
{1: 42}

depending on whether you want to enforce the matching of the 
values as well.

Sure, it's not a native operator, but given the ambiguity of the 
definition (do you or don't you include the values in the 
comparison?), it's best to leave it as a function rather than 
trying to shoehorn it into the __sub__ operator.

-tkc



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


Re: Web Hosting

2006-10-16 Thread Jose C
> With web hosting, does the ISP you chose have to support the framework
> you work with as well?
>
> Im looking at making a site in Python, however, Im lost as to what ISPs
> actually support. Some ISPs say they support Python so does that mean
> if I wanted to use TurboGears It would just work anyway?
>

Check out http://webfaction.com...  They have a one-click TurboGears
installation procedure (as well as some other frameworks) but you can
also install your own custom frameworks if they don't support it
directly.

HTH,

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


Need a strange sort method...

2006-10-16 Thread SpreadTooThin
I have a list and I need to do a custom sort on it...

for example:
a = [1,2,3,4,5,6,7,8,9,10] #Although not necessarily in order

def cmp(i,j):  #to be defined in this thread.

a.sort(cmp)

print a
[1,4,7,10,  2,5,8, 3,6,9]

So withouth making this into an IQ test.
Its more like
1 4 7 10
2 5 8
3 6 9

Read that top to bottom from column 1 to column 4.
When you get to the bottom of a column move to the next column.
Get it?

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


Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-16 Thread Bruno Desthuilliers
Kay Schluehr wrote:
> Bruno Desthuilliers wrote:
> 
>> Just for the record : Ruby's code-blocks (closures, really) come from
>> Smalltalk, which is still the OneTrueObjectLanguage(tm).
> 
> IsTheOneTrueObjectLanguage(tm)ReallyCamelCased?
> 
ThatsAGoodQuestion.

DoYouMeanIsTheIdentifierTheOneTrueObjectLanguage(tm)CamelCasedOrIsTheObjectObjectBoundToIdentifierTheOneTrueObjectLanguage(tm)CamelCasedOrYetSomethingElse?

-- 
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: set operations on dictionaries?

2006-10-16 Thread aba cus
              It should be quite obvious what should happen when the values stored forthe relevant keys are identical. It is less obvious (and needs somethough) what should happen when the keys are the same in the twooperands, but the values are different.I think you answered you own proposal in the negative.  Precisely becausethe result of this example{1: 10, 2: 20} | {2: 25, 3:30}is ill-defined, Python shouldn't implement set operations
 on dictionaries."In the face of ambiguity, refuse the temptation to guess."I understand this point but this is just an argument for saying that it should throw an exception when the values don't match. It is not an argument for not doing the logical thing when they do. In fact in many situations it can be reasonably expected that the values will be the same. If not, give an error. There is no danger in that. The programmer should know whether this is a reasonable expectation in any givn case.(As it is at the moment, you get an error even if they match...)-- 
http://mail.python.org/mailman/listinfo/python-list

urllib.urlopen: Errno socket error

2006-10-16 Thread kgrafals
Hi,

I'm just trying to read from a webpage with urllib but I'm getting
IOErrors. This is my code:

import urllib
sock = urllib.urlopen("http://www.google.com/";)

and this is the error:

Traceback (most recent call last):
  File "", line 1, in 
sock = urllib.urlopen("http://www.google.com/";)
  File "C:\Python25\lib\urllib.py", line 82, in urlopen
return opener.open(url)
  File "C:\Python25\lib\urllib.py", line 190, in open
return getattr(self, name)(url)
  File "C:\Python25\lib\urllib.py", line 325, in open_http
h.endheaders()
  File "C:\Python25\lib\httplib.py", line 856, in endheaders
self._send_output()
  File "C:\Python25\lib\httplib.py", line 728, in _send_output
self.send(msg)
  File "C:\Python25\lib\httplib.py", line 695, in send
self.connect()
  File "C:\Python25\lib\httplib.py", line 679, in connect
raise socket.error, msg
IOError: [Errno socket error] (10060, 'Operation timed out')

I'm behind my company's firewall. Would that cause a problem? If it
does, How do I get around it?

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


Re: OT: What's up with the starship?

2006-10-16 Thread rurpy

Fredrik Lundh wrote:
> [EMAIL PROTECTED] wrote:
>
> > But, I am still completely at a loss why you, he, or anyone,
> > based on the information presented so far,.would conclude
> > that the python security problem is unrelated.
>
> Because he's read the security advisory, perhaps, and understands what
> it says?

Then perhaps you or he could explain it to us less intelligent
people in very simple terms?

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


Re: Python-list Digest, Vol 37, Issue 292

2006-10-16 Thread brojoe
thanks,do not sentonother message it's enougth


---
For super low premiums, click here http://www.webmail.co.za/dd.pwm

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


Re: OT: What's up with the starship?

2006-10-16 Thread rurpy

[EMAIL PROTECTED] wrote:
> [EMAIL PROTECTED] wrote:
>
> > I don't think that would help in the case of Pywin32 since the
> > Sourceforge dates for build 210 are 9/22.
> > I emailed Mark Hammond but have not heard anything back yet.
>
> In the case of pywin32, are you at all sure that you actually
> downloaded anything from starship.python.net?  AFAICT all the files are
> now hosted on sf, and there doesn't seem to be any vaguely new files in
> the backup of /home/www.

The files I downloaded were from sourceforge.  I don't know if
starship.python.net hosts the source files or plays any role in
building the disrtribution package.  It may be that is all done
elsewhere.  But given starship.python.net's historical association
with Pywin32, I am not going to just assume that.

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


Re: OT: What's up with the starship?

2006-10-16 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> But, I am still completely at a loss why you, he, or anyone,
> based on the information presented so far,.would conclude
> that the python security problem is unrelated.

Because he's read the security advisory, perhaps, and understands what 
it says?



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


Re: OT: What's up with the starship?

2006-10-16 Thread micahel

[EMAIL PROTECTED] wrote:

> > > 5. Verifying that such a thing has not happened can be very
> > > difficult, particularly if the date and other details of the
> > > compromise cannot be accurately determined.
> >
> > I guess you should find out from the author of whatever you downloaded
> > what the checksums should have been for what you downloaded and check
> > that against what you downloaded.
> >
> > If you don't still have the downloaded files, I can tell you what the
> > md5's of the files in the back up are.
>
> I don't think that would help in the case of Pywin32 since the
> Sourceforge dates for build 210 are 9/22.
> I emailed Mark Hammond but have not heard anything back yet.

In the case of pywin32, are you at all sure that you actually
downloaded anything from starship.python.net?  AFAICT all the files are
now hosted on sf, and there doesn't seem to be any vaguely new files in
the backup of /home/www.

Cheers,
mwh

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


Re: OT: What's up with the starship?

2006-10-16 Thread rurpy

[EMAIL PROTECTED] wrote:
> [EMAIL PROTECTED] wrote:

--snip--

> As far as I can tell, the machine was compromised on 2006-09-02.

So it was compromised for over a month.

> Irritatingly we didn't find out until just after logrotate had deleted
> the logs for around the time of the attack.

Murphy strikes again. :-(

> It wasn't a very subtle rootkit -- installing a version of netstat with
> different command line options, for example...
>
> > 5. Verifying that such a thing has not happened can be very
> > difficult, particularly if the date and other details of the
> > compromise cannot be accurately determined.
>
> I guess you should find out from the author of whatever you downloaded
> what the checksums should have been for what you downloaded and check
> that against what you downloaded.
>
> If you don't still have the downloaded files, I can tell you what the
> md5's of the files in the back up are.

I don't think that would help in the case of Pywin32 since the
Sourceforge dates for build 210 are 9/22.
I emailed Mark Hammond but have not heard anything back yet.

> > 6. Many organisations give image and pr a higher priority
> > than the safety of their customers/users and wave off security
> > breechs with "don't worry, everything is fine.  We're sure
> > nothing has been touched" when in fact they have no idea.
>
> There is no organization behind python.net.
>
> I am a volunteer.  I help run python.net in my spare time.

Organizations do not have to be formal or official to exhibit
similar behavior.

> > 7. I have seen no public statements or information about
> > this leading me to wonder about the stuation and how it's
> > being handled, hence my seeking of further information.
>
> I'm sorry, I'm busy trying to get the server going again.

I understand, and appreciate your (and the other people
involved) efforts.  I know it must be a royal pain in the
ass.  But I am still responsible for the code I (and my
clients) run so I had to ask.

> > But, I am still completely at a loss why you, he, or anyone,
> > based on the information presented so far,.would conclude
> > that the python security problem is unrelated.
>
> Why would it be?  For all it's position in the community, there aren't
> actually many python web apps running on python.net, certainly not as
> root...

That's what one would hope but to assume that without better
information (such as you just provided) would be foolish.

Thanks again for taking the time to answer my questions.

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


SAPI and Python

2006-10-16 Thread Sean Kennedy
Ok - I've done a lot of searching with google for info on 
what I'm about to ask, and haven't found enough to accomplish
what I'm after - so if anyone has the answers (or even
just ideas on how to proceed) I'd love the help.

I'm fairly new to Python, but not to OO programming.  I've
written a simple wx application that uses an SpSharedRecognizer
for voice recognition, and currently sendKeys to send control
applications.  The basic ideas came from Inigo Surguy's 
web page describing voice recognition in Python.

The problems:

1.  The application is specifically tailored to World of Warcraft, 
and it will not be useful to the folks who might otherwise use it
if I can't share the audio in with Teamspeak and/or Ventrillo.  I
currently have Push-to-Talk implemented by clearing the wordsrule
when it's not listening and setting it when it is.  That, as far
as I can tell, will not allow another app to grab the audio in 
device.

My first notion of an idea on how to accomplish this came from the
following code at http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/SAPI51sr/html/VB_ISpeechRecognizer_AudioInput.asp

It looks there like they are releasing the audio-in.  However, setting
the AudioInput property to None in Python results in an exceptions with
a type mismatch.

Question:  Do you think clearing the AudioInput property will actually
release the audio-in?  And, what is the correct way to do it in Python?

2.  sendKeys works - but it has the problem of causing McAfee to perk
up and raise a warning on the python interpreter.  I can tell it to allow
the script to run, but it only works until the next time I close and 
restart the application. 

Question:  Is sendEvent a better way to do this?  And is there a nice
web site with sample python code about it?

Thanks from a python newbie for any insights you folks have.

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


Re: Strange Behavior

2006-10-16 Thread Fredrik Lundh
Carsten Haese wrote:

> I think this statement needs to be clarified. The binding of "data" to
> the empty list *does* happen at runtime, not at compile time. However,
> the binding happens only once, when the "def" statement is executed, as
> opposed to every time the __init__ function is called.

to be precise, it happens every time the "def" statement is executed.



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


Re: Strange Behavior

2006-10-16 Thread Carsten Haese
On Mon, 2006-10-16 at 10:51, Steven D'Aprano wrote:
> On Mon, 16 Oct 2006 07:26:05 -0700, abcd wrote:
> 
> > class Foo:
> > def __init__(self, name, data=[]):
> 
> The binding of the name "data" to the empty list happens at compile time,
> not runtime.

I think this statement needs to be clarified. The binding of "data" to
the empty list *does* happen at runtime, not at compile time. However,
the binding happens only once, when the "def" statement is executed, as
opposed to every time the __init__ function is called.

-Carsten


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


Problem: Python search path - module order

2006-10-16 Thread aznach
Hello!

I have a shared hosting account at GrokThis.net and have a problem with
the module order of the Python search path.

I'd like to use django's svn trunk instead of the
"Django-0.95-py2.4.egg" provided in site-packages.

The problem is that the "django egg" gets preference over the "django
svn trunk" module I manually added to PYTHONPATH...

Instead of being prepended to the top of sys.path, the "django svn
trunk" module gets inserted AFTER the eggs that are in
"/usr/lib/python2.4/site-packages".

I use ~/.bash_profile to set:

export PYTHONPATH="$HOME/local/lib/python:$HOME/django_src"


where "django_src" is the location of django's svn trunk directory

sys.path contains:


/usr/lib/python2.4/site-packages/flup-0.5-py2.4.egg
/usr/lib/python2.4/site-packages/setuptools-0.6c1-py2.4.egg
/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg
/usr/lib/python2.4/site-packages/Myghty-1.0.2-py2.4.egg
/usr/lib/python2.4/site-packages/PasteScript-0.9.7-py2.4.egg
/usr/lib/python2.4/site-packages/PasteDeploy-0.9.6-py2.4.egg
/usr/lib/python2.4/site-packages/Paste-0.9.7-py2.4.egg
/usr/lib/python2.4/site-packages/Routes-1.4-py2.4.egg
/usr/lib/python2.4/site-packages/Cheetah-1.0-py2.4-linux-x86_64.egg
/home/shared/username/local/lib/python
/home/shared/username/django_src
/usr/lib/python24.zip
/usr/lib/python2.4
/usr/lib/python2.4/plat-linux2
/usr/lib/python2.4/lib-tk
/usr/lib/python2.4/lib-dynload
/usr/local/lib/python2.4/site-packages
/usr/lib/python2.4/site-packages
/usr/lib/python2.4/site-packages/PIL



importing django form the Python console renders:

>>> import django
>>> django.VERSION
(0, 95, 'post-magic-removal')
>>>


Is there a way to give the "django svn trunk" module preference over
the "django egg" (i.e. to have the "django svn trunk" inserted BEFORE
the eggs listed)??

Does anyone know a solution to this problem? Any help would be greatly
appreciated!

Best regards,
Aznach

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


  1   2   >