CherryPy-2.1.0-final released

2005-10-23 Thread remi
Hello everyone,

I am happy to announce the release of CherryPy-2.1.0

If is the result of 6 months of intense development since the
last stable release and the work of a growing number of
contributors.

CherryPy has become increasingly popular these past few months
(the mailing lists now have more than 500 people) and it is
also used in other popular products such as Subway and Turbogears.

This release is a major step forward for CherryPy. It is packed
with new features and bug fixes.

Here are the main improvements in this release:
 - New WSGI interface, which allow CherryPy sites to be deployed on
any WSGI server. People are already running it on mod_python, FastCGI,
SCGI, IIS or CherryPy's own built-in HTTP server.
 - New implementation for sessions, which supports multiple backends
 - Built-in list of convenient filters for things like gzip
compression,
XHTML validation, caching, unicode decoding/encoding, authentication,
XML-RPC wrapper, etc ... These filters can easily be enabled/disabled
through configuration.
 - New development mode which provides things like autoreload (no
need to manually restart your server when you make a change), logging
of page stats, etc ...
 - Better handling of file uploads
 - Internal implementation now uses generators everywhere (no more
StringIO)
 - New built-in HTTP server implementation

***
About CherryPy:

CherryPy-2 is a pythonic, object-oriented web development framework.

Here is a sample Hello, World in CherryPy-2:

# import cherrypy
# class HelloWorld:
# @cherrypy.expose
# def index(self):
# yield htmlbody
# yield Hello world!
# yield /body/html
# cherrypy.root = HelloWorld()
# cherrypy.server.start()

Main properties:
- this code starts a multi-threaded HTTP server that dispatches
requests to methods
- requests like http://domain/dir/page?arg1=va l1arg2=val2 are
mapped to dir.page(arg1='val1', arg2='val2')
- CherryPy also supports RESTful URLs like
http://domain/book/science/9
- requests are mapped to an object tree that is mounted on
cherrypy.root
(for instance: cherrypy.root.user, cherrypy.root.user.remi, ...)
- method must be explicitly exposed with a decorator @cherrypy.expose
(or index.exposed = True for Python-2.3)

Remi.

http://www.cherrypy.org

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

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


Re: IDE recommendation please

2005-10-23 Thread Joe

SPE is great I suggest you take a look at it 
http://www.stani.be/python/spe/

[EMAIL PROTECTED] wrote:
 On the Mac, I think the XCode integration you get with PyObjC is
 probably best.  I know there are plugins for Eclipse but haven't tried
 any personally, so it's hard to make suggestions (I'm a dinosaur, and I
 prefer to develop with GVim + a command-line tool, such as Python's own
 interactive mode...).  I'm not sure if BlackAdder (simplest and fastest
 to learn) and WingIDE (probably THE one most powerful Python IDE) work
 on the Mac (shame on me, as a Python AND Mac enthusiast, for not having
 tried them...), but they're surely worth investigating.  Ditto for
 ActiveState's Komodo tool...
 
 
 Alex

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


Test

2005-10-23 Thread cracki
The message contains Unicode characters and has been sent as a binary 
attachment.

KWF Email scanner was unable to check following file (i.e. corrupted/encrypted 
zip archive):
Name:   message.zip
Content type:   application/octet-stream
This file was removed by Firewall.

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

calling a dylib in python on OS X

2005-10-23 Thread robspychala
Hi

Is there something similar to python's windll for calling DLLs on win32
but meant for calling dylib's on OS X?

thanks,

r.s.

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


downloading web images

2005-10-23 Thread Joe
I'm just wandering if I'm doing this correct way I'm trying to download an
image and store it into a file this does the job, but created file does not
apear to be an image, it works fine and I can open image, I'm just
wandering if there is a better way of doing this. 

htmlSource=urllib.urlopen(http://www.godandscience.org/images/nebula.jpg;)
# Read from the object, storing the page's contents in 's'.
s = htmlSource.read()
htmlSource.close()
myfile = open(myfile.jpg, w)
myfile.write(s)
myfile.close

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


Syntax across languages

2005-10-23 Thread bearophileHUGS
This post comes from a boring morning, if you are busy ignore this.
This post is only for relaxed people.

I've found this page, Syntax Across Languages, it contains many
errors and omissions, but it's interesting.
http://merd.sourceforge.net/pixel/language-study/syntax-across-languages.html

Compared to the other languages Python comes out rather well, in quick
scan only few things look better in other languages (usually all/most
things are possible in all languages, so it's often just a matter of
brevity, elegance, etc):

- Nestable Pascal-like comments (useful): (* ... *)

- Information about the current line and file as Ruby:
__LINE__ __FILE__
Instead of the python version:
inspect.stack()[0][2] inspect.stack()[0][1]

- ~== for approximate FP equality

- comparison returns 4 values (i.e. inferior, equal, superior or not
comparable), as in Pliant:
compare

- identity function: identity as in Common Lisp (probably of little
use in Python).

- Exception retrying: after catching an exception, tell the snippet to
be re-run
retry as in Ruby

- object cloning: obj.copy()  obj.deepcopy()

- accessing parent method:
super as in Ruby, instead as in Python:
super(Class, self).meth(args)

- recursive flatten as in Ruby (useful)

Probably there are some errors of mine too, there are many things I
don't know aboyt Python yet.

Bye,
bearophile

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


Re: IDE recommendation please

2005-10-23 Thread kery
Alex Martelli wrote:
 microsnot [EMAIL PROTECTED] wrote:

  ...

 On the Mac, I think the XCode integration you get with PyObjC is
 probably best.  I know there are plugins for Eclipse but haven't tried
 any personally, so it's hard to make suggestions (I'm a dinosaur, and I
 prefer to develop with GVim + a command-line tool, such as Python's own
 interactive mode...).  I'm not sure if BlackAdder (simplest and fastest
 to learn) and WingIDE (probably THE one most powerful Python IDE) work
 on the Mac (shame on me, as a Python AND Mac enthusiast, for not having
 tried them...), but they're surely worth investigating.  Ditto for
 ActiveState's Komodo tool...


 Alex

Any suggestions for Linux, specifically SuSE or perhaps Red Hat?

Thanks in advance,
Kery

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


Re: Syntax across languages

2005-10-23 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

 - Information about the current line and file as Ruby:
 __LINE__ __FILE__
 Instead of the python version:
 inspect.stack()[0][2] inspect.stack()[0][1]

(that's (mostly) CPython-dependent, and should be avoided)

 - ~== for approximate FP equality

str(a) == str(b)

 - comparison returns 4 values (i.e. inferior, equal, superior or not
 comparable), as in Pliant: compare

 cmp(a, b)
-1
 cmp(a, a)
0
 cmp(b, a)
1
 cmp(ä, uä)
Traceback (most recent call last):
  File stdin, line 1, in ?
UnicodeDecodeError: 'ascii' codec can't decode byte /.../

sure looks like four possible outcomes.

 - identity function: identity as in Common Lisp (probably of little
 use in Python).

id(a)

 - Exception retrying: after catching an exception, tell the snippet to
 be re-run retry as in Ruby

 x = 0
 while 1:
... try:
... x += 1
... if x = 5:
... raise ValueError
... except ValueError:
... print retry
... continue
... else:
... break
...
retry
retry
retry
retry
retry


 - object cloning: obj.copy()  obj.deepcopy()

import copy

(cloning is usually a sign of a design problem in python.  if you think
you need it, you probably don't.  if you really think you need it, import
copy.)

 - recursive flatten as in Ruby (useful)

if you can define the semantics, it's a few lines of code.  if you're not
sure about the semantics, a built-in won't help you...

etc.

/F



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

Re: Syntax across languages

2005-10-23 Thread bearophileHUGS
Thank you for the comments, Fredrik Lundh.

(that's (mostly) CPython-dependent, and should be avoided)

Then a non CPython-dependent way of doing it can be even more useful.


sure looks like four possible outcomes.

Right (but to me four explicit answers seem better than three answers
and an exception still).


id(a)

I think in Python it can be something more like (but it's of little
use):
def identity(x): return x
Or:
identity = lambda x: x


(cloning is usually a sign of a design problem in python.  if you think
you need it, you probably don't.  if you really think you need it,
import
copy.)

I agree (importing a module is worse than using a standard copy method,
but I think this can be seen as a way to discourage the use of copy in
Python).


if you can define the semantics, it's a few lines of code.  if you're not
sure about the semantics, a built-in won't help you...

I think the language needs a fast built-in version of it. If something
is both inside Mathematica and Ruby, then probably it can be useful in
Python too :-)

Bye and thank you,
bearophile

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


Re: downloading web images

2005-10-23 Thread Steven D'Aprano
On Sun, 23 Oct 2005 06:52:26 +, Joe wrote:

 I'm just wandering if I'm doing this correct way I'm trying to download an
 image and store it into a file this does the job, but created file does not
 apear to be an image, it works fine and I can open image, I'm just
 wandering if there is a better way of doing this. 

What do you mean that the file does not appear to be an image? If it works
fine and you can open the image, then what is the problem?


-- 
Steven.

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


Re: Syntax across languages

2005-10-23 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

 if you can define the semantics, it's a few lines of code.  if you're not
 sure about the semantics, a built-in won't help you...

 I think the language needs a fast built-in version of it. If something
 is both inside Mathematica and Ruby, then probably it can be useful in
 Python too :-)

numpy already has one:

http://numeric.scipy.org/numpydoc/numpy-9.html#pgfId-36512

(it's probably there in scipy too, but the scipy docs don't appear to be
freely available. hmm...)

PIL also has one:

http://www.effbot.org/imagingbook/image.htm#image-getdata-method

there's also one in Tkinter:

 import Tkinter
 Tkinter._flatten([abc, 1, 2, (3, 4, 5), None, [6, 7, 8, (9,)]])
('abc', 1, 2, 3, 4, 5, 6, 7, 8, 9)

to create a generic version, you have to decide which sequences to
treat like sequences, and which sequences you don't want to treat
like sequences...

/F



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


Re: Microsoft Hatred FAQ

2005-10-23 Thread axel
In comp.lang.perl.misc David Schwartz [EMAIL PROTECTED] wrote:
 Mike Meyer [EMAIL PROTECTED] wrote in message 
 
 Sorry, but nobody but the government actually owns property. In most
 places, you can't make non-trivial changes to your property without
 permission from the government. They even charge you rent on your
 property, only they call it property tax.
 
I see you are a totalitarianist or perhaps a communist. If you want to 
 live in America and discuss things that are relevent to America, let me 
 know.

Why would you say that - Mike Meyer made a point to which you have
obviously no answer. Or do you deny that his comments on this matter
of property are true?

Axel

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


execution order in list/generator expression

2005-10-23 Thread [EMAIL PROTECTED]
Hi,

I am wondering how this is evaluated.

a=(x for x in [1,2,3,4])
p=[4,5]

c=[x for x in p if x in list(a)]

c is []

but if I expand a first, like a = list(a)

c is [4]

So it seems that the if part don't get expanded ?

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


Re: execution order in list/generator expression

2005-10-23 Thread Robert Kern
[EMAIL PROTECTED] wrote:
 Hi,
 
 I am wondering how this is evaluated.
 
 a=(x for x in [1,2,3,4])
 p=[4,5]
 
 c=[x for x in p if x in list(a)]
 
 c is []

No it isn't.

In [1]: a=(x for x in [1,2,3,4])

In [2]: p=[4,5]

In [3]: c=[x for x in p if x in list(a)]

In [4]: c
Out[4]: [4]

I'm willing to bet that you used up the 'a' iterator before you ran that
list comprehension, though.

In [5]: c=[x for x in p if x in list(a)]

