Graphical Engine

2007-11-09 Thread Vlad Dogaru
Hi,

A few friends and myself were thinking of writing a graphical engine 
based on OpenGL. Does Python have the required speed for that task? Are 
there any examples out there of open-source engines which we can look 
at? A Google search yielded no interesting results, but then again I'm 
probably missing something.

Vlad
-- 
Lisp is to emacs what sex is to STDs.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using python as primary language

2007-11-09 Thread Martin Vilcans
> If by 'this' you mean the global interpreter lock, yes, there are good
> technical reasons.  All attempts so far to remove it have resulted in an
> interpeter that is substantially slower on a single processor.

Is there any good technical reason that CPython doesn't use the GIL on
single CPU systems and other locking mechanisms on multi-CPU systems?
It could be selected at startup with a switch, couldn't it?

-- 
[EMAIL PROTECTED]
http://www.librador.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating a cell 'by hand'

2007-11-09 Thread Duncan Booth
"Prepscius, Colin \(IT\)" <[EMAIL PROTECTED]> wrote:

> The last argument to new.function takes a closure, which is a tuple of
> cell objects.  Does anybody know how to create those cell objects 'by
> hand'?
> 

>>> def newcell():
def f(): cell
return f.func_closure[0]
cell = None

>>> newcell()


Hmm, looks like there's a bug here:

>>> cell.cell_contents

Traceback (most recent call last):
  File "", line 1, in 
cell.cell_contents
SystemError: error return without exception set
>>> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Graphical Engine

2007-11-09 Thread Diez B. Roggisch
Vlad Dogaru schrieb:
> Hi,
> 
> A few friends and myself were thinking of writing a graphical engine 
> based on OpenGL. Does Python have the required speed for that task? Are 
> there any examples out there of open-source engines which we can look 
> at? A Google search yielded no interesting results, but then again I'm 
> probably missing something.

Look e.g. at spyro.

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


Re: spawn background process and detach it w/o problems

2007-11-09 Thread Dmitry Teslenko
Hello!

On 08/11/2007, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Take a look at the subprocess module.

Big thanks!

It's interesting what's happening with subprocess.Popen instance after
it has been instatiated and script's main thread exits leaving
Popen'ed application open.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Duncan Booth
Scott David Daniels <[EMAIL PROTECTED]> wrote:

>> To quote a poster at 
http://www.thescripts.com/forum/thread22741.html,
>> "While we are at it, I also don't understand why sequences can't be
>> used as indices. Why not, say, l[[2,3]] or l[(2, 3)]? Why a special
>> slice concept? "  Isn't that unpythonic?
> 
> Right now, after:
> 
>  which_corner = {}
>  corner = {}
>  for n, position in enumerate([(1,1), (1,5), (3,5), (3,1)]):
>  corner[n] = position
>  which_corner[position] = n
> 
>  which_corner[1,5] returns 1
> 
> I would hate to have to know whether which_corner is a dictionary
> or a list before I can decide whether this is iteration.
> 

Quite so, tuples are currently a valid and indeed commonly used type for 
subscripts, so if there was going to be special treatment it would have 
to be for lists only and not sequences in general.

Alternatively, and more pythonically (explicit is better than implicit), 
we could have a special syntax to indicate that we want to use each 
element of the sequence as a separate subscript. I'd like to propose 
that the special syntax be:

  [s[y] for y in x]

Now someone go and fire up the time machine.

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


Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Duncan Booth
Steven D'Aprano <[EMAIL PROTECTED]> wrote:

> Besides, if you want this behaviour, you can add it yourself:
> 
> class mylist(list):
> # Untested!
> def __getitem__(self, index):
> if type(index) is list:
>  return [self[i] for i in index]
> return super(mylist, self).__getitem__(index)
> 
> list = mylist

It works very nicely, just don't try passing it a recursive list.

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


Re: Graphical Engine

2007-11-09 Thread Karlo Lozovina
Vlad Dogaru wrote:

> A few friends and myself were thinking of writing a graphical engine
> based on OpenGL. Does Python have the required speed for that task? Are
> there any examples out there of open-source engines which we can look
> at? A Google search yielded no interesting results, but then again I'm
> probably missing something.

http://www.ogre3d.org/wiki/index.php/PyOgre

-- 
Karlo Lozovina -- Mosor
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using python as primary language

2007-11-09 Thread Hrvoje Niksic
"Martin Vilcans" <[EMAIL PROTECTED]> writes:

>> If by 'this' you mean the global interpreter lock, yes, there are good
>> technical reasons.  All attempts so far to remove it have resulted in an
>> interpeter that is substantially slower on a single processor.
>
> Is there any good technical reason that CPython doesn't use the GIL
> on single CPU systems and other locking mechanisms on multi-CPU
> systems?

It's not the locking mechanism itself that is slow, what's slow is the
Python you get when you remove it.  By removing the GIL you grant
different threads concurrent access to a number of shared resources.
Removing the global lock requires protecting those shared resources
with a large number of smaller locks.  Suddenly each incref and decref
(at the C level) must acquire a lock, every dict operation must be
locked (dicts are used to implement namespaces and in many other
places), every access to a global (module) variable must be locked, a
number of optimizations that involve using global objects must be
removed, and so on.  Each of those changes would slow down Python;
combined, they grind it to a halt.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using python as primary language

2007-11-09 Thread Michel Albert
On Nov 8, 8:55 pm, [EMAIL PROTECTED] wrote:
> On Nov 8, 1:52 am, Michel Albert <[EMAIL PROTECTED]> wrote:
>
>
>
> > In our company we are looking for one language to be used as default
> > language. So far Python looks like a good choice (slacking behind
> > Java). A few requirements that the language should be able cope with
> > are:
>
> > * Database access to Sybase.
> >   This seems to be available for python, but the windows-binaries for
> > the library
> >   are not available. Self-Compiling them proved to be non-trivial (As
> > always
> >   on windows).
> > * Easy GUI creation.
> >   Solved using PyQt.
> > * Cross Platform (Linux + Windows).
> >   Again, PyQt, solves this
> > * Easy deployment.
> >   Solved using py2exe + innosetup
> > * Charting (Histograms, Line charts, bar charts, pie charts, ...)
> >   I am currently looking into PyQwt, which looks promising.
> > * Report generation with GUI support
> >   reportlab + rml?
>
> > So far, nearly all point seems to be manageable. But I was not yet
> > able to find a solution for the report generation. What we would like
> > to have is a sort of GUI interface to prepare the reports without
> > having to "code" the positioning. I found reportlab, and it looks like
> > it can do all that is needed in terms of output. But you still have to
> > code the report. And this is a no go. In context, I found RML and saw
> > links to graphical RML editors. But I have not yet found a concrete
> > example code, or documentation. What am I missing? Is RML a reportlab
> > creation or is it a recognised open standard? If not, is there an open
> > standard, that is easily to process with python?
>
> > Any pointers? I would prefer coding Python to coding Java or
> > worse. VB ;) which is another contender in our roundup.
>
> It looks like RML (Reportlab Markup Language) is a type of XML to me.
> It also appears to be a ReportLab invention. Lots of code examples can
> be found here:
>
> http://developer.reportlab.com/examples.html
>
> See also:http://www.reportlab.com/rml_index.html
>
> I'm not sure what you mean by "editing" a report. I have an
> application that allows users to enter data into a GUI and then it
> takes their data and inputs it into a ReportLab generated PDF.
>
> Mike

What I meant was that one should be able to "draw" a report template.
Basically a graphical user interface for RML in this case. I
personally would opt for writing RML or whatever code myself. But it's
impossible to convice my boss. The dialog usually goes like this:

"So, did you find a click-and-play editor for reports" - "Not yet, but
anyway, writing code is more flexible and easier to manage later on" -
"Hmmm... but it's code!" - "Sure, but you only write it once for one
report, you can easily re-use code-snippets, modifying the code does
not require one additional program, you just use your text-editor of
choice,..." - "Okay, but it's CODE!"

and this goes on forever. My boss seems to be allergic to writing code
by hand. Which is very frustrating. I'm happy that Qt has the
"designer", although it's very easy to code the GUI's too ;)

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


Modeling (Re: Pythonic ORM with support for composite primary/foreign keys?)

2007-11-09 Thread Wolfgang Keller
Hello,

thanks for the hints towards Elixir and Storm.

In fact I would have loved to use Modeling 
(http://modeling.sourceforge.net/), as it seems to fulfil all my 
requirements perfectly so far, except the one with the composite keys. 
In particular I like its proximity to EOF (R.I.P.) concerning the basic 
concepts and the notification service. I would like the notification 
service even more if it was possible to send notifications directly 
from PostgreSQL. ;-) Well, maybe that would even be possible using 
PL/Python... :-?

Modeling imho is especially well documented and at a first glance the 
sourcecode seems to be quite comprehensible even to me (unlike 
SQLAlchemy :-( ). The author has stated that composite keys were 
foreseen to be implemented and that the code was already written 
considering this feature.

So I'll maybe even try to "hack" it until it works for my schema, with 
(hopefully) some spoonfeeding by the original author. But in case my 
skills aren't enough to actually make it work, I need a fallback 
option.

Maybe someone could even convince someone else >;-> to implement a 
"plug-in" for Gaphor (or for MetaEdit) for Modeling, so that one could 
generate (and round-trip) nice "colorful and children-suitable" 
diagrams for the CXOs... >:->

TIA,

Sincerely,

Wolfgang Keller


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


How to link different site-packages to different Python?

2007-11-09 Thread Davy
Hi all,

I have Python 2.4 and 2.5 in my PC. And PythonWin is installed as IDE.

When I tried to use site-packages "Numpy", I installed the both
version (i.e. for 2.4 and 2.5).

Python 2.4 and Numpy for it work together well.

But when I type "from numpy import *" in Python 2.5. It throw out an
error indicate that the numpy library is link to Python 2.4 package?
How to fix this problem?


The error pasted below is copied from Python 2.5 PythonWin console:
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Program Files\nupic-1.4\lib\python2.4\site-packages\numpy
\__init__.py", line 39, in 
import core
  File "C:\Program Files\nupic-1.4\lib\python2.4\site-packages\numpy
\core\__init__.py", line 5, in 
import multiarray
ImportError: Module use of python24.dll conflicts with this version of
Python.

Best regards,
Davy

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


parallel csv-file processing

2007-11-09 Thread Michel Albert
Currently I am faced with a large computation tasks, which works on a
huge CSV file. As a test I am working on a very small subset which
already contains 2E6 records. The task itself allows the file to be
split however as each computation only involves one line. The
application performing the computation exists already, but it was
never meant to run on such a big dataset.

One thing that is clear, is that it will take a while to compute all
this. So a distributed approach is probably a good idea. There ar a
couple of options for this:

Scenario A ( file is split manually in smaller parts ):
1) Fire up an openmosix/kerrighed cluster, and run one process for
each file part.

Scenario B ( file is "split" using the application itself ):
2) Again with an openmosix/kerrighed cluster, but only one instance of
the application is run, using parallelpython
3) Using parallelpython without cluster, but using ppserver.py on each
node.

The second case looks most interesting as it is quite flexible. In
this case I would need to address subsets of the CSV file however. And
the default csv.reader class does not allow random-access of the file
(or jumping to a specific line).

What would be the most efficient way to subset a CSV-file. For
example:

f1 = job_server.submit(calc_scores, datafile[0:1000])
f2 = job_server.submit(calc_scores, datafile[1001:2000])
f3 = job_server.submit(calc_scores, datafile[2001:3000])
...

and so on

Obviously this won't work as you cannot access a slice of a csv-file.
Would it be possible to subclass the csv.reader class in a way that
you can somewhat efficiently access a slice? Jumping backwards is not
really necessary, so it's not really random access.

The obvious way is to do the following:

buffer = []
for line in reader:
   buffer.append(line)
   if len(buffer) == 1000:
  f = job_server.submit(calc_scores, buffer)
  buffer = []

f = job_server.submit(calc_scores, buffer)
buffer = []

but would this not kill my memory if I start loading bigger slices
into the "buffer" variable?

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


defaultdict and dict?

2007-11-09 Thread Davy
Hi all,

In Python 2.5 document, defaultdict is called high performance
container. From document, we can know defaultdict is subclass of dict.
So, why defaultdict have higher performance than dict? And at what
circumstance, we can make use of such high performance?

That is, when use defaultdict and when use dict? Any suggestions are
welcome!

Best regards,
Davy

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


Re: parallel csv-file processing

2007-11-09 Thread Paul Rubin
Michel Albert <[EMAIL PROTECTED]> writes:
> buffer = []
> for line in reader:
>buffer.append(line)
>if len(buffer) == 1000:
>   f = job_server.submit(calc_scores, buffer)
>   buffer = []
> 
> f = job_server.submit(calc_scores, buffer)
> buffer = []
> 
> but would this not kill my memory if I start loading bigger slices
> into the "buffer" variable?

Why not pass the disk offsets to the job server (untested):

   n = 1000
   for i,_ in enumerate(reader):
 if i % n == 0:
   job_server.submit(calc_scores, reader.tell(), n)

the remote process seeks to the appropriate place and processes n lines
starting from there.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: >>>> 911 operation by evil JEWS and Mossad <<<

2007-11-09 Thread Tom Potter
On Nov 8, 7:28 pm, philipp neulist <[EMAIL PROTECTED]>
wrote:
> On Nov 7, 4:08 pm, [EMAIL PROTECTED] wrote:> 911 carried out by evil jews and 
> mossadhttp://www.guba.com/watch/2000991770
>
> >911 truckload of Explosives on the George 
> >WashingtonBridgehttp://www.youtube.com/watch?v=J520P-MD9a0
>
> [...]
>
> I reported the first post in this thread (on Google groups) as abuse
> as its content is "false and defamatory". In addition to that, it has
> nothing to do with TeX.
>
> => Double reason to blaim the author!
>
> Please ignore threads like those in future and just report it!
>
> PN

Thanks for calling my attention to this Web Site philipp,

As my Pappy used to say:
"A stuck pig squeals.",

and when I see a post by a "squealing pig",
I try to find out what made him squeal,
as this saves me a lot of time in
getting to the heart of issues.

As one can view and easily download
many interesting videos from the site that one cannot find elsewhere,
I suggest that folks interested in interesting videos should visit the
site.

The following URL lists several interesting videos.

http://www.guba.com/general/search?query=israel&set=5&x=17&y=9

Thanks again philipp!

Your pal,

--
Tom Potter

http://home.earthlink.net/~tdp
http://notsocrazyideas.blogspot.com/

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


Re: defaultdict and dict?

2007-11-09 Thread Hrvoje Niksic
Davy <[EMAIL PROTECTED]> writes:

> In Python 2.5 document, defaultdict is called high performance
> container. From document, we can know defaultdict is subclass of dict.
> So, why defaultdict have higher performance than dict?

I don't think the "high performance" attribute is supposed to mean
that it has higher performanec than dict, only that it is not a
simple-minded hack on top of dict, but code carefully written in C
with performance in mind -- like dict itself.

> That is, when use defaultdict and when use dict? Any suggestions are
> welcome!

Use defaultdict when you need the dict to handle missing keys
automatically, dict in all other cases.  If in doubt, simply use dict.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Graphical Engine

2007-11-09 Thread Vlad Dogaru
Karlo Lozovina wrote:
> Vlad Dogaru wrote:
> 
>> A few friends and myself were thinking of writing a graphical engine
>> based on OpenGL. Does Python have the required speed for that task? Are
>> there any examples out there of open-source engines which we can look
>> at? A Google search yielded no interesting results, but then again I'm
>> probably missing something.
> 
> http://www.ogre3d.org/wiki/index.php/PyOgre
> 

