ANN: munepy 1.3 - yet another Python enumeration package

2007-06-30 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I'm pleased to announce the release of munepy 1.3.  munepy is yet  
another Python enumeration package.  It is compatible with Python 2.4  
and 2.5.  It's not called 'enum' because that's already taken by an  
alternative enum package.  From the README.txt file:

Introduction


This package is called `munepy`.  It is yet another Python enum  
package, but
with a slightly different take on syntax and semantics than earlier such
packages.

The goals of munepy were to produce simple, specific, concise  
semantics in an
easy to read and write syntax.  munepy has just enough of the  
features needed
to make Enums useful, but without a lot of extra baggage to weigh  
them down.
This work grew out of the Mailman 3.0 project and it is the enum  
package used
there.

The name `munepy` is a play on words.  *mune* is *enum* backwards,  
and *py* is
a common suffix for Python code.  *munepy* is pronounced exactly the  
same as
the delicious round chocolaty (if appearance indicates) pastry Moon  
Pie, which
is best when consumed with an RC cola.

Why another Python enum implementation?  'Cause I like mine better. :)

Here's just a small example, from the documentation:

  from munepy import Enum
  class Colors(Enum):
 ... red = 1
 ... green = 2
 ... blue = 3

  print Colors.red
 Colors.red

  Colors.red is Colors.red
 True
  Colors.blue is Colors.blue
 True
  Colors.red is not Colors.blue
 True
  Colors.blue is Colors.red
 False

  int(Colors.red)
 1
  int(Colors.green)
 2
  int(Colors.blue)
 3

Download the package from the Cheeseshop:

http://cheeseshop.python.org/pypi/munepy

The source code is maintained under the Bazaar version control  
system.  You can access the code from here:

https://code.launchpad.net/munepy/

The project home is here:

https://launchpad.net/munepy/

Enjoy,
- -Barry

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)

iQCVAwUBRoaJ3nEjvBPtnXfVAQLOnwQAshlhRB9+xSCeSxST2Qvj5lOmxNrBaAdX
Q7KbnChJxcIajoKTv0eQhT1cyNDmLriLkE0D1Wpv5T47PyXi0Li1D/SXDUvyubN+
mGFAh5KvlhBCzC+lBh31xvoxrGaHQM+3KTn3BmoBaVovsw7xzEzlWx2foAR5HvOz
QjAZEkZFEA0=
=PQu2
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


[ANN] Release 0.64.2 of Task Coach

2007-06-30 Thread Frank Niessink
Hi,

I'm pleased to announce release 0.64.2 of Task Coach. This is a bug
fix release that should fix the following bugs:

* Don't take child task priority into account when sorting by priority
in the task tree view.
* Don't block OS shutdown on Windows.


What is Task Coach?

Task Coach is a simple task manager that allows for hierarchical
tasks, i.e. tasks in tasks. Task Coach is open source (GPL) and is
developed using Python and wxPython. You can download Task Coach from:

http://www.taskcoach.org
https://sourceforge.net/projects/taskcoach/

In addition to the source distribution, packaged distributions are
available for Windows XP, Mac OSX, and Linux (Debian and RPM format).

Note that Task Coach is alpha software, meaning that it is wise to back
up your task file regularly, and especially when upgrading to a new release.

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

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


Re: Python's only one way to do it philosophy isn't good?

2007-06-30 Thread Michele Simionato
On Jun 29, 3:42 pm, Douglas Alan [EMAIL PROTECTED] wrote:
 Michele Simionato [EMAIL PROTECTED] writes:
  I've written plenty of Python code that relied on destructors to
  deallocate resources, and the code always worked.
  You have been lucky:

 No I haven't been lucky -- I just know what I'm doing.



  $ cat deallocating.py
  import logging

  class C(object):
  def __init__(self):
  logging.warn('Allocating resource ...')

  def __del__(self):
  logging.warn('De-allocating resource ...')
  print 'THIS IS NEVER REACHED!'

  if __name__ == '__main__':
  c = C()

  $ python deallocating.py
  WARNING:root:Allocating resource ...
  Exception exceptions.AttributeError: 'NoneType' object has no
  attribute 'warn' in bound method C.__del__ of __main__.C object at
  0xb7b9436c ignored

 Right.  So?  I understand this issue completely and I code
 accordingly.

What does it mean you 'code accordingly'? IMO the only clean way out
of this issue
is to NOT rely on the garbage collector and to manage resource
deallocation
explicitely, not implicitely. Actually I wrote a recipe to help with
this
a couple of months ago and this discussion prompted me to publish it:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/523007
But how would you solve the issue using destructors only? I am just
curious,
I would be happy if there was a simple and *reliable* solution, but I
sort
of doubt it. Hoping to be proven wrong,


Michele Simionato

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


good matlab interface

2007-06-30 Thread felix seltzer

Does any one know of a good matlab interface?
I would just use scipy or numpy, but i also need to use
the matlab neural network functions.  I have tried PyMat, but am having
a hard time getting it to install correctly.

For that mater, a good neural net module for python would
work just as well as a good matlab interface.

Any suggestions?

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

Free usefull article.Do you need contents to add to your web site?

2007-06-30 Thread mostselect
Free usefull article.Do you need contents to add to your web site?
www.real-article.com

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

Close/hide a child window

2007-06-30 Thread Cubells
Hi there:

I have two simple classes in two diferent files:

$ cat first.py

#/usr/bin/env python
# -*- coding: utf-8 -*-

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

import second

class first:

def close_program(self, widget, data=None):
gtk.main_quit()
return False
def open_second(self, widget):
second_window = eval(second.second)(self)

def __init__(self):
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.connect(delete_event, self.close_program)
window.set_title(First)
window.set_border_width(10)
button = gtk.Button(Open)
button.connect(clicked, self.open_second)
window.add(button)
window.show_all()

def main():
gtk.main()
return 0

if __name__ == __main__:
first()   
main()


That's the second one:

$ cat second.py

#/usr/bin/env python
# -*- coding: utf-8 -*-

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

class second(gtk.Window):

def close_second(self,widget):
self.hide()
#self.destroy()
#gtk.main_quit()
return False

def __init__(self, parent=None):
gtk.Window.__init__(self)
try:
self.set_screen(parent.get_screen())
except:
self.connect(destroy, lambda *w: gtk.main_quit())
window2 = gtk.Window(gtk.WINDOW_TOPLEVEL)
window2.set_title(Second)
window2.set_border_width(10)
window2.set_modal(True)
window2.set_resizable(False)
button2 = gtk.Button(Second)
button2.connect(clicked, self.close_second)
window2.add(button2)
window2.show_all()

def main():
gtk.main()
return 0

if __name__ == __main__:
second()   
main()

The question is simple:

How can I close/hide/destroy the second window without to destroy the 
first window when I click the button2??
When I close the second window it works, but when I click the button2 it 
doesn't.

A lot of thanks...


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


Re: overriding base class

2007-06-30 Thread Michele Simionato
On Jun 30, 5:23 am, Carl Banks [EMAIL PROTECTED] wrote:

 Now that I've suggested that, I highly recommend you be sure you're
 very acquainted with new-style objects and method resolution order
 before attempting this.  You need extra care when using MI, even
 though this use of it is rather tame.

 Cark Banks

I would say that the burden on the writer of the hierarchy is not that
much.
The real burder is on the *reader* of the code, which can get easily
confused from where methods are coming. This is way I usually do not
recommend MI: because of the reading and maintenance effort (see for
instance the nightmarish situation in Zope 2). To the OP I would
suggest to
consider containment instead, to consider using proxy objects,
__getattr__ and
other similiar tricks that usually do the job.

Michele Simionato

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


Re: Building a Python app with Mozilla

2007-06-30 Thread Josiah Carlson
Thorsten Kampe wrote:
 Hi,
 
 I've already sent this to the Komodo mailing list (which seemed to me 
 the more appropriate place) but unfortunately I got no response.
 
 I'd like to build a Python GUI app. Neither Tkinter nor Wxpython nor 
 PyQT are actually what I want (because the lack of GUI builders and 
 they don't really look good on Windows and Linux).

You apparently didn't look very hard.  On the wxPython end of things 
(which I have experience with), there is wxGlade, XRCed, Boa 
Constructor, Dabo, etc.  I don't know about Tkinter (I don't use it), 
but I know that at least Qt has a very nice GUI designer and builder 
(from Trolltech if you are willing to pay for it), and if I remember 
correctly, Eric4 offers some tools to make PyQt editing nice and 
friendly.  I'm sure there are others.

As for wxPython applications not looking good on all platforms; I hate 
to break it to you, but the majority of the controls are *native* on 
whatever platform you happen to be using (except for Qt-based frontends 
in *nix, wxPython uses a Gtk binding in *nix).  Take a browse through a 
few of the applications listed in the wiki: 
http://wiki.wxpython.org/wxPythonPit_Apps , or even Andrea Gavana's 
custom widgets http://xoomer.alice.it/infinity77/eng/freeware.html .


 Komodo itself is an excellent example of a - at least Python driven - 
 application that looks superb and has superior functionality so it 
 seems natural to use the Komodo approach for me.

I could have sworn that Komodo was written in PyQt.  Unless my memory is 
failing me (doubtful, as they at least used to offer some PyQt 
development tools), I would imagine they merely embedded the mozilla 
bits and pieces with some C extensions.

In any case, you really don't want to be developing an application using 
XPI.  According to everyone I've ever talked to about XPI, while getting 
the basic stuff working isn't bad, doing anything worth mentioning is 
about as big a pain in the butt than just writing everything in 8088 
assembly.  You mileage may vary of course.


 * Is there a simple How-To how to build a very simple (Python) app 
 with the Mozilla framework? Kind of Hello world...?

Maybe.  Search terms you should use are 'embed XPI python', which give 
me about 189k results in google, some of which seem applicable on the 
first page (which also leads me to believe that my statements regarding 
Komodo embedding mozilla technology may be right, though maybe they 
wrote Komodo in C and Qt).


 * Is is reasonable to think that building a GUI with Mozilla is easier 
 than using Python frameworks because Mozilla does most of the GUI 
 work?

Doubtful.  Building a GUI app with XRCed and wxPython is pretty easy if 
you understand Python and object-oriented programming.  There are some 
annoying vagaries with events, but if you ask your questions on the 
wxpython-users mailing list (over at wxpython.org), one of at least a 
half-dozen people will likely answer your question.


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


Re: Building a Python app with Mozilla

2007-06-30 Thread Diez B. Roggisch
 You apparently didn't look very hard.  On the wxPython end of things 
 (which I have experience with), there is wxGlade, XRCed, Boa 
 Constructor, Dabo, etc.  I don't know about Tkinter (I don't use it), 
 but I know that at least Qt has a very nice GUI designer and builder 
 (from Trolltech if you are willing to pay for it), and if I remember 
 correctly, Eric4 offers some tools to make PyQt editing nice and 
 friendly.  I'm sure there are others.

You're somewhat wrong regarding Qt. The designer is free (I did never 
use a commercial Qt, maybe there comes something additional - but IF I 
don't have the faintest idea what it could do that would make it better 
than the free designer.)

And eric is cool and integrates with Qt (and is an example of a Qt-app 
itself), via launching the designer - but it hasn't have any 
gui-building stuff in there.

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


Re: Building a Python app with Mozilla