In [6]: c
Out[6]: []

Note that x in list(a) gets executed on each iteration, but the
iterator is used up on the first time.

In [7]: a=(x for x in [1,2,3,4])

In [8]: p = [4, 5, 2, 3]

In [9]: c=[x for x in p if x in list(a)]

In [10]: c
Out[10]: [4]

-- 
Robert Kern
[EMAIL PROTECTED]

In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die.
  -- Richard Harter

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


Re: execution order in list/generator expression

2005-10-23 Thread Devan L
[EMAIL PROTECTED] wrote:
 Hi,

 I am wondering how this is evaluated.

 a=(x for x in [1,2,3,4])
 p=[4,5]

 c=[x for x in p if x in list(a)]

 c is []

 but if I expand a first, like a = list(a)

 c is [4]

 So it seems that the if part don't get expanded ?

Well, for every element in p it recalculates list(a). Since the
generator is exhausted after making a list from it, it gives you
nothing afterwards. So after it checks the first element, it's
equivalent to [x for x in p if x in []].

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


Re: execution order in list/generator expression

2005-10-23 Thread [EMAIL PROTECTED]
Ah, no wonder. I test with p=[5,4].

thanks. so basically, I still need to expand it first given this
behaviour.

Robert Kern wrote:
 [EMAIL PROTECTED] wrote:
  Hi,
 
  I am wondering how this is evaluated.
 
  a=(x for x in [1,2,3,4])
  p=[4,5]
 
  c=[x for x in p if x in list(a)]
 
  c is []

 No it isn't.

 In [1]: a=(x for x in [1,2,3,4])

 In [2]: p=[4,5]

 In [3]: c=[x for x in p if x in list(a)]

 In [4]: c
 Out[4]: [4]

 I'm willing to bet that you used up the 'a' iterator before you ran that
 list comprehension, though.

 In [5]: c=[x for x in p if x in list(a)]

 In [6]: c
 Out[6]: []

 Note that x in list(a) gets executed on each iteration, but the
 iterator is used up on the first time.

 In [7]: a=(x for x in [1,2,3,4])

 In [8]: p = [4, 5, 2, 3]

 In [9]: c=[x for x in p if x in list(a)]

 In [10]: c
 Out[10]: [4]

 --
 Robert Kern
 [EMAIL PROTECTED]

 In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die.
   -- Richard Harter

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


Re: Syntax across languages

2005-10-23 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

 sure looks like four possible outcomes.

 Right (but to me four explicit answers seem better than three answers
 and an exception still).

def cmp4(a, b):
try:
return cmp(a, b)
except:
return None

/F



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


Re: Syntax across languages

2005-10-23 Thread bearophileHUGS
Thank you Fredrik Lundh for showing everybody that indeed lot of people
feel the need of such function in Python too.

to create a generic version, you have to decide which sequences to treat like 
sequences

In my version I give the function some parameter(s) to define what I
want to flatten. I'll probably put it in the cookbook...

Bye,
Bearophile

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


Re: best way to replace first word in string?

2005-10-23 Thread Steven D'Aprano
On Sun, 23 Oct 2005 01:30:36 -0400, Mike Meyer wrote:

 At least, that's what it looks like to me -- I'm perplexed by the *vast*
 increase in speed in your version, far more than I would have predicted
 from pulling out the char conversion. I can think of three
 possibilities:
 
 Everything got faster, so it wasn't just pulling the chr conversion.

Sure -- I'm not concerned about proportional speed increases.
 
 (1) Your PC is *hugely* faster than mine;
 
 It's a 3Ghz P4.

Perhaps a tad faster, but not too much.
 
 (2) Your value of x is a lot smaller than I was using (you don't actually
 say what x you use); or
 
 It's still in the buffer, and I copied it from your timings:
 
 x = 10
 
 (3) You are using a version and/or implementation of Python that has a
 different underlying implementation of string concatenation.
 
 I'm runing Python 2.4.1 built with GCC 3.4.2.

There is a difference there:

http://www.python.org/doc/2.4/whatsnew/node12.html

Second-last paragraph:

[quote]
String concatenations in statements of the form s = s + abc and s +=
abc are now performed more efficiently in certain circumstances. This
optimization won't be present in other Python implementations such as
Jython, so you shouldn't rely on it; using the join() method of strings is
still recommended when you want to efficiently glue a large number of
strings together. (Contributed by Armin Rigo.)
[end quote]


-- 
Steven.

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


Re: IDE recommendation please

2005-10-23 Thread Gian Mario Tagliaretti
microsnot wrote:

 I'm new to Python but am wondering what IDE Python developers use? I use
 Mac OS X 10.4.2. I have PythonIDE which comes with MacPython but I don't
 think that has even rudimentary intellisense. Xcode and Eclipse don't
 seem to support Python out of the box. Suggestions for plugins for Eclipse
 would also be nice.

I use wingIDE and as Alex said before is the best python IDE ever...

cheers
-- 
Gian Mario Tagliaretti
PyGTK GUI programming
http://www.parafernalia.org/pygtk/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Syntax across languages

2005-10-23 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

 Thank you Fredrik Lundh for showing everybody that indeed lot of people
 feel the need of such function in Python too.

you seem to be missing the point: all those versions are highly optimized,
and tuned for the specific use-cases.  a generic flatten would be useless
in all three cases.

/F



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


Re: IDE recommendation please

2005-10-23 Thread Jaroslaw Zabiello
Dnia 23 Oct 2005 00:33:41 -0700, kery napisał(a):

 Any suggestions for Linux, specifically SuSE or perhaps Red Hat?

Eric3 http://www.die-offenbachs.de/detlev/eric3.html

Eclipse http://www.eclipse.org/ 
  + pydev plugin http://pydev.sourceforge.net/

SPE http://pythonide.stani.be/

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


Re: IDE recommendation please

2005-10-23 Thread Jaroslaw Zabiello
Dnia Sun, 23 Oct 2005 14:54:38 +1000, microsnot napisał(a):

 Eclipse don't seem to support Python out of the box. 

It is very easy to add excelent python plugin
http://pydev.sourceforge.net/

Fast install: just go to the update manager (inside the help menu) and add
update site: http://pydev.sf.net/updates/ (eclipse should do the rest)

An alternative is just getting the zip file and extracting it yourself in
eclipse. If you choose to do it, just make sure the plugins folder is
extracted on top of the eclipse plugins folder.

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


Re: System tray Icon

2005-10-23 Thread Dave Brueck
Mike Pippin wrote:
 How would I have an app run with just a system tray Icon??? any help 
 would be greatly appreciated. I have no clue where to start.

Choose a GUI toolkit, e.g. wxPython.

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


os.system, IIS6.0

2005-10-23 Thread David Duerrenmatt
Hi there

Since we migrated from Windows 2000 Server to Windows 2003 Server, we 
encountered some problems with the Python scripts calling os.system(). 
They either copy files (permissions on files properly set) or run local 
programs. While using Win 2K, everything was alright. I assume, it's 
caused by stronger security settings for the IUSR-Account (the programs 
do their work if they are run from the command prompt by the system 
administrator).

Does anybody know how to change the permissions of the IUSR account to 
allow the execution of system commands or external programs? Or is it 
another issue which creates these problems?

Some system details:
- Windows 2003 Web Edition
- IIS 6.0
- Python 1.5.2 (has to be this outdated version because of pyd files 
which depend on Python15.dll)


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


Re: Python vs Ruby

2005-10-23 Thread Max M
Mike Meyer wrote:

 There were studies done in the 70s that showed that programmers
 produced the same number of debugged lines of code a day no matter
 what language they used. So a language that lets you build the same
 program with fewer lines of code will let you build the program in
 less time.

In my experience the LOC count is *far* less significant than the levels 
of indirections.

Eg. how many levels of abstraction do I have to understand to follow a 
traceback, or to understand what a method relly does in a complex system.


-- 

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: System tray Icon

2005-10-23 Thread bearophileHUGS
Questo non e' sufficiente, ma puo' essere un punto di partenza:

http://www.pycode.com/modules/?id=2tab=download

Bearophile

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


Problem with subprocess.call and cp

2005-10-23 Thread Torsten Bronger
Hallöchen!

The following code

from subprocess import call
call(['cp', 'subdir/*.jpg', 'othersubdir/'])

yields