Ogre is nice at a glance, but we are looking to write our own engine. I 
realise it's deplicating effort, but we're looking to learn.

Vlad

-- 
Lisp is to emacs what sex is to STDs.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: parallel csv-file processing

2007-11-09 Thread Marc 'BlackJack' Rintsch
On Fri, 09 Nov 2007 02:51:10 -0800, Michel Albert wrote:

> Obviously this won't work as you cannot access a slice of a csv-file.
> Would it be possible to subclass the csv.reader class in a way that
> you can somewhat efficiently access a slice?

An arbitrary slice?  I guess not as all records before must have been read
because the lines are not equally long.

> The obvious way is to do the following:
> 
> buffer = []
> for line in reader:
>buffer.append(line)
>if len(buffer) == 1000:
>   f = job_server.submit(calc_scores, buffer)
>   buffer = []

With `itertools.islice()` this can be written as:

while True:
buffer = list(itertools.islice(reader, 1000))
if not buffer:
break
f = job_server.submit(calc_scores, buffer)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] Stupid email disclaimers

2007-11-09 Thread Bruno Desthuilliers
Ben Finney a écrit :
> "Prepscius, Colin (IT)" <[EMAIL PROTECTED]> writes:
> 
(snip)
>> please destroy and notify sender.

Does that mean I should first destroy the sender ? And if so, how could 
I *then* notify her ?-)

> (Insert humour regarding different parsings of the grammar in the
> above.)
> 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: How to link different site-packages to different Python?

2007-11-09 Thread Boris Borcic
Davy wrote:
> Hi all,
> 
> I have Python 2.4 and 2.5 in my PC. And PythonWin is installed as IDE.
> 
> When I tried to use site-packages "Numpy", I installed the both
> version (i.e. for 2.4 and 2.5).
> 
> Python 2.4 and Numpy for it work together well.
> 
> But when I type "from numpy import *" in Python 2.5. It throw out an
> error indicate that the numpy library is link to Python 2.4 package?
> How to fix this problem?

Shouldn't occur if you properly installed python+pythonwin+numpy
from their respective installer once for each of python 2.4 and 2.5. You may use
the (Tools/Browse Pythonpath) and (Tools/Edit PythonPath) menu items in each of
Pythonwin 2.4 and 2.5 to sort things out. If your lazyness isn't caused by your
impatience, a possibility is to deinstall and then reinstall everything :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] Stupid email disclaimers

2007-11-09 Thread Marc 'BlackJack' Rintsch
On Fri, 09 Nov 2007 12:58:46 +0100, Bruno Desthuilliers wrote:

> Ben Finney a écrit :
>> "Prepscius, Colin (IT)" <[EMAIL PROTECTED]> writes:
>> 
> (snip)
>>> please destroy and notify sender.
> 
> Does that mean I should first destroy the sender ? And if so, how could 
> I *then* notify her ?-)

Ask a medium?  Use a crystal ball for the very long distance call?  Call
Dr. Frankenstein for help?  =:o)

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

Re: parallel csv-file processing

2007-11-09 Thread Paul Boddie
On 9 Nov, 12:02, Paul Rubin  wrote:
>
> Why not pass the disk offsets to the job server (untested):
>
>n = 1000
>for i,_ in enumerate(reader):
>  if i % n == 0:
>job_server.submit(calc_scores, reader.tell(), n)
>
> the remote process seeks to the appropriate place and processes n lines
> starting from there.

This is similar to a lot of the smarter solutions for Tim Bray's "Wide
Finder" - a problem apparently in the same domain. See here for more
details:

http://www.tbray.org/ongoing/When/200x/2007/09/20/Wide-Finder

Lots of discussion about more than just parallel processing/
programming, too.

Paul

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


Re: recording sound with python

2007-11-09 Thread Furkan Kuru
try pymedia

On Nov 9, 2007 3:57 AM, jesse j <[EMAIL PROTECTED]> wrote:

> Hello Everyone,
>
> I'm new to python.  I have worked through some tutorials and played around
> with the language a little bit but I'm stuck.
>
> I want to know how I can make python run a program.  More specifically, I
> want to get python to work with SOX to record a sound through the
> microphone, save the sound and then play the sound by typing one command
> into a linux terminal (UBUNTU).
>
> Can someone give me some hints on how this can be done?
>
> Thank You.
>
> jessej
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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

get the shape of a numpy ndarray in C++ code [boost.python]

2007-11-09 Thread Marc Oldenhof
[sorry is half a post appeared earlier. Bloody Google groups...]

Hello,

I'm trying to use a numpy array in C++ (win2000) using boost.python.

Test code:
void test( numeric::array& nsP)
{
   object shape = nsP.getshape();
   int rows = extract(shape[0]);
   int cols = extract(shape[1]);
}

At first, running it in Python got me this message:

   ArgumentError: Python argument types in
   d3d.wr_conn(numpy.ndarray)
   did not match C++ signature:
   wr_conn(class boost::python::numeric::array {lvalue})

I fixed this using this line:

   numeric::array::set_module_and_type( "numpy", "ndarray");

[was that right?]


At least it got me one step further; the array is accepted. Now the
message is this:

   AttributeError: 'numpy.ndarray' object has no attribute 'getshape'

Now I'm stumped. The only thing I can find is
   http://www.thescripts.com/forum/showthread.php?t=644270

which regrettably ends with the same question. What's wrong here?

greets,
Marc

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


email.get_filename() with newline

2007-11-09 Thread Thomas Guettler
Hi,

if I use part.get_filename() with the following email part:

--_=_NextPart_001_01C81B11.52AB8006
Content-Type: application/vnd.ms-excel;

name="=?iso-8859-1?Q?30102007=28aktualisiert=29=5FK=FCndigungen_enviaM=5FErdgas?=
=?iso-8859-1?Q?_S=FCds__GmbH=2Exls?="
Content-Disposition: attachment;

filename="=?iso-8859-1?Q?30102007=28aktualisiert=29=5FK=FCndigungen_enviaM=5FErdgas?=
=?iso-8859-1?Q?_S=FCds__GmbH=2Exls?="
Content-Description: 
=?iso-8859-1?Q?30102007=28aktualisiert=29=5FK=FCndigungen_enviaM=5FErdgas?=
=?iso-8859-1?Q?_S=FCds__GmbH=2Exls?=
Content-Transfer-Encoding: base64

0M8R4KGxGu...

I get a filename which includes a newline character and the ?iso... encoding
is not resolved. But the mail user agent "mutt" does display the filename
correct. I tried it with the latest email packages (4.0.2).

Any hints how to parse this filename?

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


Python Extension Building Network

2007-11-09 Thread kyosohma
Hi,

I am trying to get a small group of volunteers together to create
Windows binaries for any Python extension developer that needs them,
much like the package/extension builders who volunteer their time to
create Linux RPMs.

The main thing I need are people willing to test the binaries to make
sure the extension is stable. This would require installing the binary
and probably downloading the source too to get the developer's test
code. I've been able to get some of the tests to run great while
others are pretty finicky and some extensions don't come with tests.
It would be nice to know which extensions are most in need of this
too.

While I can create the binaries on my own for a while, if I get too
many requests, there will be a backlog, so it would be nice to have
help with that too. I'm also looking for knowledgeable people to be
sounding boards (i.e. give advice).

Developers: all I would require is a request, a link to the source,
and a well-written setup.py file for a cross-platform extension.

You can find the few that I've already done here:http://
www.pythonlibrary.org/python_modules.htm

I have also posted a way to create the binaries using the MinGW
compiler. I have VS2003 installed on my PC and MinGW is installed in a
VM, so I can compile the extensions both ways.

Thanks in advance for any feedback.

Mike

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


Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Frank Samuelson
Steven D'Aprano wrote:

> Why? What benefit do you gain?
> 
>> Define function objects as "function"s, let users put them where they 
>> want to.  Get rid of lambda, get rid of def, only use = for assignments.
> 
> So you remove two keywords. That's a plus. But then you have to create a 
> WHOLE lot more syntax to support it, and that's about a thousand minuses. 
> Python has very little syntax, and the designers are (rightly) very 
> resistant to adding more.

You answered your own question. There is less syntax.

> 
> It's also not clear how you expect this to work with anything more 
> complex than a single expression. How do you handle statements and 
> multiple returns?
 >
> def foo(x, y):
> L = []
> try:
> if x[y] % 2:
> print x, y
> return y
> return x[y]
> except:
> return None

Huh?  This is trivial.  I don't see why this is so hard to grasp.

foo= function(x, y):
 L = []
 try:
 if x[y] % 2:
 print x, y
 return y
 return x[y]
  except:
  return None


>>  >>> s[x]   # Simpler, clearer, more productive
> 
> It's certainly smaller.
> 
> But the fatal objection to this is that it is a special case for a very 
> limited benefit: saving half a dozen characters.

It sounds like you are describing slices here.  It is interesting
how python people don't like specific case syntax, unless it applies
to their already existing specific cases.  Lists and tuples represent
any sequence that slices can.  Why slices?

> 
> But can't you see that the suggestion to use sequences as replacements 
> for slices is completely incompatible with your suggestion above?
> 
> seq = range(10)
> 
> Would you expect seq[[2,6]] to do an index lookup, as you suggested 
> originally, or a slice? In the first case, it would return [2, 6], but in 
> the second, it would return [2, 3, 4, 5].
> 
> If sequence indices are slices, what does an index of [1, 2, 3, 4] mean?

It means whatever you decide it to mean.  Make a definition and stick with it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Closure/binding problem or misunderstanding

2007-11-09 Thread [EMAIL PROTECTED]
If I run the following code:

class path(object):
def __init__(self, **subdirs):
for name, path in subdirs.iteritems():
def getpath():
return path
setattr(self, name, getpath)

export = path(
one = 'this is one',
two = 'this is two',
)

print "invoking", export.one, export.one()
print "invoking", export.two, export.two()

I get this output:

invoking  this is one
invoking  this is one

So there apparently are two definitions of the function "getpath" (the
addresses are different, anyway), but they seem to have the same value
for the binding of "path". It's not clear to me, after reading what I
can find about python name binding, whether this is the expected
behavior, or not (although I was surprised).

Can anyone enlighten me?

Thanks,
Bob Sidebotham

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


Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Duncan Booth
Frank Samuelson <[EMAIL PROTECTED]> wrote:

>> It's also not clear how you expect this to work with anything more 
>> complex than a single expression. How do you handle statements and 
>> multiple returns?
> >
>> def foo(x, y):
>> L = []
>> try:
>> if x[y] % 2:
>> print x, y
>> return y
>> return x[y]
>> except:
>> return None
> 
> Huh?  This is trivial.  I don't see why this is so hard to grasp.
> 
> foo= function(x, y):
>  L = []
>  try:
>  if x[y] % 2:
>  print x, y
>  return y
>  return x[y]
>   except:
>   return None
> 
It is hard to grasp because you said you wanted:

name = function(*argument_list) expression

There is no colon in your proposed syntax, and you only asked for a 
single expression in the function rather than a suite. Your 'this is 
trivial' response seems to be proposing another syntax entirely.

Unfortunately my crystal ball is away being cleaned, so I am unable to 
guess whether you meant for a function definition to be an expression 
(opening up a whole host of questions about how you nest it inside other 
expressions) or a special case of an assignment to a single name and 
wanted to disallow such things as:

foo = l[3] = function(): pass

or if you didn't mean to disallow them, what name should that function 
have.

If you are going to make syntax proposals you must be precise.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Extension Building Network

2007-11-09 Thread Tim Golden
[EMAIL PROTECTED] wrote:
> Hi,
> 
> I am trying to get a small group of volunteers together to create
> Windows binaries for any Python extension developer that needs them,
> much like the package/extension builders who volunteer their time to
> create Linux RPMs.
> 
> The main thing I need are people willing to test the binaries to make
> sure the extension is stable. This would require installing the binary
> and probably downloading the source too to get the developer's test
> code. I've been able to get some of the tests to run great while
> others are pretty finicky and some extensions don't come with tests.
> It would be nice to know which extensions are most in need of this
> too.
> 
> While I can create the binaries on my own for a while, if I get too
> many requests, there will be a backlog, so it would be nice to have
> help with that too. I'm also looking for knowledgeable people to be
> sounding boards (i.e. give advice).
> 
> Developers: all I would require is a request, a link to the source,
> and a well-written setup.py file for a cross-platform extension.
> 
> You can find the few that I've already done here:http://
> www.pythonlibrary.org/python_modules.htm
> 
> I have also posted a way to create the binaries using the MinGW
> compiler. I have VS2003 installed on my PC and MinGW is installed in a
> VM, so I can compile the extensions both ways.

Mike, this is great news. Whenever I have time  I'll try to run through some of the modules
you've compiled.

As a slight aside, the main problem I've found when I've tried
to build extensions (and I've been doing it recently with AVBin and
Pyglet) is that Windows just doesn't have the build environment, the
directory structures, the env vars and all that that a ./configure or
even a python setup.py install sometimes expects. eg if I were to
offer to build a MySQL extension (as someone who doesn't use MySQL
and wouldn't have the source libs installed if I did) there would
be a fair bit of pain to go through. You've obviously gone through
that pain barrier for at least some of the extensions on the modules
page. Was it tough?

TJG

(PS SendKeys link on this page is dead: 
http://www.pythonlibrary.org/automation.htm)

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


Re: Closure/binding problem or misunderstanding

2007-11-09 Thread Paul Hankin
On Nov 9, 2:32 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> If I run the following code:
>
> class path(object):
> def __init__(self, **subdirs):
> for name, path in subdirs.iteritems():
> def getpath():
> return path
> setattr(self, name, getpath)
>
> export = path(
> one = 'this is one',
> two = 'this is two',
> )
>
> print "invoking", export.one, export.one()
> print "invoking", export.two, export.two()
>
> I get this output:
>
> invoking  this is one
> invoking  this is one
>
> So there apparently are two definitions of the function "getpath" (the
> addresses are different, anyway), but they seem to have the same value
> for the binding of "path". It's not clear to me, after reading what I
> can find about python name binding, whether this is the expected
> behavior, or not (although I was surprised).

Clearly it wasn't the expected behaviour, or you wouldn't be
surprised :)

It's behaving as defined though, and the usual work-around is to add a
variable with a default value.

class path(object):
def __init__(self, **subdirs):
for name, path in subdirs.iteritems():
def getpath(path=path):
return path
setattr(self, name, getpath)

--
Paul Hankin

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


Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Frank Samuelson
Bruno Desthuilliers wrote:

> Yes. Python deliberately choosed to be a statement-based language.
> 
>> Why not use the = operator like most other assignments?
> 
> This dead horse has been beaten to hell and back.
> 
> Note that as far as I'm concerned, I may like an expression-based 
> Python-inspired language. But this is another story.

My bad!  In my rush I forgot that python requires the return statements.
You people think I'm trying to push lisp, which I am not. (Apparently
many people do, because you are rather skittish.)
In S the value of the last executed statement of a function is the
returned value of the function by default, if there is no return() function.
It is very convenient for writing really small functions.  But skip that for 
now.

foo = function(x,y) {  # S language
 if (x>2) return(x+y*2)
 x+y
}

foo = func(x,y):  # My suggested python syntax (Improved!)
 if x>2: return x+y*2
 return x+y

# put the function object in the code wherever you want it.
bb= bar( a,b, func(x,y): x=x*2 ; b=4 ; return x*b+y )