2007-06-30 Thread Diez B. Roggisch
Thorsten Kampe schrieb:
 Hi,
 
 I've already sent this to the Komodo mailing list (which seemed to me 
 the more appropriate place) but unfortunately I got no response.
 
 I'd like to build a Python GUI app. Neither Tkinter nor Wxpython nor 
 PyQT are actually what I want (because the lack of GUI builders and 
 they don't really look good on Windows and Linux).

The latter statement is bogus. Qt is THE native look on KDE. GTK for 
Gnome. So how is it not looking good on linux?

And as it has been said in this thread already, Qt has an excellent free 
GUI-builder.

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


Re: ORM layer

2007-06-30 Thread Ben Finney
David [EMAIL PROTECTED] writes:

 I am looking for an ORM for Python that fulfills a few simple needs.

 - ability to support a number of backends (probably mysql and sqlite  
 at present, csv a bonus)
 - ability to be used easily from console python scripts, a bonus if I  
 can add a simple web GUI later using some framework
 - decent documentation a definite plus

I second the recommendation for SQLAlchemy. I've not used Elixir, but
that's a way to abstract SQLAlchemy further, if you want to work at an
even higher level of abstraction.

The documentation for SQLAlchemy is very good, in my experience. The
library allows one to work entirely with the object system (using it
as an ORM), or dynamically build SQL statements, or combine the two
methods.

-- 
 \ I think there is a world market for maybe five computers.  -- |
  `\  Thomas Watson, chairman of IBM, 1943 |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Shed Skin Python-to-C++ Compiler 0.0.21, Help needed

2007-06-30 Thread Luis M . González
On Jun 29, 7:48 am, Mark Dufour [EMAIL PROTECTED] wrote:
 Hi all,

 I have just released version 0.0.22 of Shed Skin, an experimental
 Python-to-C++ compiler. Among other things, it has the exciting new
 feature of being able to generate (simple, for now) extension modules,
 so it's much easier to compile parts of a program and use them (by
 just importing them). Here's the complete changelog:

 -support for generating simple extension modules (linux/windows; see README)
 -dos text format fix (long overdue)
 -improved detection of dynamic types (avoid hanging on them)
 -improved overloading (__nonzero__, __int__, __abs__ etc.)
 -add str(ing).{capitalize, capwords, swapcase, center, ato*)
 -fix string.maketrans
 -several other minor bug fixes

 For more details about Shed Skin and a collection of 27 programs, at a
 total of about 7,000 lines, that it can compile (resulting in an
 average speedup of about 39 times over CPython and 11 times over Psyco
 on my computer), please visit the homepage at:

 http://mark.dufour.googlepages.com

 I could really use some help in pushing Shed Skin forward. Please try
 the latest release and send in bug reports, or join the project via
 the homepage.

 Thanks,
 Mark Dufour.

 On 3/31/07, Mark Dufour [EMAIL PROTECTED] wrote:



  Hi all,

  I have recently released version 0.0.20 and 0.0.21 of Shed Skin, an
  optimizing Python-to-C++ compiler. Shed Skin allows for translation of
  pure (unmodified), implicitly statically typed Python programs into
  optimized C++, and hence, highly optimized machine language. Besides
  many bug fixes and optimizations, these releases add the following
  changes:

  -support for 'bisect', 'collections.deque' and 'string.maketrans'
  -improved 'copy' support
  -support for 'try, else' construction
  -improved error checking for dynamic types
  -printing of floats is now much closer to CPython

  For more details about Shed Skin and a collection of 27 programs, at a
  total of about 7,000 lines, that it can compile (resulting in an
  average speedup of about 39 times over CPython and 11 times over Psyco
  on my computer), please visit the homepage at:

 http://mark.dufour.googlepages.com

  I could really use more help it pushing Shed Skin further. Simple ways
  to help out, but that can save me lots of time, are to find smallish
  code fragments that Shed Skin currently breaks on, and to help
  improve/optimize the (C++) builtins and core libraries. I'm also
  hoping someone else would like to deal with integration with CPython
  (so Shed Skin can generate extension modules, and it becomes easier to
  use 'arbitrary' external CPython modules such as 're' and 'pygame'.)
  Finally, there may be some interesting Master's thesis subjects in
  improving Shed Skin, such as transforming heap allocation into stack-
  and static preallocation, where possible, to bring performance even
  closer to manual C++. Please let me know if you are interested in
  helping out, and/or join the Shed Skin mailing list.

  Thanks!
  Mark Dufour.
  --
  One of my most productive days was throwing away 1000 lines of code
  - Ken Thompson

 Mark Dufour.
 --
 One of my most productive days was throwing away 1000 lines of code
 - Ken Thompson


I love it! This is absolutely fantastic!!!
I can't belive I can write extension modules that easily...
Keep up the good work and thank you!!!

Luis

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


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-30 Thread Paul Rubin
Bruno Desthuilliers [EMAIL PROTECTED] writes:
  [A type system is a] tractable syntactic method for proving the
  absence of certain program behaviors by classifying phrases
  according to the kinds of values they compute. (Pierce 2002).
 
 Is this supposed to contradict my assertion that *static* typing is
 for compilers ?

Yes, the main benefit these days is to prove the absence of certain
types of bugs in the program.

The article What To Know Before Debating Type Systems is pretty
informative (though it doesn't go as far as to call C/C++ untyped):

   http://cdsmith.twu.net/types.html

  C and C++ are basically untyped languages.

 Hem... This assertion is at least debatable. Care to post this on
 c.l.c or c.l.c++, so we get some feedback ?

I wouldn't consider the aficionados of those dinosaur languages to be
authorities on such a question.
-- 
http://mail.python.org/mailman/listinfo/python-list


shelve crashing under Win ME

2007-06-30 Thread gluckj
Hi,

I'm not a Win ME fan myself (I'm a Mac user), but I'm here in Thailand
developing software for special-needs kids, and the test PC in my home
office is a Win ME machine (sigh). So when I ported my Python program
today to the PC, it quickly crashed. Everything seems to work except
for shelve. Using the latest version of Python (2.5.1), when I do the
following in IDLE on the Win ME machine here's the result:

Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC
v.1310 32 bit (Intel)] on win32
IDLE 1.2.1
 import shelve
 f=shelve.open(foo)

Traceback (most recent call last):
  File pyshell#1, line 1, in module
f=shelve.open(foo)
  File C:\PYTHON25\lib\shelve.py, line 225, in open
return DbfilenameShelf(filename, flag, protocol,
writeback)
  File C:\PYTHON25\lib\shelve.py, line 209, in
__init__
Shelf.__init__(self, anydbm.open(filename, flag),
protocol, writeback)
  File C:\PYTHON25\lib\anydbm.py, line 83, in open
return mod.open(file, flag, mode)
  File C:\PYTHON25\lib\dbhash.py, line 16, in open
return bsddb.hashopen(file, flag, mode)
  File C:\PYTHON25\lib\bsddb\__init__.py, line 306,
in hashopen
d.open(file, db.DB_HASH, flags, mode)
DBError: (5, 'Input/output error')


For those who know shelve, this should actually run fine (if the file
foo does not exist it should create it). Printing the value of f
should show an empty dictionary {}.

It does run fine on my iBook (under Python 2.4.4) and on my iBook's
Virtual PC running Win XP  Python 2.5.0. I do not think this is a
Python 2.5.1 problem, because my first attempt to run my program on
the Win ME machine was with a version of the program I ported using
Py2exe on the VPC under Python 2.5.0, and it crashed the same way when
run on the Win ME machine (I subsequently installed Python on the Win
ME PC to try to get to the root of the problem.)

Help! How do I get Win ME (or at least the misbehaving Win ME machine
in my office) to run shelve? (or more specifically run bsddb's
hashopen?)

Or should I trash shelve entirely and rewrite all my code to use a
simpler, homemade database scheme?

Thanks for any advice!

Warmly,
Joel
[EMAIL PROTECTED]

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


Re: ironpython exception line number

2007-06-30 Thread Troels Thomsen

If you're hosting IronPython and catching this from a .NET language
then you'll be catching the .NET exception.

Yes

In that case you can access the original Python exception
from ex.Data[PythonExceptionInfo].

Yes ! YES !
Thx

regards tpt


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


Re: simplifying algebraic expressions

2007-06-30 Thread [EMAIL PROTECTED]

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

 So if someone can point me in the direction of an algebraic expressions
 library that can simplify expression trees and weed out redundancies, that
 would be awesome.

half-joking:

Maxima http://maxima.sourceforge.net/   --- ala os.popen('maxima  ') ... ^_^

The problem with genetic algorithm's, as I understand Stuar Kaufmann, is that
while weeding out redundancies the fitness space becomes more spiky and
therefore harder to search. The optimal solution decays into simple random
guessing in in infinite search space. So, sloppiness and waste is Good - it
helps by creating an area of the fitness space where the creature can move
i.e. adopt/evolve.


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


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-30 Thread Bruno Desthuilliers
Paul Rubin a écrit :
 Bruno Desthuilliers [EMAIL PROTECTED] writes:
 
[A type system is a] tractable syntactic method for proving the
absence of certain program behaviors by classifying phrases
according to the kinds of values they compute. (Pierce 2002).

Is this supposed to contradict my assertion that *static* typing is
for compilers ?
 
 Yes, the main benefit these days is to prove the absence of certain
 types of bugs in the program.

As someone said, if declaring types thrices was enough to ensure 
correctness, I'd happily do so.

I still maintain that the primary *practical* reason behind static 
typing is to provide optimization clues for the compiler. You can (or at 
least could) have declarative static typing with very few type 
*checking* - I may be wrong here but I think one could even write a C 
compiler without *any* type checking. Heck, the programmer said it's a 
char*, so it must be one, right ?-) Of course, no one in it's own mind 
would use such a compiler (if you have to suffer from the restrictions 
imposed by static typing, you want to also profit from it's benefices - 
or at least avoid the possibly dramatic effects of a type error in these 
systems). Also, some (mostly) dynamically typed languages have grown 
type-annotations for the very same reason : hinting the compiler about 
possible optimizations.

wrt/ proofs of correctness, I'll just point to the spectacular failure 
of Ariane, which was caused by a *runtime* type error in a system 
programmed in ADA - one of the languages with the most psychorigid 
declarative static type systems. Not to say these proofs are inexistant, 
just that they are IMHO a bit overvalued - at least wrt/ to my daily 
concerns. Most of the errors I have to deal with are logical errors, not 
type errors, and given the kind of logic (err...) you can find in 
business applications (to make a long story short : it has very few to 
do with mathematics), I have some doubt about what a static type system 
- even a _very_ smart one - could prove here, at least if we hope to 
deliver the application within time and budget constraints (sorry for 
being soo practical here).

 The article What To Know Before Debating Type Systems is pretty
 informative (though it doesn't go as far as to call C/C++ untyped):
 
http://cdsmith.twu.net/types.html

Quote :

Therefore: I give the following general definitions for strong and weak 
typing, at least when used as absolutes:

 * Strong typing: A type system that I like and feel comfortable with
 * Weak typing: A type system that worries me, or makes me feel 
uncomfortable


According to this definition, I herefore declare that Python is strongly 
typed and Java weakly typed !-)

(sorry, couldn't resist).

More seriously, it's indeed an interesting article - even if I do not 
necessarily share all the views of the author - for those not knowing 
anything about type systems. But it's clearly a bit oriented and IMHO 
fails to present the pros of dynamic typing.

BTW, if I may insert another quote, that I think is relevant here as 
well as in another recent thread about 'typed' containers in Python:

I find it amusing when novice programmers believe their main job is 
preventing programs from crashing.  I imagine this spectacular failure 
argument wouldn't be so appealing to such a programmer.  More 
experienced programmers realize that correct code is great, code that 
crashes could use improvement, but incorrect code that doesn't crash is 
a horrible nightmare.


 
C and C++ are basically untyped languages.

Hem... This assertion is at least debatable. Care to post this on
c.l.c or c.l.c++, so we get some feedback ?
  
 I wouldn't consider the aficionados of those dinosaur languages

Hmmm... For a dinausor, C seems well alive. Can you remind me which 
language is used to implement CPython and most of actual operating 
systems and low-level libraries ?

 to be
 authorities on such a question.

If you mean that most them aren't necessarily great CS theorists, then 
you may be right. OTHO, they do have some practical experience with 
these languages, so they might have something to say...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: noob question How do I run a Python script.

2007-06-30 Thread Bruno Desthuilliers
CarlP a écrit :
 How do I run a Python script.

usually, it's:

$ python /path/to/somescript.py arg1 argN

on a command line prompt.

 I have one that gmail loader needs to
 run on my email box. Here's the script
 
 http://www.marklyon.org/gmail/cleanmbox.py
 
 I can't seem to find what I need to run it. I installed python, run
 the interpreter and the script , but all it will do is say invalid
 syntax.

Am I right if I guess you did something like :

[EMAIL PROTECTED] ~ $ python
Python 2.4.3 (#1, Mar 12 2007, 23:32:01)
[GCC 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)] on 
linux2
Type help, copyright, credits or license for more information.
  cleanmbox.py testmbox
   File stdin, line 1
 cleanmbox.py testmbox
 ^
SyntaxError: invalid syntax
 

?-)


FWIW, I ran the script (the correct way) on a copy of a mozilla mbox 
dir, and it seemed to work.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Building a Python app with Mozilla

2007-06-30 Thread Sebastian Wiesner
[ Diez B. Roggisch [EMAIL PROTECTED] ]
 And as it has been said in this thread already, Qt has an excellent free
 GUI-builder.

Free as long as you develop free software. Development of proprietary, 
non-gpl software with Qt requires a commercial licence from Trolltech.

-- 
Freedom is always the freedom of dissenters.
  (Rosa Luxemburg)


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list

linecache and comparison with input

2007-06-30 Thread Ross Hetherington
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Say I've got a file called 'testfile' that contains the following three
lines:

foo
bar
baz

And a script that goes like this:

#!/usr/bin/env python

import random
import sys
import linecache

rnd = random.randint(1,3)
line = linecache.getline('testfile', rnd)

print line

gss = raw_input('Enter line: ',)

if gss == line:
print 'yes'
sys.exit()
else:
print 'no'


Even if the right word is entered, the script always prints `no'. Can
anyone explain why this happens?
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFGhmUm0HlvQApfM3gRCl23AJ45cv7A0KVi2h8/cWmcCrg4X8HZOACfT6V8
IpXAzpD0jKnFFDEJEmOFvc4=
=UA5b
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: linecache and comparison with input

2007-06-30 Thread Sebastian Wiesner
[ Ross Hetherington [EMAIL PROTECTED] ]
 #!/usr/bin/env python

 import random
 import sys
 import linecache

 rnd = random.randint(1,3)
 line = linecache.getline('testfile', rnd)

 print line
Try print repr(line) ...

 gss = raw_input('Enter line: ',)
and print repr(gss) ;)

 if gss == line:
 print 'yes'
 sys.exit()
 else:
 print 'no'


Then you will see, that getline returns the line *including the newline 
character*, while raw_input does not.  Use line.strip('\n') to remove 
trailing newline characters from the return value of getline.

-- 
Freedom is always the freedom of dissenters.
  (Rosa Luxemburg)


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: linecache and comparison with input

2007-06-30 Thread Ross Hetherington
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Sebastian Wiesner wrote:
 Then you will see, that getline returns the line *including the newline 
 character*, while raw_input does not.  Use line.strip('\n') to remove 
 trailing newline characters from the return value of getline.