cp: call of stat for subdir/*.jpg not possible: File or directory not found

(This may not be the real error message since it's back-translated
from German.)  I could use shell=True, however, what's going wrong
here?

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetusICQ 264-296-646
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with subprocess.call and cp

2005-10-23 Thread Fredrik Lundh
Torsten Bronger wrote:

 The following code

 from subprocess import call
 call(['cp', 'subdir/*.jpg', 'othersubdir/'])

 yields

 cp: call of stat for subdir/*.jpg not possible: File or directory not found

 (This may not be the real error message since it's back-translated
 from German.)  I could use shell=True, however, what's going wrong
 here?

under Unix, it's the shell that expands glob patterns.  individual commands
usually don't know anything about such patterns.

so if you run the cp command directly, it will look for a single file named
subdir/*.jpg.  if you run it via the shell, it will get a list of matching 
files
from the shell.

here's a corresponding pure-python solution, btw:

import glob, shutil
for file in glob.glob(subdir/*.jpg):
shutil.copy(file, othersubdir)

/F



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


Re: Listening for keypress in the background

2005-10-23 Thread Peter Hansen
Mathias Dahl wrote:
 Peter Hansen [EMAIL PROTECTED] writes:
How can I make it listen for a certain keypress (say, Windows-key +
space) in a controlled fashion even when it is not the program having
focus?

I need to do this running under GNOME in Mandrake GN/Linux 10.

Search Google for python keylogger.
 
 Thanks, good idea! The relevant pages I found only link to
 Windows-specific keyloggers though.

Oops, you're quite right.  Sorry!  I didn't even read the second 
sentence in your post.  Stupid me...

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


Re: C replacement for Queue module

2005-10-23 Thread Peter Hansen
Jason Lai wrote:
 As far as Queues go, the adding/popping is apparently done with deque
 which are implemented in C. The Queue class pretty much just provides
 blocking operations and is otherwise a very thin layer around deque. As
 far as primitives go, only threading.Lock is written in C and the
 others are pure Python, so they're not that fast, which might be a
 reason for Queue's slowness.

BTW, I didn't mean (or expect) that one could improve significantly on 
Queue's performance in general just by re-writing it.

I meant that if the OP took into account _his own unique situation_, he 
might see opportunities for improvement which Queue couldn't possibly 
provide, given that it's a general purpose tool.  If his own situation 
simply involves a massive number of discrete put/get operations which 
cannot be bundled in any fashion, rewriting the entire Queue in C just 
to avoid the Python method calls (which have high setup overhead) might 
be the only real option.

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


Re: Microsoft Hatred FAQ

2005-10-23 Thread entropy
[EMAIL PROTECTED] wrote...
 In comp.lang.perl.misc David Schwartz [EMAIL PROTECTED] wrote:
  Mike Meyer [EMAIL PROTECTED] wrote in message 
  
  Sorry, but nobody but the government actually owns property. In most
  places, you can't make non-trivial changes to your property without
  permission from the government. They even charge you rent on your
  property, only they call it property tax.
  
 I see you are a totalitarianist or perhaps a communist. If you want to 
  live in America and discuss things that are relevent to America, let me 
  know.
 
 Why would you say that - Mike Meyer made a point to which you have
 obviously no answer. Or do you deny that his comments on this matter
 of property are true?

Methinks David simply missed that Mike was being facetious.  (Irony 
and facetiousness don't translate well into print, as Frank Zappa 
once noted.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Missing modules '_ssl', 'ext.IsDOMString', 'ext.SplitQName'

2005-10-23 Thread Peter Hansen
[EMAIL PROTECTED] wrote:
 i get the following error message when i use py2exe on my application:
 
 The following modules appear to be missing
 ['_ssl', 'ext.IsDOMString', 'ext.SplitQName']
 
 I've installed PyXML-0.8.4.win32-py2.4.exe. My version of python is 2.4
 I've checked in the pyxml directories and these modules are not there.
 
 Anybody have an idea what I'm doing wrong?

Maybe nothing.  Often py2exe will complain about modules which are not 
actually required by the application.

If your code runs and you've tested all areas of it, then you can chalk 
the above up to a py2exe feature.

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


Re: Microsoft Hatred FAQ

2005-10-23 Thread entropy
[EMAIL PROTECTED] wrote...
 [EMAIL PROTECTED] wrote...
  In comp.lang.perl.misc David Schwartz [EMAIL PROTECTED] wrote:
   Mike Meyer [EMAIL PROTECTED] wrote in message 
   
   Sorry, but nobody but the government actually owns property. In most
   places, you can't make non-trivial changes to your property without
   permission from the government. They even charge you rent on your
   property, only they call it property tax.
   
  I see you are a totalitarianist or perhaps a communist. If you want to 
   live in America and discuss things that are relevent to America, let me 
   know.
  
  Why would you say that - Mike Meyer made a point to which you have
  obviously no answer. Or do you deny that his comments on this matter
  of property are true?
 
 Methinks David simply missed that Mike was being facetious.  (Irony 
 and facetiousness don't translate well into print, as Frank Zappa 
 once noted.)

Uh, you _were_ being facetious there, weren't you Mike?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxpython - passing arg to wx.app OnInit

2005-10-23 Thread Peter Hansen
Stuart McGraw wrote:
 I have a wxPython app, conventionally structured
 with a Application class derived from wx.App.
 My problem is that the app accepts a command
 line argument that must be acted upon within the
 OnInit() method of the Application class.  How do
 I pass it cleanly from main() into app.OnInit()?  In 
 the simplified example below, dbfn is the piece of 
 info that is in main() that OnInit() needs to use.
 Is a global variable is the only way?  :-(

There are various ways, but the simplest is to accept that sys.argv is
*already* a global and just to access it directly from the
Application's OnInit() method.

This wiki page demonstrates:
http://wiki.wxpython.org/index.cgi/UsingCommandLineArguments

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


Re: Syntax across languages

2005-10-23 Thread beza1e1
 id(blub)
-1210548288

This is not identity in a mathematical view.

def identity(x): return x

It has is uses. I had some kind of parser and had a dict like this:
{case: function, ...} It had to be a dict, because i wanted to
dynamically add and remove cases. In some cases nothing had to be done.
To represent this in the dict a identity function is needed. There
surely are other ways, but identity was the most expressive in my eyes.

Nice read, by the way. Thanks for sharing ;)

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


Re: IDE recommendation please

2005-10-23 Thread SPE - Stani's Python Editor
Mac users of SPE collected money for me to buy a Mac. This means that
in the near future SPE will be especially improved for Mac. So feedback
from Mac users is more than welcome and will probably be taken into
account. SPE is a free, open source IDE with a lot of features like a
debugger, UML diagrams and a GUI designer.

Stani
--
http://pythonide.stani.be
http://pythonide.stani.be/manual/html/manual.html

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


Re: Syntax across languages

2005-10-23 Thread [EMAIL PROTECTED]
just curious, how can this identity function be used ? In haskell,
because all functions are curried, I can sort of visualize/understand
how id is used. Not quite understand how it can be used in python.

beza1e1 wrote:
  id(blub)
 -1210548288

 This is not identity in a mathematical view.

 def identity(x): return x

 It has is uses. I had some kind of parser and had a dict like this:
 {case: function, ...} It had to be a dict, because i wanted to
 dynamically add and remove cases. In some cases nothing had to be done.
 To represent this in the dict a identity function is needed. There
 surely are other ways, but identity was the most expressive in my eyes.
 
 Nice read, by the way. Thanks for sharing ;)

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


Re: Syntax across languages

2005-10-23 Thread Fredrik Lundh
beza1e1 wrote:

 It has is uses. I had some kind of parser and had a dict like this:
 {case: function, ...} It had to be a dict, because i wanted to
 dynamically add and remove cases. In some cases nothing had to be done.
 To represent this in the dict a identity function is needed.

in Python, that's spelled lambda x: x (or None, in some contexts)

/F



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


Re: Microsoft Hatred FAQ

2005-10-23 Thread Shmuel (Seymour J.) Metz
In [EMAIL PROTECTED], on 10/18/2005
   at 01:21 PM, [EMAIL PROTECTED] said:

Yes, he deserves credit for what he did.

As well as blame. The commercialization of the Internet was grossly
mismanaged. Take the InterNIC - please!

-- 
Shmuel (Seymour J.) Metz, SysProg and JOAT  http://patriot.net/~shmuel

Unsolicited bulk E-mail subject to legal action.  I reserve the
right to publicly post or ridicule any abusive E-mail.  Reply to
domain Patriot dot net user shmuel+news to contact me.  Do not
reply to [EMAIL PROTECTED]

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


Re: Syntax across languages

2005-10-23 Thread garabik-news-2005-05
Fredrik Lundh [EMAIL PROTECTED] wrote:
 
 - comparison returns 4 values (i.e. inferior, equal, superior or not
 comparable), as in Pliant: compare
 
 cmp(a, b)
 -1
 cmp(a, a)
 0
 cmp(b, a)
 1
 cmp(ä, uä)
 Traceback (most recent call last):
  File stdin, line 1, in ?
 UnicodeDecodeError: 'ascii' codec can't decode byte /.../

that is not because of the comparison, but because of the coercion:

 'ä'+u'ä'
Traceback (most recent call last):
  File stdin, line 1, in ?
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal 
not in range(128)
 

 
 sure looks like four possible outcomes.


 cmp(1, 1+2j)
Traceback (most recent call last):
  File stdin, line 1, in ?
TypeError: cannot compare complex numbers using , =, , =


a fifth one :-)


-- 
 ---
| Radovan Garabík http://kassiopeia.juls.savba.sk/~garabik/ |
| __..--^^^--..__garabik @ kassiopeia.juls.savba.sk |
 ---
Antivirus alert: file .signature infected by signature virus.
Hi! I'm a signature virus! Copy me into your signature file to help me spread!
-- 
http://mail.python.org/mailman/listinfo/python-list

How to separate directory list and file list?

2005-10-23 Thread Gonnasi
With
glob.glob(*)

or
os.listdir(cwd)

I can get a combined file list with directory list, but I just wanna a
bare file list, no directory list. How to get it?

Tons of thanks in advance!

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


Re: How to separate directory list and file list?

2005-10-23 Thread Oliver Andrich
Hi,

2005/10/23, Gonnasi [EMAIL PROTECTED]:
 With
 glob.glob(*)

 or
 os.listdir(cwd)

 I can get a combined file list with directory list, but I just wanna a
 bare file list, no directory list. How to get it?

don't know if it is the best solution, but it looks nice. :)

path = /home/test
files = [fn for fn in os.listdir(path) if
os.path.isfile(os.path.join(path, fn))]

This gives you just the list of files in a given directory.

Best regards,
Oliver



--
Oliver Andrich [EMAIL PROTECTED] --- http://roughbook.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to separate directory list and file list?

2005-10-23 Thread Fredrik Lundh
Gonnasi wrote:

 With
 glob.glob(*)

 or
 os.listdir(cwd)

 I can get a combined file list with directory list, but I just wanna a
 bare file list, no directory list. How to get it?

use os.path.isfile on the result.

for file in glob.glob(*):
if not os.path.isfile(file):
continue
... deal with file ...

for file in os.listdir(cwd):
file = os.path.join(cwd, file)
if not os.path.isfile(file):
continue
... deal with file ...

files = map(os.path.isfile, glob.glob(*))

files = (file for file in os.listdir(cwd) if 
os.path.isfile(os.path.join(cwd, file)))

etc.

/F



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


ANN: CherryPy-2.1.0-final released

2005-10-23 Thread remi
Hello everyone,

I am happy to announce the release of CherryPy-2.1.0

If is the result of 6 months of intense development since the
last stable release and the work of a growing number of
contributors.

CherryPy has become increasingly popular these past few months
(the mailing lists now have more than 500 people) and it is
also used in other popular products such as Subway and Turbogears.

This release is a major step forward for CherryPy. It is packed
with new features and bug fixes.

Here are the main improvements in this release:
 - New WSGI interface, which allow CherryPy sites to be deployed on
any WSGI server. People are already running it on mod_python, FastCGI,
SCGI, IIS or CherryPy's own built-in HTTP server.
 - New implementation for sessions, which supports multiple backends
 - Built-in list of convenient filters for things like gzip
compression,
XHTML validation, caching, unicode decoding/encoding, authentication,
XML-RPC wrapper, etc ... These filters can easily be enabled/disabled
through configuration.
 - New development mode which provides things like autoreload (no
need to manually restart your server when you make a change), logging
of page stats, etc ...
 - Better handling of file uploads
 - Internal implementation now uses generators everywhere (no more
StringIO)
 - New built-in HTTP server implementation

***
About CherryPy:

CherryPy-2 is a pythonic, object-oriented web development framework.

Here is a sample Hello, World in CherryPy-2:

# import cherrypy
# class HelloWorld:
# @cherrypy.expose
# def index(self):
# yield htmlbody
# yield Hello world!
# yield /body/html
# cherrypy.root = HelloWorld()
# cherrypy.server.start()

Main properties:
- this code starts a multi-threaded HTTP server that dispatches
requests to methods
- requests like http://domain/dir/page?arg1=va l1arg2=val2 are
mapped to dir.page(arg1='val1', arg2='val2')
- CherryPy also supports RESTful URLs like
http://domain/book/science/9
- requests are mapped to an object tree that is mounted on
cherrypy.root
(for instance: cherrypy.root.user, cherrypy.root.user.remi, ...)
- method must be explicitly exposed with a decorator @cherrypy.expose
(or index.exposed = True for Python-2.3)

Remi.

http://www.cherrypy.org

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


Re: High Order Messages in Python

2005-10-23 Thread Michael
[EMAIL PROTECTED] wrote:

 I'm reading about high order messages in Ruby by Nat Pryce, and
 thinking if it could be  util and if so, if it could be done in Python.

Nice sunday afternoon exercise. Yes, you can do this in python. This is
based on a relatively naive translation of the ruby version:

class HigherOrderMessage(object):
def __init__(self,handler):
  self.handler = handler

class Do(HigherOrderMessage):
def __HOM__(self, methname, *args):
implement ruby's method_missing idea
try:
for e in self.handler:
meth = getattr(e, methname)
meth(*args)
except TypeError: # Handle non-iterator, could be nicer
 if self.handler is not None:
 meth = getattr(self.handler, methname)
 meth(*args)
def __getattribute__(self, methname):
try:
return super(Do,self).__getattribute__(methname)
except AttributeError:
def myHom(*args):
return self.__HOM__(methname, *args)
return myHom

class Where(HigherOrderMessage):
def __HOM__(self, methname, *args):
implement ruby's method_missing idea
try:
r = List()
for e in self.handler:
meth = getattr(e, methname)
if meth(*args):
r.append(e)
return r
except TypeError:
 r = List()
 if self.handler is not None:
 meth = getattr(self.handler, methname)
 if meth(*args):
 r.append(self.handler)
 return r
#
def __getattribute__(self, methname):
Probably belongs in the baseclass
try:
return super(Where,self).__getattribute__(methname)
except AttributeError:
def myHom(*args):
return self.__HOM__(methname, *args)
return myHom

class enumerable(object):
def do(self):return Do(self)
def where(self): return Where(self)

class List(enumerable,list):
List using enumerable as a mixin

class Claimant(enumerable):
def __init__(self, name, age, gender):
self.name = name
self.age = age
self.gender = gender
self.benefits = 0

def retired(self):
return (self.gender == male and self.age = 65) or \
   (self.gender == female and self.age = 60)

def receive_benefit(self,amount):
self.benefits = self.benefits + amount

def __str__(self):
return %s,%s age: %s benefits: %s % (
  self.name,
  self.gender,
  str(self.age),
  str(self.benefits)
   )

#
# Create an enumerable list capable of responding to 
#

claimants = List([  # Just a list which is enumerable as well
Claimant(tom, 32, male),
Claimant(dick, 64, male),
Claimant(harry, 128, male),
Claimant(Ivanova, 32, female),
Claimant(Kochansky, 64, female),
Claimant(Sung, 128, female),
])

# First the normal python way I prefer this)
for claimant in claimants:
if claimant.retired():
claimant.receive_benefit(50)

# Display the results
for claimant in claimants: print str(claimant)
print

# The more direct translation of :
# claimants.select {|e| e.retired?}.each {|e| e.receive_benefit 50}

[ e.receive_benefit(50) for e in claimants if e.retired() ]

# Display the results
for claimant in claimants: print str(claimant)
print

# The single claimant version of the higher order message approach
# re-uses the last claimant from above. This one unconditionally
# grants benefits.
#
claimant.do().receive_benefit(50)
print claimant
print

# Iterating over a bunch of Claimants with the higher order message
# approach. This conditionally updates the claimaints

claimants.where().retired().do().receive_benefit(50)
# display results
for claimant in claimants: print str(claimant)

I'm not convinced I'd actually *use* this approach(*), but it does show that
you can certainly take this approach in python. It's certainly interesting
though.
   (*) Largely because there's a bunch of magic happening as far as the user
   (next programmer to edit the file) is concerned. After all you can't
   find the definition of retried in where or claimant; you can't
   find the definition of receive_benefit in do, retired, where
   or claimants. 

I'm also pretty sure there's other things you'd want to do more than the
above generally speaking if you wanted to handle inheritance/etc nicely.
(That does make me wonder as well if you'd need to do more in ruby as
well)

However, this certainly isn't a case of ruby can do this, and python
can't, because clearly python CAN do it :-)

Regards,


Michael

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


bsddb version?

2005-10-23 Thread leasun
Anybody knows which version bsddb is released with py2.3 and py2.4?
Thanks.

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

Re: How to separate directory list and file list?

2005-10-23 Thread Peter Hansen
Gonnasi wrote:
 With
glob.glob(*)
 or
os.listdir(cwd)
 
 I can get a combined file list with directory list, but I just wanna a
 bare file list, no directory list. How to get it?

Using Jason Orendorff's path module, it's just this:

  from path import path
  path('.').files()  # returns list of files in current dir


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


Re: bsddb version?

2005-10-23 Thread Peter Hansen
leasun wrote:
 Anybody knows which version bsddb is released with py2.3 and py2.4?

Is this what you wanted?

Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on
win32
 import bsddb
 bsddb.__version__
'4.3.0'

I'll leave it up to you to do the work to find out what it is on
Python2.3...  I hope you can manage the effort. ;-)

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

Re: How to separate directory list and file list?

2005-10-23 Thread George Sakkis
Gonnasi [EMAIL PROTECTED] wrote:

 With
 glob.glob(*)

 or
 os.listdir(cwd)

 I can get a combined file list with directory list, but I just wanna a
 bare file list, no directory list. How to get it?

 Tons of thanks in advance!

 Gonnasi

Using the path module (http://www.jorendorff.com/articles/python/path/):

from path import path
path('.').files()

George


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


Re: Python vs Ruby

2005-10-23 Thread Alex Martelli
Mike Meyer [EMAIL PROTECTED] wrote:
   ...
  Of course, these results only apply where the complexity (e.g., number
  of operators, for example) in a single line of code is constant.
 
 I'm not sure what you're trying to say here. The tests ranged over
 things from PL/I to assembler. Are you saying that those two languages
 have the same complexity in a single line?

Not necessarily, since PL/I, for example, is quite capable of usages at
extremes of operator density per line.  So, it doesn't even have the
same complexity as itself, if used in widely different layout styles.

If the studies imply otherwise, then I'm reminded of the fact that both
Galileo and Newton published alleged experimental data which can be
shown to be too good to be true (fits the theories too well, according
to chi-square tests etc)...


  for item in sequence: blaap(item)
 
  or
 
  for item in sequence:
  blaap(item)
 
  are EXACTLY as easy (or hard) to write, maintain, and document -- it's
  totally irrelevant that the number of lines of code has doubled in the
  second (more standard) layout of the code!-)
 
 The studies didn't deal with maintenance. They only dealt with
 documentation in so far as code was commented.
 
 On the other hand, studies of reading comprehension have shown that
 people can read and comprehend faster if the line lengths fall within
 certain ranges. While it's a stretch to assume those studies apply to
 code, I'd personally be hesitant to assume they don't apply without
 some reseach. If they do apply, then your claims about the difficulty
 of maintaining and documenting being independent of the textual line
 lengths are wrong. And since writing code inevitable involves
 debugging it - and the studies specified debugged lines - then the
 line length could affect how hard the code is to write as well.

If time to code depends on textual line lengths, then it cannot solely
depend on number of lines at the same time.  If, as you say, the studies
prove that speed of delivering debugged code depends strictly on the
LOCs in the delivered code, then those studies would also be showing
that the textual length of the lines is irrelevant to that speed (since,
depending on coding styles, in most languages one can trade off
textually longer lines for fewer lines).

OTOH, the following mental experiment shows that the purported
deterministic connection of coding time to LOC can't really hold:

say that two programmers, Able and Baker, are given exactly the same
task to accomplish in (say) language C, and end up with exactly the same
correct source code for the resulting function;

Baker, being a honest toiling artisan, codes and debugs his code in
expansive style, with lots of line breaks (as lots of programming
shops practice), so, given the final code looks like:
while (foo())
  {
bar();
baz();
  }
(etc), he's coding 5 lines for each such loop;

Able, being able, codes and debugs extremely crammed code, so the same
final code looks, when Able is working on it, like:
while (foo()) { bar(); baz(); }
so, Able is coding 1 line for each such loop, 5 times less than Baker
(thus, by hypothesis, Able must be done 5 times faster);

when Able's done coding and debugging, he runs a code beautifier
utility which runs in negligible time (compared to the time it takes to
code and debug the program) and easily produces the same expansively
laid-out code as Baker worked with all the time.

So, Able is 5 times faster than Baker yet delivers identical final code,
based, please note, not on any substantial difference in skill, but
strictly on a trivial trick hinging on a popular and widely used kind of
code-reformatting utility.


Real-life observation suggests that working with extremely crammed code
(to minimize number of lines) and beautifying it at the end is in fact
not a sensible coding strategy and cannot deliver such huge increases in
coding (and debugging) speed.  Thus, either those studies or your
reading of them must be fatally flawed in this respect (most likely,
some putting hands forward footnote about coding styles and tools in
use was omitted from the summaries, or neglected in the reading).

Such misunderstandings have seriously damaged the practice of
programming (and managements of programming) in the past.  For example,
shops evaluating coders' productivity in terms of lines of code have
convinced their coders to distort their style to emit more lines of code
in order to be measured as more productive -- it's generally trivial to
do so, of course, in many cases, e.g.
for i in range(100):
a[i] = i*i
can easily become 100 lines a[0] = 0 and so on (easily produced by
copy and paste or editor macros, or other similarly trivial means).  At
the other extreme, some coders (particularly in languages suitable for
extreme density, such as Perl) delight in producing one-liner
(unreadable) ``very clever'' equivalents of straightforward loops that
would take up a few lines if 

Re: How to separate directory list and file list?

2005-10-23 Thread Alex Martelli
Gonnasi [EMAIL PROTECTED] wrote:

 With
 glob.glob(*)
 
 or
 os.listdir(cwd)
 
 I can get a combined file list with directory list, but I just wanna a
 bare file list, no directory list. How to get it?

I see everybody's suggesting os.path.* solutions, and they're fine, but
an interesting alternative is os.walk:

__, thedirs, thefiles = os.walk('.').next()

thefiles is the list of filenames (and thedirs is the list of directory
names), and each is sorted alphabetically.  (I'm assigning to '__' the
absolute path of the current directory, meaning I intend to ignore it).
An expression that just provides the filename list is

  os.walk('.').next()[2]

although this may be a tad too obscure to recommend it!-)


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


Re: Syntax across languages

2005-10-23 Thread Alex Martelli
[EMAIL PROTECTED] wrote:
   ...
 - Information about the current line and file as Ruby:
 __LINE__ __FILE__
 Instead of the python version:
 inspect.stack()[0][2] inspect.stack()[0][1]

__file__ is around in Python, too, but there's no __line__ (directly).

 - identity function: identity as in Common Lisp (probably of little
 use in Python).

I've seen enough occurrences of lambda x: x in Python code with a
generally functional style that I'd love to have operator.identity (and
a few more trivial functions like that) for readability;-)

 - object cloning: obj.copy()  obj.deepcopy()

Like (say) container.length() versus len(container), I'm perfectly
comfortable relying on functions rather than methods.  It even makes it
easier to allow several alternative ways for an object to provide such
functionality (e.g. by implementing __getstate__ and maybe __setstate__
as opposed to __copy__ and maybe __deepcopy__) -- which would be
feasible even with a method, of course (Template Method DP), but IS
easier when relying on functions (and operators).

 - accessing parent method:
 super as in Ruby, instead as in Python:
 super(Class, self).meth(args)

Ruby's syntax may be better for a single-inheritance language, but
Python's, while less elegant, may be more appropriate in the presence of
multiple inheritance.

 - recursive flatten as in Ruby (useful)

Usage too rare to deserve a built-in method, IMHO, considering the ease
of coding the equivalent:

def flatten(x):
if not isinstance(x, list): yield x
for y in x: yield flatten(y)

What I _do_ envy Ruby's syntax, a little, is the convention of ending
methodnames with exclamation mark to indicate modifies in-place (and,
secondarily, question mark to indicate predicates).  The distinction
between, e.g.,
y = x.sort()
and
x.sort!()
in Ruby is much clearer, IMHO, than that between, say,
y = sorted(x)
and
x.sort()
in Python...


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


Re: Syntax across languages

2005-10-23 Thread Alex Martelli
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 just curious, how can this identity function be used ? In haskell,
 because all functions are curried, I can sort of visualize/understand
 how id is used. Not quite understand how it can be used in python.

There was a very recent example posted to this group (by Robin Becker, I
believe, looking for ways to override property), something like:
def __init__(self, validate=None):
if not validate: validate = lambda x: x
self.validate = validate
and later on, self.validate is always unconditionally called to extract
a valid value from an input argument to another method -- a nicer style,
arguably, than assigning self.validate unconditionally and then having
to test each and every time in the other method.  Such subcases of the
well-known Null Object design pattern, where you don't want to store
None to mean no such object but, to avoid repeated testing, rather
want to store an object which reliably does nothing, are reasonably
common.  In an abstract way, they're somewhat akin to having the 'pass'
statement in the language itself;-).


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


Re: Syntax across languages

2005-10-23 Thread skip

Alex I've seen enough occurrences of lambda x: x in Python code with
Alex a generally functional style that I'd love to have
Alex operator.identity (and a few more trivial functions like that) for
Alex readability;-)

But, but, but [Skip gets momentarily apoplectic, then recovers...]
operator.identity is way more to type than lambda x: x.  Plus you have
to remember to import the operator module. 0.5 wink

Not to mention which (from pydoc operator):

[The operator module] exports a set of functions implemented in C
corresponding to the intrinsic operators of Python.

Last time I checked, Python didn't have an intrinsic identity operator.

For which reason, I'd be -1 on the idea of an identity function, certainly
in the operator module.

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


Re: calling a dylib in python on OS X

2005-10-23 Thread Kevin Walzer
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

[EMAIL PROTECTED] wrote:
| Hi
|
| Is there something similar to python's windll for calling DLLs on win32
| but meant for calling dylib's on OS X?
|
| thanks,
|
| r.s.
|
Can you be more specific about what you are trying to do/what dylib you
want to call?


- --
Cheers,

Kevin Walzer, PhD
WordTech Software - Tame the Terminal
http://www.wordtech-software.com
sw at wordtech-software.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDW8ZmJmdQs+6YVcoRAvKPAJ0TUW8hgRN6AOn/nBP1v12kqmLXrQCfc5B1
uVv3uBAz7I/jO7l/htpuTb0=
=oXiv
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Syntax across languages

2005-10-23 Thread Alex Martelli
[EMAIL PROTECTED] wrote:

 Alex I've seen enough occurrences of lambda x: x in Python code with
 Alex a generally functional style that I'd love to have
 Alex operator.identity (and a few more trivial functions like that) for
 Alex readability;-)
 
 But, but, but [Skip gets momentarily apoplectic, then recovers...]
 operator.identity is way more to type than lambda x: x.  Plus you have
 to remember to import the operator module. 0.5 wink

But, it's way more readable, IMHO.


 Not to mention which (from pydoc operator):
 
 [The operator module] exports a set of functions implemented in C
 corresponding to the intrinsic operators of Python.
 
 Last time I checked, Python didn't have an intrinsic identity operator.

attrgetter and itemgetter don't exactly correspond to intrinsic
operators, either (getitem, and the built-in getattr, are more like
that)... yet module operator exports them today, offering more readable
(and faster) alternatives to lambda x: x[y] and lambda x: getattr(x,
y).

 
 For which reason, I'd be -1 on the idea of an identity function, certainly
 in the operator module.

I'm not at all wedded to having 'identity' in the operator module (which
may arguably be the wrong placement for 'attrgetter' and 'itemgetter'
too).  But identity is a useful primitive for a functional style of
Python programming, so having it SOMEwhere would be nice, IMHO.


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


Re: calling a dylib in python on OS X

2005-10-23 Thread Alex Martelli
[EMAIL PROTECTED] wrote:

 Hi
 
 Is there something similar to python's windll for calling DLLs on win32
 but meant for calling dylib's on OS X?

ctypes should work just fine on Macs, just as well as on Windows and
Linux machines as well as many other Unix dialects.  Try
http://starship.python.net/crew/theller/ctypes/ ...


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


Re: Microsoft Hatred FAQ

2005-10-23 Thread Mike Meyer
entropy [EMAIL PROTECTED] writes:
 [EMAIL PROTECTED] wrote...
 [EMAIL PROTECTED] wrote...
  In comp.lang.perl.misc David Schwartz [EMAIL PROTECTED] wrote:
   Mike Meyer [EMAIL PROTECTED] wrote in message 
   Sorry, but nobody but the government actually owns property. In most
   places, you can't make non-trivial changes to your property without
   permission from the government. They even charge you rent on your
   property, only they call it property tax.
  I see you are a totalitarianist or perhaps a communist. If you want 
   to 
   live in America and discuss things that are relevent to America, let me 
   know.
  Why would you say that - Mike Meyer made a point to which you have
  obviously no answer. Or do you deny that his comments on this matter
  of property are true?
 Methinks David simply missed that Mike was being facetious.  (Irony 
 and facetiousness don't translate well into print, as Frank Zappa 
 once noted.)
 Uh, you _were_ being facetious there, weren't you Mike?

No, I wasn't. The statements I made are true: the government charges
you taxes on your property, and in most places restricts the changes
you can make to it and the things you can do in it. I used the words
rent and ownership in an unconventional way to emphasize the
point.

The conventional usage of ownwership ignores these kinds of
facts. So you can talk about your house even if you're renting it,
or if the bank still owns most of the house. There are political
groups that are unhappy with these facts, and like to point out the
inconsistencies in the usage of the word ownership. See URL:
http://www.huppi.com/kangaroo/L-propertyrights.htm  and URL:
http://magazine.14850.com/9307/politics.html  for examples of this.

David claimed that everyone had a right to do whatever they wanted
with their property. This is simply false throughout most of the
civilized world - zoning laws control what kinds of business you can
run on your property, various laws designed to control the looks of
the town dictate what you can do to the exterior or lawn, flood and
earthquake laws state what kinds of structural changes you can make,
and so on. I took the view of a political extremist to point out that
he was wrong. David predictably used that to tar me as an extremist
from the other end of the spectrum.

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

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


Re: wxpython - passing arg to wx.app OnInit

2005-10-23 Thread Stuart McGraw

Peter Hansen [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 Stuart McGraw wrote:
  I have a wxPython app, conventionally structured
  with a Application class derived from wx.App.
  My problem is that the app accepts a command
  line argument that must be acted upon within the
  OnInit() method of the Application class.  How do
  I pass it cleanly from main() into app.OnInit()?  In 
  the simplified example below, dbfn is the piece of 
  info that is in main() that OnInit() needs to use.
  Is a global variable is the only way?  :-(
 
 There are various ways, but the simplest is to accept that sys.argv is
 *already* a global and just to access it directly from the
 Application's OnInit() method.
 
 This wiki page demonstrates:
 http://wiki.wxpython.org/index.cgi/UsingCommandLineArguments
 
 -Peter

I simplied the my code for posting.  In my real program, the
thing being passed is not a command line argument per se,
but the result of signifigant processing dependent on the 
command line argument.  I do not want to repeat that 
processing in the wx.App method.
Would you elaborate on the other ways?
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: PyLZMA 0.1.0 released

2005-10-23 Thread Joachim Bauch

Hi,

I'm pleased to announce the release of PyLZMA 0.1.0

PyLZMA is a platform independent python library that provides compression
using the LZMA algorithm by Igor Pavlov.  The LZMA algorithm usually performs
better than the zlib or bz2 algorithms.

Changes from 0.0.3:
* updated to 7-zip 4.23 and LZMA SDK 4.27
* fixed compilation problems with GCC 4 on Linux
* added matchfinder algorithms HashChain and Patricia in addition to the
  default BinTree
* support for multithreaded compression on Windows
* new usage.txt documentation
* added compatibility decompression methods for compressed data without the
  end of stream marker if the total uncompressed size is unknown

You can download the source and Windows installers of the new version from
the projects area of my homepage at http://www.joachim-bauch.de

The latest sourcecode can be found in the subversion repository at
http://fancycode.com/viewcvs/pylzma/trunk/?root=python

Greetings,
  Joachim


signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Localized strftime()

2005-10-23 Thread Sebastjan Trepca
Hi!

I'm trying to get a localized date format from strftime() but it seems
that is doesn't have any parameters for that or any information about
this issue in Python docs.

For example I want to turn this:
19 Oct, 2005
to this(slovene language):
19 Okt, 2005

Thanks for help, Sebastjan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDE recommendation please

2005-10-23 Thread Wolfgang Keller
 I'm new to Python but am wondering what IDE Python developers use?
 I use Mac OS X 10.4.2. 

Just look in the archives of the Pythonmac mailinglist. We have 
discussed this very subject intensively recently, with a pretty 
extensive review of the different IDEs available.

I'll get a copy of WingIDE as soon as I get my new PowerMac.

 Suggestions for plugins for Eclipse would also be nice.

Err, Eclipse (imho) is a H-O-G.

Sincerely,

Wolfgang


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


Re: Localized strftime()

2005-10-23 Thread Fredrik Lundh
Sebastjan Trepca wrote:

 I'm trying to get a localized date format from strftime() but it seems
 that is doesn't have any parameters for that or any information about
 this issue in Python docs.

 For example I want to turn this:
 19 Oct, 2005
 to this(slovene language):
 19 Okt, 2005

you must call locale.setlocale first, to switch from the default C
locale to a locale of your choice.

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

 import time
 print time.strftime(%a, %d %b %Y %H:%M:%S)
Sun, 23 Oct 2005 20:38:56
 import locale
 locale.setlocale(locale.LC_TIME, sv_SE) # swedish
'sv_SE'
 print time.strftime(%a, %d %b %Y %H:%M:%S)
sön, 23 okt 2005 20:39:15
 locale.setlocale(locale.LC_TIME, sl_SI)
'sl_SI'
 print time.strftime(%a, %d %b %Y %H:%M:%S)
ned, 23 okt 2005 20:39:32

/F



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

Re: Microsoft Hatred FAQ

2005-10-23 Thread David Schwartz

Steven D'Aprano [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 No, not at all. It is the gravest act of self-contradiction to 
 maintain
 that one should be allowed to pursue one's own interest while denying 
 that
 same right to others.

 This is perhaps the most ignorant thing I've seen written down by somebody
 educated for a long, long long time. An individual's self-interest may
 very well include theft, murder or rape, to mention just a few examples.

You are dishonest, lying sack of shit.

DS


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


Re: Microsoft Hatred FAQ

2005-10-23 Thread David Schwartz

Steven D'Aprano [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 On Sat, 22 Oct 2005 18:02:44 -0700, David Schwartz wrote:

 I see you are a totalitarianist or perhaps a communist. If you want 
 to
 live in America and discuss things that are relevent to America, let me
 know.

 In other words, why don't you go back to Russia, you commie pinko
 fascist Jew Nazi.

No.

 Mike Meyer has got just as much right to live in America as David
 Schwartz. Nice to see how quickly Americans' supposed love of freedom
 disappears once they are exposed to views that contradict their own.

This is about whether we're talking *ABOUT* America, you idiot. It's as 
if he said the press has no freedom, and I replied, if you want to talk 
about some country where that's true, fine, but this discussion presumed 
America as the basis.

Remember, he is the one who said the government owned the economy. That 
may be true in some countries, but it's simply *FALSE* in this country. Our 
government has limited powers and ownership of the economy is not one of 
them.

DS


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


Re: Microsoft Hatred FAQ

2005-10-23 Thread David Schwartz

Mike Meyer [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 I am not saying Microsoft did not know the law. I am saying that no
 rational person could have expected the law to be applied to Microsoft
 that
 way it was. The law *must* put a person on notice of precisely what
 conduct
 it prohibits. However, in this case, the law's applicability was
 conditioned
 on an abritrary and irrational choice of what the relevant market was.

 MS has a long history of dancing with the DOJ, and has been repeatedly
 warned about the legality - or lack thereof - of their behavior. No
 rational person who knew of that history could expect the law to be
 applied to MS in any way other than the way it was.

 Since when does the DOJ get to make the law? (George Bush's claims to
 the contrary not withstanding.) The issue is whether the *LAW* put 
 Microsoft
 on notice. A just law must itself put people on notice as to precisely 
 what
 conduct constitutes a violation of that law.

 In that case, we hav an *awful* lot of unjust laws, because laws
 seldom disallow precise behavior.

That is true. A law *must* put a reasonable person on notice of 
precisely what conduct it prohibits and what it does not. At the fringes, 
the tie goes to the runner, that is, the conduct is not illegal. The law is 
not supposed to care about things that are trivial. (Except in genuine 
private entity versus private entity non-criminal cases, where the law 
really is about the slightest tip of the scales and there is no presumption 
for either party.)

Which is the only rational way for
 a system of laws to work. Requiring that the law predict *everything*
 that someone might do to harm others and explicitly listing all those
 cases is silly.

That's not what I'm asking for. I'm asking that the law *clearly* put 
people on notice of what conduct is prohibited. That's very easy in 
legitimate laws, because we all know what it means to punch someone or to 
rob them. It becomes very difficult in illegitimate laws, because there is 
no reasonable test to decide whether something is a 'monopoly' or not. This 
burden makes it harder for the government to pass unjust laws, and that is a 
good thing.

 Instead, you outline a class of actions and tag them
 all as illegal. That's why we have laws against assault and battery
 and unsafe driving. And laws against exercising monopoly power in an
 unfair manner.

Interesting how you, again, equate a gun and an argument. It is very 
important to you to justify responding to arguments with guns. However, I 
reject that premise at its roots, not just in your application of it.

DS


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


Re: Microsoft Hatred FAQ

2005-10-23 Thread David Schwartz

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

 In comp.lang.perl.misc David Schwartz [EMAIL PROTECTED] wrote:
 Mike Meyer [EMAIL PROTECTED] wrote in message

 Sorry, but nobody but the government actually owns property. In most
 places, you can't make non-trivial changes to your property without
 permission from the government. They even charge you rent on your
 property, only they call it property tax.

I see you are a totalitarianist or perhaps a communist. If you want to
 live in America and discuss things that are relevent to America, let me
 know.

 Why would you say that - Mike Meyer made a point to which you have
 obviously no answer. Or do you deny that his comments on this matter
 of property are true?

His comments are not applicable to America. They are applicable to a 
country where the government owns the economy.

No reply is needed to his comments except to point out that they only 
apply to a communist or totalitarian state. We don't have one here, so his 
argument doesn't apply.

I am not saying because you are a communist, your argument is wrong. I 
am saying, because your argument is based upon communist or totalitarian 
premises about the relationship between the government and the economy, it 
does not apply to the United States, and we were talking about the United 
States.

I really felt that this was obvious, but I guess it wasn't.

DS


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


Re: Microsoft Hatred FAQ

2005-10-23 Thread David Schwartz

Mike Meyer [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 David claimed that everyone had a right to do whatever they wanted
 with their property. This is simply false throughout most of the
 civilized world - zoning laws control what kinds of business you can
 run on your property, various laws designed to control the looks of
 the town dictate what you can do to the exterior or lawn, flood and
 earthquake laws state what kinds of structural changes you can make,
 and so on. I took the view of a political extremist to point out that
 he was wrong. David predictably used that to tar me as an extremist
 from the other end of the spectrum.

Here's a question for you, Mike. Presumably, you have the right not to 
be shot for no reason at all. Does that right act as a bulletproof vest that 
actually physically prevents me from shooting you? If I argued that a person 
had a right not to be shot for no reason at all by a random stranger, would 
you point out that such shootings occur throughout the civilized world as 
some kind of refutation?

The way you respond to what I'm saying shows that you really don't have 
any clue whatsoever of what the words I'm using *mean*. Do you even know 
what a right is? (Such that, for example, it's possible for rogue 
governments to violate the rights of their citizens even if those 
governments don't recognize those rights.)

DS


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


Re: wxpython - passing arg to wx.app OnInit

2005-10-23 Thread Peter Hansen
Stuart McGraw wrote:
 I simplied the my code for posting.  In my real program, the
 thing being passed is not a command line argument per se,
 but the result of signifigant processing dependent on the 
 command line argument.  I do not want to repeat that 
 processing in the wx.App method.
 Would you elaborate on the other ways?

In that case, override __init__ something like this:

class Application(wx.App):
def __init__(self, *pargs, clargs=None, **kwargs):
self.clargs = clargs or []   # store reference to args

# call parent class initializer
wx.App.__init__(self, *pargs, **kwargs)

   def OnInit(self):
   # use self.clargs here


app = Application(redirect=0, clargs=[dbfn])

or whatever... I just guessed at what you meant to do with dbfn though,
but I think the basic idea is clear enough.

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


Re: Microsoft Hatred FAQ

2005-10-23 Thread Alex Martelli
Mike Meyer [EMAIL PROTECTED] wrote:
...
 David claimed that everyone had a right to do whatever they wanted
 with their property. This is simply false throughout most of the
 civilized world - zoning laws control what kinds of business you can

Incidentally, the perfectly good rationale for this universal existence
of limitations to doing whatever you want with your property is known
in economics as *externalities*.  Transactions that appear to involve
just one or two parties, and be entirely voluntary between them, may in
fact produce all sort of beneficial or detrimental effects on further
parties who have not necessarily agreed to that.  For example, I may
own a certain lot of land, but if on that lot I place a siren blaring
and a huge flashing red sign, the energy of the sound waves and light
will inevitably also affect other nearby places, which I do _not_ own
(either they're commons, or owned by somebody else), imposing an
externality on owners and/or users of those nearby places.

Of course, while some externalities are entirely obvious (it's hard to
argue against such sirens and flashing lights being otherwise), many
others are subtler and more debatable, so one reasonable society might
acknowledge a certain class of externality and try to regulate it while
another might prefer not to do so.  But the general concept of society
as a whole placing limitations on private owners' uses of the property,
based on externalities certain uses might impose on unwilling parties,
is as solid as a rock, both practically and theoretically -- however
much anarchists or extreme libertarians might wish otherwise.


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


Re: Microsoft Hatred FAQ

2005-10-23 Thread Matt Garrish

David Schwartz [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 Mike Meyer [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]

 David claimed that everyone had a right to do whatever they wanted
 with their property. This is simply false throughout most of the
 civilized world - zoning laws control what kinds of business you can
 run on your property, various laws designed to control the looks of
 the town dictate what you can do to the exterior or lawn, flood and
 earthquake laws state what kinds of structural changes you can make,
 and so on. I took the view of a political extremist to point out that
 he was wrong. David predictably used that to tar me as an extremist
 from the other end of the spectrum.

Here's a question for you, Mike. Presumably, you have the right not to 
 be shot for no reason at all. Does that right act as a bulletproof vest 
 that actually physically prevents me from shooting you? If I argued that a 
 person had a right not to be shot for no reason at all by a random 
 stranger, would you point out that such shootings occur throughout the 
 civilized world as some kind of refutation?

The way you respond to what I'm saying shows that you really don't have 
 any clue whatsoever of what the words I'm using *mean*. Do you even know 
 what a right is? (Such that, for example, it's possible for rogue 
 governments to violate the rights of their citizens even if those 
 governments don't recognize those rights.)


I'd be interested in hearing what you think a right is? In Florida, for 
example, you have the right to gun someone down if you think they're a bit 
too menacing. In Canada, most people find that reprehensible. So does a 
Floridian visiting Canada have their rights infringed on by our rogue 
government because they're not allowed to gun down menacing looking 
Canadians at will? Should they be able to exercise that right regardless and 
not have to face the consequences of our laws?

I think right, however, was the wrong choice of words in this thread; 
there is rarely anything codifying a company's right to succeed at all 
costs and at the expense of all competition (except Crown Corporations and 
the like, which are created (in theory, anyway) in the interest of general 
population as opposed to it). Your question here appears to be one of 
ethics. Is MS ethically bankrupt for pursuing business practices that run 
counter to society's established norms, and should they be punished for 
doing so? And is their behaviour the more reprehensible because of the 
contempt they show for the decisions of society's judicial arm.

Matt 


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


Tricky Areas in Python

2005-10-23 Thread PyPK
What possible tricky areas/questions could be asked in Python based
Technical Interviews?

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


Re: Localized strftime()

2005-10-23 Thread Sebastjan Trepca
Great, it works, thanks :)

On 23/10/05, Fredrik Lundh [EMAIL PROTECTED] wrote:
 Sebastjan Trepca wrote:

  I'm trying to get a localized date format from strftime() but it seems
  that is doesn't have any parameters for that or any information about
  this issue in Python docs.
 
  For example I want to turn this:
  19 Oct, 2005
  to this(slovene language):
  19 Okt, 2005

 you must call locale.setlocale first, to switch from the default C
 locale to a locale of your choice.

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

  import time
  print time.strftime(%a, %d %b %Y %H:%M:%S)
 Sun, 23 Oct 2005 20:38:56
  import locale
  locale.setlocale(locale.LC_TIME, sv_SE) # swedish
 'sv_SE'
  print time.strftime(%a, %d %b %Y %H:%M:%S)
 sön, 23 okt 2005 20:39:15
  locale.setlocale(locale.LC_TIME, sl_SI)
 'sl_SI'
  print time.strftime(%a, %d %b %Y %H:%M:%S)
 ned, 23 okt 2005 20:39:32

 /F





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


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


Re: Tricky Areas in Python

2005-10-23 Thread Gerhard Häring
PyPK wrote:
 What possible tricky areas/questions could be asked in Python based
 Technical Interviews?

I would try to check if the applicant understands the Python data model: 
http://docs.python.org/ref/objects.html Because I thinkt that's 
fundamental to understanding the Python language and understanding 
complexity of operations.

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


Re: Microsoft Hatred FAQ

2005-10-23 Thread David Schwartz

Matt Garrish [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 I'd be interested in hearing what you think a right is?

A right is a scope of authority. That is, a sphere within which one's 
decision is sovereign.

 In Florida, for example, you have the right to gun someone down if you 
 think they're a bit too menacing. In Canada, most people find that 
 reprehensible. So does a Floridian visiting Canada have their rights 
 infringed on by our rogue government because they're not allowed to gun 
 down menacing looking Canadians at will?

That's obviously a complicated question but totally unrelated to the 
issue at hand, which was one's sovereignty over one's own property. 
Obviously issues where a person has to use force against another are going 
to be complicated. The existence of complicated questions doesn't make the 
simple ones complicated.

 Should they be able to exercise that right regardless and not have to face 
 the consequences of our laws?

I think there are objective criteria in which the use of force is 
justified regardless of the laws. However, the strategic decision of whether 
to use objectively justifiable force when one may not be able to justify it 
to non-objective observers who may use force against you is going to be a 
complicated one.

 I think right, however, was the wrong choice of words in this thread; 
 there is rarely anything codifying a company's right to succeed at all 
 costs and at the expense of all competition (except Crown Corporations and 
 the like, which are created (in theory, anyway) in the interest of general 
 population as opposed to it).

My point was that the Microsoft corporation was not an impersonal 
entity. It is an entity that is supposed to embody the will and rights of 
its shareholders and exists to allow them to act together for their own 
benefit.

 Your question here appears to be one of ethics. Is MS ethically bankrupt 
 for pursuing business practices that run counter to society's established 
 norms, and should they be punished for doing so? And is their behaviour 
 the more reprehensible because of the contempt they show for the decisions 
 of society's judicial arm.

It is only proper to show contempt for bad decisions. MS obligation was 
to comply with the law and not perform actions that the law put them on 
clear notice were prohibited. The court's determination of the relevent 
market, on wich all of their other decisions were predicated, was arbitrary 
and bizarre, and the law did not provide any notice of how the market would 
be determined.

In the sense of interchangeability, almost all operating systems are 
monopolies. And if you go by application, Windows, Linux, and FreeBSD are 
all interchangeable -- there is nothing significant you can do on one that 
you can't do on the other.

DS


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


TurboGears the Podcast

2005-10-23 Thread rdsteph
Can be found at http://www.awaretek.com/python/index.html

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


Hengelsportbeurs

2005-10-23 Thread Henk-Jan de Jong
http://www.drentorganisatiebureau.nl/beurs/indexfront.html

Nog zin om te gaan?
-- 
http://mail.python.org/mailman/listinfo/python-list


PyGTK color blackout

2005-10-23 Thread egbert
Without success I try to understand the color mechanism in PyGTK.
It's about the classes Color an Colormap, and their methods and
related functions and other paraphernalia.
If anyone knows about a tutorial-like systematic description, 
I will be very grateful.
-- 
Egbert Bouwman - Keizersgracht 197 II - 1016 DS  Amsterdam - 020 6257991

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


Re: IDE recommendation please

2005-10-23 Thread Steve Holden
Gian Mario Tagliaretti wrote:
 microsnot wrote:
 
 
I'm new to Python but am wondering what IDE Python developers use? I use
Mac OS X 10.4.2. I have PythonIDE which comes with MacPython but I don't
think that has even rudimentary intellisense. Xcode and Eclipse don't
seem to support Python out of the box. Suggestions for plugins for Eclipse
would also be nice.
 
 
 I use wingIDE and as Alex said before is the best python IDE ever...
 
 cheers

I too am a happy Wing IDE user. The debugging features are very convenient.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: IDE recommendation please

2005-10-23 Thread Kevin Walzer
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

microsnot wrote:
| I'm new to Python but am wondering what IDE Python developers use? I
use Mac
| OS X 10.4.2. I have PythonIDE which comes with MacPython but I don't think
| that has even rudimentary intellisense. Xcode and Eclipse don't seem to
| support Python out of the box. Suggestions for plugins for Eclipse would
| also be nice.
|
The situation has been pretty bleak, and I've tried (even maintained Mac
packages for awhile) nearly all the open-source IDE's out there,
including SPE, Boa, Eric3, etc. They all crashed constantly in my
experience. SPE has been making more of a Mac push since I stopped
maintaining Mac packages so it may have improved.

Komodo is a good IDE and is currently in beta testing on OS X: see
www.activestate.com for the particulars. It's more polished than any of
the open-source tools (though it should be for the $300 that the pro
version costs), and runs natively (as an Aqua app). Komodo is not
Python-only, but if you are developing commercially it is a very  good
tool to consider.

WingIDE is also very powerful, but runs only as an X11 app on the Mac.
That may or may not be a problem for you.

I've ultimately settled on a primitive set of tools myself, Emacs or
IDLE, plus the console. Fewer bells and whistles, but they are stable,
and don't get in my way.

- --
Cheers,

Kevin Walzer, PhD
WordTech Software - Tame the Terminal
http://www.wordtech-software.com
sw at wordtech-software.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDXAIlJmdQs+6YVcoRAqsKAJ0YX14aGH5pUpujXb+wmYoWbGUkWQCfX0oK
6kiXX9w+rAIbo5qCYGUWIuc=
=YSju
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Hatred FAQ

2005-10-23 Thread Mike Meyer
David Schwartz [EMAIL PROTECTED] writes:
 Instead, you outline a class of actions and tag them
 all as illegal. That's why we have laws against assault and battery
 and unsafe driving. And laws against exercising monopoly power in an
 unfair manner.
 Interesting how you, again, equate a gun and an argument. It is very 
 important to you to justify responding to arguments with guns. However, I 
 reject that premise at its roots, not just in your application of it.

Another straw man. I never mentioned the word gun at all, and none
of the crimes I discussed require a gun.

You apparently aren't interested in constructive intercourse on the
question. You're just interesting in knocking down your own
arguments. Personally, I'd rather not watch you masterbate.

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


Re: Tricky Areas in Python

2005-10-23 Thread PyPK
hmm Thats one thing. Also I was thinking of something like benefites of
python over other languages. Probably that coould be one ?

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


Re: Microsoft Hatred FAQ

2005-10-23 Thread Matt Garrish

David Schwartz [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 Matt Garrish [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]

 I'd be interested in hearing what you think a right is?

A right is a scope of authority. That is, a sphere within which one's 
 decision is sovereign.


Then why were you claiming that a government can infringe on a person's 
rights if those rights are not codified or even accepted by those people? 
The idea of inalienable rights for anyone in a Western society only exists 
if you believe that the rights of Western societies are inalienable and 
should be respected everywhere. There is a huge arrogance in that 
assumption, though, and once you enter a jurisdiction that does not hold 
your rights to be inalienable they are no longer your rights.

You can have generally agreed upon rights, but as you note, those rights can 
only be hoped for if the systems exist to enforce them. Once those systems 
erode, you no longer have rights only hopes. The more you allow those 
systems to be eroded, the less you can expect your rights to exist.

In the end, the slippery slope theory would suggest that if you allow MS to 
get away with bad business practices you are in effect giving all companies 
the right to leverage whatever means are at their disposal to do the same, 
to the detriment of society.

 In Florida, for example, you have the right to gun someone down if you 
 think they're a bit too menacing. In Canada, most people find that 
 reprehensible. So does a Floridian visiting Canada have their rights 
 infringed on by our rogue government because they're not allowed to gun 
 down menacing looking Canadians at will?

That's obviously a complicated question but totally unrelated to the 
 issue at hand, which was one's sovereignty over one's own property. 
 Obviously issues where a person has to use force against another are going 
 to be complicated. The existence of complicated questions doesn't make the 
 simple ones complicated.


I brought it up as an example of why rights are difficult in all cases. You 
can't claim that anyone has a right to the land they live on. Your only 
legitimacy to ownership comes through goverment and its ability to enforce 
that legitimacy for you. And if you really want to get contentious, in 
Canada and the US your only legitimacy comes from an artificial transaction 
between a landowner and your government at some time in the past to 
legitimize its sovereignty over Native American land.

Your only real right when it comes to land ownership is to receive some kind 
of compensation if it is taken away. Your government could decide at any 
time to expropriate your property to build a new highway (for example), and 
you'd be out in the cold. You can try to fight the government in court but 
more often than not you'll lose because the greater good of society 
outweighs your right to own the land (and the assumption is always that 
governments work for the greater good of society).

And add to that all the covenants and municipal laws you have to obey when 
purchasing property and the notion that you have sovereignty over your land 
becomes even less tenable.

Matt 


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


Re: Microsoft Hatred FAQ

2005-10-23 Thread Steven D'Aprano
On Sun, 23 Oct 2005 11:43:44 -0700, David Schwartz wrote:

 You are dishonest, lying sack of shit.


And David posts his true colours to the mast at last. When rational
argument and logical thoughts fails, fall back on personal insults.


-- 
Steven.

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


Re: Python variables are bound to types when used?

2005-10-23 Thread Tom Anderson
On Sat, 22 Oct 2005, Fredrik Lundh wrote:

 [EMAIL PROTECTED] wrote:

 reset your brain:

 http://effbot.org/zone/python-objects.htm

Is it really a good idea to say that objects have names? Isn't it cleaner 
to describe objects without any reference to names or variables or 
whatnot, then introduce names, namespaces and references as tools for 
working with objects? You go on to explain this clearly, but it's a bit of 
a confusing way to start!

tom

PS Sorry to be following up to a message other than the one i'm actually 
replying to - the original, i'm afraid, is an ex-message.

-- 
It is a laborious madness, and an impoverishing one, the madness of
composing vast books. -- Jorge Luis Borges
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Hatred FAQ

2005-10-23 Thread David Schwartz

Mike Meyer [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 David Schwartz [EMAIL PROTECTED] writes:

 Instead, you outline a class of actions and tag them
 all as illegal. That's why we have laws against assault and battery
 and unsafe driving. And laws against exercising monopoly power in an
 unfair manner.

 Interesting how you, again, equate a gun and an argument. It is very
 important to you to justify responding to arguments with guns. However, I
 reject that premise at its roots, not just in your application of it.

 Another straw man. I never mentioned the word gun at all, and none
 of the crimes I discussed require a gun.

You can't be that stupid, can you?! Tell me it wasn't obvious to you 
that the phrase a gun and an argument means the difference between force 
and disagreement.

 You apparently aren't interested in constructive intercourse on the
 question. You're just interesting in knocking down your own
 arguments. Personally, I'd rather not watch you masterbate.

You're are the one who brought up assault and battery and unsafe 
driving, equating Microsoft's persuasive negotiation tactics with force in 
an attempt to justify responding to them with force.

DS


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


Re: Microsoft Hatred FAQ

2005-10-23 Thread Alan Connor
Matt Garrish wrote:
body not downloaded

That does it. From this point on my newsfilter is killing
(leaving on the server) any articles cross-posted to more than
three groups.

To all of the snivelling punks polluting the Usenet with their
verbal diarrhea here:

Shut up and go away.

Done.

(I haven't read a single post here, but don't need to. A bunch
of aliases with no posting histories equals trolls equals verbal
diarrhea.)

And my killfile thanks you for the sumptuous feast all of the
aliases used on this thread have given it.

Do your Mommy's know that you are playing with their computers
again?


AC


-- 
Homepage: http://home.earthlink.net/~alanconnor/
Fanclub: http://www.pearlgates.net/nanae/kooks/alanconnor.shtml
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Hatred FAQ

2005-10-23 Thread David Schwartz

Matt Garrish [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

A right is a scope of authority. That is, a sphere within which one's 
 decision is sovereign.

 Then why were you claiming that a government can infringe on a person's 
 rights if those rights are not codified or even accepted by those people? 
 The idea of inalienable rights for anyone in a Western society only exists 
 if you believe that the rights of Western societies are inalienable and 
 should be respected everywhere. There is a huge arrogance in that 
 assumption, though, and once you enter a jurisdiction that does not hold 
 your rights to be inalienable they are no longer your rights.

 You can have generally agreed upon rights, but as you note, those rights 
 can only be hoped for if the systems exist to enforce them. Once those 
 systems erode, you no longer have rights only hopes. The more you allow 
 those systems to be eroded, the less you can expect your rights to exist.

This would suggest that rogue governments can't infringe on the rights 
of their people because those people have no rights since their societies 
don't recognize any. This is another principle I reject at its roots. Your 
rights exist whether or not others choose to respect them.

DS


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


Re: Microsoft Hatred FAQ

2005-10-23 Thread Steven D'Aprano
On Sun, 23 Oct 2005 13:52:38 -0700, David Schwartz wrote:

 The court's determination of the relevent 
 market, on wich all of their other decisions were predicated, was arbitrary 
 and bizarre, and the law did not provide any notice of how the market would 
 be determined.

You keep saying that, as if people could do their word processing and run
their financial accounting software on the micro-controllers of microwave
ovens or the computer in their car engine.

The market of desktop PC is a perfectly obvious and natural market. You
are the one insisting on arbitrarily lumping together who knows what other
products in with the desktop PC. I say who knows for a reason -- the
only two examples you have come up with were Apple Macintoshes and
desktop PCs running Linux (both less than 5% of the market *now*, and
even less back when the court was investigating Microsoft). Making your
position even more bizarre, both of these products were recognised by the
court as part of the market in question, both were recognised as potential
competing products put at risk due to Microsoft's illegal behaviour.


 In the sense of interchangeability, almost all operating systems are
 monopolies. 

You don't know what the word monopoly actually means in either law or
economics, do you? What you have written is a perfectly grammatical
sentence that makes no sense whatsoever. If OSes are monopolies, then they
are NOT interchangeable -- but you state in the very next sentence that
they are.

 And if you go by application, Windows, Linux, and FreeBSD
 are all interchangeable -- there is nothing significant you can do on
 one that you can't do on the other.

Try telling that to a business that needs to do computerised book-keeping
of wages and payroll.



-- 
Steven.

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


Re: Tricky Areas in Python

2005-10-23 Thread Chris Curvey
I usually start by asking how you make variables private within
classes.  That seems to tell me if they understand something about the
design of the language and it's a quick filter to tell if they know
something about the syntax.

The other question that I use is asking about 3rd party libraries that
they have found useful.  That can lead into some good questions about
what they like about those libraries and what they dislike.  That
question helps me understand whether they've thought at all about how
to design in Python.

If I can't get a good conversation started with either of those, I'll
ask what they don't like about Python, to see if they've actually used
it to solve a real problem, or if they've just read the tutorial.

As always, the best interview questions are open-ended, and give the
candidate some room to really show their stuff (or give them enough
rope to hang themselves).

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


Re: calling a dylib in python on OS X

2005-10-23 Thread Victor Ng
You can use Pyrex which will generate a C module for you.

vic

On 22 Oct 2005 23:40:17 -0700, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 Hi

 Is there something similar to python's windll for calling DLLs on win32
 but meant for calling dylib's on OS X?

 thanks,

 r.s.

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



--
Never attribute to malice that which can be adequately explained by
stupidity.  - Hanlon's Razor
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Hatred FAQ

2005-10-23 Thread Roedy Green
On Sat, 22 Oct 2005 19:54:58 -0300, Shmuel (Seymour J.) Metz
[EMAIL PROTECTED] wrote or quoted :

As well as blame. The commercialization of the Internet was grossly
mismanaged. Take the InterNIC - please!

As global bureaucracies go, I think they have done a good job.  Can
you imagine herding the cats of egotistical dictators and politicians
from every country on earth who have not a clue about what the
function of domain are?


-- 
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Syntax across languages

2005-10-23 Thread Tom Anderson
On Sun, 23 Oct 2005, Fredrik Lundh wrote:

 [EMAIL PROTECTED] wrote:

 - ~== for approximate FP equality

 str(a) == str(b)

This is taken from the AI 754 standard, i take it? :)

Seriously, that's horrible. Fredrik, you are a bad man, and run a bad 
railway.

However, looking at the page the OP cites, the only mention of that 
operator i can find is in Dylan, and in Dylan, it's nothing to do with 
approximate FP equality - it means 'not identical', which we can spell is 
not.

What would approximate FP equality even mean? How approximate?

 - Exception retrying: after catching an exception, tell the snippet to
 be re-run retry as in Ruby

 x = 0
 while 1:
 ... try:
 ... x += 1
 ... if x = 5:
 ... raise ValueError
 ... except ValueError:
 ... print retry
 ... continue
 ... else:
 ... break
 ...
 retry
 retry
 retry
 retry
 retry


That works well for trivial cases, and not at all for anything complex. If 
you have this sort of structure:

def reverse_the_polarity_of_the_neutron_flow():
five_hundred_lines_of_code()
and_dozens_of_layers_of_nesting_and_indirection()
interrossitor.activate() # can raise InterrossitorError
do_what_we_came_here_to_do()

try:
reverse_the_polarity_of_the_neutron_flow()
except InterrossitorError:
degausser.degauss(interrossitor)
interrossitor.activate()
RETRY # how do you implement this?

You're in trouble. I realise that this snippet is not a hugely compelling 
example, but the point is that there could be some corrective action that 
you can take in an exception handler which, for some reason, you can't 
write close enough to the source of the exception that control can carry 
on flowing in the right direction.

What you can do - and this is fairly high-grade evil of a different sort - 
is package the exception-handling specifics in a function, and pass that 
in, to be applied at the appropriate point:

def reverse_the_polarity_of_the_neutron_flow(ie_hdlr):
five_hundred_lines_of_code()
and_dozens_of_layers_of_nesting_and_indirection()
try:
interrossitor.activate() # can raise InterrossitorError
except InterrossitorError, e:
ie_hdlr(e)
do_what_we_came_here_to_do()

def handle_interrossitor_error(e):
degausser.degauss(interrossitor)
interrossitor.activate()
reverse_the_polarity_of_the_neutron_flow(handle_interrossitor_error)

You can even do extra bonus higher-order-functioning:

def reverse_the_polarity_of_the_neutron_flow(ie_hdlr):
five_hundred_lines_of_code()
and_dozens_of_layers_of_nesting_and_indirection()
ie_hdlr(interrossitor.activate)
do_what_we_came_here_to_do()

def handle_interrossitor_error(fn):
try:
fn()
except InterrossitorError, e:
degausser.degauss(interrossitor)
interrossitor.activate()
reverse_the_polarity_of_the_neutron_flow(handle_interrossitor_error)

Although i can't see any reason why you'd want to.

 - recursive flatten as in Ruby (useful)

 if you can define the semantics, it's a few lines of code.  if you're 
 not sure about the semantics, a built-in won't help you...

While we're on the subject, we had a big recursive flatten bake-off round 
here a few months back: look for a thread called flatten(), [was Re: 
map/filter/reduce/lambda opinions andbackground unscientific 
mini-survey], and filter out the posts with code from the posts with 
rants. There are all sorts of solutions, coming at the problem from 
different angles, but the end of it is more or less here:

http://groups.google.co.uk/group/comp.lang.python/msg/0832db53bd2700db

Looking at the code now, i can see a couple of points where i could tweak 
my flatten even more, but i think the few microseconds it might save 
aren't really worth it!

tom

-- 
It is a laborious madness, and an impoverishing one, the madness of
composing vast books. -- Jorge Luis Borges
-- 
http://mail.python.org/mailman/listinfo/python-list


how to count and extract images

2005-10-23 Thread Joe
I'm trying to get the location of the image uisng 

start = s.find('a href=somefile') + len('a
href=somefile') 
stop = s.find('Save File/a/B',
start) fileName = s[start:stop]
and then construct the url with the filename to download the image 
which works fine as cause every image has the Save File link and I can
count number of images easy the problem is when there is more than image I
try using while loop downlaod files, wirks fine for the first one but
always matches the same, how can count and thell the look to skip the fist
one if it has been downloaded and go to next one, and if next one is
downloaded go to next one, and so on.
-- 
http://mail.python.org/mailman/listinfo/python-list


All kind of download just here

2005-10-23 Thread aasava
All What You Are Looking For And More


Hello Dear friend...
Here http://s14.invisionfree.com/SaVaTaGe4eVeR/
you can find all what you are looking for in all the internet to
download it like ...

New Applications just here
http://s14.invisionfree.com/SaVaTaGe4eVeR/index.php?showtopic=94
New Movies just here
http://s14.invisionfree.com/SaVaTaGe4eVeR/index.php?showtopic=96
New PC Games just here
http://s14.invisionfree.com/SaVaTaGe4eVeR/index.php?showtopic=95
New Animes just here
http://s14.invisionfree.com/SaVaTaGe4eVeR/index.php?showtopic=104
New Musics just here
http://s14.invisionfree.com/SaVaTaGe4eVeR/index.php?showtopic=104
New Mobile just here http://s14.invisionfree.com/SaVaTaGe4eVeR/
New e-books just here http://s14.invisionfree.com/SaVaTaGe4eVeR/
and many many more

So please come and see what we can offer for you at
http://s14.invisionfree.com/SaVaTaGe4eVeR/

SaVaTaGe4eVeR forum team

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


Re: Syntax across languages

2005-10-23 Thread Alex Martelli
Tom Anderson [EMAIL PROTECTED] wrote:
   ...
 What would approximate FP equality even mean? How approximate?

In APL, it meant to within [a certain quad-global whose name I don't
recall] in terms of relative distance, i.e., if I recall correctly,
a=b meant something like abs(a-b)/(abs(a)+abs(b))  quadEpsilon or
thereabouts.  Not too different from Numeric.allclose, except the latter
is richer (it takes both absolute and relative epsilons, and also
implies an and-reduce if the objects being compared are arrays).


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


Re: how to count and extract images

2005-10-23 Thread Alex Martelli
Joe [EMAIL PROTECTED] wrote:

 I'm trying to get the location of the image uisng 
 
 start = s.find('a href=somefile') + len('a
 href=somefile') 
 stop = s.find('Save File/a/B',
 start) fileName = s[start:stop]
 and then construct the url with the filename to download the image 
 which works fine as cause every image has the Save File link and I can
 count number of images easy the problem is when there is more than image I
 try using while loop downlaod files, wirks fine for the first one but
 always matches the same, how can count and thell the look to skip the fist
 one if it has been downloaded and go to next one, and if next one is
 downloaded go to next one, and so on.

Pass the index from where the search must start as the second argument
to the s.find method -- you're already doing that for the second call,
so it should be pretty obvious it will also work for the first one, no?


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


Re: Tricky Areas in Python

2005-10-23 Thread Alex Martelli
PyPK [EMAIL PROTECTED] wrote:

 What possible tricky areas/questions could be asked in Python based
 Technical Interviews?

I like to present code that seems like it should work, but has some kind
of relatively subtle problem, either of correctness in some corner case,
or of performance, etc -- and I ask them what they would say if they
were to code-review that code, or how they would help a student who came
to them with that code and complaints about it not working, c.

This tells me whether they have real-world Python experience, and how
deep, or whether they've carefully studied the appropriate areas of
Python in a Nutshell and the Cookbook (and I'm biased enough to think
that the second kind of preparation is almost as good as the first
kind...;-).

Not sure whether you think this count as tricky... they're typically
problems that do come up in the real world, from (e.g.):
for string_piece in lots_of_pieces:
bigstring += string_piece
(a typical performance-trap) to
for item in somelist:
if isbad(item):
somelist.remove(item)
(with issues of BOTH correctness and performance), to
class Sic:
def getFoo(self): ...
def setFoo(self): ...
foo = property(getFoo, setFoo)
to
class Base(object)
def getFoo(self): ...
def setFoo(self): ...
foo = property(getFoo, setFoo)

class Derived(Base):
def getFoo(self): 

and so on, and so forth.  If a candidate makes short work of a couple of
these, and I've been asked to focus my part of the interview solely on
Python coding, I may branch out into more advanced stuff such as asking
for an example use case for a closure, a custom descriptor, or an import
hook, for example -- those are the cases in which I'm trying to decide
if, on a scale of 1 to 5, the candidate's Python competence is about 4
or well over 4 (I would not consider having no idea of why one might
want to code a custom descriptor to be at all disqualifying -- it
would just mean I'd rate the candidate 4 out of five, instead of 4.5 or
more, for Python coding competence).


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


Re: how to count and extract images

2005-10-23 Thread Mike Meyer
Joe [EMAIL PROTECTED] writes:
 start = s.find('a href=somefile') + len('a
 href=somefile') 
 stop = s.find('Save File/a/B',
 start) fileName = s[start:stop]
 and then construct the url with the filename to download the image 
 which works fine as cause every image has the Save File link and I can
 count number of images easy the problem is when there is more than image I
 try using while loop downlaod files, wirks fine for the first one but
 always matches the same, how can count and thell the look to skip the fist
 one if it has been downloaded and go to next one, and if next one is
 downloaded go to next one, and so on.

To answer your question, use the first optional argument to find in both
invocations of find:

stop = 0
while end = 0:
  start = s.find('a href=somefile', stop) + len('a href=somefile')
  stop = s.find('Save File/a/B', start)
  fileName = s[start:stop]

Now, to give you some advice: don't do this by hand, use an HTML
parsing library. The code above is incredibly fragile, and will break
on any number of minor variations in the input text.  Using a real
parser not only avoids all those problems, it makes your code shorter.
I like BeautifulSoup:

soup = BeautifulSoup(s)
for anchor in soup.fetch('a'):
fileName = anchor['href']

to get all the hrefs. If you only want the ones that have Save File
in the link text, you'd do:

soup = BeautifulSoup(s)
for link in soup.fetchText('Save File'):
fileName = link.findParent('a')['href']

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


  1   2   >