It still is a statement language.  The statement is an explicit
assignment using the "=" like most other assignments.  "Def" and "lambda"
are silly.  Assign names to function objects names the same way
you assign them to any other object.  Call a duck a duck.

While I'm at it, classes are objects too.  Assign names to them the
same way you assign names to _any_ other object: "="

MyClass= class(inhereted):
 attributes
 functions
 whatever

x=MyClass()  # an object of the above class.



> The Pythonic way to write "more complicated yet still comprehensible 
> list comprehensions" is to not use list comprehensions.
> 
> b = []
> for x in vec1:
>   if x > 0:
> for y in vec2:
>   if y > x:
> b.append(x + y)
> 

You have just demonstrated that list comprehensions are not really
necessary at all.  So given the "one clear way of doing things",
shouldn't they be removed?  My point is that if you are going to
have them, why make some new unstructured syntax for them?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Closure/binding problem or misunderstanding

2007-11-09 Thread Boris Borcic
[EMAIL PROTECTED] wrote:
> If I run the following code:
> 
> class path(object):
> def __init__(self, **subdirs):
> for name, path in subdirs.iteritems():
> def getpath():
> return path
> setattr(self, name, getpath)
> 
> export = path(
> one = 'this is one',
> two = 'this is two',
> )
> 
> print "invoking", export.one, export.one()
> print "invoking", export.two, export.two()
> 
> I get this output:
> 
> invoking  this is one
> invoking  this is one
> 
> So there apparently are two definitions of the function "getpath" (the
> addresses are different, anyway), but they seem to have the same value
> for the binding of "path". It's not clear to me, after reading what I
> can find about python name binding, whether this is the expected
> behavior, or not (although I was surprised).
> 
> Can anyone enlighten me?

Yes this is the expected behavior. Both your getpath() functions return the 
current value of the single path variable at the time of invocation. Perhaps 
this would be the slightest bit clearer if subdir.iteritems() did not provide 
your items in swapped order (so that the returned values would be "this is 
two").

To create distinct bindings to distinct values of path at the distinct 
executions of "def getpath() :...", you should write
"def getpath(path=path) :..."

HTH, BB

> 
> Thanks,
> Bob Sidebotham
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: pyglet 1.0beta1

2007-11-09 Thread Alex Holkner
Greetings

I am pleased to announce the first public beta of pyglet, a 
cross-platform windowing and multimedia package useful for developing 
games and other visually-rich applications.

http://www.pyglet.org

pyglet is written entirely in Python, with no external requirements 
needed to develop applications for Windows XP, Mac OS X or Linux.

pyglet allows applications to open any number of top-level windows and 
draw into them using the OpenGL API.  Multiple-monitor setups are 
well-supported.

Applications using pyglet can also play sound and music samples in 
surround-sound, taking advantage of hardware acceleration where 
available.  With the addition of a single DLL based on FFmpeg, 
applications can read compressed sound and video in many formats.

pyglet is provided under the BSD open-source license, allowing you to 
use it for both commercial and other open-source projects with very 
little restriction.

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


Re: Closure/binding problem or misunderstanding

2007-11-09 Thread [EMAIL PROTECTED]
On Nov 9, 9:49 am, Paul Hankin <[EMAIL PROTECTED]> wrote:

> It's behaving as defined though, and the usual work-around is to add a
> variable with a default value.
>
> class path(object):
> def __init__(self, **subdirs):
> for name, path in subdirs.iteritems():
> def getpath(path=path):
> return path
> setattr(self, name, getpath)
>

Thanks, Paul. That's helpful. I will re-read the reference manual, and
see if I can find out where this behavior is defined. It looks like
it's binding both locals and globals, but not actually taking a
snapshot in time, as would, say Perl (I think). From an efficiency POV
this makes great sense, and I can see that you get everything you need
by essentially creating the closure yourself (by putting everything in
the local space for the function).

Bob

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


Re: Closure/binding problem or misunderstanding

2007-11-09 Thread [EMAIL PROTECTED]
On Nov 9, 9:54 am, Boris Borcic <[EMAIL PROTECTED]> wrote:

> Yes this is the expected behavior. Both your getpath() functions return the
> current value of the single path variable at the time of invocation. Perhaps
> this would be the slightest bit clearer if subdir.iteritems() did not provide
> your items in swapped order (so that the returned values would be "this is 
> two").

Yes, this helps, too. It's actually quite elegantly simple (it's just
not fully obvious (from the manual) until you completely grok the way
namespaces work).

Thanks,
Bob

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


Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Chris Mellon
On Nov 9, 2007 8:52 AM, Frank Samuelson
<[EMAIL PROTECTED]> wrote:
> Bruno Desthuilliers wrote:
>
> > Yes. Python deliberately choosed to be a statement-based language.
> >
> >> Why not use the = operator like most other assignments?
> >
> > This dead horse has been beaten to hell and back.
> >
> > Note that as far as I'm concerned, I may like an expression-based
> > Python-inspired language. But this is another story.
>
> My bad!  In my rush I forgot that python requires the return statements.
> You people think I'm trying to push lisp, which I am not. (Apparently
> many people do, because you are rather skittish.)
> In S the value of the last executed statement of a function is the
> returned value of the function by default, if there is no return() function.
> It is very convenient for writing really small functions.  But skip that for 
> now.
>
> foo = function(x,y) {  # S language
>  if (x>2) return(x+y*2)
>  x+y
> }
>
> foo = func(x,y):  # My suggested python syntax (Improved!)
>  if x>2: return x+y*2
>  return x+y
>
> # put the function object in the code wherever you want it.
> bb= bar( a,b, func(x,y): x=x*2 ; b=4 ; return x*b+y )
>
> It still is a statement language.  The statement is an explicit
> assignment using the "=" like most other assignments.  "Def" and "lambda"
> are silly.  Assign names to function objects names the same way
> you assign them to any other object.  Call a duck a duck.
>
> While I'm at it, classes are objects too.  Assign names to them the
> same way you assign names to _any_ other object: "="
>
> MyClass= class(inhereted):
>  attributes
>  functions
>  whatever
>
> x=MyClass()  # an object of the above class.
>
>
>
> > The Pythonic way to write "more complicated yet still comprehensible
> > list comprehensions" is to not use list comprehensions.
> >
> > b = []
> > for x in vec1:
> >   if x > 0:
> > for y in vec2:
> >   if y > x:
> > b.append(x + y)
> >
>
> You have just demonstrated that list comprehensions are not really
> necessary at all.  So given the "one clear way of doing things",
> shouldn't they be removed?  My point is that if you are going to
> have them, why make some new unstructured syntax for them?
>

There are at least 2 posts a month by someone who decides that they
want to re-wire Python syntax. Usually it's because of some particular
idiom they're used to in another language, in other cases it's because
they've got some particular issue with "consistency". The ideas are
*never* fully thought out or materialized, and they invariably invite
scorn from the user community. The poster is almost always a Python
beginner (I don't know if thats true in your case or not).

Arbitrary changes to syntax are never going to fly. It's a lost cause.
If you can't handle Python without your pet changes, fork it and write
your own version and let the marketplace of ideas decide if its
useful.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Carl Banks
On Nov 9, 9:52 am, Frank Samuelson
<[EMAIL PROTECTED]> wrote:
> Bruno Desthuilliers wrote:
> > Yes. Python deliberately choosed to be a statement-based language.
>
> >> Why not use the = operator like most other assignments?
>
> > This dead horse has been beaten to hell and back.
>
> > Note that as far as I'm concerned, I may like an expression-based
> > Python-inspired language. But this is another story.
>
> My bad!  In my rush I forgot that python requires the return statements.
> You people think I'm trying to push lisp, which I am not. (Apparently
> many people do, because you are rather skittish.)
> In S the value of the last executed statement of a function is the
> returned value of the function by default, if there is no return() function.
> It is very convenient for writing really small functions.  But skip that for 
> now.
>
> foo = function(x,y) {  # S language
>  if (x>2) return(x+y*2)
>  x+y
>
> }
>
> foo = func(x,y):  # My suggested python syntax (Improved!)
>  if x>2: return x+y*2
>  return x+y
>
> # put the function object in the code wherever you want it.
> bb= bar( a,b, func(x,y): x=x*2 ; b=4 ; return x*b+y )
>
> It still is a statement language.  The statement is an explicit
> assignment using the "=" like most other assignments.  "Def" and "lambda"
> are silly.  Assign names to function objects names the same way
> you assign them to any other object.  Call a duck a duck.


If you do that, then when your pure, duck-called function results in a
raised exception, your stack trace will look like this:

File "xxx.py", line yy

instead of the much more helpful

File "xxx.py", line yy, in foo