Ah, thank you. I did notice that getline left a trailing newline, but I
didn't realise raw_input didn't. Ooops.

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFGhml20HlvQApfM3gRCozzAJ0QAENDkQn8StlEr9Mh0yoCCkUhzQCcCmOC
5tPusqS4MwnisNLZmtKc3Y4=
=hlHr
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-30 Thread Eduardo \EdCrypt\ O. Padoan
On 6/30/07, Bruno Desthuilliers [EMAIL PROTECTED] wrote:
 Eduardo EdCrypt O. Padoan a écrit :
  Remember that pure CPython has no different compile time and
  runtiime.

 Oh yes ? So what's the compiler doing, and what are those .pyc files ?
 (hint: read the doc)

Sorry, I surely know that Python has a compile time, I wanted to say
somthing like compile time checks except from syntax. My intention
was to show that a *huge* change in the Python interpretation model
would be needed to allow what he wanted, but I finished my email too
early :P
And yes, I readed the docs :)

-- 
EduardoOPadoan (eopadoan-altavix::com)
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Building a Python app with Mozilla

2007-06-30 Thread Kevin Walzer
Thorsten Kampe wrote:
 Hi,
 
 I've already sent this to the Komodo mailing list (which seemed to me 
 the more appropriate place) but unfortunately I got no response.
 
 I'd like to build a Python GUI app. Neither Tkinter nor Wxpython nor 
 PyQT are actually what I want (because the lack of GUI builders and 
 they don't really look good on Windows and Linux).
 
 Komodo itself is an excellent example of a - at least Python driven - 
 application that looks superb and has superior functionality so it 
 seems natural to use the Komodo approach for me.
 

Komodo is not a Python application. It is a Mozilla application that 
supports Python development. Komodo is more akin to Thunderbird and 
Firefox than anything else; it uses the XUL framework for rendering 
widgets, if I'm not mistaken. If you want to build an application like 
Komodo, get a book on developing with the Mozilla framework (XUL, XPCOM, 
and all that) and look at that. Python has little to do with that.

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-30 Thread Alex Martelli
Bruno Desthuilliers [EMAIL PROTECTED] wrote:
   ...
 I still maintain that the primary *practical* reason behind static 
 typing is to provide optimization clues for the compiler. You can (or at

It's definitely a helpful aspect, yes -- given that compilers able to
infer types are still not very common for widely used languages; also,
complete type checking or inference requires analysis of the whole
program, which may be quite impractical -- and stops what Van Roy and
Haridi, in their masterpiece Concepts, Techniques and Models of
Computer Programming, call totally open programming.  Quoting a post
of mine from 2004:

I love the explanations of Van Roy and Haridi, p. 104-106 of their book,
though I may or may not agree with their conclusions (which are 
basically that the intrinsic difference is tiny -- they point to Oz and
Alice as interoperable languages without and with static typing, 
respectively), all the points they make are good.  Most importantly, I 
believe, the way dynamic typing allows real modularity (harder with 
static typing, since type discipline must be enforced across module 
boundaries), and exploratory computing in a computation model that 
integrates several programming paradigms. 

Dynamic typing is recommended, they conclude, when programs must be 
as flexible as possible.  I recommend reading the Agile Manifesto to 
understand why maximal flexibility is crucial in most real-world 
application programming -- and therefore why, in said real world rather
than in the more academic circles Dr. Van Roy and Dr. Hadidi move in, 
dynamic typing is generally preferable, and not such a tiny issue as 
they make the difference to be.  Still, they at least show more 
awareness of the issues, in devoting 3 excellent pages of discussion 
about it, pros and cons, than almost any other book I've seen -- most 
books have clearly delineated and preformed precedence one way or the 
other, so the discussion is rarely as balanced as that;). 


 least could) have declarative static typing with very few type 
 *checking* - I may be wrong here but I think one could even write a C
 compiler without *any* type checking. Heck, the programmer said it's a
 char*, so it must be one, right ?-)

That compiler, I believe, would violate the ISO standard for C (so
calling it a C compiler would be about as correct as calling it a
banana, in my view:-).

 wrt/ proofs of correctness, I'll just point to the spectacular failure
 of Ariane, which was caused by a *runtime* type error in a system 

I like a quote by Knuth -- beware this program may have bugs as I have
only proven it and not tested it:-)

 Hmmm... For a dinausor, C seems well alive. Can you remind me which 

So do chickens.


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


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-30 Thread Bruno Desthuilliers
Alex Martelli a écrit :
 Bruno Desthuilliers [EMAIL PROTECTED] wrote:
...
 
I still maintain that the primary *practical* reason behind static 
typing is to provide optimization clues for the compiler. You can (or at
 
 
 It's definitely a helpful aspect, yes -- given that compilers able to
 infer types are still not very common for widely used languages;

or given that languages using a type-inferenced based system are not 
very widely used...

(snip)

least could) have declarative static typing with very few type 
*checking* - I may be wrong here but I think one could even write a C
compiler without *any* type checking. Heck, the programmer said it's a
char*, so it must be one, right ?-)
 
 
 That compiler, I believe, would violate the ISO standard for C (so
 calling it a C compiler would be about as correct as calling it a
 banana, in my view:-).

Lol. That being said, there were bananas - oops, I meant C compilers - 
before the standard existed !-)

 
wrt/ proofs of correctness, I'll just point to the spectacular failure
of Ariane, which was caused by a *runtime* type error in a system 
 
 
 I like a quote by Knuth -- beware this program may have bugs as I have
 only proven it and not tested it:-)

Yeps.

 
Hmmm... For a dinausor, C seems well alive. Can you remind me which 
  
 So do chickens.
 
I'm afraid I didn't get the joke... Are you saying that C is a rather, 
well, primitive language ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Building a Python app with Mozilla

2007-06-30 Thread Diez B. Roggisch
Sebastian Wiesner schrieb:
 [ Diez B. Roggisch [EMAIL PROTECTED] ]
 And as it has been said in this thread already, Qt has an excellent free
 GUI-builder.
 
 Free as long as you develop free software. Development of proprietary, 
 non-gpl software with Qt requires a commercial licence from Trolltech.

The OP did debuke Qt because of a lack of a gui-builder, not because of 
it's licensing.

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


Re: Python Memory Usage