because the function will be nameless.  For me, this is more than
enough to justify a special assignment syntax for function.  (In fact,
I'd say there are at least three reasons that are good enough by
themselves, but this'll do for now.)

More generally: your proposals are not "Pythonic", and will get very
little support in the Python community, because the mentality "If it's
good for X, it's good for Y" isn't Pythonic.  Python is about a
practical balance of many concerns, and all decisions are considered
from many viewpoints.  An argument for consistency for the sake of
keeping things simple is only one of many factors considered.


Carl Banks

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


Re: Python Extension Building Network

2007-11-09 Thread kyosohma
On Nov 9, 8:36 am, Tim Golden <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > Hi,
>
> > I am trying to get a small group of volunteers together to create
> > Windows binaries for any Python extension developer that needs them,
> > much like the package/extension builders who volunteer their time to
> > create Linux RPMs.
>
> > The main thing I need are people willing to test the binaries to make
> > sure the extension is stable. This would require installing the binary
> > and probably downloading the source too to get the developer's test
> > code. I've been able to get some of the tests to run great while
> > others are pretty finicky and some extensions don't come with tests.
> > It would be nice to know which extensions are most in need of this
> > too.
>
> > While I can create the binaries on my own for a while, if I get too
> > many requests, there will be a backlog, so it would be nice to have
> > help with that too. I'm also looking for knowledgeable people to be
> > sounding boards (i.e. give advice).
>
> > Developers: all I would require is a request, a link to the source,
> > and a well-written setup.py file for a cross-platform extension.
>
> > You can find the few that I've already done here:http://
> >www.pythonlibrary.org/python_modules.htm
>
> > I have also posted a way to create the binaries using the MinGW
> > compiler. I have VS2003 installed on my PC and MinGW is installed in a
> > VM, so I can compile the extensions both ways.
>
> Mike, this is great news. Whenever I have time  means it sincerely> I'll try to run through some of the modules
> you've compiled.
>
> As a slight aside, the main problem I've found when I've tried
> to build extensions (and I've been doing it recently with AVBin and
> Pyglet) is that Windows just doesn't have the build environment, the
> directory structures, the env vars and all that that a ./configure or
> even a python setup.py install sometimes expects. eg if I were to
> offer to build a MySQL extension (as someone who doesn't use MySQL
> and wouldn't have the source libs installed if I did) there would
> be a fair bit of pain to go through. You've obviously gone through
> that pain barrier for at least some of the extensions on the modules
> page. Was it tough?

The hardest part was finding accurate information. Most people on the
user groups have been unhelpful or sarcastic. I had better luck
contacting developers directly who had already created Windows
binaries. They didn't mind giving me some pointers.

The directions for MinGW were usually only partially correct. So I
went through the two sets of directions I found (links on the site)
and mixed and matched until I got it right.

There are no directions on how to use Visual Studio 2003 that I've
found, just some old free edition. those directions were incompatible
with VS2003. I'll post VS2003's correct usage eventually, but it's
basically just installing it and then using distutils.

>
> TJG
>
> (PS SendKeys link on this page is 
> dead:http://www.pythonlibrary.org/automation.htm)

I've noticed some of the stuff I thought I uploaded seems to have gone
MIA. I'll get that fixed tonight. Thanks for the bug report and offer
of help.

Mike

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


Re: Using python as primary language

2007-11-09 Thread Martin Vilcans
On Nov 9, 2007 10:37 AM, Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
> "Martin Vilcans" <[EMAIL PROTECTED]> writes:
>
> >> If by 'this' you mean the global interpreter lock, yes, there are good
> >> technical reasons.  All attempts so far to remove it have resulted in an
> >> interpeter that is substantially slower on a single processor.
> >
> > Is there any good technical reason that CPython doesn't use the GIL
> > on single CPU systems and other locking mechanisms on multi-CPU
> > systems?
>
> It's not the locking mechanism itself that is slow, what's slow is the
> Python you get when you remove it.  By removing the GIL you grant
> different threads concurrent access to a number of shared resources.
> Removing the global lock requires protecting those shared resources
> with a large number of smaller locks.  Suddenly each incref and decref
> (at the C level) must acquire a lock, every dict operation must be
> locked (dicts are used to implement namespaces and in many other
> places), every access to a global (module) variable must be locked, a
> number of optimizations that involve using global objects must be
> removed, and so on.  Each of those changes would slow down Python;
> combined, they grind it to a halt.

But if Python gets slow when you add fine-grained locks, then most
certainly it wouldn't get so slow if the locks were very fast, right?

But that's not what my question was about. It was about whether it
would make sense to, on the same python installation, select between
the GIL and fine-grained locks at startup. Because even if the locks
slows down the interpreter, if they let you utilize a 32 core CPU, it
may not be so bad anymore. Or am I missing something?

-- 
[EMAIL PROTECTED]
http://www.librador.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Loic Mahe
Frank Samuelson a écrit :
> foo = function(x,y) x+y*2   # Example S language code
> bar = foo
> bar(3,4)
> m = lapply( s, foo )
> bb = lapply(s, function(t) t[3]*4 )

Here you want all functions to be lambda functions:

you can get something very close to what you want,
just like this:

foo = lambda x,y: x+y*2
bar = foo
bar(3,4)

you would only need to extend existing lambda:
  * support all python keywords/expressions in lambda
  * multiline lambda
  * multi return value lambda
  * and possibility to map 'function' name to be equivalent to 'lambda'


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


[no subject]

2007-11-09 Thread gregory . miller

I will be out of the office starting  11/09/2007 and will not return until
11/12/2007.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Looking for a good Python environment

2007-11-09 Thread Fabio Zadrozny
On 07 Nov 2007 08:50:49 -0800, Paul Rubin <"http://phr.cx"@nospam.invalid>
wrote:

> "Colin J. Williams" <[EMAIL PROTECTED]> writes:
> > Could you elaborate on "lightweight" please? I find PyScripter to be a
> > powerful editor/debugger combination.
> >
> > What functionality does Eclipse have that PyScripter does not?
>
> While we're at it, do any of these debuggers implement a good way to
> debug multi-threaded Python programs?
>

Pydev handles multi-threaded debugging.

Cheers,

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

Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Chris M


Multi-return value lambda? Just so you know, there is no concept of
returning more than one value from a function.

def a(): return 1, 2

returns one value - a tuple of (1, 2).

lambda: (1, 2)

does the same thing.

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


Re: Python Extension Building Network

2007-11-09 Thread Tim Golden
[EMAIL PROTECTED] wrote:
> The hardest part was finding accurate information. Most people on the
> user groups have been unhelpful or sarcastic. 

That's a shame to hear. Because you were building on Windows?
Or for some other reason? (I ask because, even here on the
Python lists, reactions like "Get a working O/S" are not unknown
in answer to questions like "How do I... on Windows?")

> The directions for MinGW were usually only partially correct. 

The gripe I've had MingW -- which is obviously tempered by the
fact of its existence and the huge amount of effort which has
gone into it -- is the difficulty of finding a version of all
the tools which pleases everyone. And/or of knowing whether it's
safe to mix "Stable", "Candidate" etc. release packages.

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


Re: Using python as primary language

2007-11-09 Thread Chris Mellon
On Nov 9, 2007 9:54 AM, Martin Vilcans <[EMAIL PROTECTED]> wrote:
>
> On Nov 9, 2007 10:37 AM, Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
> > "Martin Vilcans" <[EMAIL PROTECTED]> writes:
> >
> > >> If by 'this' you mean the global interpreter lock, yes, there are good
> > >> technical reasons.  All attempts so far to remove it have resulted in an
> > >> interpeter that is substantially slower on a single processor.
> > >
> > > Is there any good technical reason that CPython doesn't use the GIL
> > > on single CPU systems and other locking mechanisms on multi-CPU
> > > systems?
> >
> > It's not the locking mechanism itself that is slow, what's slow is the
> > Python you get when you remove it.  By removing the GIL you grant
> > different threads concurrent access to a number of shared resources.
> > Removing the global lock requires protecting those shared resources
> > with a large number of smaller locks.  Suddenly each incref and decref
> > (at the C level) must acquire a lock, every dict operation must be
> > locked (dicts are used to implement namespaces and in many other
> > places), every access to a global (module) variable must be locked, a
> > number of optimizations that involve using global objects must be
> > removed, and so on.  Each of those changes would slow down Python;
> > combined, they grind it to a halt.
>
> But if Python gets slow when you add fine-grained locks, then most
> certainly it wouldn't get so slow if the locks were very fast, right?
>
> But that's not what my question was about. It was about whether it
> would make sense to, on the same python installation, select between
> the GIL and fine-grained locks at startup. Because even if the locks
> slows down the interpreter, if they let you utilize a 32 core CPU, it
> may not be so bad anymore. Or am I missing something?
>

The performance overhead of a runtime swap between fine-grained locks
and the GIL would probably swamp any benefit you gained from having it
be switchable. A compile time switch is more reasonable, but it has
all the other problems of going fine-grained in the first place (it
breaks compatibility with existing extensions, large code size
increase, increased maintenance burden) and it adds the additional
problem that one or other of the modes won't be as heavily tested
(this will start out as the fine-grained mode, of course, which is the
worst case because it's the more complicated and subtly error prone
one). It's really best in the long term to pick one and stick with it.

The heavy use of dicts is one of the problems - they're all over the
place and even if you removed the GIL, a "global dict lock" would give
essentially the same effect. And a per-dict lock means that there will
be a *lot* more locking and unlocking, which means a slower
interpreter.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Expanding the size of wx Frame

2007-11-09 Thread kyosohma
On Nov 8, 11:02 pm, sundarvenkata <[EMAIL PROTECTED]> wrote:
> hello all, is there a way to make wxpython frame to expand itself
>as we add controls to it

Yes. I recommend using sizers. Then you can have the frame fit the
widgets it holds using the Fit() command. I think this only applies
when you first create the frame. After that the usual way is to call
Layout() or Refresh() on the parent of the widgets (the frame in this
case).

I've done something like this before when I've changed elements in my
panel:

self.SetClientSize(self.panel.GetBestSize())

You might also find the wx.CollapsiblePane valuable.

Mike

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


Re: Python Extension Building Network

2007-11-09 Thread kyosohma
On Nov 9, 10:02 am, Tim Golden <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > The hardest part was finding accurate information. Most people on the
> > user groups have been unhelpful or sarcastic.
>
> That's a shame to hear. Because you were building on Windows?
> Or for some other reason? (I ask because, even here on the
> Python lists, reactions like "Get a working O/S" are not unknown
> in answer to questions like "How do I... on Windows?")

I don't think it was because of Windows, but because I was asking
about how to use Visual Studio. I've had classes in it, but intro
classes in Comp Sci don't teach you how to compile. One of the people
on this list told me to go read Microsoft's docs.

Well, those docs are uniformly unhelpful until you actually know what
you're doing. And they were useless since the actual way to use the
compiler was to use the python command:

python setup.py bdist_wininst

Which of course won't be found in any docs produced from the venerable
Microsoft.

>
> > The directions for MinGW were usually only partially correct.
>
> The gripe I've had MingW -- which is obviously tempered by the
> fact of its existence and the huge amount of effort which has
> gone into it -- is the difficulty of finding a version of all
> the tools which pleases everyone. And/or of knowing whether it's
> safe to mix "Stable", "Candidate" etc. release packages.
>
> TJG

I used Candidate. At some point, I'll have to try uninstalling MinGW
and try Stable. Mixing them sounds interesting too.

I'm no expert in either one yet, but I hope to be soon.

Mike

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


Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Frank Samuelson

So you like my ideas too!

> 
> There are at least 2 posts a month by someone who decides that they
> want to re-wire Python syntax. Usually it's because of some particular
> idiom they're used to in another language, 

And python does not use idioms from other languages?

> in other cases it's because
> they've got some particular issue with "consistency". 

My impression was that "consistency" was important to Python.
"Consistency" improves my productivity because I don't have to
keep referring to the manual.  Things work the way I expect them
to work.

> The ideas are
> *never* fully thought out or materialized, and they invariably invite
> scorn from the user community. 

Of course, they're thought out:  They're stolen from another language.
Specifically, the language in which I am most productive.

> The poster is almost always a Python
> beginner (I don't know if thats true in your case or not).

Only a couple years at it, but that is true of all of the languages
that  I know, I guess...

> 
> Arbitrary changes to syntax are never going to fly. It's a lost cause.

The changes are not arbitrary.  They are logical, consistent, less
arbitrary and thus more productive.  If such
changes are a lost cause, that is too bad, because
it implies that Python will stagnate.  Unfortunately that appears the case.
Though backward compatibility is not an issue (3.0 breaks stuff), I have
learned that there are many pythonistas who make up lots of arbitrary
reasons not to change anything, even if it is for the better.

> If you can't handle Python without your pet changes, fork it and write
> your own version and let the marketplace of ideas decide if its
> useful.

Apparently you missed my statement about loving Python.  I love it
because it is the second most productive language I have ever used,
though I do believe it has the potential to be the greatest ever by
far.




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


PyCon 2008 - Call for Tutorials

2007-11-09 Thread Greg Lindstrom
Still thinking of presenting a tutorial at PyCon 2008 in Chicago?  "Tutorial
Day" is March 13th offering 1/2 day classes on just about any topic Python.
It's a great way to help others in the community learn more about Python and
you get paid ($1000.00 cash money + conference registration; not a bad
gig!).  We have a number of proposals already but want more ideas.  The more
topics we can offer the better the conference will be for everyone.

   - Testing
   - "Intermediate" Python
   - Working with Databases
   - Documentation
   - Object Oriented Python
   - Web Development
   - Anything Else (just about)

Anything is up for consideration.  Pop on over to
http://us.pycon.org/2008/tutorials/proposals/  for more information or
submit your idea to [EMAIL PROTECTED]

Thanks!

Greg Lindstrom
Tutorial Coordinator, PyCon 2008 (Chicago)
-- 
http://mail.python.org/mailman/listinfo/python-list

Games on ps2

2007-11-09 Thread Charles Tunley
Hi I need a list of games on ps2 and I'm in the united states, oklahoma
<*Charli jo*>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using python as primary language

2007-11-09 Thread kyosohma
On Nov 9, 4:32 am, Michel Albert <[EMAIL PROTECTED]> wrote:
> On Nov 8, 8:55 pm, [EMAIL PROTECTED] wrote:
>
>
>
> > On Nov 8, 1:52 am, Michel Albert <[EMAIL PROTECTED]> wrote:
>
> > > In our company we are looking for one language to be used as default
> > > language. So far Python looks like a good choice (slacking behind
> > > Java). A few requirements that the language should be able cope with
> > > are:
>
> > > * Database access to Sybase.
> > >   This seems to be available for python, but the windows-binaries for
> > > the library
> > >   are not available. Self-Compiling them proved to be non-trivial (As
> > > always
> > >   on windows).
> > > * Easy GUI creation.
> > >   Solved using PyQt.
> > > * Cross Platform (Linux + Windows).
> > >   Again, PyQt, solves this
> > > * Easy deployment.
> > >   Solved using py2exe + innosetup
> > > * Charting (Histograms, Line charts, bar charts, pie charts, ...)
> > >   I am currently looking into PyQwt, which looks promising.
> > > * Report generation with GUI support
> > >   reportlab + rml?
>
> > > So far, nearly all point seems to be manageable. But I was not yet
> > > able to find a solution for the report generation. What we would like
> > > to have is a sort of GUI interface to prepare the reports without
> > > having to "code" the positioning. I found reportlab, and it looks like
> > > it can do all that is needed in terms of output. But you still have to
> > > code the report. And this is a no go. In context, I found RML and saw
> > > links to graphical RML editors. But I have not yet found a concrete
> > > example code, or documentation. What am I missing? Is RML a reportlab
> > > creation or is it a recognised open standard? If not, is there an open
> > > standard, that is easily to process with python?
>
> > > Any pointers? I would prefer coding Python to coding Java or
> > > worse. VB ;) which is another contender in our roundup.
>
> > It looks like RML (Reportlab Markup Language) is a type of XML to me.
> > It also appears to be a ReportLab invention. Lots of code examples can
> > be found here:
>
> >http://developer.reportlab.com/examples.html
>
> > See also:http://www.reportlab.com/rml_index.html
>
> > I'm not sure what you mean by "editing" a report. I have an
> > application that allows users to enter data into a GUI and then it
> > takes their data and inputs it into a ReportLab generated PDF.
>
> > Mike
>
> What I meant was that one should be able to "draw" a report template.
> Basically a graphical user interface for RML in this case. I
> personally would opt for writing RML or whatever code myself. But it's
> impossible to convice my boss. The dialog usually goes like this:
>
> "So, did you find a click-and-play editor for reports" - "Not yet, but
> anyway, writing code is more flexible and easier to manage later on" -
> "Hmmm... but it's code!" - "Sure, but you only write it once for one
> report, you can easily re-use code-snippets, modifying the code does
> not require one additional program, you just use your text-editor of
> choice,..." - "Okay, but it's CODE!"
>
> and this goes on forever. My boss seems to be allergic to writing code
> by hand. Which is very frustrating. I'm happy that Qt has the
> "designer", although it's very easy to code the GUI's too ;)

wxPython has multiple "designers", like Boa and SPE...but as for a way
to "draw a report", I think you're stuck with something like VBA in an
Office application or the "holy grail" of report generators, Crystal
Reports. Personally speaking, I find Crystal to be more difficult to
use than coding it myself. To each their own, I suppose.

Mike

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


Re: Games on ps2

2007-11-09 Thread kyosohma
On Nov 9, 11:03 am, Charles Tunley <[EMAIL PROTECTED]> wrote:
> Hi I need a list of games on ps2 and I'm in the united states, oklahoma
> <*Charli jo*>

Then you shouldn't post to a programming user's group. Try sony.com or
http://www.playstation.com/

Mike

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


Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Marc 'BlackJack' Rintsch
On Fri, 09 Nov 2007 11:41:24 -0500, Frank Samuelson wrote:

>> There are at least 2 posts a month by someone who decides that they
>> want to re-wire Python syntax. Usually it's because of some particular
>> idiom they're used to in another language, 
> 
> And python does not use idioms from other languages?

It does.  So what?  Does that mean any idiom from any other language makes
sense in Python?

>> in other cases it's because they've got some particular issue with
>> "consistency".
> 
> My impression was that "consistency" was important to Python.

It is but to quote a headline from the Python style guide: `A Foolish
Consistency is the Hobgoblin of Little Minds`.

> "Consistency" improves my productivity because I don't have to keep
> referring to the manual.  Things work the way I expect them to work.

I expect meaningful function names in tracebacks.

>> The ideas are *never* fully thought out or materialized, and they
>> invariably invite scorn from the user community.
> 
> Of course, they're thought out:  They're stolen from another language.
> Specifically, the language in which I am most productive.

They are not thought out.  You just ripped an aspect from that other
language and threw it into a Python environment.  This doesn't mean it
will fit into the language or scales beyond the small toy examples.  What
about function names in tracebacks?  What about nesting these anonymous
multiline functions?  What about the impact on the grammar?

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


Re: Using python as primary language

2007-11-09 Thread Rhamphoryncus
On Nov 9, 9:14 am, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
> The heavy use of dicts is one of the problems - they're all over the
> place and even if you removed the GIL, a "global dict lock" would give
> essentially the same effect. And a per-dict lock means that there will
> be a *lot* more locking and unlocking, which means a slower
> interpreter.

It's worse than that.  Not only are they slower for a single thread,
but when using multiple threads the cores will contend over the cache
lines containing the locks, leaving you yet slower still!

I've starting putting together a site explaining my approach to
solving these problems:

http://code.google.com/p/python-safethread/


--
Adam Olsen, aka Rhamphoryncus

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


Re: Python good for data mining?

2007-11-09 Thread Francesc
[I've just seen this thread.  Although it might be a bit late, let me
state a couple of precisions]

On 6 Nov, 03:09, "D.Hering" <[EMAIL PROTECTED]> wrote:
> On Nov 5, 10:29 am, Maarten <[EMAIL PROTECTED]> wrote:
>
> > As forpytables: it is the most elegant programming interface for HDF
> > on any platform that I've encountered so far. Most other platforms
> > stay close the HDF5 library C-interface, which is low-level, and quite
> > complex.PyTableswas written with the end-user in mind, and it shows.
> > One correction though:PyTablesis not a database: it is a storage for
> > (large) arrays, datablocks that you don't want in a database. Use a
> > database for the metadata to find the right file and field within that
> > file. Keep in mind though that I mostly work with externally created
> > HDF-5 files, not with files created inpytables.PyTablesPro has an
> > indexing feature which may be helpful for datamining (if you write the
> > hdf-5 files from python).
>
> > Maarten
>
> Hi Maarten,
>
> I respectfully disagree that HDF5 is not a DB. Its true that HDF5 on
> its prima facie is not relational but rather hierarchical.

Yeah.  This largely depends on what we understand by a DB.  Lately,
RDBMs are used everywhere, and we tend to believe that they are the
only entities that can be truly called DBs.  However, in a less
restrictive view, even a text file can be considered a DB (in fact,
many DBs have been implemented using text files as a base).  So, I
wouldn't say that HDF5 is not a DB, but just that it is not a RDBM ;)

> Hierarchical is truely a much more natural/elegant[1] design from my
> perspective. HDF has always had meta-data capabilities and with the
> new 1.8beta version available, it is increasing its ability with
> 'references/links' allowing for pure/partial relational datasets,
> groups, and files as well as storing self implemented indexing.
>
> The C API is obviously much more low level, and Pytables does not yet
> support these new features.

That's correct.  And although it is well possible that we, PyTables
developers, would end incorporating some relational features to it, we
also recognize that PyTables does not intend (and was never in our
plans) to be a competitor of a pure RDBMS, but rather a *teammate* (as
it is clearly stated in the www.pytables.org home page).

In our opinion, PyTables opens the door to a series of capabilities
that are not found in typical RDBMS, like hierarchical classification,
multidimensional datasets, powerful table entities that are able to
deal with multidimensional columns or nested records, but must
specially, the ability to work with extremely large amounts of data in
a very easy way, without having to renounce to first-class speed.

> [1] Anything/everything that is physical/virtual, or can be conceived
> is hierarchical... if the system itself is not random/chaotic. Thats a
> lovely revelation I've had... EVERYTHING is hierarchical. If it has
> context it has hierarchy.

While I agree that this sentence has a part of truth, it is also known
that a lot of things (perhaps much more than we think) in the universe
enter directly in the domain of random/chaotic ;)

IMO, the wisest path should be recognizing the strengths (and
weaknesses) of each approach and use whatever fits better to your
needs.  If you need the best of both then go ahead and choose a RDBMS
in combination with a hierarchical DB, and utilize the powerful
capabilities of Python to take the most out of them.

Cheers,

Francesc Altet

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


Re: Using python as primary language

2007-11-09 Thread Boris Borcic
Michel Albert wrote:
> 
> What I meant was that one should be able to "draw" a report template.
> Basically a graphical user interface for RML in this case. I
> personally would opt for writing RML or whatever code myself. But it's
> impossible to convice my boss. The dialog usually goes like this:
> 
> "So, did you find a click-and-play editor for reports" - "Not yet, but
> anyway, writing code is more flexible and easier to manage later on" -
> "Hmmm... but it's code!" - "Sure, but you only write it once for one
> report, you can easily re-use code-snippets, modifying the code does
> not require one additional program, you just use your text-editor of
> choice,..." - "Okay, but it's CODE!"
> 
> and this goes on forever. My boss seems to be allergic to writing code
> by hand. Which is very frustrating. I'm happy that Qt has the
> "designer", although it's very easy to code the GUI's too ;)
> 