2007-06-30 Thread malkarouri
On Jun 20, 4:48 am, [EMAIL PROTECTED] [EMAIL PROTECTED]
wrote:
 I am using Python to process particle data from a physics simulation.
 There are about 15 MB of data associated with each simulation, but
 there are many simulations.  I read the data from each simulation into
 Numpy arrays and do a simple calculation on them that involves a few
 eigenvalues of small matricies and quite a number of temporary
 arrays.  I had assumed that that generating lots of temporary arrays
 would make my program run slowly, but I didn't think that it would
 cause the program to consume all of the computer's memory, because I'm
 only dealing with 10-20 MB at a time.

 So, I have a function that reliably increases the virtual memory usage
 by ~40 MB each time it's run.  I'm measuring memory usage by looking
 at the VmSize and VmRSS lines in the /proc/[pid]/status file on an
 Ubuntu (edgy) system.  This seems strange because I only have 15 MB of
 data.

 I started looking at the difference between what gc.get_objects()
 returns before and after my function.  I expected to see zillions of
 temporary Numpy arrays that I was somehow unintentionally maintaining
 references to.  However, I found that only 27 additional objects  were
 in the list that comes from get_objects(), and all of them look
 small.  A few strings, a few small tuples, a few small dicts, and a
 Frame object.

 I also found a tool called heapy (http://guppy-pe.sourceforge.net/)
 which seems to be able to give useful information about memory usage
 in Python.  This seemed to confirm what I found from manual
 inspection: only a few new objects are allocated by my function, and
 they're small.

 I found Evan Jones article about the Python 2.4 memory allocator never
 freeing memory in certain circumstances:  
 http://evanjones.ca/python-memory.html.
 This sounds a lot like what's happening to me.  However, his patch was
 applied in Python 2.5 and I'm using Python 2.5.  Nevertheless, it
 looks an awful lot like Python doesn't think it's holding on to the
 memory, but doesn't give it back to the operating system, either.  Nor
 does Python reuse the memory, since each successive call to my
 function consumes an additional 40 MB.  This continues until finally
 the VM usage is gigabytes and I get a MemoryException.

 I'm using Python 2.5 on an Ubuntu edgy box, and numpy 1.0.3.  I'm also
 using a few routines from scipy 0.5.2, but for this part of the code
 it's just the eigenvalue routines.

 It seems that the standard advice when someone has a bit of Python
 code that progressively consumes all memory is to fork a process.  I
 guess that's not the worst thing in the world, but it certainly is
 annoying.  Given that others seem to have had this problem, is there a
 slick package to do this?  I envision:
 value = call_in_separate_process(my_func, my_args)

 Suggestions about how to proceed are welcome.  Ideally I'd like to
 know why this is going on and fix it.  Short of that workarounds that
 are more clever than the separate process one are also welcome.

 Thanks,
 Greg

I had almost the same problem. Will this do?

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/511474

Any comments are welcome (I wrote the recipe with Pythonistas' help).

Regards,
Muhammad Alkarouri

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


Re: shelve crashing under Win ME

2007-06-30 Thread jim-on-linux
On Saturday 30 June 2007 04:52, [EMAIL PROTECTED] 
wrote:
 Hi,

 I'm not a Win ME fan myself (I'm a Mac user),
 but I'm here in Thailand developing software
 for special-needs kids, and the test PC in my
 home office is a Win ME machine (sigh). So when
 I ported my Python program today to the PC, it
 quickly crashed. Everything seems to work
 except for shelve. Using the latest version of
 Python (2.5.1), when I do the following in IDLE
 on the Win ME machine here's the result:

 Python 2.5.1 (r251:54863, Apr 18 2007,
 08:51:08) [MSC v.1310 32 bit (Intel)] on win32
 IDLE 1.2.1

  import shelve
  f=shelve.open(foo)

 Traceback (most recent call last):
   File pyshell#1, line 1, in module
 f=shelve.open(foo)
   File C:\PYTHON25\lib\shelve.py, line 225,
 in open return DbfilenameShelf(filename, flag,
 protocol, writeback)
   File C:\PYTHON25\lib\shelve.py, line 209,
 in __init__
 Shelf.__init__(self, anydbm.open(filename,
 flag), protocol, writeback)
   File C:\PYTHON25\lib\anydbm.py, line 83, in
 open return mod.open(file, flag, mode)
   File C:\PYTHON25\lib\dbhash.py, line 16, in
 open return bsddb.hashopen(file, flag, mode)
 File C:\PYTHON25\lib\bsddb\__init__.py, line
 306, in hashopen
 d.open(file, db.DB_HASH, flags, mode)
 DBError: (5, 'Input/output error')


 For those who know shelve, this should actually
 run fine (if the file foo does not exist it
 should create it). Printing the value of f
 should show an empty dictionary {}.

 It does run fine on my iBook (under Python
 2.4.4) and on my iBook's Virtual PC running Win
 XP  Python 2.5.0. I do not think this is a
 Python 2.5.1 problem, because my first attempt
 to run my program on the Win ME machine was
 with a version of the program I ported using
 Py2exe on the VPC under Python 2.5.0, and it
 crashed the same way when run on the Win ME
 machine (I subsequently installed Python on the
 Win ME PC to try to get to the root of the
 problem.)

 Help! How do I get Win ME (or at least the
 misbehaving Win ME machine in my office) to run
 shelve? (or more specifically run bsddb's
 hashopen?)

 Or should I trash shelve entirely and rewrite
 all my code to use a simpler, homemade database
 scheme?

 Thanks for any advice!

 Warmly,
 Joel
 [EMAIL PROTECTED]

what version of py2exe are you using?

I had a similar problem with an old version of 
py2exe but it it is fixed now.  If my memory is 
correct I had to import dbhash into my setup for 
py2exe back then to fix it.. 

Your code for shelve is correct, the problem is 
someplace else.


jim-on-linux
http:\\www.inqvista.com


 







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


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-30 Thread Diez B. Roggisch
 
 wrt/ proofs of correctness, I'll just point to the spectacular failure 
 of Ariane, which was caused by a *runtime* type error in a system 
 programmed in ADA - one of the languages with the most psychorigid 
 declarative static type systems.

That's simply not true. The problem hadn't to do with typing - it was a 
overflow due to larger input quantities. It had been shown for the 
Ariane 4 that this overrun could never happen - by whatever thechnique, 
operational or denotational semanticse, I don't know.

For the ariane 5, these input constraints didn't hold, which caused the 
unexpected runtime error to occur.

But there is _no_ type-error here! The programmers might have chosen a 
different type with larger range, sure. But to say that's a type error 
is as saying using a string where a tuple of int and string were better 
is a type error. It's another path of implementation.

Or from a testing angle: if the unit tests did only produce input values 
to a certain quantity, the results were ok. Nobody thought about writing 
new tests with larger quantities - the same way nobody thought about 
proving the program with those same quantities.

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


Re: Building a Python app with Mozilla

2007-06-30 Thread Sebastian Wiesner
[ Diez B. Roggisch [EMAIL PROTECTED] ]
  I'd like to build a Python GUI app. Neither Tkinter nor Wxpython nor
  PyQT are actually what I want (because the lack of GUI builders and
  they don't really look good on Windows and Linux).

 The latter statement is bogus. Qt is THE native look on KDE. GTK for
 Gnome. So how is it not looking good on linux?

I guess, not looking good on linux refers to Tkinter, which is in fact 
really ugly on linux systems.

 And as it has been said in this thread already, Qt has an excellent free
 GUI-builder. 

So have Gtk and WxWidgets.

-- 
Freedom is always the freedom of dissenters.
  (Rosa Luxemburg)


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: shelve crashing under Win ME

2007-06-30 Thread jim-on-linux
On Saturday 30 June 2007 10:07, jim-on-linux 
wrote:
 On Saturday 30 June 2007 04:52,
 [EMAIL PROTECTED]

 wrote:
  Hi,
 
  I'm not a Win ME fan myself (I'm a Mac user),
  but I'm here in Thailand developing software
  for special-needs kids, and the test PC in my
  home office is a Win ME machine (sigh). So
  when I ported my Python program today to the
  PC, it quickly crashed. Everything seems to
  work except for shelve. Using the latest
  version of Python (2.5.1), when I do the
  following in IDLE on the Win ME machine
  here's the result:
 
  Python 2.5.1 (r251:54863, Apr 18 2007,
  08:51:08) [MSC v.1310 32 bit (Intel)] on
  win32 IDLE 1.2.1
 
   import shelve
   f=shelve.open(foo)
 
  Traceback (most recent call last):
File pyshell#1, line 1, in module
  f=shelve.open(foo)
File C:\PYTHON25\lib\shelve.py, line 225,
  in open return DbfilenameShelf(filename,
  flag, protocol, writeback)
File C:\PYTHON25\lib\shelve.py, line 209,
  in __init__
  Shelf.__init__(self,
  anydbm.open(filename, flag), protocol,
  writeback)
File C:\PYTHON25\lib\anydbm.py, line 83,
  in open return mod.open(file, flag, mode)
  File C:\PYTHON25\lib\dbhash.py, line 16, in
  open return bsddb.hashopen(file, flag, mode)
  File C:\PYTHON25\lib\bsddb\__init__.py,
  line 306, in hashopen
  d.open(file, db.DB_HASH, flags, mode)
  DBError: (5, 'Input/output error')
 
 
  For those who know shelve, this should
  actually run fine (if the file foo does not
  exist it should create it). Printing the
  value of f should show an empty dictionary
  {}.
 
  It does run fine on my iBook (under Python
  2.4.4) and on my iBook's Virtual PC running
  Win XP  Python 2.5.0. I do not think this is
  a Python 2.5.1 problem, because my first
  attempt to run my program on the Win ME
  machine was with a version of the program I
  ported using Py2exe on the VPC under Python
  2.5.0, and it crashed the same way when run
  on the Win ME machine (I subsequently
  installed Python on the Win ME PC to try to
  get to the root of the problem.)
 
  Help! How do I get Win ME (or at least the
  misbehaving Win ME machine in my office) to
  run shelve? (or more specifically run bsddb's
  hashopen?)
 
  Or should I trash shelve entirely and rewrite
  all my code to use a simpler, homemade
  database scheme?
 
  Thanks for any advice!
 
  Warmly,
  Joel
  [EMAIL PROTECTED]

 what version of py2exe are you using?

 I had a similar problem with an old version of
 py2exe but it it is fixed now.  If my memory is
 correct I had to import dbhash into my setup
 for py2exe back then to fix it..

 Your code for shelve is correct, the problem is
 someplace else.


 jim-on-linux
 http:\\www.inqvista.com


Correction:

I had to import dbhash into my program to make 
things work. 

jim-on-linux
http:\\www.inqvista.com




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


Re: How do I remotely access Scheduled Tasks from Windows XP to Windows Server 2003?

2007-06-30 Thread Roger Upole

kj7ny wrote:
 How can I access and manipulate Scheduled Tasks in Windows using
 Python?

 I have a Windows XP workstation running Python 2.4.4 using the
 win32all modules to control the windows services on multiple Windows
 2003 servers.  It works great.

 However, I also need to remotely collect the settings for the
 scheduled tasks (on those same Windows 2003 servers) and then
 manipulate those task settings.

 At the very least, I need to find out which ones are enabled and then
 be able to disable and re-enable those tasks at will.  It would be
 better to be able to also detect the account each task runs as so that
 I could only disable selected tasks, but I'll any help I can get.

 Thanks,


Pywin32 comes with a module that lets you do this, win32com.taskscheduler.
You can use PyITaskScheduler.SetTargetComputer to access tasks on remote
machines.

   Roger






== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 100,000 
Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's only one way to do it philosophy isn't good?

2007-06-30 Thread Douglas Alan
Paul Rubin http://[EMAIL PROTECTED] writes:

 Douglas Alan [EMAIL PROTECTED] writes:

 But that's a library issue, not a language issue.  The technology
 exists completely within Lisp to accomplish these things, and most
 Lisp programmers even know how to do this, as application frameworks
 in Lisp often do this kind.  The problem is getting anything put into
 the standard.  Standardizing committees just suck.

 Lisp is just moribund, is all.  Haskell has a standardizing committee
 and yet there are lots of implementations taking the language in new
 and interesting directions all the time.  The most useful extensions
 become de facto standards and then they make it into the real
 standard.

You only say this because you are not aware of all the cool dialetcs
of Lisp that are invented.  The problem is that they rarely leave the
tiny community that uses them, because each community comes up with
it's own different cool dialect of Lisp.  So, clearly the issue is not
one of any lack of motivation or people working on Lisp innovations --
it's getting them to sit down together and agree on a standard.

This, of course is a serious problem.  One that is very similar to the
problem with Python vs. Ruby on Rails.  It's not the problem that you are
ascribing to Lisp, however.

|oug

P.S. Besides Haskell is basically a refinement of ML, which is a
dialect of Lisp.

P.P.S. I doubt that any day soon any purely (or even mostly)
functional language is going to gain any sort of popularity outside of
academia.  Maybe 20 years from now, they will, but I wouldn't bet on
it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's only one way to do it philosophy isn't good?

2007-06-30 Thread Paul Rubin
Douglas Alan [EMAIL PROTECTED] writes:
 P.S. Besides Haskell is basically a refinement of ML, which is a
 dialect of Lisp.

I'd say Haskell and ML are descended from Lisp, just like mammals are
descended from fish.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's only one way to do it philosophy isn't good?

2007-06-30 Thread Douglas Alan
Michele Simionato [EMAIL PROTECTED] writes:

 Right.  So?  I understand this issue completely and I code
 accordingly.

 What does it mean you 'code accordingly'? IMO the only clean way out
 of this issue is to NOT rely on the garbage collector and to manage
 resource deallocation explicitely, not implicitely.

(1) I don't rely on the refcounter for resources that ABSOLUTELY,
POSITIVELY must be freed before the scope is left.  In the code that
I've worked on, only a small fraction of resources would fall into
this category.  Open files, for instance, rarely do.  For open files,
in fact, I actually want access to them in the traceback for debugging
purposes, so closing them using with would be the opposite of what I
want.

(2) I don't squirrel away references to tracebacks.

(3) If a procedure catches an exception but isn't going to return
quickly, I clear the exception.

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


Re: Python's only one way to do it philosophy isn't good?

2007-06-30 Thread Douglas Alan
Paul Rubin http://[EMAIL PROTECTED] writes:

 Douglas Alan [EMAIL PROTECTED] writes:

 P.S. Besides Haskell is basically a refinement of ML, which is a
 dialect of Lisp.

 I'd say Haskell and ML are descended from Lisp, just like mammals are
 descended from fish.

Hardly -- they all want to share the elegance of lambda calculus,
n'est-ce pas?  Also, ML was originally implemented in Lisp, and IIRC
correctly, at least in early versions, shared much of Lisp's syntax.

Also, Scheme has a purely functional core (few people stick to it, of
course), and there are purely functional dialects of Lisp.

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


Reading image dimensions before it is loaded from a web form using python.

2007-06-30 Thread Norman Khine
Hello,
I am writing an application using python that allows the user to upload
an image to a folder on the server.

Is there a way to get the size of the file before it has been uploaded
onto the server and give an error if the size does not comply to the
maximum size.

So far, my apps loads the image and checks it and then returns an error
if the image is too big.  Which is a bit pointless in that I should be
able to get the file info before it is loaded, but I am not sure where
to go.

PIL reads the image size before it is loaded, but this is when I run
this on my local machine. There is also a post
http://mail.python.org/pipermail/python-list/2005-May/323018.html by
Will McGugan where he loads 1px and rejects it if its too big. But his
apps is an image scraper, so I suppose it fits his use case where he
checks the size and then pulls the image if it fits.

Anyone with ideas on how to deal with this.

Thanks

Norman

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


Re: Python's only one way to do it philosophy isn't good?

2007-06-30 Thread Paul Rubin
Douglas Alan [EMAIL PROTECTED] writes:
  I'd say Haskell and ML are descended from Lisp, just like mammals are
  descended from fish.
 
 Hardly -- they all want to share the elegance of lambda calculus,
 n'est-ce pas?  Also, ML was originally implemented in Lisp, and IIRC
 correctly, at least in early versions, shared much of Lisp's syntax.

Haskell and ML are both evaluate typed lambda calculus unlike Lisp
which is based on untyped lambda calculus.  Certainly the most
familiar features of Lisp (dynamic typing, S-expression syntax,
programs as data (Lisp's macro system results from this)) are absent
from Haskell and ML.  Haskell's type system lets it do stuff that
Lisp can't approach.  I'm reserving judgement about whether Haskell is
really practical for application development, but it can do stuff that
no traditional Lisp can (e.g. its concurrency and parallelism stuff,
with correctness enforced by the type system).  It makes it pretty
clear that Lisp has become Blub.

ML's original implementation language is completely irrelevant; after
all Python is still implemented in C.

 Also, Scheme has a purely functional core (few people stick to it, of
 course), and there are purely functional dialects of Lisp.

Scheme has never been purely functional.  It has had mutation since
the beginning.

Hedgehog Lisp (purely functional, doesn't have setq etc.) is really
cute.  I almost used it in an embedded project but that got cancelled
too early.  It seems to me more like a poor man's Erlang though, than
anything resemblant to ML.
-- 
http://mail.python.org/mailman/listinfo/python-list


trouble with sqlite under debian etch

2007-06-30 Thread Rustom Mody
I was trying to follow the sqlalchemy tutorial on my debian etch box
and got stuck with installation.  Any help/pointers will be welcome.

First after installing sqlalchemy needed some sqlite package
synaptic showed me packages python-pysqlite, python-pysqlite1.1 and
python-pysqlite2.

Theres some confusion regarding numbers: python-pysqlite2 is for
sqlite3 or some such thing

Tried python-pysqlite1.1 and got errors. Tried 2 and got version warnings.

Downloaded the tgz and did a setup build followed by a setup install

Now the
 db = create_engine('sqlite:///tutorial.db')
gives me no module _sqlite
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's only one way to do it philosophy isn't good?

2007-06-30 Thread Douglas Alan
Paul Rubin http://[EMAIL PROTECTED] writes:

 Haskell and ML are both evaluate typed lambda calculus unlike Lisp
 which is based on untyped lambda calculus.  Certainly the most
 familiar features of Lisp (dynamic typing, S-expression syntax,
 programs as data (Lisp's macro system results from this)) are absent
 from Haskell and ML.

And that is supposed to make them better and more flexible???  The
ideal language of the future will have *optional* manifest typing
along with type-inference, and will have some sort of pramgma to turn
on warnings when variables are forced to become dynamic due to there
not being enough type information to infer the type.  But it will
still allow programming with dynamic typing when that is necessary.

The last time I looked at Haskell, it was still in the stage of being
a language that only an academic could love.  Though, it was certainly
interesting.

 Haskell's type system lets it do stuff that Lisp can't approach.

What kind of stuff?  Compile-time polymorphism is cool for efficiency
and type safety, but doesn't actually provide you with any extra
functionality that I'm aware of.

 I'm reserving judgement about whether Haskell is really practical
 for application development, but it can do stuff that no traditional
 Lisp can (e.g. its concurrency and parallelism stuff, with
 correctness enforced by the type system).  It makes it pretty clear
 that Lisp has become Blub.

Where do you get this idea that the Lisp world does not get such
things as parallelism?  StarLisp was designed for the Connection
Machine by Thinking Machines themselves.  The Connection Machine was
one of the most parallel machines ever designed.  Alas, it was ahead of
it's time.

Also, I know a research scientist at CSAIL at MIT who has designed and
implemented a version of Lisp for doing audio and video art.  It was
designed from the ground-up to deal with realtime audio and video
streams as first class objects.  It's actually pretty incredible -- in
just a few lines of code, you can set up a program that displays the
same video multiplied and tiled into a large grid of little videos
tiles, but where a different filter or delay is applied to each tile.
This allows for some stunningly strange and interesting video output.
Similar things can be done in the language with music (though if you
did that particular experiment it would probably just sound
cacophonous).

Does that sound like an understanding of concurrency to you?  Yes, I
thought so.

Also, Dylan has optional manifests types and type inference, so the
Lisp community understands some of the benefits of static typing.
(Even MacLisp had optional manifest types, but they weren't  there for
safety, but rather for performance.  Using them, you could get Fortran
level of performance out of Lisp, which was quite a feat at the time.)

 ML's original implementation language is completely irrelevant;
 after all Python is still implemented in C.

Except that in the case of ML, it was mostly just a thin veneer on
Lisp that added a typing system and type inference.

 Also, Scheme has a purely functional core (few people stick to it, of
 course), and there are purely functional dialects of Lisp.

 Scheme has never been purely functional.  It has had mutation since
 the beginning.

I never said that was purely functional -- I said that it has a purely
functional core.  I.e., all the functions that have side effects have
and ! on their ends (or at least they did when I learned the
language), and there are styles of programming in Scheme that
discourage using any of those functions.

|oug

P.S.  The last time I took a language class (about five or six years
ago), the most interesting languages I thought were descended from
Self, not any functional language.  (And Self, of course is descended
from Smalltalk, which is descended from Lisp.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's only one way to do it philosophy isn't good?

2007-06-30 Thread Douglas Alan
Lenard Lindstrom [EMAIL PROTECTED] writes:

 Explicitly clear the exception? With sys.exc_clear?

Yes.  Is there a problem with that?

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


Re: win32event.WaitForInputIdle() returns too soon

2007-06-30 Thread Hans

[EMAIL PROTECTED] schreef in bericht 
news:[EMAIL PROTECTED]
On Jun 29, 3:03 pm, Hans [EMAIL PROTECTED] wrote:
 Gabriel Genellina [EMAIL PROTECTED] schreef in 
 berichtnews:[EMAIL PROTECTED]



  En Thu, 28 Jun 2007 19:15:40 -0300, Hans [EMAIL PROTECTED] escribió:

  I'm sending keyboard and mouse events to a seperate windows 
  application.
  I use win32event.WaitForInputIdle() before calling e.g.
  win32api.keybd_event()
  However it seems that WaitForInputIdle() returns too soon because some
  of my
  events get lost. Now I'v created my own  WaitForInputIdle() which calls

  From the Microsoft docs for WaitForInputIdle: The WaitForInputIdle
  function only works with GUI applications. If a console application 
  calls
  the function, it returns immediately, with no wait.
  A typical Python script is a console application.

  --
  Gabriel Genellina

 It would explain my problem.
 Perhaps I could create a small windows application as interface..
 I have to think about it ( and wait, as I currently don't have access to
 visual C++, nor the MS documentation)

 Thanks,
 Hans

: Who says you have to create it with Visual C++? You could use Tkinter
: or wxPython. Both are pretty easy to pick up and can look professional
: with a little work.

: Mike


Nobody.
However, yesterday I tried wrapping my piece of offending code into a very 
simple Tkinter application.
Alas, the problem wasn't solved. WaitForInputIdle() returns too soon
(unless I don't understand WaitForInputIdle(), which is actually a Microsoft 
call.
Therefore using Visual Studio is sometimes handier: doc available and most 
compatible with Microsoft's quirks)

Any other suggestions are welcome.

Cheers, Hans


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

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-30 Thread Bruno Desthuilliers
Diez B. Roggisch a écrit :

 wrt/ proofs of correctness, I'll just point to the spectacular failure 
 of Ariane, which was caused by a *runtime* type error in a system 
 programmed in ADA - one of the languages with the most psychorigid 
 declarative static type systems.
 
 
 That's simply not true. The problem hadn't to do with typing - it was a 
 overflow due to larger input quantities.

cf below.

 It had been shown for the 
 Ariane 4 that this overrun could never happen - by whatever thechnique, 
 operational or denotational semanticse, I don't know.

IIRC it was in the specs.

 For the ariane 5, these input constraints didn't hold, which caused the 
 unexpected runtime error to occur.


Because of the different flight path, a data conversion from a 64-bit 
floating point to 16-bit signed integer value caused a hardware 
exception (more specifically, an arithmetic overflow, as the floating 
point number had a value too large to be represented by a 16-bit signed 
integer).


As far as I'm concerned, it surely qualifies as a runtime type error - 
data conversion from a floating point to a 16-bit signed int should 
not be allowed when unsafe, isn't it ?


Efficiency considerations had led to the disabling of the software 
handler (in Ada code) for this error trap.


Which implies that even in ADA, runtime type errors are in fact expected 
- else there would be no handler for such a case.

The root of the problem is - of course - not technical but human. As you 
said, no one cared to write the appropriate unit tests to ensure this 
module - specified for Ariane 4 - could be reused 'as is' for Ariane 5. 
But what, how could an ADA module not be correct if it compiles - the 
ADA type system is here to prove the absence of certain bugs, isn't it ?-)

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


Re: win32event.WaitForInputIdle() returns too soon

2007-06-30 Thread Hans

Gabriel Genellina [EMAIL PROTECTED] schreef in bericht 
news:[EMAIL PROTECTED]
 En Thu, 28 Jun 2007 19:15:40 -0300, Hans [EMAIL PROTECTED] escribió:

 I'm sending keyboard and mouse events to a seperate windows application.
 I use win32event.WaitForInputIdle() before calling e.g.
 win32api.keybd_event()
 However it seems that WaitForInputIdle() returns too soon because some 
 of my
 events get lost. Now I'v created my own  WaitForInputIdle() which calls

 From the Microsoft docs for WaitForInputIdle: The WaitForInputIdle 
 function only works with GUI applications. If a console application calls 
 the function, it returns immediately, with no wait.
 A typical Python script is a console application.

 -- 
 Gabriel Genellina

Well, this is weird. I searched for doc on the internet and that description 
differs:
The process you're waiting for needs bo have a message queue (it does in my 
case), not the process that calls WaitForInputIdle.
Hans

Waits until the specified process is waiting for user input with no input 
pending, or until the time-out interval has elapsed.

DWORD WINAPI WaitForInputIdle(
  HANDLE hProcess,
  DWORD dwMilliseconds
);
Parameters
  hProcess
  [in] A handle to the process. If this process is a console application or 
does not have a message queue, WaitForInputIdle returns immediately.
  dwMilliseconds
  [in] The time-out interval, in milliseconds. If dwMilliseconds is 
INFINITE, the function does not return until the process is idle.



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

Re: Python's only one way to do it philosophy isn't good?

2007-06-30 Thread Douglas Alan
I wrote:

 P.S.  The last time I took a language class (about five or six years
 ago), the most interesting languages I thought were descended from
 Self, not any functional language.  (And Self, of course is descended
 from Smalltalk, which is descended from Lisp.)

I think that Cecil is the particular language that I was most thinking
of:

   http://en.wikipedia.org/wiki/Cecil_programming_language

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


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-30 Thread Paddy
On Jun 30, 8:30 pm, Bruno Desthuilliers
[EMAIL PROTECTED] wrote:
 Paul Rubin a écrit :

  Bruno Desthuilliers [EMAIL PROTECTED] writes:

 [A type system is a] tractable syntactic method for proving the
 absence of certain program behaviors by classifying phrases
 according to the kinds of values they compute. (Pierce 2002).

 Is this supposed to contradict my assertion that *static* typing is
 for compilers ?

  Yes, the main benefit these days is to prove the absence of certain
  types of bugs in the program.

 As someone said, if declaring types thrices was enough to ensure
 correctness, I'd happily do so.

 I still maintain that the primary *practical* reason behind static
 typing is to provide optimization clues for the compiler.

The primary *practical* reason for static typing is that it allows
large software companies to convince customers that they have *the*
method to allow them to apply divide  conquer techniques to solve
their problems with a large team of programmers and justifying
large fees.

How many of those cancelled UK government software projects that
cost me hundreds of millions of pounds were programmed by people
espousing the greater safety of their static typing?

- Paddy.


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


Re: Building a Python app with Mozilla

2007-06-30 Thread Brian Quinlan
Kevin Walzer wrote:
 Komodo is not a Python application. It is a Mozilla application that 
 supports Python development. Komodo is more akin to Thunderbird and 
 Firefox than anything else; it uses the XUL framework for rendering 
 widgets, if I'm not mistaken. If you want to build an application like 
 Komodo, get a book on developing with the Mozilla framework (XUL, XPCOM, 
 and all that) and look at that. Python has little to do with that.

Most application logic in Komodo is implemented in Python, using the 
PyXPCOM bindings. The UI is implemented using XUL and JavaScript. The 
editor is Scintilla (C++).

../Komodo Edit.app/Contents/MacOS % find . -name *.py | xargs wc
...
...
126392  456858 4949602 total

This doesn't include the python code in the Python libraries themselves.

Cheers,
Brian


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


Re: Reading image dimensions before it is loaded from a web form using python.

2007-06-30 Thread Evan Klitzke
On 6/30/07, Norman Khine [EMAIL PROTECTED] wrote:
 Hello,
 I am writing an application using python that allows the user to upload
 an image to a folder on the server.

 Is there a way to get the size of the file before it has been uploaded
 onto the server and give an error if the size does not comply to the
 maximum size.

The easiest way to do this is to simply restrict the maximum file
upload size. When the client makes the POST request you can see how
big it will be. This won't really give you the image dimensions of
course, but there's no simple way to find out that information without
uploading the entire image.

-- 
Evan Klitzke [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


How To Greatly Increase Your Calling Area ... [prtkb]

2007-06-30 Thread Steven Simmons
Hello I just bought a new V3 razor phone and I have t-mobile, but didn't buy it 
through t-mobile, thing is I get good reception everywhere but in my house.  It 
says emergency only and I have problems sending a txt message.  Will this 
product actually work for that and increase mt reception?

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

Python + Google Calendar API issue

2007-06-30 Thread kyosohma
Hi,

I was trying to hook into Google Calendar today using their gdata
module for Python, but I can't seem to get Python to work with it.
When I run the setup.py from the command line, I get the following:

Traceback (most recent call last):
  File J:\Python\Lib\site-packages\gdata\setup.py, line 39, in ?
package_dir = {'gdata':'src/gdata', 'atom':'src/atom'}
  File J:\Python\lib\distutils\core.py, line 137, in setup
raise SystemExit, gen_usage(dist.script_name) + \nerror: %s %
msg
SystemExit: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2
[cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: no commands supplied


I tried using some different commands, like --verbose, but it would
just give me the same traceback. I also tried manually copying all the
files into my site-packages directory (as you can see from the
traceback) in hopes that it might work without running the setup.py
file.

Does anyone have any ideas? I don't usually have any problem getting
these things to work. I am using Python 2.4.3 on Windows XP Pro SP2.

Thanks a lot!

Mike

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


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-30 Thread Alex Martelli
Bruno Desthuilliers [EMAIL PROTECTED] wrote:
   ...
 Hmmm... For a dinausor, C seems well alive. Can you remind me which
   
  So do chickens.
  
 I'm afraid I didn't get the joke... Are you saying that C is a rather,
 well, primitive language ?

The joke's just based on the fact that (based on DNA analysis) birds are
said to be dinosaurs, and are definitely well alive:-).


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


object references/memory access

2007-06-30 Thread dlomsak
Hello,
I have searched a good deal about this topic and have not found
any good information yet. It seems that the people asking all want
something a bit different than what I want and also don't divulge much
about their intentions. I wish to improve the rate of data transfer
between two python programs on the same machine. The project in
question is a database server that I built (written in python) that
works in conjunction with another python script for searching which is
executed via Apache. Basically, I am serving a database but since the
database is large, it remains in the memory of a server program. Upon
submitting a search request, the search script is called by Apache.
This search script makes a connection to the server, sends over the
query and waits on the reply. Queries and records are represented by
dictionaries and the database is a list of dictionaries. The only
problem here is that for large returns, it takes more time and I'd
like to transmit the data. The part that is slowing the data
transmission down seems to be the fact that the data has to travel
across a socket connection to be put back together on the other side.
The server makes a list of dictionaries which represents the records
that match the given criteria and then sends a pickle string of that
object back to the client (the search script).

What I'd like to do is somehow take the returned results of the search
and send over a memory address through the socket and let the search
script read the results directly from the server's memory rather than
send it all through the sockets. There is one more solution which
would work just as well for this application but would be less useful
in general terms. The second method would involve some tricks with the
python CGI module. I am fairly ignorant of how Apache works with the
CGI module but here is what I'd like to do. I want to somehow let the
server print out to the user's browser instead of the search script in
order to cut out the time of sending the results over the socket. This
sounds like it is not possible but I would like to know in greater
detail how the CGI module and Apache work together such that the
'print' statements write out to the user's browser. Mainly, I'd like
to know if there is any kind of descriptor or ID that can be passed
and used by another process to print output to the user's browser
instead of the script that Apache invoked.

If there is not a good Pythonic way to do the above, I am open to
mixing in some C to do the job if that is what it takes. I apologize
if this topic has been brought up many times before but hopefully I
have stated my intentions clearly enough for those with a higher
knowledge of the topic to help. If the above are not possible but you
have a really good idea for zipping large amounts of data from one
program to another, I'd like to hear it.

Thanks to all who take the time to read my request and also those with
a response.

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


Re: Memory leak in PyQt application

2007-06-30 Thread David Boddie
On Thu Jun 28 19:21:36 CEST 2007, Alexander Eisenhuth wrote:

 I've a memory leak in a PyQt application and no idea how to find it. What 
 happens in the application ?
 
  From QWindow a QDialog is called on a button pressed() signal, that 
 instantiate a QThread and waits for it. If the thread has finished, the
 QDialog closes.

Do you delete the dialog when you close it? Did you create it with a parent
object?

 I've stipped down everything that nothing more happens (to me obviously). 
 Boost.Python is used to wrap a C++ Lib (used in the thread). Every time
 memory usage increases for ~70 KB.

 Sometimes the application crash on closing QWindow. (QtCore.dll)

 - One thing I ask me is weather garbage collection is done in the PyQt main
 loop?

Some objects will be garbage collected but others may will be kept around
if they are used from C++.

 What hints do you have to find the leak?

You may need to show us some of your code so that we can see exactly what
you're doing. If you can post the stripped down example you have here, we
can take a look at it.

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


help search file

2007-06-30 Thread Alejandro Decchi

Hello Python user.
I am a newbie with python and i am interesting to do a web apliation to
search file on the hard disk and give a link to download the file found.
Someone can give a help ???
Thz
Ale
-- 
http://mail.python.org/mailman/listinfo/python-list

Problem with PEXPECT in Python

2007-06-30 Thread Kevin Erickson
Hello,

I am attempting to use pexpect in python to copy files from a server
using scp; the copy works however exceptions are thrown and it exits
unsuccessfully.  Below is the a sample code and the error:

#Begin Code

import sys
import pexpect

def GetServerData(self):
foo = pexpect.spawn('scp [EMAIL PROTECTED]:/home/config/
role{/file1,/files/file2,/files/file3} /tmp')
foo.expect('.*password:*')
foo.sendline('server_password')
foo.interact()

#End Code

#Begin Output

file1   100%   10KB  10.0KB/s
00:01
file2   100%  946 0.9KB/s
00:00
file3   100% 1655 1.6KB/s
00:00
Traceback (most recent call last):
  File mygui.py, line 6, in ?
f = Form1()
  File /home/Kevin/form1.py, line 41, in __init__
self.GetServerData()
  File /home/Kevin/form1.py, line 84, in GetServerData
foo.interact()
  File /usr/lib/python2.4/site-packages/pexpect.py, line 1062, in
interact
selfw.__interact_copy(escape_character)
  File /usr/lib/python2.4/site-packages/pexpect.py, line 1086, in
__interact_copy
data = self.__interact_read(self.child_fd)
  File /usr/lib/python2.4/site-packages/pexpect.py, line 1075, in
__interact_read
return os.read(fd, 1000)
OSError: [Errno 5] Input/output error

#End Output

The problem seems to be with the call foo.interact(); does anyone know
how to fix this?  Any help will be much appreciated.

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


Re: Reading image dimensions before it is loaded from a web form using python.

2007-06-30 Thread Cameron Laird
In article [EMAIL PROTECTED],
Evan Klitzke [EMAIL PROTECTED] wrote:
On 6/30/07, Norman Khine [EMAIL PROTECTED] wrote:
 Hello,
 I am writing an application using python that allows the user to upload
 an image to a folder on the server.

 Is there a way to get the size of the file before it has been uploaded
 onto the server and give an error if the size does not comply to the
 maximum size.

The easiest way to do this is to simply restrict the maximum file
upload size. When the client makes the POST request you can see how
big it will be. This won't really give you the image dimensions of
course, but there's no simple way to find out that information without
uploading the entire image.
.
.
.
Maybe we disagree about simple, but there *are* definite
ways to do so.  It's a bit involved--I fear that when Mr. 
Khine writes image, he might have in mind not just .gif,
.jpg, and .png, but perhaps also SVG, Flash, PDF, ...--but,
yes, it's possible with most image formats to upload just a
small portion of the header and test whether what follows
meets the size requirements.
-- 
http://mail.python.org/mailman/listinfo/python-list


Python app as a Display Manager

2007-06-30 Thread hg
Hi,

I asked that question a while back ... and then gave up:

I want to write a simple display manager (*nix / X11) in Python.

I'm going through lots of documentation as well as the code of XDM.

1) I currently understand that the X11 Intrinsics are what I need to
master in order to get there.

2) Also, it seems that The Python app needs to adjust to X11 callbacks ...
although I will use TKinter or another Framework to actually do the
drawing.

I feel at this stage that what I miss is: assuming I manage to get a
python-based dialog box started automatically from init.rc (instead of xdm,
gdm, ...): how do I start an X11 session with the user/pw information
retrieved ... + set the correct *nix environment variables.


Can you direct me some info / give me a clue ?

Many thanks,

hg



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


Re: shelve crashing under Win ME

2007-06-30 Thread gluckj
Hi Jim,

Thanks for your messages -- however, py2exe is NOT the issue -- as you
can see with my example above, shelve is crashing even just by calling
it from IDLE (latest PC version of IDLE  Python), running on a Win ME
machine.

Anyone else out there having access to a Win ME PC willing to try it?
Thanks for checking!

In the meantime, I may replace shelve with a simpler workaround using
cPickle  basic flat file operations.

-- Joel
p.s. -- Jim, I too had to import dbhash in my program to make it work
using py2exe, so you are right on, there.

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


Re: Problem with PEXPECT in Python

2007-06-30 Thread Kevin Erickson
On Jun 30, 5:50 pm, Kevin  Erickson [EMAIL PROTECTED] wrote:
 Hello,

 I am attempting to use pexpect in python to copy files from a server
 using scp; the copy works however exceptions are thrown and it exits
 unsuccessfully.  Below is the a sample code and the error:

 #Begin Code

 import sys
 import pexpect

 def GetServerData(self):
 foo = pexpect.spawn('scp [EMAIL PROTECTED]:/home/config/
 role{/file1,/files/file2,/files/file3} /tmp')
 foo.expect('.*password:*')
 foo.sendline('server_password')
 foo.interact()

 #End Code

 #Begin Output

 file1   100%   10KB  10.0KB/s
 00:01
 file2   100%  946 0.9KB/s
 00:00
 file3   100% 1655 1.6KB/s
 00:00
 Traceback (most recent call last):
   File mygui.py, line 6, in ?
 f = Form1()
   File /home/Kevin/form1.py, line 41, in __init__
 self.GetServerData()
   File /home/Kevin/form1.py, line 84, in GetServerData
 foo.interact()
   File /usr/lib/python2.4/site-packages/pexpect.py, line 1062, in
 interact
 selfw.__interact_copy(escape_character)
   File /usr/lib/python2.4/site-packages/pexpect.py, line 1086, in
 __interact_copy
 data = self.__interact_read(self.child_fd)
   File /usr/lib/python2.4/site-packages/pexpect.py, line 1075, in
 __interact_read
 return os.read(fd, 1000)
 OSError: [Errno 5] Input/output error

 #End Output

 The problem seems to be with the call foo.interact(); does anyone know
 how to fix this?  Any help will be much appreciated.


I have found a work around for my problem.  I replace the following
line:

foo.interact()
with
foo.expect(pexpect.EOF)

That change gets rid of the errors and works great for copying the
files down from the server.

Kevin

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


Re: Reading image dimensions before it is loaded from a web form using python.

2007-06-30 Thread Evan Klitzke
On 6/30/07, Cameron Laird [EMAIL PROTECTED] wrote:
 In article [EMAIL PROTECTED],
 Evan Klitzke [EMAIL PROTECTED] wrote:
 On 6/30/07, Norman Khine [EMAIL PROTECTED] wrote:
  Hello,
  I am writing an application using python that allows the user to upload
  an image to a folder on the server.
 
  Is there a way to get the size of the file before it has been uploaded
  onto the server and give an error if the size does not comply to the
  maximum size.
 
 The easiest way to do this is to simply restrict the maximum file
 upload size. When the client makes the POST request you can see how
 big it will be. This won't really give you the image dimensions of
 course, but there's no simple way to find out that information without
 uploading the entire image.
 .
 .
 .
 Maybe we disagree about simple, but there *are* definite
 ways to do so.  It's a bit involved--I fear that when Mr.
 Khine writes image, he might have in mind not just .gif,
 .jpg, and .png, but perhaps also SVG, Flash, PDF, ...--but,
 yes, it's possible with most image formats to upload just a
 small portion of the header and test whether what follows
 meets the size requirements.

Without running some special client-side application, I think you'd
have to do some trickery with the web server involving artificially
stopping the upload after receiving enough bytes to constitute the
image header, and then deciding whether or not to proceed with the
upload at that point. I think that this is definitely nontrivial since
it would most likely involve some hacking of Apache (or whatever web
server you are using).

-- 
Evan Klitzke [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: object references/memory access

2007-06-30 Thread Evan Klitzke
On 6/30/07, dlomsak [EMAIL PROTECTED] wrote:
 If there is not a good Pythonic way to do the above, I am open to
 mixing in some C to do the job if that is what it takes. I apologize
 if this topic has been brought up many times before but hopefully I
 have stated my intentions clearly enough for those with a higher
 knowledge of the topic to help. If the above are not possible but you
 have a really good idea for zipping large amounts of data from one
 program to another, I'd like to hear it.

You can do things like this in C with shared memory segments. I'm not
familiar enough with the Python C API to tell you how easy this would
be, but that might be a good place to start your investigations.

-- 
Evan Klitzke [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: object references/memory access

2007-06-30 Thread Paul Rubin
dlomsak [EMAIL PROTECTED] writes:
 knowledge of the topic to help. If the above are not possible but you
 have a really good idea for zipping large amounts of data from one
 program to another, I'd like to hear it.

One cheesy thing you might try is serializing with marshal rather than
pickle.  It won't handle as many object types, and it's not guaranteed
interoperable from one Python version to another, but it's potentially
faster than pickle.  Of course for pickling I presume you're already
using cPickle (written in C) instead of Pickle (written in Python).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: object references/memory access

2007-06-30 Thread dlomsak

Paul Rubin wrote:
 dlomsak [EMAIL PROTECTED] writes:
  knowledge of the topic to help. If the above are not possible but you
  have a really good idea for zipping large amounts of data from one
  program to another, I'd like to hear it.

 One cheesy thing you might try is serializing with marshal rather than
 pickle.  It won't handle as many object types, and it's not guaranteed
 interoperable from one Python version to another, but it's potentially
 faster than pickle.  Of course for pickling I presume you're already
 using cPickle (written in C) instead of Pickle (written in Python).

Well, I was using the regular pickle at first but then I switched to
just using repr() / eval() because the resulting string doesn't have
all the extra 's1=' and all that so it cuts down on the amount of data
I have to send for large returns when you cut out all of that
formatting. The speed of the above method is pretty high even for
really large returns and it works fine for a list of dictionaries.

To the previous poster: I'll be looking into C shared memory like you
said. I have a feeling C will let me lay my hands on the things I want
and that Python probably will not. That's fine though because Python
is a wonderful language and I don't mind calling in tedious C to do
the real dirty jobs if that is what it takes.

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


How to uninstall packages

2007-06-30 Thread Rustom Mody
Recently I had trouble with the sqlite package under my debian etch
box as follows:

I first installed the debian package python-pysqlite1.1 using
synaptic. Since this seemed too old for other packages (sqlalchemy) I
downloaded the sources  pysqlite-2.3.4.tar.gz and ran setup install.

This gave the problem that _sqlite was not found.

And now the apt system started complaining that it could not uninstall
it because of some new files.

I finally (seem to have :-) ) got it to work by going into
/usr/lib/python2.4/site-packages/ and deleting the pysqlite directory
and reinstalling using apt.

However this is an unsatisfactory solution because I do not know what
else I should delete

So now my question:  How does one uninstall  *cleanly*

1 a package installed using setup.py install
2 a package installed with easy_install

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


unicode

2007-06-30 Thread 7stud
Based on this example and the error:

-
u_str = uabc\u
print u_str

UnicodeEncodeError: 'ascii' codec can't encode character u'\u' in
position 3: ordinal not in range(128)
--

it looks like when I try to display the string, the ascii decoder
parses each character in the string and fails when it can't convert a
numerical code that is higher than 127 to a character, i.e. the
character \u.

In the following example, I use encode() to convert a unicode string
to a regular string:

-
u_str = uabc\u
reg_str = u_str.encode(utf-8)
print repr(reg_str)
-

and the output is:

'abc\xe9\xa6\x99'

1) Why aren't the characters 'a', 'b', and 'c' in hex notation?  It
looks like python must be using the ascii decoder to parse the
characters in the string again--with the result being python converts
only the 1 byte numerical codes to characters. 2) Why didn't that
cause an error like above for the 3 byte character?

Then if I try this:

---
u_str = uabc\u
reg_str = u_str.encode(utf-8)
print reg_str
---

I get the output:

abcsome chinese character

Here it looks like python isn't using the ascii decoder anymore.  2)
What determines which decoder python uses?

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


[ python-Bugs-1581906 ] test_sqlite fails on OSX G5 arch if test_ctypes is run

2007-06-30 Thread SourceForge.net
Bugs item #1581906, was opened at 2006-10-21 13:02
Message generated for change (Comment added) made by montanaro
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1581906group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Skip Montanaro (montanaro)
Assigned to: Thomas Heller (theller)
Summary: test_sqlite fails on OSX G5 arch if test_ctypes is run

Initial Comment:
I noticed a test_sqlite test failure on my Mac G5 the other day while trying 
to set up a buildbot for sqlalchemy.  Everything runs fine on my G4 
powerbook.  Both machines run Mac OSX 10.4.8 with Apple's gcc 4.0.0, 
build 5026.

I whittled the problem down to just having test_ctypes and test_sqlite 
enabled, then further whittled it down to just having Lib/ctypes/test/
test_find.py available (all other ctypes tests eliminated).  More detailed 
problem descriptions are in these two postings to python-dev:

http://article.gmane.org/gmane.comp.python.devel/84478
http://article.gmane.org/gmane.comp.python.devel/84481

Skip


--

Comment By: Skip Montanaro (montanaro)
Date: 2007-06-30 05:42

Message:
Logged In: YES 
user_id=44345
Originator: YES

I'll be damned...  Based on your last response I ran Python
under ktrace then looked at the kdump output.  As it's
marching along it sees a mention of /usr/lib/libsqlite3.so
in /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
then just a few lines later I see

 20023 python   NAMI  /usr/lib/libsqlite3.0.dylib
 20023 python   RET   open 3
 20023 python   CALL  fstat(0x3,0xbfffc770)
 20023 python   RET   fstat 0
 20023 python   CALL  pread(0x3,0xbfffcbd0,0x1000,0)

then a bit later I see what I had wanted to see:

 20023 python   NAMI 
/Users/skip/local/lib/python2.6/lib-dynload/_sqlite3.so
 20023 python   RET   open 6
 20023 python   CALL  fstat(0x6,0xbfff9c00)
 20023 python   RET   fstat 0
 20023 python   CALL  pread(0x6,0xbfffa060,0x1000,0)
 ...
 20023 python   NAMI  /Users/skip/local/lib/libsqlite3.0.dylib
 20023 python   RET   open 6
 20023 python   CALL  fstat(0x6,0xbfff99b0)
 20023 python   RET   fstat 0
 20023 python   CALL  pread(0x6,0xbfff9e10,0x1000,0)

I can't execute the CDLL call if I've renamed
/usr/lib/libsqlite.3.0.dylib.  (I suppose that stands to
reason.)

Now the question becomes whether or not the Apple-provided
library can be replaced with something more modern.
Presumably every application that uses CoreData (most
Apple things) gets it if during startup.

Thomas, for the purposes of the Python regression test
suite do you think you can find something other than
GLUT to dynamically load?

Mark, thanks for the sleuthing.

Skip


--

Comment By: Mark Dickinson (marketdickinson)
Date: 2007-06-29 22:56

Message:
Logged In: YES 
user_id=703403
Originator: NO

It looks as though GLUT is a red herring.  I can reproduce the problem
with a variety of frameworks in place of GLUT, for example Quartz, Cocoa,
AppKit, CoreData, as in the following lines.

import ctypes
ctypes.CDLL('/System/Library/Frameworks/CoreData.framework/CoreData')
import sqlite3
sqlite3.connect(:memory:)

Furthermore, I notice that the GLUT framework has a library dependency on
the AppKit framework,  AppKit on CoreData, and CoreData depends on the
Apple-supplied libsqlite3, and that Quartz and Cocoa similarly ultimately
depend on libsqlite3.  Coincidence?

I can reproduce the problem with a variety of frameworks in place of GLUT,
for example Quartz, Cocoa, AppKit, CoreData.  (The .glutWireTetrahedron is
unnecessary.)

--

Comment By: Mark Dickinson (marketdickinson)
Date: 2007-06-29 22:32

Message:
Logged In: YES 
user_id=703403
Originator: NO

I think your minor(?) data point is a major data point.  I'm using the
Macports version of sqlite3.  Furthermore, after hiding the /usr/lib
version with

fibonacci:/usr/lib dickinsm$ sudo mv libsqlite3.0.dylib
libsqlite3.0.dylib.temp

I can't reproduce the problem any more.  I tried sprinkling a few printf
statements through the sqlite3 source to see what was going on.  Bizarrely,
it looks as though the Apple-supplied sqlite3SafetyCheck() routine is being
called from the Macports createCollation(); or at least that's the only way
that I can understand the results I'm getting.  Is this possible?

Mark

--

Comment By: Skip Montanaro (montanaro)
Date: 2007-06-29 21:45

Message:
Logged In: YES 
user_id=44345
Originator: YES

One other minor(?) data point.  I am using a version of sqlite3 which I
compiled and installed, not 

[ python-Bugs-1581906 ] test_sqlite fails on OSX G5 arch if test_ctypes is run

2007-06-30 Thread SourceForge.net
Bugs item #1581906, was opened at 2006-10-21 13:02
Message generated for change (Comment added) made by montanaro
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1581906group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Skip Montanaro (montanaro)
Assigned to: Thomas Heller (theller)
Summary: test_sqlite fails on OSX G5 arch if test_ctypes is run

Initial Comment:
I noticed a test_sqlite test failure on my Mac G5 the other day while trying 
to set up a buildbot for sqlalchemy.  Everything runs fine on my G4 
powerbook.  Both machines run Mac OSX 10.4.8 with Apple's gcc 4.0.0, 
build 5026.

I whittled the problem down to just having test_ctypes and test_sqlite 
enabled, then further whittled it down to just having Lib/ctypes/test/
test_find.py available (all other ctypes tests eliminated).  More detailed 
problem descriptions are in these two postings to python-dev:

http://article.gmane.org/gmane.comp.python.devel/84478
http://article.gmane.org/gmane.comp.python.devel/84481

Skip


--

Comment By: Skip Montanaro (montanaro)
Date: 2007-06-30 06:15

Message:
Logged In: YES 
user_id=44345
Originator: YES

I submitted a bug report to Apple about the problem, though I don't
really expect a response.  (The other bug I filed in 2004 has never
received any response as far as I can tell.)  Maybe a more recent
version of SQLite will be delivered with Leopard...


--

Comment By: Skip Montanaro (montanaro)
Date: 2007-06-30 05:42

Message:
Logged In: YES 
user_id=44345
Originator: YES

I'll be damned...  Based on your last response I ran Python
under ktrace then looked at the kdump output.  As it's
marching along it sees a mention of /usr/lib/libsqlite3.so
in /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
then just a few lines later I see

 20023 python   NAMI  /usr/lib/libsqlite3.0.dylib
 20023 python   RET   open 3
 20023 python   CALL  fstat(0x3,0xbfffc770)
 20023 python   RET   fstat 0
 20023 python   CALL  pread(0x3,0xbfffcbd0,0x1000,0)

then a bit later I see what I had wanted to see:

 20023 python   NAMI 
/Users/skip/local/lib/python2.6/lib-dynload/_sqlite3.so
 20023 python   RET   open 6
 20023 python   CALL  fstat(0x6,0xbfff9c00)
 20023 python   RET   fstat 0
 20023 python   CALL  pread(0x6,0xbfffa060,0x1000,0)
 ...
 20023 python   NAMI  /Users/skip/local/lib/libsqlite3.0.dylib
 20023 python   RET   open 6
 20023 python   CALL  fstat(0x6,0xbfff99b0)
 20023 python   RET   fstat 0
 20023 python   CALL  pread(0x6,0xbfff9e10,0x1000,0)

I can't execute the CDLL call if I've renamed
/usr/lib/libsqlite.3.0.dylib.  (I suppose that stands to
reason.)

Now the question becomes whether or not the Apple-provided
library can be replaced with something more modern.
Presumably every application that uses CoreData (most
Apple things) gets it if during startup.

Thomas, for the purposes of the Python regression test
suite do you think you can find something other than
GLUT to dynamically load?

Mark, thanks for the sleuthing.

Skip


--

Comment By: Mark Dickinson (marketdickinson)
Date: 2007-06-29 22:56

Message:
Logged In: YES 
user_id=703403
Originator: NO

It looks as though GLUT is a red herring.  I can reproduce the problem
with a variety of frameworks in place of GLUT, for example Quartz, Cocoa,
AppKit, CoreData, as in the following lines.

import ctypes
ctypes.CDLL('/System/Library/Frameworks/CoreData.framework/CoreData')
import sqlite3
sqlite3.connect(:memory:)

Furthermore, I notice that the GLUT framework has a library dependency on
the AppKit framework,  AppKit on CoreData, and CoreData depends on the
Apple-supplied libsqlite3, and that Quartz and Cocoa similarly ultimately
depend on libsqlite3.  Coincidence?

I can reproduce the problem with a variety of frameworks in place of GLUT,
for example Quartz, Cocoa, AppKit, CoreData.  (The .glutWireTetrahedron is
unnecessary.)

--

Comment By: Mark Dickinson (marketdickinson)
Date: 2007-06-29 22:32

Message:
Logged In: YES 
user_id=703403
Originator: NO

I think your minor(?) data point is a major data point.  I'm using the
Macports version of sqlite3.  Furthermore, after hiding the /usr/lib
version with

fibonacci:/usr/lib dickinsm$ sudo mv libsqlite3.0.dylib
libsqlite3.0.dylib.temp

I can't reproduce the problem any more.  I tried sprinkling a few printf
statements through the sqlite3 source to see what was going on.  Bizarrely,
it looks as though the Apple-supplied sqlite3SafetyCheck() routine is 

[ python-Bugs-1745533 ] Filename providing cross platform capability

2007-06-30 Thread SourceForge.net
Bugs item #1745533, was opened at 2007-06-30 02:35
Message generated for change (Comment added) made by orsenthil
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1745533group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Damian (atagar)
Assigned to: Nobody/Anonymous (nobody)
Summary: Filename providing cross platform capability

Initial Comment:
The help section for the open method should note that a Unix style filename 
work in a cross platform fashion (like Java). After scouring several resources 
including two O'Reilly texts on Python, a dozen web pages, all reliant help 
pages, I finally got my answer from a mailing list. -Damian

--

Comment By: O.R.Senthil Kumaran (orsenthil)
Date: 2007-06-30 17:54

Message:
Logged In: YES 
user_id=942711
Originator: NO

I am not getting as what you are indicating Damian. You mean to say use
'/' forward slashes in all documentation as they can work cross platform?

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1745533group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1581906 ] test_sqlite fails on OSX G5 arch if test_ctypes is run

2007-06-30 Thread SourceForge.net
Bugs item #1581906, was opened at 2006-10-21 13:02
Message generated for change (Comment added) made by montanaro
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1581906group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Skip Montanaro (montanaro)
Assigned to: Thomas Heller (theller)
Summary: test_sqlite fails on OSX G5 arch if test_ctypes is run

Initial Comment:
I noticed a test_sqlite test failure on my Mac G5 the other day while trying 
to set up a buildbot for sqlalchemy.  Everything runs fine on my G4 
powerbook.  Both machines run Mac OSX 10.4.8 with Apple's gcc 4.0.0, 
build 5026.

I whittled the problem down to just having test_ctypes and test_sqlite 
enabled, then further whittled it down to just having Lib/ctypes/test/
test_find.py available (all other ctypes tests eliminated).  More detailed 
problem descriptions are in these two postings to python-dev:

http://article.gmane.org/gmane.comp.python.devel/84478
http://article.gmane.org/gmane.comp.python.devel/84481

Skip


--

Comment By: Skip Montanaro (montanaro)
Date: 2007-06-30 08:17

Message:
Logged In: YES 
user_id=44345
Originator: YES

Thomas,

Here's a possible modification to ctypes.test.test_find which appears
to be the only place that OpenGL (and thus CoreData on the Mac?) is
accessed.  On Darwin I replace the GL find stuff with Tcl find stuff.
It's a bit ugly, but it might solve the problem.

Skip

File Added: test_find.diff

--

Comment By: Skip Montanaro (montanaro)
Date: 2007-06-30 06:15

Message:
Logged In: YES 
user_id=44345
Originator: YES

I submitted a bug report to Apple about the problem, though I don't
really expect a response.  (The other bug I filed in 2004 has never
received any response as far as I can tell.)  Maybe a more recent
version of SQLite will be delivered with Leopard...


--

Comment By: Skip Montanaro (montanaro)
Date: 2007-06-30 05:42

Message:
Logged In: YES 
user_id=44345
Originator: YES

I'll be damned...  Based on your last response I ran Python
under ktrace then looked at the kdump output.  As it's
marching along it sees a mention of /usr/lib/libsqlite3.so
in /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
then just a few lines later I see

 20023 python   NAMI  /usr/lib/libsqlite3.0.dylib
 20023 python   RET   open 3
 20023 python   CALL  fstat(0x3,0xbfffc770)
 20023 python   RET   fstat 0
 20023 python   CALL  pread(0x3,0xbfffcbd0,0x1000,0)

then a bit later I see what I had wanted to see:

 20023 python   NAMI 
/Users/skip/local/lib/python2.6/lib-dynload/_sqlite3.so
 20023 python   RET   open 6
 20023 python   CALL  fstat(0x6,0xbfff9c00)
 20023 python   RET   fstat 0
 20023 python   CALL  pread(0x6,0xbfffa060,0x1000,0)
 ...
 20023 python   NAMI  /Users/skip/local/lib/libsqlite3.0.dylib
 20023 python   RET   open 6
 20023 python   CALL  fstat(0x6,0xbfff99b0)
 20023 python   RET   fstat 0
 20023 python   CALL  pread(0x6,0xbfff9e10,0x1000,0)

I can't execute the CDLL call if I've renamed
/usr/lib/libsqlite.3.0.dylib.  (I suppose that stands to
reason.)

Now the question becomes whether or not the Apple-provided
library can be replaced with something more modern.
Presumably every application that uses CoreData (most
Apple things) gets it if during startup.

Thomas, for the purposes of the Python regression test
suite do you think you can find something other than
GLUT to dynamically load?

Mark, thanks for the sleuthing.

Skip


--

Comment By: Mark Dickinson (marketdickinson)
Date: 2007-06-29 22:56

Message:
Logged In: YES 
user_id=703403
Originator: NO

It looks as though GLUT is a red herring.  I can reproduce the problem
with a variety of frameworks in place of GLUT, for example Quartz, Cocoa,
AppKit, CoreData, as in the following lines.

import ctypes
ctypes.CDLL('/System/Library/Frameworks/CoreData.framework/CoreData')
import sqlite3
sqlite3.connect(:memory:)

Furthermore, I notice that the GLUT framework has a library dependency on
the AppKit framework,  AppKit on CoreData, and CoreData depends on the
Apple-supplied libsqlite3, and that Quartz and Cocoa similarly ultimately
depend on libsqlite3.  Coincidence?

I can reproduce the problem with a variety of frameworks in place of GLUT,
for example Quartz, Cocoa, AppKit, CoreData.  (The .glutWireTetrahedron is
unnecessary.)

--

Comment By: Mark Dickinson (marketdickinson)
Date: 2007-06-29 22:32

Message:
Logged In: 

[ python-Feature Requests-1745722 ] please add wsgi to SimpleXMLRPCServer

2007-06-30 Thread SourceForge.net
Feature Requests item #1745722, was opened at 2007-06-30 13:31
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1745722group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: XML
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Helmut Grohne (gnarfk)
Assigned to: Nobody/Anonymous (nobody)
Summary: please add wsgi to SimpleXMLRPCServer

Initial Comment:
There should be a simple wsgi xmlrpc application and in fact it is not 
difficult. You could for instance take this one and append it to 
SimpleXMLRPCServer.py.

class WSGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
def __init__(self, allow_none=False, encoding=None):
SimpleXMLRPCDispatcher.__init__(self, allow_none, encoding)
def __call__(self, environ, start_response):
WSGI interface
if environ[REQUEST_METHOD] != POST:
status = 400 Bad request
headers = [(Content-type, text/html)]
data = htmlheadtitle400 Bad 
request/title/headbodyh1400 Bad request/h1/body/html
headers.append((Content-length, str(len(data
start_response(status, headers)
if environ[REQUEST_METHOD] == HEAD:
return []
return [data]
l = int(environ[CONTENT_LENGTH])
request = environ[wsgi.input].read(l)
response = self._marshaled_dispatch(request)
headers = [(Content-type, text/xml)]
headers.append((Content-length, str(len(response
start_response(200 OK, headers)
return [response]


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1745722group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Feature Requests-1745722 ] please add wsgi to SimpleXMLRPCServer

2007-06-30 Thread SourceForge.net
Feature Requests item #1745722, was opened at 2007-06-30 13:31
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1745722group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: XML
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Helmut Grohne (gnarfk)
Assigned to: Fredrik Lundh (effbot)
Summary: please add wsgi to SimpleXMLRPCServer

Initial Comment:
There should be a simple wsgi xmlrpc application and in fact it is not 
difficult. You could for instance take this one and append it to 
SimpleXMLRPCServer.py.

class WSGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
def __init__(self, allow_none=False, encoding=None):
SimpleXMLRPCDispatcher.__init__(self, allow_none, encoding)
def __call__(self, environ, start_response):
WSGI interface
if environ[REQUEST_METHOD] != POST:
status = 400 Bad request
headers = [(Content-type, text/html)]
data = htmlheadtitle400 Bad 
request/title/headbodyh1400 Bad request/h1/body/html
headers.append((Content-length, str(len(data
start_response(status, headers)
if environ[REQUEST_METHOD] == HEAD:
return []
return [data]
l = int(environ[CONTENT_LENGTH])
request = environ[wsgi.input].read(l)
response = self._marshaled_dispatch(request)
headers = [(Content-type, text/xml)]
headers.append((Content-length, str(len(response
start_response(200 OK, headers)
return [response]


--

Comment By: Georg Brandl (gbrandl)
Date: 2007-06-30 14:59

Message:
Logged In: YES 
user_id=849994
Originator: NO

Assigned to Fredrik.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1745722group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1745761 ] Bad attributes/data handling in SGMLib

2007-06-30 Thread SourceForge.net
Bugs item #1745761, was opened at 2007-06-30 16:38
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1745761group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Alvaro Lopez (wolfete)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bad attributes/data handling in SGMLib

Initial Comment:
When feeding an parser with a tag in which its arguments contain a  (as in a 
href='http://www.example.org/;;'example/a the SGMLParsers doesn't handle 
the data/arguments correcly. For example, with the above string I get:

Fed: a href='http://www.example.org/;;'example/a
Tag opened: a
Arg  href  -  http://www.example.org/;;
Arg escaped 'http://www.example.org/gt;;'
Data: ;'example
Tag closed: a

I have attached a small example.

I'm using python2.5.1

Cheers,

Álvaro.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1745761group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1745035 ] DoS smtpd vulnerability

2007-06-30 Thread SourceForge.net
Bugs item #1745035, was opened at 2007-06-28 21:44
Message generated for change (Settings changed) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1745035group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 7
Private: No
Submitted By: billiejoex (billiejoex)
Assigned to: Nobody/Anonymous (nobody)
Summary: DoS smtpd vulnerability

Initial Comment:
Method collect_incoming_data of SMTPChannel class should stop buffering if 
received lines are too long (possible Denial-of-Service attacks).
Without truncating such buffer a simple malicious script sending extremely long 
lines without \r\n terminator could easily saturate system resources.

--

Comment By: billiejoex (billiejoex)
Date: 2007-06-29 20:00

Message:
Logged In: YES 
user_id=1357589
Originator: YES

Sorry, I realized I've forgotten to reset to zero the bytes counter.
Here's the patch of the patch:

124a125
 self.__in_buffer_len = 0
135a137,140
 self.__in_buffer_len += len(data)
 if self.__in_buffer_len  4096:
 self.__line = []
 self.__in_buffer_len = 0
141a147
 self.__in_buffer_len = 0


--

Comment By: billiejoex (billiejoex)
Date: 2007-06-28 21:45

Message:
Logged In: YES 
user_id=1357589
Originator: YES

--- malicious script

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((127.0.0.1, 8025))
while 1:
s.sendall('x' * 1024)


--- proposed smtpd.py patch

124a125
 self.__in_buffer_len = 0
135a137,139
 self.__in_buffer_len += len(data)
 if self.__in_buffer_len  4096:
 self.__line = []



--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1745035group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1743795 ] Some incorrect national characters (Polish) in unicodedata

2007-06-30 Thread SourceForge.net
Bugs item #1743795, was opened at 2007-06-26 20:45
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1743795group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Unicode
Group: 3rd Party
Status: Closed
Resolution: Invalid
Priority: 5
Private: No
Submitted By: admindomeny (admindomeny)
Assigned to: Mark Hammond (mhammond)
Summary: Some incorrect national characters (Polish) in unicodedata

Initial Comment:
Hello,

This problem regards pythonwin (I haven't checked whether unix/commandline 
python is affected), Python 2.5.1.

Examples on attached screenshot.

E.g. print u'\N{LATIN SMALL LETTER A WITH CIRCUMFLEX}' prints wrong character 
(latin small a with some caret above it it seems) as well as 

print unicodedata.name( / latin small letter a with circumflex, typed in 
Windows using Polish programmer's keyboard / ) produces 'SUPERSCRIPT ONE', 
which is obviously incorrect.



--

Comment By: Martin v. Löwis (loewis)
Date: 2007-06-30 19:34

Message:
Logged In: YES 
user_id=21627
Originator: NO

Actually, we should close this here. Please report it through the
PythonWin bugtracker.

--

Comment By: M.-A. Lemburg (lemburg)
Date: 2007-06-27 21:38

Message:
Logged In: YES 
user_id=38388
Originator: NO

Assigning to Mark Hammond who wrote Pythonwin.

--

Comment By: admindomeny (admindomeny)
Date: 2007-06-27 19:25

Message:
Logged In: YES 
user_id=1829093
Originator: YES

You were correct, the attached test file for Polish national characters
shows correctt character encodings when ran in Pythonwin and edited
correctly Unicode with Polish characters from Unicode Unicode.

The problem of entering characters in Pythonwin remains, however (OS: Win
XP SP2, Polish edition): I have tried changing fonts to what are Unicode
fonts as far as I know (Times New Roman, Arial, etc), including CE fonts as
well. It doesn't work.

I made sure that Polish Programmer's Keyboard is turned on which gives me
correct encoding in almost all Windows applications, including Unicode
editors like UniRed. Still, Pythonwin shell in particular thinks that
AltGr+a (standard way of entering 'LATIN SMALL LETTER A WITH OGONEK') is
actually 'SUPERSCRIPT ONE' for example.

So, to summarize:

1. IDLE edits the text in Unicode correctly provided there's a #-*-
coding: utf-8 -*- header in first line.

2. Pythonwin executes that file correctly.

3. Pythonwin enters national characters INCORRECTLY (at least as far
Polish is concerned, but I suspect it's also the case with other
languages).


File Added: test.py

--

Comment By: M.-A. Lemburg (lemburg)
Date: 2007-06-27 10:28

Message:
Logged In: YES 
user_id=38388
Originator: NO

This sounds more like a problem with entry of Unicode characters in
pythonwin than the unicodedata module.

Please create a test.py file with the character using e.g. UTF-8 as source
code encoding and run that through the Python interpreter directly to see
if the problem persists.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1743795group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1745533 ] Filename providing cross platform capability

2007-06-30 Thread SourceForge.net
Bugs item #1745533, was opened at 2007-06-29 14:05
Message generated for change (Comment added) made by atagar
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1745533group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.4
Status: Closed
Resolution: Invalid
Priority: 5
Private: No
Submitted By: Damian (atagar)
Assigned to: Nobody/Anonymous (nobody)
Summary: Filename providing cross platform capability

Initial Comment:
The help section for the open method should note that a Unix style filename 
work in a cross platform fashion (like Java). After scouring several resources 
including two O'Reilly texts on Python, a dozen web pages, all reliant help 
pages, I finally got my answer from a mailing list. -Damian

--

Comment By: Damian (atagar)
Date: 2007-06-30 14:38

Message:
Logged In: YES 
user_id=1613266
Originator: YES

No, I'm talking about the documentation when entering help(file) or
help(open). The filename parameter works in a cross platform fashion when
given a Unix path. For instance,
file = open(/path/to/content.xml, r) # Cross platform
file = open(\\path\\to\\content.xml, r) # Win32 only
This seemed to be an undocumented yet important detail (unless I'm
mistaken it means its advantageous to always use the former method when
coding paths). However, looking around some more I think this is largely a
misunderstanding on my part in terms of where the cross platform capability
came from (Windows accepting a forward slash rather than the open method
translating the path for the current OS). Sorry about the confusion.

--

Comment By: O.R.Senthil Kumaran (orsenthil)
Date: 2007-06-30 05:24

Message:
Logged In: YES 
user_id=942711
Originator: NO

I am not getting as what you are indicating Damian. You mean to say use
'/' forward slashes in all documentation as they can work cross platform?

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1745533group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1745533 ] Filename providing cross platform capability

2007-06-30 Thread SourceForge.net
Bugs item #1745533, was opened at 2007-06-29 14:05
Message generated for change (Comment added) made by atagar
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1745533group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.4
Status: Closed
Resolution: Invalid
Priority: 5
Private: No
Submitted By: Damian (atagar)
Assigned to: Nobody/Anonymous (nobody)
Summary: Filename providing cross platform capability

Initial Comment:
The help section for the open method should note that a Unix style filename 
work in a cross platform fashion (like Java). After scouring several resources 
including two O'Reilly texts on Python, a dozen web pages, all reliant help 
pages, I finally got my answer from a mailing list. -Damian

--

Comment By: Damian (atagar)
Date: 2007-06-30 14:48

Message:
Logged In: YES 
user_id=1613266
Originator: YES

No, I'm talking about the documentation when entering help(file) or
help(open). The filename parameter works in a cross platform fashion when
given a Unix path. For instance,
file = open(/path/to/content.xml, r) # Cross platform
file = open(\\path\\to\\content.xml, r) # Win32 only
This seemed to be an undocumented yet important detail (unless I'm
mistaken it means its advantageous to always use the former method when
coding paths). However, looking around some more I think this is largely a
misunderstanding on my part in terms of where the cross platform capability
came from (Windows accepting a forward slash rather than the open method
translating the path for the current OS). Sorry about the confusion.

--

Comment By: Damian (atagar)
Date: 2007-06-30 14:38

Message:
Logged In: YES 
user_id=1613266
Originator: YES

No, I'm talking about the documentation when entering help(file) or
help(open). The filename parameter works in a cross platform fashion when
given a Unix path. For instance,
file = open(/path/to/content.xml, r) # Cross platform
file = open(\\path\\to\\content.xml, r) # Win32 only
This seemed to be an undocumented yet important detail (unless I'm
mistaken it means its advantageous to always use the former method when
coding paths). However, looking around some more I think this is largely a
misunderstanding on my part in terms of where the cross platform capability
came from (Windows accepting a forward slash rather than the open method
translating the path for the current OS). Sorry about the confusion.

--

Comment By: O.R.Senthil Kumaran (orsenthil)
Date: 2007-06-30 05:24

Message:
Logged In: YES 
user_id=942711
Originator: NO

I am not getting as what you are indicating Damian. You mean to say use
'/' forward slashes in all documentation as they can work cross platform?

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1745533group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com