Probably worth pointing out that a click-and-point editor for reports can't be 
both fully mimetic (as a GUI designer may be) and practical.

FWIW OpenOffice 2.3 added something of the sort. The kind of tools I'd expect 
to 
lead me to roadblocks. Now OpenOffice *does* allow scripting with python; but 
the couple times I looked into it, the specs&docs on the scripting interface 
scared me completly.

Good luck, BB



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


Re: Python Extension Building Network

2007-11-09 Thread John Nagle
[EMAIL PROTECTED] wrote:
> Hi,
> 
> I am trying to get a small group of volunteers together to create
> Windows binaries for any Python extension developer that needs them,
> much like the package/extension builders who volunteer their time to
> create Linux RPMs.

 Really good idea.

 Can you get some corporate support?  It would be good to have
some organization behind this.  Binaries are a security issue;
you need an organization or a reputation to distribute binaries.

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


Re: Games on ps2

2007-11-09 Thread Diez B. Roggisch
Charles Tunley schrieb:
> Hi I need a list of games on ps2 and I'm in the united states, oklahoma
> <*Charli jo*>

I'm deeply sorry, we don't post lists of PS2 Games to people from 
Oklahoma. If you lived in Texas though... then I'm positive I could send 
you a comprehensive list of PS2 games, together with some nice videos of 
the still-secret PSX, successor of the PS3

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


Re: Python Extension Building Network

2007-11-09 Thread kyosohma
On Nov 9, 12:24 pm, John Nagle <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > Hi,
>
> > I am trying to get a small group of volunteers together to create
> > Windows binaries for any Python extension developer that needs them,
> > much like the package/extension builders who volunteer their time to
> > create Linux RPMs.
>
>  Really good idea.
>
>  Can you get some corporate support?  It would be good to have
> some organization behind this.  Binaries are a security issue;
> you need an organization or a reputation to distribute binaries.
>
> John Nagle

Right now all I have is Steve Holden's backing (and now Golden's too).
If you have some suggestions beyond Python luminaries, let me know.

Mike

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


Re: Python Extension Building Network

2007-11-09 Thread kyosohma
On Nov 9, 12:24 pm, John Nagle <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > Hi,
>
> > I am trying to get a small group of volunteers together to create
> > Windows binaries for any Python extension developer that needs them,
> > much like the package/extension builders who volunteer their time to
> > create Linux RPMs.
>
>  Really good idea.
>
>  Can you get some corporate support?  It would be good to have
> some organization behind this.  Binaries are a security issue;
> you need an organization or a reputation to distribute binaries.
>
> John Nagle

I forgot to ask, but what would that look like? Some kind of message
like "these binaries are backed by the Blah Blah Organization" ? I
can't get a reputation until I start doing it...

Mike

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


Global variables within classes.

2007-11-09 Thread Donn Ingle
Hi,
I'm getting myself really confused. I have three classes. Two of them need
to reference the third, like so:

Canvas ---> Stack <--- Thing

I am doing this right now:

s = Stack()

And then within  I am referring directly to the global
variable 's' (and again from Thing).

Now, this works, but it bugs me somewhat. I don't want to limit a user to
having to declare a global variable of a particular name.
They should be able to say 

This may also leads to more confusion because the user can also make Things
directly  and I want the new things to all reference the
*same* Stack. (Right now it works because I reference 's' within Thing.)

I thought this might be a case for multiple inheritance but I just keep
getting recursion errors as one thing refers to another in a big mess.

Does that makes sense?

\d

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


Re: Global variables within classes.

2007-11-09 Thread Bruno Desthuilliers
Donn Ingle a écrit :
> Hi,
> I'm getting myself really confused. I have three classes. Two of them need
> to reference the third, like so:
> 
> Canvas ---> Stack <--- Thing
> 
> I am doing this right now:
> 
> s = Stack()
> 
> And then within  I am referring directly to the global
> variable 's' (and again from Thing).
>
> Now, this works, but it bugs me somewhat.

Indeed...

> I don't want to limit a user to
> having to declare a global variable of a particular name.
> They should be able to say 
> 
> This may also leads to more confusion because the user can also make Things
> directly  and I want the new things to all reference the
> *same* Stack. (Right now it works because I reference 's' within Thing.)

> I thought this might be a case for multiple inheritance

???

> but I just keep
> getting recursion errors as one thing refers to another in a big mess.
> 
> Does that makes sense?

wrt/ all Thing instances having to refer to a same Stack instance, 
there's a pretty obvious answer: make the Stack instance an attribute of 
class Thing, ie:

class Thing(object):
   stack = Stack()

   def some_method(self, val):
  self.stack.push(val)
   # etc...

This way you can access this stack from the Thing class directly, as 
well as from any instance, subclass and subclass instance of.

Now the point that isn't clear is the exact relationship between Stack 
and Canvas. You didn't give enough details for any answer, advice or 
hint to make sens.

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


Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Frank Samuelson
Carl Banks wrote:

>> "Consistency" improves my productivity because I don't have to keep
>> referring to the manual.  Things work the way I expect them to work.
> 
> Really, should we be taking suggestions from someone who needs a manual 
> to recall the syntax of the def statement?
> 
> What you say is correct in principle, but it's senseless to apply it to 
> something you use every day, like def.  It's like arguing that irregular 
> verbs make speech less productive.

They do for people who speak foreign languages.  It's always easier
for me to remember Spanish verbs that conjugate regularly.   And based
on the speaking snafus of my French coworker, I would say that it is
true for her English too!

Likewise, consistency helps me remember the syntax of the
seven or so programming languages that I use regularly.


>> Unfortunately that appears the case. Though backward compatibility is
>> not an issue (3.0 breaks stuff), I have learned that there are many
>> pythonistas who make up lots of arbitrary reasons not to change
>> anything, even if it is for the better.
> 
> I'm getting the feeling that to you, "arbitrary" is an synonym for 
> "something not pure enough for my personal taste".
> 

That was the point that I was trying to make to the previous poster,
who called my suggestions "arbitrary",
but who never actually addressed the suggestions.


> The "defects in productivity" 
> in Python aren't going to be "fixed", 

That doesn't sound very promising, though I'm not sure whom you are
quoting.


> 
> Carl Banks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Terry Reedy

"Frank Samuelson" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]


| My impression was that "consistency" was important to Python.

Important, but not over-riding of all else.

| "Consistency" improves my productivity because I don't have to
| keep referring to the manual.  Things work the way I expect them
| to work.

Different people have different expectations.  I noticed soon after 
learning Python that def, class, and import statements are alternate and 
special forms of name-binding statements.  Some forms of import can be done 
(more awkwardly) as = assignment with the __import__ function.  Indeed, if 
the name of the file to import is not known until runtime (as a string), 
then the import must be so done.  But I never expected function definition 
to done that way.  Perhaps this is because it is special cased in the 
previous languages I have used, from Fortran to C.

To me, complete consistency would demand a syntax like

name = func('name', ('param1', ), '''

''')

While anonymous data objects are fine, anonymous code is not.

| Though backward compatibility is not an issue (3.0 breaks stuff),

While there will be minor breakage, backward compatibility was most 
definitely an issue in the design of Python 3 (not pretty well done as far 
as syntax goes).

PS.  If you did not want the hostility you perceive, then I think your 
title was a mistake.  Calling your proposals 'pythonic' invites 
disagreement and distracts from discussion of their merits.

Terry Jan Reedy





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


Re: Using python as primary language

2007-11-09 Thread Terry Reedy

"Martin Vilcans" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
| But that's not what my question was about. It was about whether it
| would make sense to, on the same python installation, select between
| the GIL and fine-grained locks at startup. Because even if the locks
| slows down the interpreter, if they let you utilize a 32 core CPU, it
| may not be so bad anymore. Or am I missing something?

1. The need for some group to develop and maintain what anounts to a forked 
version of CPython.

2. If micro-locked Python ran, say, half as fast, then you can have a lot 
of IPC (interprocess communition) overhead and still be faster with 
multiple processes rather than multiple threads. 



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


Codec lookup fails for bad codec name, blowing up BeautifulSoup

2007-11-09 Thread John Nagle
   I just had our web page parser fail on "www.nasa.gov".
It seems that NASA returns an HTTP header with a charset of ".utf8", which
is non-standard.  This goes into BeautifulSoup, which blows up trying to
find a suitable codec.

   This happens because BeautifulSoup does this:

  def _codec(self, charset):
 if not charset: return charset
 codec = None
 try:
 codecs.lookup(charset)
 codec = charset
 except LookupError:
 pass
 return codec

The documentation for codecs.lookup says:

lookup(encoding)
Looks up a codec tuple in the Python codec registry and returns
the function tuple as defined above.

Encodings are first looked up in the registry's cache. If not found,
the list of registered search functions is scanned.
If no codecs tuple is found, a LookupError is raised.

So BeautifulSoup's lookup ought to be safe, right?  Wrong.
What actually happens is a ValueError exception:

File "./sitetruth/BeautifulSoup.py", line 1770, in _codec
codecs.lookup(charset)
File "/usr/local/lib/python2.5/encodings/__init__.py", line 97,
in search_function
globals(), locals(), _import_tail)
ValueError: Empty module name

This is a known bug. It's in the old tracker on SourceForge:
[ python-Bugs-960874 ] codecs.lookup can raise exceptions other
than LookupError
but not in the new tracker.

The "resolution" back in 2004 was "Won't Fix", without a change
to the documentation.  Grrr.

Patched BeautifulSoup to work around the problem:

 def _codec(self, charset):
 if not charset: return charset
 codec = None
 try:
 codecs.lookup(charset)
 codec = charset
 except (LookupError, ValueError):
 pass
 return codec


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


Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Cliff Wells
On Thu, 2007-11-08 at 15:00 -0500, Frank Samuelson wrote:
> I love Python, and it is one of my 2 favorite
> languages.  I would suggest that Python steal some
> aspects of the S language.

In general, I agree that Python has some antiquated concepts at its core
(statements being a major one) and that some of these things make the
language inconsistent and introduce additional syntax.
  
However, despite the apparent close-mindedness of some of the
respondents (it doesn't look like current Python syntax, hence it's
"ugly"), I also agree with them to a degree: changing Python at this
level would mean it would no longer be Python, it would be some other
language.  What you are basically asking is that GvR abandon Python
(like ABC before it) and start on a "next generation" language.  That's
quite a request.  I'm not saying it's a bad request, simply that you
should recognize the scale of request you are making.

On a more practical level, you might take a look at Boo.  It's
intentionally Python-like in appearance, yet lifts several key
limitations (and is probably far more open to suggestions at this early
stage in its life).  Unfortunately it's nowhere near Python in
completeness (notably documentation, size of community and overall
maturity) and, for better or worse, it runs on .NET/Mono.  

Regards,
Cliff



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


Re: Binary search tree

2007-11-09 Thread Larry Bates
[EMAIL PROTECTED] wrote:
> Hi,
> 
> I have to get list of URLs one by one and to find the URLs that I have
> more than one time(can't be more than twice).
> 
> I thought to put them into binary search tree, this way they'll be
> sorted and I'll be able to check if the URL already exist.
> 
> Couldn't find any python library that implements trees.
> Is there some library of this kind in python? Or can I find it
> somewhere else?
> 
Put them into a set.  You can check for existence (very fast) and at the end it 
is easy to sort.

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


Re: Binary search tree

2007-11-09 Thread Neil Cerutti
On 2007-11-09, Larry Bates <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
>> I have to get list of URLs one by one and to find the URLs
>> that I have more than one time(can't be more than twice).
>> 
>> I thought to put them into binary search tree, this way
>> they'll be sorted and I'll be able to check if the URL already
>> exist.
>> 
>> Couldn't find any python library that implements trees. Is
>> there some library of this kind in python? Or can I find it
>> somewhere else?
>
> Put them into a set.  You can check for existence (very fast)
> and at the end it is easy to sort.

The set is likely the way to go.

Python's library support for binary search trees consists of the
bisect module.

-- 
Neil Cerutti
Ask about our plans for owning your home --sign at mortgage company
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Binary search tree

2007-11-09 Thread Jake McKnight
What if someone wants to implement, say, Huffman compression?  That requires
a binary tree and the ability to traverse the tree.  I've been looking for
some sort of binary tree library as well, and I haven't had any luck.

On 11/9/07, Larry Bates <[EMAIL PROTECTED]> wrote:
>
> [EMAIL PROTECTED] wrote:
> > Hi,
> >
> > I have to get list of URLs one by one and to find the URLs that I have
> > more than one time(can't be more than twice).
> >
> > I thought to put them into binary search tree, this way they'll be
> > sorted and I'll be able to check if the URL already exist.
> >
> > Couldn't find any python library that implements trees.
> > Is there some library of this kind in python? Or can I find it
> > somewhere else?
> >
> Put them into a set.  You can check for existence (very fast) and at the
> end it
> is easy to sort.
>
> -Larry
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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

Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Bruno Desthuilliers
Frank Samuelson a écrit :
> Bruno Desthuilliers wrote:
> 
>> Yes. Python deliberately choosed to be a statement-based language.
>>
>>> Why not use the = operator like most other assignments?
>>
>>
>> This dead horse has been beaten to hell and back.
>>
>> Note that as far as I'm concerned, I may like an expression-based 
>> Python-inspired language. But this is another story.
> 
> 
> My bad!  In my rush I forgot that python requires the return statements.
> You people think I'm trying to push lisp, which I am not.

Did I mention Lisp ??? No need to go lispish for this - Javascript 
already does what you want here. FWIW, I was somewhat thinking out loud, 
and I guess I thought of Javascript's use of anonymous functions, then 
switched to Ruby (and it's code blocks), which took me to 
expression-based languages. That's all.

> (Apparently
> many people do, because you are rather skittish.)

I don't get the point here.

> In S the value of the last executed statement of a function is the
> returned value of the function by default,

Which is what expression-based languages usually do - cf Ruby and most 
functional languages.

> if there is no return() 
> function.

Actually, in most languages, it's a statement !-)

> It is very convenient for writing really small functions.

For really small functions, Python has lambda - which actually work that 
way.

>  But skip that 
> for now.
> 
> foo = function(x,y) {  # S language
> if (x>2) return(x+y*2)
> x+y
> }
> 
> foo = func(x,y):  # My suggested python syntax (Improved!)
> if x>2: return x+y*2
> return x+y


> # put the function object in the code wherever you want it.
> bb= bar( a,b, func(x,y): x=x*2 ; b=4 ; return x*b+y )

bb = bar(a, b, func(x,y):
   for x in y:
 if x > 10:
   do_something_with(x)
 return y[-1] * 42

ho, wait, I have a couple keyword args to pass to bar too... How should 
I do ? add a comma after the return statement ???

Franck, believe us, *this has been beaten to hell and back*. The point 
is not that full anonymous functions are a bad thing (I personally use 
them a lot in Javascript), but that it just doesn't fit within Python, 
and that the necessary modifications would yield a mostly different 
language. Perhaps a pretty good one, but not Python anymore. You see, I 
don't necessarily share all Python's design choices, and I'm well aware 
of some restrictions they impose. But day in, day out, it happens that 
these choices are mostly coherent, and that the resulting language 
offers a (IMHO) great balance between simplicity and power. 
Non-programmers can (and do) use it, C programmers can (and do) use it, 
Java programmers can (and do) use it, Lisp programmers can (and do) use 
it, etc, etc, etc.

> While I'm at it, classes are objects too.  Assign names to them the
> same way you assign names to _any_ other object: "="

Same problem. Note that in both cases, you already *can* build functions 
and classes that way - as you say, they are objects, and both the def 
and class statements are somewhat syntactic sugar. The only point is 
that, to instanciate a function, you have more to do:

Help on class function in module __builtin__:

class function(object)
  |  function(code, globals[, name[, argdefs[, closure]]])
  |
  |  Create a function object from a code object and a dictionary.
  |  The optional name string overrides the name from the code object.
  |  The optional argdefs tuple specifies the default argument values.
  |  The optional closure tuple supplies the bindings for free variables


>> The Pythonic way to write "more complicated yet still comprehensible 
>> list comprehensions" is to not use list comprehensions.
>>
>> b = []
>> for x in vec1:
>>   if x > 0:
>> for y in vec2:
>>   if y > x:
>> b.append(x + y)
>>
> 
> You have just demonstrated that list comprehensions are not really
> necessary at all.  So given the "one clear way of doing things",

Actually, it's: "there should be one - and preferably only one - obvious 
way to do it". List comps are the obvious way for simple list 
operations, and for loops are the obvious way for complex operations. If 
you're in for Python Zen quotes, here are some others:
"""
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
"""


> shouldn't they be removed?  My point is that if you are going to
> have them, why make some new unstructured syntax for them?

Because there's already a (well-known) structured syntax for the cases 
that are too complex to fit a single, simple expression. It's a question 
of balance between purity, readability, and practicallity.

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


Binary search tree

2007-11-09 Thread maxim . novak
Hi,

I have to get list of URLs one by one and to find the URLs that I have
more than one time(can't be more than twice).

I thought to put them into binary search tree, this way they'll be
sorted and I'll be able to check if the URL already exist.

Couldn't find any python library that implements trees.
Is there some library of this kind in python? Or can I find it
somewhere else?

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


Re: Binary search tree

2007-11-09 Thread D.Hering
On Nov 9, 4:06 pm, [EMAIL PROTECTED] wrote:
> Hi,
>
> I have to get list of URLs one by one and to find the URLs that I have
> more than one time(can't be more than twice).
>
> I thought to put them into binary search tree, this way they'll be
> sorted and I'll be able to check if the URL already exist.
>
> Couldn't find any python library that implements trees.
> Is there some library of this kind in python? Or can I find it
> somewhere else?

Can you use set() or set.difference()?

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


Re: Global variables within classes.

2007-11-09 Thread Donn Ingle
>> I thought this might be a case for multiple inheritance
> ???
Well, in terms of having Canvas and Thing inherit from Stack and thereby
(somehow, not sure how) they would both have access to Stack.stack (a list)
 
> wrt/ all Thing instances having to refer to a same Stack instance,
> there's a pretty obvious answer: make the Stack instance an attribute of
> class Thing, ie:
> class Thing(object):
>stack = Stack()
> 
>def some_method(self, val):
>   self.stack.push(val)
># etc...

No can do:
Canvas ---> Stack <--- Thing
Both Canvas and Thing have to use the same Stack. It gets things pushed onto
it by them both.

> Now the point that isn't clear is the exact relationship between Stack
> and Canvas. You didn't give enough details for any answer, advice or
> hint to make sens.
Sorry, didn't want to write an overly long post.

a Canvas holds many Things (graphics) and it pushes each Thing onto the
Stack. The Things also push data onto the same Stack. After that the Stack
pops and draws each Thing to the screen.

What I'm asking about is subtle and I don't know how to word it: how can
Classes share common objects without using global variables specifically
named within them?


## == API in another module perhaps ===
Class Stack:
 def push(self,stuff):
  pass

Class Canvas:
 def do(self):
  s.push("data") #I don't feel right about 's' here.

Class Thing:
 def buzz(self):
  print s.pop(0)

## == User space code area ===
s = Stack() #I want to avoid this direct naming to 's'
c = Canvas()
c.push("bozo")
t = Thing()
t.buzz()

Hope that makes more sense.
\d


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


wx.listctrl- insertstringitem not working

2007-11-09 Thread barronmo
Newbie with problem.  I'm trying to build a multicolumn list control
with wxPython and am having difficulty getting the data from my query
into each column.  I'm getting the following error:

Traceback (most recent call last):
  File "/home/mb/PyPrograms/EMRGUI/Selectable.py", line 115, in

Repository(None, -1, 'Repository')
  File "/home/mb/PyPrograms/EMRGUI/Selectable.py", line 57, in
__init__
index = self.list.InsertStringItem(sys.maxint, i['patient_ID'])
  File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/lib/
mixins/listctrl.py", line 751, in __InsertStringItem_
index = self.InsertImageStringItem(index, label, 0)
  File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/
_controls.py", line 4716, in InsertImageStringItem
return _controls_.ListCtrl_InsertImageStringItem(*args, **kwargs)
TypeError: String or Unicode type required


The code I'm using is based on the wxPython tutorial at Zetcode:

#!/usr/bin/python


import wx
import sys
import MySQLdb
from wx.lib.mixins.listctrl import CheckListCtrlMixin,
ListCtrlAutoWidthMixin

conn = MySQLdb.connect(host = "localhost",
  user = "root",
  passwd = "Barron85",
  db = "meds")

def name_find(namefrag):

 cursor = conn.cursor(MySQLdb.cursors.DictCursor)
 cursor.execute("SELECT patient_ID, firstname, lastname,
phonenumber, SSN, \
DOB FROM demographics WHERE lastname LIKE '%s%%'" % 
(namefrag))

 results = cursor.fetchall()
 results_list = list(results)
 return results_list
 cursor.close()



class CheckListCtrl(wx.ListCtrl, CheckListCtrlMixin,
ListCtrlAutoWidthMixin):
def __init__(self, parent):
wx.ListCtrl.__init__(self, parent, -1, style=wx.LC_REPORT |
wx.SUNKEN_BORDER)
CheckListCtrlMixin.__init__(self)
ListCtrlAutoWidthMixin.__init__(self)


class Repository(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(850, 400))

panel = wx.Panel(self, -1)

vbox = wx.BoxSizer(wx.VERTICAL)
hbox = wx.BoxSizer(wx.HORIZONTAL)

leftPanel = wx.Panel(panel, -1)
rightPanel = wx.Panel(panel, -1)

self.log = wx.TextCtrl(rightPanel, -1, style=wx.TE_MULTILINE)
self.list = CheckListCtrl(rightPanel)
self.list.InsertColumn(0, 'Patient ID', width=100)
self.list.InsertColumn(1, 'Lastname', width=200)
self.list.InsertColumn(2, 'Firstname', width=125)
self.list.InsertColumn(3, 'Phone')
self.list.InsertColumn(4, 'SSN')
self.list.InsertColumn(5, 'DOB')

patients = name_find(str(raw_input('Select the first several letters
of the last name: ')))
for i in patients:
index = self.list.InsertStringItem(sys.maxint,
i['patient_ID'])
self.list.SetStringItem(index, 1, i['lastname'])
self.list.SetStringItem(index, 2, i['firstname'])
self.list.SetStringItem(index, 3, i['phonenumber'])
self.list.SetStringItem(index, 4, i['SSN'])
self.list.SetStringItem(index, 5, i['DOB'])

vbox2 = wx.BoxSizer(wx.VERTICAL)

sel = wx.Button(leftPanel, -1, 'Select All', size=(100, -1))
des = wx.Button(leftPanel, -1, 'Deselect All', size=(100, -1))
apply = wx.Button(leftPanel, -1, 'Apply', size=(100, -1))


self.Bind(wx.EVT_BUTTON, self.OnSelectAll, id=sel.GetId())
self.Bind(wx.EVT_BUTTON, self.OnDeselectAll, id=des.GetId())
self.Bind(wx.EVT_BUTTON, self.OnApply, id=apply.GetId())

vbox2.Add(sel, 0, wx.TOP, 5)
vbox2.Add(des)
vbox2.Add(apply)

leftPanel.SetSizer(vbox2)

vbox.Add(self.list, 1, wx.EXPAND | wx.TOP, 3)
vbox.Add((-1, 10))
vbox.Add(self.log, 0.5, wx.EXPAND)
vbox.Add((-1, 10))

rightPanel.SetSizer(vbox)

hbox.Add(leftPanel, 0, wx.EXPAND | wx.RIGHT, 5)
hbox.Add(rightPanel, 1, wx.EXPAND)
hbox.Add((3, -1))

panel.SetSizer(hbox)

self.Centre()
self.Show(True)

def OnSelectAll(self, event):
num = self.list.GetItemCount()
for i in range(num):
self.list.CheckItem(i)

def OnDeselectAll(self, event):
num = self.list.GetItemCount()
for i in range(num):
self.list.CheckItem(i, False)

def OnApply(self, event):
num = self.list.GetItemCount()
for i in range(num):
if i == 0: self.log.Clear()
if self.list.IsChecked(i):
self.log.AppendText(self.list.GetItemText(i) + '\n')

app = wx.App()
Repository(None, -1, 'Repository')
app.MainLoop()



If you see what I'm doing wrong I'd be grateful for any help.

Mike

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


Re: wx.listctrl- insertstringitem not working

2007-11-09 Thread kyosohma
On Nov 9, 4:07 pm, barronmo <[EMAIL PROTECTED]> wrote:
> Newbie with problem.  I'm trying to build a multicolumn list control
> with wxPython and am having difficulty getting the data from my query
> into each column.  I'm getting the following error:
>
> Traceback (most recent call last):
>   File "/home/mb/PyPrograms/EMRGUI/Selectable.py", line 115, in
> 
> Repository(None, -1, 'Repository')
>   File "/home/mb/PyPrograms/EMRGUI/Selectable.py", line 57, in
> __init__
> index = self.list.InsertStringItem(sys.maxint, i['patient_ID'])
>   File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/lib/
> mixins/listctrl.py", line 751, in __InsertStringItem_
> index = self.InsertImageStringItem(index, label, 0)
>   File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/
> _controls.py", line 4716, in InsertImageStringItem
> return _controls_.ListCtrl_InsertImageStringItem(*args, **kwargs)
> TypeError: String or Unicode type required
>
> The code I'm using is based on the wxPython tutorial at Zetcode:
>
> #!/usr/bin/python
>
> import wx
> import sys
> import MySQLdb
> from wx.lib.mixins.listctrl import CheckListCtrlMixin,
> ListCtrlAutoWidthMixin
>
> conn = MySQLdb.connect(host = "localhost",
>   user = "root",
>   passwd = "Barron85",
>   db = "meds")
>
> def name_find(namefrag):
>
>  cursor = conn.cursor(MySQLdb.cursors.DictCursor)
>  cursor.execute("SELECT patient_ID, firstname, lastname,
> phonenumber, SSN, \
> DOB FROM demographics WHERE lastname LIKE '%s%%'" % 
> (namefrag))
>
>  results = cursor.fetchall()
>  results_list = list(results)
>  return results_list
>  cursor.close()
>
> class CheckListCtrl(wx.ListCtrl, CheckListCtrlMixin,
> ListCtrlAutoWidthMixin):
> def __init__(self, parent):
> wx.ListCtrl.__init__(self, parent, -1, style=wx.LC_REPORT |
> wx.SUNKEN_BORDER)
> CheckListCtrlMixin.__init__(self)
> ListCtrlAutoWidthMixin.__init__(self)
>
> class Repository(wx.Frame):
> def __init__(self, parent, id, title):
> wx.Frame.__init__(self, parent, id, title, size=(850, 400))
>
> panel = wx.Panel(self, -1)
>
> vbox = wx.BoxSizer(wx.VERTICAL)
> hbox = wx.BoxSizer(wx.HORIZONTAL)
>
> leftPanel = wx.Panel(panel, -1)
> rightPanel = wx.Panel(panel, -1)
>
> self.log = wx.TextCtrl(rightPanel, -1, style=wx.TE_MULTILINE)
> self.list = CheckListCtrl(rightPanel)
> self.list.InsertColumn(0, 'Patient ID', width=100)
> self.list.InsertColumn(1, 'Lastname', width=200)
> self.list.InsertColumn(2, 'Firstname', width=125)
> self.list.InsertColumn(3, 'Phone')
> self.list.InsertColumn(4, 'SSN')
> self.list.InsertColumn(5, 'DOB')
>
> patients = name_find(str(raw_input('Select the first several letters
> of the last name: ')))
> for i in patients:
> index = self.list.InsertStringItem(sys.maxint,
> i['patient_ID'])
> self.list.SetStringItem(index, 1, i['lastname'])
> self.list.SetStringItem(index, 2, i['firstname'])
> self.list.SetStringItem(index, 3, i['phonenumber'])
> self.list.SetStringItem(index, 4, i['SSN'])
> self.list.SetStringItem(index, 5, i['DOB'])
>
> vbox2 = wx.BoxSizer(wx.VERTICAL)
>
> sel = wx.Button(leftPanel, -1, 'Select All', size=(100, -1))
> des = wx.Button(leftPanel, -1, 'Deselect All', size=(100, -1))
> apply = wx.Button(leftPanel, -1, 'Apply', size=(100, -1))
>
> self.Bind(wx.EVT_BUTTON, self.OnSelectAll, id=sel.GetId())
> self.Bind(wx.EVT_BUTTON, self.OnDeselectAll, id=des.GetId())
> self.Bind(wx.EVT_BUTTON, self.OnApply, id=apply.GetId())
>
> vbox2.Add(sel, 0, wx.TOP, 5)
> vbox2.Add(des)
> vbox2.Add(apply)
>
> leftPanel.SetSizer(vbox2)
>
> vbox.Add(self.list, 1, wx.EXPAND | wx.TOP, 3)
> vbox.Add((-1, 10))
> vbox.Add(self.log, 0.5, wx.EXPAND)
> vbox.Add((-1, 10))
>
> rightPanel.SetSizer(vbox)
>
> hbox.Add(leftPanel, 0, wx.EXPAND | wx.RIGHT, 5)
> hbox.Add(rightPanel, 1, wx.EXPAND)
> hbox.Add((3, -1))
>
> panel.SetSizer(hbox)
>
> self.Centre()
> self.Show(True)
>
> def OnSelectAll(self, event):
> num = self.list.GetItemCount()
> for i in range(num):
> self.list.CheckItem(i)
>
> def OnDeselectAll(self, event):
> num = self.list.GetItemCount()
> for i in range(num):
> self.list.CheckItem(i, False)
>
> def OnApply(self, event):
> num = self.list.GetItemCount()
> for i in range(num):
> if i == 0: self.log.Clear()
> if self.list.IsChecked(i):
> self.log.AppendText(self.list.GetItemText(i) + '\n')
>
> app = wx.App()
> Repository(None, -1, 'Repository')
> app.MainLoop()
>
> If you see what I'm 

Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Bruno Desthuilliers
Frank Samuelson a écrit :
(snip)
>> Arbitrary changes to syntax are never going to fly. It's a lost cause.
> 
> 
> The changes are not arbitrary.

Which ones ?

>  They are logical, consistent, less
> arbitrary and thus more productive.

For who ?

>  If such
> changes are a lost cause, that is too bad, because
> it implies that Python will stagnate.  Unfortunately that appears the case.

This is totally ridiculous. Let's see : list comprehensions, a new, 
widely improved object system, with metaclasses, and the descriptor 
protocol which brings customisable computed attributes -, lexical 
closures, iterators, generator expressions, syntactic sugar for function 
decorators, contexts (the 'with' statement), and coroutines. Just to 
name a few, and only talking of production releases. Which other 
language grew so many new features in the last seven years ? Java ? C ? 
C++ ? Lisp ? VB (lol) ?

(snip)
>> If you can't handle Python without your pet changes, fork it and write
>> your own version and let the marketplace of ideas decide if its
>> useful.
>  
> Apparently you missed my statement about loving Python.  I love it
> because it is the second most productive language I have ever used,
> though I do believe it has the potential to be the greatest ever by
> far.

I don't think you'll gain that much productivity by fighting against the 
language trying to write  in it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wx.listctrl- insertstringitem not working

2007-11-09 Thread Larry Bates
barronmo wrote:
> Newbie with problem.  I'm trying to build a multicolumn list control
> with wxPython and am having difficulty getting the data from my query
> into each column.  I'm getting the following error:
> 
> Traceback (most recent call last):
>   File "/home/mb/PyPrograms/EMRGUI/Selectable.py", line 115, in
> 
> Repository(None, -1, 'Repository')
>   File "/home/mb/PyPrograms/EMRGUI/Selectable.py", line 57, in
> __init__
> index = self.list.InsertStringItem(sys.maxint, i['patient_ID'])
>   File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/lib/
> mixins/listctrl.py", line 751, in __InsertStringItem_
> index = self.InsertImageStringItem(index, label, 0)
>   File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/
> _controls.py", line 4716, in InsertImageStringItem
> return _controls_.ListCtrl_InsertImageStringItem(*args, **kwargs)
> TypeError: String or Unicode type required
> 
> 
> The code I'm using is based on the wxPython tutorial at Zetcode:
> 
> #!/usr/bin/python
> 
> 
> import wx
> import sys
> import MySQLdb
> from wx.lib.mixins.listctrl import CheckListCtrlMixin,
> ListCtrlAutoWidthMixin
> 
> conn = MySQLdb.connect(host = "localhost",
>   user = "root",
>   passwd = "Barron85",
>   db = "meds")
> 
> def name_find(namefrag):
> 
>  cursor = conn.cursor(MySQLdb.cursors.DictCursor)
>  cursor.execute("SELECT patient_ID, firstname, lastname,
> phonenumber, SSN, \
>   DOB FROM demographics WHERE lastname LIKE '%s%%'" % 
> (namefrag))
> 
>  results = cursor.fetchall()
>  results_list = list(results)
>  return results_list
>  cursor.close()
> 
> 
> 
> class CheckListCtrl(wx.ListCtrl, CheckListCtrlMixin,
> ListCtrlAutoWidthMixin):
> def __init__(self, parent):
> wx.ListCtrl.__init__(self, parent, -1, style=wx.LC_REPORT |
> wx.SUNKEN_BORDER)
> CheckListCtrlMixin.__init__(self)
> ListCtrlAutoWidthMixin.__init__(self)
> 
> 
> class Repository(wx.Frame):
> def __init__(self, parent, id, title):
> wx.Frame.__init__(self, parent, id, title, size=(850, 400))
> 
> panel = wx.Panel(self, -1)
> 
> vbox = wx.BoxSizer(wx.VERTICAL)
> hbox = wx.BoxSizer(wx.HORIZONTAL)
> 
> leftPanel = wx.Panel(panel, -1)
> rightPanel = wx.Panel(panel, -1)
> 
> self.log = wx.TextCtrl(rightPanel, -1, style=wx.TE_MULTILINE)
> self.list = CheckListCtrl(rightPanel)
> self.list.InsertColumn(0, 'Patient ID', width=100)
> self.list.InsertColumn(1, 'Lastname', width=200)
> self.list.InsertColumn(2, 'Firstname', width=125)
>   self.list.InsertColumn(3, 'Phone')
>   self.list.InsertColumn(4, 'SSN')
>   self.list.InsertColumn(5, 'DOB')
> 
>   patients = name_find(str(raw_input('Select the first several letters
> of the last name: ')))
> for i in patients:
> index = self.list.InsertStringItem(sys.maxint,
> i['patient_ID'])
> self.list.SetStringItem(index, 1, i['lastname'])
> self.list.SetStringItem(index, 2, i['firstname'])
>   self.list.SetStringItem(index, 3, i['phonenumber'])
>   self.list.SetStringItem(index, 4, i['SSN'])
>   self.list.SetStringItem(index, 5, i['DOB'])
> 
> vbox2 = wx.BoxSizer(wx.VERTICAL)
> 
> sel = wx.Button(leftPanel, -1, 'Select All', size=(100, -1))
> des = wx.Button(leftPanel, -1, 'Deselect All', size=(100, -1))
> apply = wx.Button(leftPanel, -1, 'Apply', size=(100, -1))
> 
> 
> self.Bind(wx.EVT_BUTTON, self.OnSelectAll, id=sel.GetId())
> self.Bind(wx.EVT_BUTTON, self.OnDeselectAll, id=des.GetId())
> self.Bind(wx.EVT_BUTTON, self.OnApply, id=apply.GetId())
> 
> vbox2.Add(sel, 0, wx.TOP, 5)
> vbox2.Add(des)
> vbox2.Add(apply)
> 
> leftPanel.SetSizer(vbox2)
> 
> vbox.Add(self.list, 1, wx.EXPAND | wx.TOP, 3)
> vbox.Add((-1, 10))
> vbox.Add(self.log, 0.5, wx.EXPAND)
> vbox.Add((-1, 10))
> 
> rightPanel.SetSizer(vbox)
> 
> hbox.Add(leftPanel, 0, wx.EXPAND | wx.RIGHT, 5)
> hbox.Add(rightPanel, 1, wx.EXPAND)
> hbox.Add((3, -1))
> 
> panel.SetSizer(hbox)
> 
> self.Centre()
> self.Show(True)
> 
> def OnSelectAll(self, event):
> num = self.list.GetItemCount()
> for i in range(num):
> self.list.CheckItem(i)
> 
> def OnDeselectAll(self, event):
> num = self.list.GetItemCount()
> for i in range(num):
> self.list.CheckItem(i, False)
> 
> def OnApply(self, event):
> num = self.list.GetItemCount()
> for i in range(num):
> if i == 0: self.log.Clear()
> if self.list.IsChecked(i):
> self.log.AppendText(self.list.GetItemText(i) + '\n')
> 
> app = wx.App()
> Repository(None, -1, 'Repository')
> app.MainLoop()
> 
> 
> 
> If you see what I'm d

Re: Global variables within classes.

2007-11-09 Thread Bruno Desthuilliers
Donn Ingle a écrit :
>>>I thought this might be a case for multiple inheritance
>>
>>???
> 
> Well, in terms of having Canvas and Thing inherit from Stack and thereby
> (somehow, not sure how) they would both have access to Stack.stack (a list)
>  
> 
>>wrt/ all Thing instances having to refer to a same Stack instance,
>>there's a pretty obvious answer: make the Stack instance an attribute of
>>class Thing, ie:
>>class Thing(object):
>>   stack = Stack()
>>
>>   def some_method(self, val):
>>  self.stack.push(val)
>>   # etc...
> 
> 
> No can do:
> Canvas ---> Stack <--- Thing

Sorry but you're exemple is using classes, not instances. So while *you* 
may know what you mean, it's not decidable for me.

> Both Canvas and Thing have to use the same Stack.

You mean: both Canvas class and Thing class have to use the same Stack 
Class ? Or : for all Canvas instances and all Thing instances, there 
must be only one same Stack instance ? Or: a given (Canvas instance, 
Thing instance) couple must share a same Stack instance ? Or (etc...)

> It gets things pushed onto
> it by them both.

Both what ? classes ? instances ?-)

> 
>>Now the point that isn't clear is the exact relationship between Stack
>>and Canvas. You didn't give enough details for any answer, advice or
>>hint to make sens.
> 
> Sorry, didn't want to write an overly long post.

There's certainly a balance between being overly vague and being overly 
long !-)

> a Canvas holds many Things (graphics) and it pushes each Thing onto the
> Stack. The Things also push data onto the same Stack. After that the Stack
> pops and draws each Thing to the screen.
> 
> What I'm asking about is subtle and I don't know how to word it: how can
> Classes

I guess you mean "instances", not "classes".

> share common objects without using global variables specifically
> named within them?

Err...Perhaps a dumb question, but what about passing the "common 
objects" to initializers ?

> ## == API in another module perhaps ===
> Class Stack:
>  def push(self,stuff):
>   pass
> 
> Class Canvas:
>  def do(self):
>   s.push("data") #I don't feel right about 's' here.
> 
> Class Thing:
>  def buzz(self):
>   print s.pop(0)
> 
> ## == User space code area ===
> s = Stack() #I want to avoid this direct naming to 's'
> c = Canvas()
> c.push("bozo")
> t = Thing()
> t.buzz()

# API land
class Stack(object):
# ok, we all know what a stack is

class Canvas(object):
   def __init__(self, stack):
 self.stack = stack
   def do(self):
 self.stack.push("data")

class Thing(object):
   def __init__(self, stack):
 self.stack = stack
   def buzz(self):
 print self.stack.pop(0)


# Userland
s = Stack()
c = Canvas(s)
t = Thing(s)

c.do()
t.buzz()

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


Re: Binary search tree

2007-11-09 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit :
> Hi,
> 
> I have to get list of URLs one by one and to find the URLs that I have
> more than one time(can't be more than twice).
> 
> I thought to put them into binary search tree, this way they'll be
> sorted and I'll be able to check if the URL already exist.

What about a set ?

s = set()
for url in urls:
   if url in s:
 print "already have ", url
   else:
 set.add(url)

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


Re: Global variables within classes.

2007-11-09 Thread Donn Ingle
> I guess you mean "instances", not "classes".
Yes.
 
> Err...Perhaps a dumb question, but what about passing the "common
> objects" to initializers ?
> s = Stack()
> c = Canvas(s)
> t = Thing(s)

Okay, I see where you're going. It's better than what I have at the moment.
Thanks.

\d


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


Re: Codec lookup fails for bad codec name, blowing up BeautifulSoup

2007-11-09 Thread Waldemar Osuch

>
> This is a known bug. It's in the old tracker on SourceForge:
> [ python-Bugs-960874 ] codecs.lookup can raise exceptions other
> than LookupError
> but not in the new tracker.

The new tracker has it too.
http://bugs.python.org/issue960874

>
> The "resolution" back in 2004 was "Won't Fix", without a change
> to the documentation.  Grrr.
>

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


Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Steven D'Aprano
On Fri, 09 Nov 2007 11:41:24 -0500, Frank Samuelson wrote:

 
>> The ideas are
>> *never* fully thought out or materialized, and they invariably invite
>> scorn from the user community.
> 
> Of course, they're thought out:  They're stolen from another language.
> Specifically, the language in which I am most productive.

No, they aren't fully thought out *at all*. To wit: 

* you've suggested crippling tracebacks, throwing away the most important 
piece of information they currently provide, just because you don't like 
the def statement;

* you've suggested allowing sequences as indices into lists, completely 
unaware that your two suggestions for what it should mean are mutually 
incompatible;

* you've suggested getting rid of the slice syntax for no advantage;

* you've suggested making the function constructor itself a function, and 
seem to be completely unaware that your request would need a very 
different syntax to that Python already uses; 

* you suggest two different versions for the function constructor, one 
that is an expression and one that is a suite, but judging by your 
comments you don't even realize they are two different versions.


Need I go on?


If you want your suggestions to be taken seriously, you need to think 
them through carefully. Well-designed programming languages are not like 
chop suey, where you grab whatever left-overs you have in the fridge and 
mix them all together because you like the individual ingredients.



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


Re: Codec lookup fails for bad codec name, blowing up BeautifulSoup

2007-11-09 Thread John Nagle
Waldemar Osuch wrote:
>> This is a known bug. It's in the old tracker on SourceForge:
>> [ python-Bugs-960874 ] codecs.lookup can raise exceptions other
>> than LookupError
>> but not in the new tracker.
> 
> The new tracker has it too.
> http://bugs.python.org/issue960874

How did you find that?  I put "codecs.lookup" into the tracker's
search box, and it returned five hits, but not that one.

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


Re: Python Extension Building Network

2007-11-09 Thread M.-A. Lemburg
[EMAIL PROTECTED] wrote:
> On Nov 9, 8:36 am, Tim Golden <[EMAIL PROTECTED]> wrote:
>> [EMAIL PROTECTED] wrote:
>>> Hi,
>>> I am trying to get a small group of volunteers together to create
>>> Windows binaries for any Python extension developer that needs them,
>>> much like the package/extension builders who volunteer their time to
>>> create Linux RPMs.

Are you aware of the repository that ActiveState created for
its version of Python (ActivePython) ? It comes with a
set of pre-compiled Python extensions (PPMs) and an easy
to use installer.

Perhaps getting ActiveState to open up the repo would be good
idea - something like Ubuntu does with the universe repo.

>>> The main thing I need are people willing to test the binaries to make
>>> sure the extension is stable. This would require installing the binary
>>> and probably downloading the source too to get the developer's test
>>> code. I've been able to get some of the tests to run great while
>>> others are pretty finicky and some extensions don't come with tests.
>>> It would be nice to know which extensions are most in need of this
>>> too.
>>> While I can create the binaries on my own for a while, if I get too
>>> many requests, there will be a backlog, so it would be nice to have
>>> help with that too. I'm also looking for knowledgeable people to be
>>> sounding boards (i.e. give advice).
>>> Developers: all I would require is a request, a link to the source,
>>> and a well-written setup.py file for a cross-platform extension.
>>> You can find the few that I've already done here:http://
>>> www.pythonlibrary.org/python_modules.htm
>>> I have also posted a way to create the binaries using the MinGW
>>> compiler. I have VS2003 installed on my PC and MinGW is installed in a
>>> VM, so I can compile the extensions both ways.
>> Mike, this is great news. Whenever I have time > means it sincerely> I'll try to run through some of the modules
>> you've compiled.
>>
>> As a slight aside, the main problem I've found when I've tried
>> to build extensions (and I've been doing it recently with AVBin and
>> Pyglet) is that Windows just doesn't have the build environment, the
>> directory structures, the env vars and all that that a ./configure or
>> even a python setup.py install sometimes expects. eg if I were to
>> offer to build a MySQL extension (as someone who doesn't use MySQL
>> and wouldn't have the source libs installed if I did) there would
>> be a fair bit of pain to go through. You've obviously gone through
>> that pain barrier for at least some of the extensions on the modules
>> page. Was it tough?
> 
> The hardest part was finding accurate information. Most people on the
> user groups have been unhelpful or sarcastic. I had better luck
> contacting developers directly who had already created Windows
> binaries. They didn't mind giving me some pointers.

Interesting: Python seems to be "growing up" in all kinds of
ways ...

> The directions for MinGW were usually only partially correct. So I
> went through the two sets of directions I found (links on the site)
> and mixed and matched until I got it right.
> 
> There are no directions on how to use Visual Studio 2003 that I've
> found, just some old free edition. those directions were incompatible
> with VS2003. I'll post VS2003's correct usage eventually, but it's
> basically just installing it and then using distutils.

Getting VS2003 ready to compile Python extensions is really easy:

1. open a command shell
2. run vcvars32.bat
3. make sure the Python version you are targetting is on the
   PATH
4. "python setup.py bdist_wininst" or "python setup.py bdist_msi"
5. pick up the installer in the build\ directory.

Note: bdist_msi is only available in Python 2.5 and later.

You need VC6 if you want to compile extensions for Python 1.5-2.3
and VC7.1 for Python 2.4 and later.

>> TJG
>>
>> (PS SendKeys link on this page is 
>> dead:http://www.pythonlibrary.org/automation.htm)
> 
> I've noticed some of the stuff I thought I uploaded seems to have gone
> MIA. I'll get that fixed tonight. Thanks for the bug report and offer
> of help.
> 
> Mike
> 

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Nov 09 2007)
>>> Python/Zope Consulting and Support ...http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


 Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: easy 3D graphics for rendering geometry?

2007-11-09 Thread gsal
Thanks for the suggestion.

I reviewed the documentation and seems pretty complete and fairly
compatible.  It does have a pretty steep learning curve, though.  For
somebody like me, totally new in the field, seems rather difficult to
start on my ownI guess they want you to buy the training...

gsal

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


Re: defaultdict and dict?

2007-11-09 Thread Raymond Hettinger
On Nov 9, 3:01 am, Davy <[EMAIL PROTECTED]> wrote:
> In Python 2.5 document, defaultdict is called high performance
> container. From document, we can know defaultdict is subclass of dict.
> So, why defaultdict have higher performance than dict? And at what
> circumstance, we can make use of such high performance?

Defaultdicts only area of superiority is the speed and code economy
for the case where you need to automatically fill-in missing values
(it runs circles around dict.setdefault).


Raymond

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


Re: easy 3D graphics for rendering geometry?

2007-11-09 Thread gsal
I actually did look at VPython last weekend. I managed to draw a
soccer field, a few players, move them around and even record/play-
back playsI was very impressed on how easy it was to learn not
only VPython, but Python in the first...I did not know any python,
either.

I am not quite sure how I would go about building ANY geometry that I
would want, though.  O.k., so they offer faces, but I did not quite
see how to go about using it...

gsal

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


Re: easy 3D graphics for rendering geometry?

2007-11-09 Thread gsal
By the way, VPython crashes my computer rather easily:

- launch the editor
- open python file
- press F5 to run
- when the graphical windows appears, attempt to manipulate (drag or
resize)
- the computer looses it...

At the end, sometimes, the computer looks like is trying to take care
of things but simply takes forever; other times, I end up with a blank
screen and an unresponsive computer and have to press the power button
for about 10 seconds to get it to power off.

gsal

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


Re: Using python as primary language

2007-11-09 Thread Rhamphoryncus
On Nov 9, 1:45 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote:
> "Martin Vilcans" <[EMAIL PROTECTED]> wrote in message
>
> news:[EMAIL PROTECTED]
> | But that's not what my question was about. It was about whether it
> | would make sense to, on the same python installation, select between
> | the GIL and fine-grained locks at startup. Because even if the locks
> | slows down the interpreter, if they let you utilize a 32 core CPU, it
> | may not be so bad anymore. Or am I missing something?
>
> 1. The need for some group to develop and maintain what anounts to a forked
> version of CPython.

That's pretty much what I'm doing.


> 2. If micro-locked Python ran, say, half as fast, then you can have a lot
> of IPC (interprocess communition) overhead and still be faster with
> multiple processes rather than multiple threads.

Of course you'd be faster still if you rewrote key portions in C.
That's usually not necessary though, so long as Python gives a roughly
constant overhead compared to C, which in this case would be true so
long as Python scaled up near 100% with the number of cores/threads.

The bigger question is one of usability.  We could make a usability/
performance tradeoff if we had more options, and there's a lot that
can give good performance, but at this point they all offer poor to
moderate usability, none having good usability.  The crux of the
"multicore crisis" is that lack of good usability.


--
Adam Olsen, aka Rhamphoryncus

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


Creating installer with external extension modules

2007-11-09 Thread mhearne808[insert-at-sign-here]gmail[insert-dot-here]com
I'm creating a piece of software which will be used by in-house
users.  My code will all be written in pure Python; however, it
depends heavily on a number of third-party Python modules, many of
which have C/C++ dependencies (numpy, scipy, etc.)  Installing these
packages on my machine involved a morning of several serial "./
configure;make;sudo make install" steps.  I'd prefer to automate all
of this for my users, but I'm not clear how to do this - I'm in an
environment of mixed Mac (desktops) and Linux (servers) and I'll need
to install on both platforms, and would prefer not to run around to
each computer making sure the dependencies are met.

I've looked through the documentation for distutils and setuptools,
and it's not obvious to me that there are hooks in either one for
passing in configure and make calls.

The fallback, I suppose, presuming that the correct version of Python
is already installed, is to write a custom Python script that "knows"
about each dependency, and takes the appropriate action.  I should be
able to depend on everyone having gcc and make installed, I think.

Does anyone have any suggestions on the best way to approach this?

Thanks,

Mike

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


Re: Creating installer with external extension modules

2007-11-09 Thread Martin v. Löwis
> Does anyone have any suggestions on the best way to approach this?

For the Mac, I recommend to provide precompiled binaries to your users,
rather than requiring them to download various source packages, to run
your build-it-all script afterwards.

To distribute a package on the Mac, you could study the Mac package
format - however, providing a tar file of all files needed should
work just as well.

For Linux, you could do the same thing, provided you can standardize
on a single distribution, and on packages that should have been
installed before (if you are using Debian, you'll find that many
of the packages you have as prerequisites are already available for
Debian with the standard release). Again, you can try to create
packages according to the package management format of your Linux
distribution (i.e. either RPM or .deb).

If you go for the "native binary packages", your users will enjoy
easy installation, and, for Linux, also convenient deinstallation
(for Mac, you can get easy deinstallation if you put everything in
a single root directory).

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


Valgrind and Python

2007-11-09 Thread Esa A E Peuha
Running Python 2.5.1 under Valgrind is interesting; just starting it and
then pressing Ctrl-D produces this:

==27082== ERROR SUMMARY: 713 errors from 56 contexts (suppressed: 10 from 1)
==27082== malloc/free: in use at exit: 1,243,153 bytes in 508 blocks.
==27082== malloc/free: 3,002 allocs, 2,494 frees, 2,748,487 bytes allocated.
==27082== For counts of detected errors, rerun with: -v
==27082== searching for pointers to 508 not-freed blocks.
==27082== checked 1,399,984 bytes.
==27082== 
==27082== LEAK SUMMARY:
==27082==definitely lost: 0 bytes in 0 blocks.
==27082==  possibly lost: 17,072 bytes in 58 blocks.
==27082==still reachable: 1,226,081 bytes in 450 blocks.
==27082== suppressed: 0 bytes in 0 blocks.
==27082== Reachable blocks (those to which a pointer was found) are not shown.
==27082== To see them, rerun with: --show-reachable=yes

A lot of those 713 errors occur in the various deallocation functions.

-- 
Esa Peuha
student of mathematics at the University of Helsinki
http://www.helsinki.fi/~peuha/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Valgrind and Python

2007-11-09 Thread Jean-Paul Calderone
On 10 Nov 2007 02:38:57 +0200, Esa A E Peuha <[EMAIL PROTECTED]> wrote:
>Running Python 2.5.1 under Valgrind is interesting; just starting it and
>then pressing Ctrl-D produces this:
>
>==27082== ERROR SUMMARY: 713 errors from 56 contexts (suppressed: 10 from 1)
>==27082== malloc/free: in use at exit: 1,243,153 bytes in 508 blocks.
>==27082== malloc/free: 3,002 allocs, 2,494 frees, 2,748,487 bytes allocated.
>==27082== For counts of detected errors, rerun with: -v
>==27082== searching for pointers to 508 not-freed blocks.
>==27082== checked 1,399,984 bytes.
>==27082==
>==27082== LEAK SUMMARY:
>==27082==definitely lost: 0 bytes in 0 blocks.
>==27082==  possibly lost: 17,072 bytes in 58 blocks.
>==27082==still reachable: 1,226,081 bytes in 450 blocks.
>==27082== suppressed: 0 bytes in 0 blocks.
>==27082== Reachable blocks (those to which a pointer was found) are not shown.
>==27082== To see them, rerun with: --show-reachable=yes
>
>A lot of those 713 errors occur in the various deallocation functions.
>

Did you use the suppression file?

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


ftplib ssl/tls support?

2007-11-09 Thread Giampaolo Rodola'
I noticed that poplib, smtplib, httplib, imaplib and probably others
include support for ssl connections.
Are there future plans for ftplib ssl/tls support?

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


Re: Python Extension Building Network

2007-11-09 Thread kyosohma
On Nov 9, 5:26 pm, "M.-A. Lemburg" <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > On Nov 9, 8:36 am, Tim Golden <[EMAIL PROTECTED]> wrote:
> >> [EMAIL PROTECTED] wrote:
> >>> Hi,
> >>> I am trying to get a small group of volunteers together to create
> >>> Windows binaries for any Python extension developer that needs them,
> >>> much like the package/extension builders who volunteer their time to
> >>> create Linux RPMs.
>
> Are you aware of the repository that ActiveState created for
> its version of Python (ActivePython) ? It comes with a
> set of pre-compiled Python extensions (PPMs) and an easy
> to use installer.
>
> Perhaps getting ActiveState to open up the repo would be good
> idea - something like Ubuntu does with the universe repo.
>
>
>
> >>> The main thing I need are people willing to test the binaries to make
> >>> sure the extension is stable. This would require installing the binary
> >>> and probably downloading the source too to get the developer's test
> >>> code. I've been able to get some of the tests to run great while
> >>> others are pretty finicky and some extensions don't come with tests.
> >>> It would be nice to know which extensions are most in need of this
> >>> too.
> >>> While I can create the binaries on my own for a while, if I get too
> >>> many requests, there will be a backlog, so it would be nice to have
> >>> help with that too. I'm also looking for knowledgeable people to be
> >>> sounding boards (i.e. give advice).
> >>> Developers: all I would require is a request, a link to the source,
> >>> and a well-written setup.py file for a cross-platform extension.
> >>> You can find the few that I've already done here:http://
> >>>www.pythonlibrary.org/python_modules.htm
> >>> I have also posted a way to create the binaries using the MinGW
> >>> compiler. I have VS2003 installed on my PC and MinGW is installed in a
> >>> VM, so I can compile the extensions both ways.
> >> Mike, this is great news. Whenever I have time  >> means it sincerely> I'll try to run through some of the modules
> >> you've compiled.
>
> >> As a slight aside, the main problem I've found when I've tried
> >> to build extensions (and I've been doing it recently with AVBin and
> >> Pyglet) is that Windows just doesn't have the build environment, the
> >> directory structures, the env vars and all that that a ./configure or
> >> even a python setup.py install sometimes expects. eg if I were to
> >> offer to build a MySQL extension (as someone who doesn't use MySQL
> >> and wouldn't have the source libs installed if I did) there would
> >> be a fair bit of pain to go through. You've obviously gone through
> >> that pain barrier for at least some of the extensions on the modules
> >> page. Was it tough?
>
> > The hardest part was finding accurate information. Most people on the
> > user groups have been unhelpful or sarcastic. I had better luck
> > contacting developers directly who had already created Windows
> > binaries. They didn't mind giving me some pointers.
>
> Interesting: Python seems to be "growing up" in all kinds of
> ways ...
>
> > The directions for MinGW were usually only partially correct. So I
> > went through the two sets of directions I found (links on the site)
> > and mixed and matched until I got it right.
>
> > There are no directions on how to use Visual Studio 2003 that I've
> > found, just some old free edition. those directions were incompatible
> > with VS2003. I'll post VS2003's correct usage eventually, but it's
> > basically just installing it and then using distutils.
>
> Getting VS2003 ready to compile Python extensions is really easy:
>
> 1. open a command shell
> 2. run vcvars32.bat
> 3. make sure the Python version you are targetting is on the
>PATH
> 4. "python setup.py bdist_wininst" or "python setup.py bdist_msi"
> 5. pick up the installer in the build\ directory.
>


I didn't need to run vcvars32.bat to make mine work. But that's good
to know...I think.


> Note: bdist_msi is only available in Python 2.5 and later.
>
> You need VC6 if you want to compile extensions for Python 1.5-2.3
> and VC7.1 for Python 2.4 and later.
>

I was aware of that you needed VC6 for 2.3, but I didn't realize it
went that far back. And I knew you needed 7.1 for 2.4 and 2.5, but
I've heard that they're moving to VS2005 soon.

Thanks for the feedback, Marc-Andre!

Mike

>
> --
> Marc-Andre Lemburg
> eGenix.com
>

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


Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Paul Boddie
On 9 Nov, 20:43, Frank Samuelson <[EMAIL PROTECTED]>
wrote:
> Carl Banks wrote:
>
> > What you say is correct in principle, but it's senseless to apply it to
> > something you use every day, like def.  It's like arguing that irregular
> > verbs make speech less productive.
>
> They do for people who speak foreign languages.  It's always easier
> for me to remember Spanish verbs that conjugate regularly.   And based
> on the speaking snafus of my French coworker, I would say that it is
> true for her English too!

But where do you seek consistency? It's true that "class" and "def"
both bind names in a namespace, and I either recall or have imagined
bizarre suggestions where "def" would be used for normal assignments,
but is the "inconsistency" really a problem? At some point you still
need to have a special syntactic component which says that, in the
case of a function, some code is going to follow (yes, "lambda" can do
this to an extent already, and people have argued for multi-line
lambdas to no avail), and similar cues are needed for classes. You
can't wipe away the things which provide meaning in the name of
consistency.

> Likewise, consistency helps me remember the syntax of the
> seven or so programming languages that I use regularly.

One can actually make an argument that people using noticeably
different natural languages are less likely to mix them up than people
using more similar languages; perhaps one can make the case for
programming languages too. For example, do people mix up Python and
SQL by accident? Java and C++?

[...]

> > The "defects in productivity"
> > in Python aren't going to be "fixed",
>
> That doesn't sound very promising, though I'm not sure whom you are
> quoting.

I started tracking some of the complaints about Python and comparing
them to Python 3000's supposed remedies. It's interesting reading:

http://wiki.python.org/moin/PythonWarts

Paul

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


Re: private data stashed in local/global execution context of PyEval_EvalCode disappears down the execution stack

2007-11-09 Thread Gabriel Genellina
En Tue, 06 Nov 2007 23:25:17 -0300, <[EMAIL PROTECTED]> escribió:

> i naively created execution context:
> PyObject *execcontext = PyDict_New();
> stuffed a handle in it:
> PyObject *ih = PyCObject_FromVoidPtr(handle, NULL);
> int st= PyDict_SetItemString(res, "interp", ih);

What's `res`?
One should make a lot of assumptions about your code because it's not  
complete. Please post a minimal complete example showing your problem.

-- 
Gabriel Genellina

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


  1   2   >