SQLObject 0.8.0b1

2006-12-18 Thread Oleg Broytmann
Hello!

I'm pleased to announce the 0.8.0b1 release of SQLObject. This is the first
beta of the new branch. Taking into account that it is a result of rather
large job the beta period will be prolonged. Meanwhile the stable 0.7
branch will be maintained, and there will be at least 0.7.3 release.


What is SQLObject
=

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, and
Firebird.  It also has newly added support for Sybase, MSSQL and MaxDB (also
known as SAPDB).


Where is SQLObject
==

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

Download:
http://cheeseshop.python.org/pypi/SQLObject/0.8.0b1

News and changes:
http://sqlobject.org/devel/News.html


What's New
==

Features  Interface


* It is now possible to create tables that reference each other.
  Constraints (in the DBMSes that support constraints) are added after the
  tables have been created.

* Added ``createSQL`` as an option for sqlmeta. Here you can add
  related SQL you want executed by sqlobject-admin create after table
  creation. createSQL expects a string, list, or dictionary. If using
  a dictionary the key should be a dbName value (ex. 'postgres') and
  the value should be a string or list.  Examples in
  sqlobject/tests/test_sqlobject_admin.py or at
  http://sqlobject.org/sqlobject-admin.html#the-create-command

* Added method ``sqlhub.doInTransaction(callable, *args, **kwargs)``,
  to be used like::

  sqlhub.doInTransaction(process_request, os.environ)

  This will run ``process_request(os.environ)``.  The return
  value will be preserved.

* Added method ``.getOne([default])`` to ``SelectResults`` (these are
  the objects returned by ``.select()`` and ``.selectBy()``).  This
  returns a single object, when the query is expected to return only
  one object.  The single argument is the value to return when zero
  results are found (more than one result is always an error).  If no
  default is given, it is an error if no such object exists.

* Added a WSGI middleware (in ``sqlobject.wsgi_middleware``) for
  configuring the database for the request.  Also handles
  transactions.  Available as ``egg:SQLObject`` in Paste Deploy
  configuration files.

* New joins! ManyToMany and OneToMany; not fully documented yet, but still
  more sensible and smarter.

* SELECT FOR UPDATE

* New module dberrors.py - a hierarchy of exceptions. Translation of DB API
  module's exceptions to the new hierarchy is performed for SQLite and MySQL.

* SQLiteConnection got a new keyword factory - a name or a reference to
  a factory function that returns a connection class; useful for
  implementing functions or aggregates. See test_select.py and
  test_sqlite_factory.py for examples.

* SQLObject now disallows columns with names that collide with existing
  variables and methods, such as _init, expire, set and so on.

Small Features
--

* Configurable client character set (encoding) for MySQL.

* Added a close option to .commit(), so you can close the transaction as
  you commit it.

* DecimalValidator.

* Added .expireAll() methods to sqlmeta and connection objects, to expire
  all instances in those cases.

* String IDs.

* FOREIGN KEY for MySQL.

* Support for sqlite3 (a builtin module in Python 2.5).

* SelectResults cannot be queried for truth value; in any case it was
  meaningless - the result was always True; now __nonzero__() raises
  NotImplementedError in case one tries bool(MyTable.select()) or
  if MyTable.select():...

Bug Fixes
-

* Fixed problem with sqlite and threads; connections are no longer shared
  between threads for sqlite (except for :memory:).

* The reference loop between SQLObject and SQLObjectState eliminated using
  weak references.

For a more complete list, please see the news:
http://sqlobject.org/devel/News.html

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Roundup Issue Tracker release 1.3.2

2006-12-18 Thread Richard Jones
I'm proud to release version 1.3.2 of Roundup.

Fixed in 1.3.2:

- relax rules for required fields in form_parser.py (sf bug 1599740)
- documentation cleanup from Luke Ross (sf patch 1594860)
- updated Spanish translation from Ramiro Morales (sf patch 1594718)
- handle 8-bit untranslateable messages in tracker templates
- handling of required for boolean False and numeric 0 (sf bug 1608200)
- removed bogus args attr of ConfigurationError (sf bug 1608056)
- implemented start_response in roundup.cgi (sf bug 1604304)
- clarified windows service documentation (sf patch 1597713)
- HTMLClass fixed to work with new item permissions check (sf bug  
1602983)
- support POP over SSL (sf patch 1597703)
- clean up input field generation and quoting of values (sf bug 1615616)
- allow use of roundup-server pidfile without forking (sf bug 1614753)
- allow translation of status/priority menu options (sf bug 1613976)

New Features in 1.3.0:

- WSGI support via roundup.cgi.wsgi_handler

If you're upgrading from an older version of Roundup you *must* follow
the Software Upgrade guidelines given in the maintenance  
documentation.

Roundup requires python 2.3 or later for correct operation.

To give Roundup a try, just download (see below), unpack and run::

 roundup-demo

Release info and download page:
  http://cheeseshop.python.org/pypi/roundup
Source and documentation is available at the website:
  http://roundup.sourceforge.net/
Mailing lists - the place to ask questions:
  http://sourceforge.net/mail/?group_id=31577


About Roundup
=

Roundup is a simple-to-use and -install issue-tracking system with
command-line, web and e-mail interfaces. It is based on the winning  
design
from Ka-Ping Yee in the Software Carpentry Track design competition.

Note: Ping is not responsible for this project. The contact for this
project is [EMAIL PROTECTED]

Roundup manages a number of issues (with flexible properties such as
description, priority, and so on) and provides the ability to:

(a) submit new issues,
(b) find and edit existing issues, and
(c) discuss issues with other participants.

The system will facilitate communication among the participants by  
managing
discussions and notifying interested parties when issues are edited.  
One of
the major design goals for Roundup that it be simple to get going.  
Roundup
is therefore usable out of the box with any python 2.3+  
installation. It
doesn't even need to be installed to be operational, though a
disutils-based install script is provided.

It comes with two issue tracker templates (a classic bug/feature  
tracker and
a minimal skeleton) and five database back-ends (anydbm, sqlite,  
metakit,
mysql and postgresql).


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

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


Re: Good Looking UI for a stand alone application

2006-12-18 Thread Vincent Delporte
On 17 Dec 2006 21:20:14 -0800, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
You could write it as a web app, with an executable which launches the
server and points a browser at it.

Right, I was thinking of this too, but since the OP was talking of a
fat app...

Python GUI work is a bit of a drag, really. One of the worst things
about it, IMHO.

But then, it was built for write text-based scripts. I assume someone
could take it, and turn it into a GUI-based solution for Windows, but
it's probably quite a lot of work, and maybe there just isn't anyone
willing to pay for it. It'd be cool, though to be able to just send
someone a 10KB GUI Python script and have it run in Windows natively
:-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: dealing with special characters in Python and MySQL

2006-12-18 Thread Fredrik Lundh
ronrsr wrote:

 now, I can't do any string operations, I get the error msg:
 
 descriptor 'lower' requires a 'str' object but received a 'unicode'
   args = (descriptor 'lower' requires a 'str' object but received
 a 'unicode',)

what's a string operation in this context?  are you trying to call 
string methods by explicit calls to class methods in the str class:

  str.upper(ufoo)
Traceback (most recent call last):
   File stdin, line 1, in module
TypeError: descriptor 'upper' requires a 'str' object but received a 
'unicode'

instead of calling methods on the string object:

  ufoo.upper()
u'FOO'

?  if so, what did you get that idea from?

/F

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


Re: dealing with special characters in Python and MySQL

2006-12-18 Thread Fredrik Lundh
ronrsr wrote:

 querystring = update zingers set keywords = '%s', citation =
 '%s', quotation = %s'   where zid = %d %
 (keywords,citation,quotation,zid)

that's not a good way to pass strings to the database.  for the right 
way to do this, see:

http://effbot.org/pyfaq/how-do-i-escape-sql-values-when-using-the-db-api

/F

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


Re: dealing with special characters in Python and MySQL

2006-12-18 Thread Leo Kislov
ronrsr wrote:
  
  Try putting use_unicode=True in the MySQLdb connect call.

 tried that, and also added charset=utf8 -

 now, I can't do any string operations, I get the error msg:

 descriptor 'lower' requires a 'str' object but received a 'unicode'
   args = (descriptor 'lower' requires a 'str' object but received
 a 'unicode',)


 or similar, on every string operation.

What is string operation? Every time you say I get error please
provide source code where this error occurs. And by the way, do you
know that for non-ascii characters you should use unicode type, not str
type?

  -- Leo

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


Re: trees

2006-12-18 Thread Raymond Hettinger
vertigo wrote:
 What library/functions/classes could i use to create trees ?

Start with random.seed, login as root, use svn to download the trunk
and branches, when Spring arrives, the leaves will fill-in ;-)

Or just use lists as Fredrik suggested.

Or look at an example in the cookbook:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/201423


Raymond

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


undefined symbol: libxml_xmlDocPtrWrap

2006-12-18 Thread Christian Wenz
Hello, 

I try to install listen on my amd64-gentoo-box. The programm 
tries to import the gst-package and throws the following trace:

Traceback (most recent call last):
  File stdin, line 1, in ?
  File /usr/lib/python2.4/site-packages/gst-0.10/gst/__init__.py, 
line 108, in ?
from _gst import *
ImportError: /usr/lib64/python2.4/site-packages/gst-0.10/gst/_gst.so:
undefined symbol: libxml_xmlDocPtrWrap

Does anybody know this problem? 

Greetings Chris

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


Re: merits of Lisp vs Python

2006-12-18 Thread Bill Atkins

This is not a response to any particular post, but rather to the
general argument that macros are not as useful as we Lispers claim.

Here is a fairly complete GUI RSS reader in 90 lines of Lisp (the GUI
code itself is 90 lines, but it makes use of some RSS reading/writing
code I had laying around and two public CL libraries: s-xml and
trivial-http).  The code employs a handy macro called DEFINE-INTERFACE
that LispWorks provides with their CAPI toolkit.  I hope this will be
useful as an illustration of what macros (and Lisp in general) can do,
and as an example of what a moderately practical CL application looks
like.

The application presents a list of feeds and allows the user to add
new feeds or to delete existing feeds.  The feeds are presented as a
tree, with each channel acting as a parent to several items.  The user
can refresh all of the feeds with the Refresh All button.
Double-clicking on any item will display its description field (as in
the screenshot).  Each channel shows the number of unread articles and
the articles are arranged so that the unseen articles appear before
the articles that have already been read.

Important things to note:

 1) the DEFINE-INTERFACE syntax closely resembles the syntax of the
standard DEFCLASS macro, so newcomers have a basic idea of what
DEFINE-INTERFACE is going to do

 2) the expansion ( http://galoot.org/~bill/code/rss-reader/expanded.lisp )
of just the DEFINE-INTERFACE is quite involved, a testament to
the amount of work the macro saves

 3) much of the GUI can be specified declaratively because of the
DEFINE-INTERFACE syntactic abstraction, and this declarativeness
makes it very easy for maintainers to understand what's going on

 4) even without knowing the implementation of DEFINE-INTERFACE and
even without prior experience with it, one can make good guesses
about what it does

 5) the GUI code is stunningly concise

Here is the GUI code alone:  

   http://galoot.org/~bill/code/rss-reader/rss-gui.lisp 

Here is a screenshot of the application in development:

   http://galoot.org/~bill/code/rss-reader/development.png 

and two screenshots of the application in use

   http://galoot.org/~bill/code/rss-reader/in%20action.png 
   http://galoot.org/~bill/code/rss-reader/in%20action%202.png 

Here are the support files:

   http://galoot.org/~bill/code/rss-reader/ 

Here is an OS X universal binary (run at your own risk; I've only
done very basic testing):

   http://galoot.org/~bill/code/rss-reader/BarebonesRSS.app.tar.gz 

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


HTTP or alternative upload for large files

2006-12-18 Thread Jacob Mathew
Hay Robin..

 

I am Jacob Mathew.. Doing some research in large file uploads for my
project. I got your matured skills and ability to do programs for upload
huge files. In fact I am a kid in programming, I cannot think to write such
a god program. Will you able to share your uploading script with me so that
it will be useful to me.. 

 

Waiting for Your Reply

 

Thanks  Regards 

Jacob Mathew

 

 

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

Re: Good Looking UI for a stand alone application

2006-12-18 Thread Peter Decker
On 12/17/06, Luc Heinrich [EMAIL PROTECTED] wrote:

  My requirement is that the application needs to look as good on Windows as
  on the Apple Mac

 Crossplatform GUIs are a myth, you *always* end up with a lowest common
 denominator (aka Windows) which makes your application look like crap on
 other platforms. And when the toolkit/framework only makes it look like
 semi-crap, it makes it *feel* like crap.

You're full of it. I routinely write GUI apps in Dabo for both Windows
and Linux users, and they look just fine on both platforms. Using
sizers is the key; layouts just 'look right' no matter what the native
fonts and control sizes are.

-- 

# p.d.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: first and last index as in matlab

2006-12-18 Thread Evan
Thanks for all the replies, it's much clearer now.

-Evan

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


Re: tuple.index()

2006-12-18 Thread Nick Maclaren

In article [EMAIL PROTECTED],
greg [EMAIL PROTECTED] writes:
| Roy Smith wrote:
| 
|  The struct does lookup by name, the tuple is inherently index based.
| 
| I was trying to help people understand the distinction
| we're talking about by showing an example of the same
| distinction in another language where it's much clearer.
| 
| There are a great many ways in which C structs are
| different from Python tuples, and C arrays are different
| from Python lists. But they're not the aspects I'm
| drawing an analogy between.

Unfortunately, you are confusing the issue, because there are far
more extraneous aspects than relevant ones, and your view of the
similarities requires looking at the issue in a very strange way.
I think that I can see what you mean, but only just.


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


Re: Roundtrip SQL data especially datetime

2006-12-18 Thread GHUM
 One side effect of this being third party code is that hosting
 services may not have it available, even when they have both Python
 and MySQL up.  This is never a problem with Perl or PHP, so that's
 a negative for Python.

I for one think it is a good thing to not have MySQL adapters
integrated into Python core. Neither the philopsophie, nor the licence
of the two products fit together.

But maybe that's because I am a PostgreSQL zealot - and PostgreSQL and
Python is really a match made in heaven.

Harald

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


Re: merits of Lisp vs Python

2006-12-18 Thread Bruno Desthuilliers
Paul Rubin a écrit :
 Rob Thorpe [EMAIL PROTECTED] writes:
 
Once you can do the above then you can phrase programs entirely in
terms of composition of functions, which is what functional programming
is about.

Getting good performance though is problematic without being able to
evaluate parts at compile time.  This is why almost all functional
languages provide that feature in some form.
 
 
 I'm not aware of any special features in Haskell for that purpose, or
 in Scheme until maybe with the more recent versions.  I thought the
 main feature needed for functional programming besides first-class
 functions was guaranteed tail call optimization.

Strictly speaking, only first-class functions are required, and 
tail-recursion optimisation is only an implentation detail. Now it's 
obvious that when it comes to real-life-size programs, this is a *very* 
important detail !-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: merits of Lisp vs Python

2006-12-18 Thread Bruno Desthuilliers
Mathias Panzenboeck a écrit :
 Bruno Desthuilliers wrote:
 
Mathias Panzenboeck a écrit :

Rob Thorpe wrote:


Mathias Panzenboeck wrote:


Mark Tarver wrote:


How do you compare Python to Lisp?  What specific advantages do you
think that one has over the other?

Note I'm not a Python person and I have no axes to grind here. 
This is
just a question for my general education.

Mark


I do not know much about Lisp. What I know is:
Python is a imperative, object oriented dynamic language with duck
typing,

Yes, but Python also supports the functional style to some extent.



I currently visit a course about functional programming at the
university of technology vienna:
python implements only a small subset of things needed to be called a
functional language (list
comprehension).

Python has functions as first-class objects (you can pass functions as
arguments to functions, return functions from functions, and bind
functions to identifiers), and that's the only thing you need to use a
functional approach.
 
 
 You mean like function pointers in C and C++? 

Absolutely not. Python's functions are normal Python objects, instances 
of the (builtin) class 'function'. FWIW, any object implementing the 
__call__ method can behave as a function.

Python functions can take functions as arguments, and return functions - 
this is how 'decorators' work.

 I think this should be possible in assembler, too.
 I thought functional languages have to be declarative?

For what definition of 'declarative' ?

 The boost C++ library has even lambdas!

So does Python - even if in a restricted way.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: merits of Lisp vs Python

2006-12-18 Thread Bruno Desthuilliers
Kaz Kylheku a écrit :
 Bruno Desthuilliers wrote:
 
André Thieme a écrit :

Bruno Desthuilliers schrieb:


(snip)

Both are highly dynamic. Neither are declarative.


Well, Lisp does support some declarative features in the ansi standard.

If you go that way, there are declarative stuff in Python too... But
neither Lisp nor Python are close to, say, SQL.
 
 
 False. Common Lisp can be made to support SQL syntax.
 
And Python can be made to support something really close to it, cf 
SQLAlchemy. And Python has list comprehensions, which are mostly on the 
declarative side (ie : what, not how):

[x for x in range(100) if x % 2 == 0]

Etc, etc, etc...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Metaclass uses?

2006-12-18 Thread Michele Simionato
Nathan Harmston wrote:
 Hi,

 Recently I posted a question about the factory pattern in python. I ve
 implemented this following one of the ideas posted. After some reading
 I ve seem a lot of Aspect Oriented Programming mentioned but I m not
 really sure what it is.

 Can anyone help me understand how metaclasses can improve the quality
 of my code and let me do better things.

Have you read the two papers in IBMDeveloperWorks about metaclasses?
There is also
a third one, about avoiding metaclasses, which is waiting for
publication. Here is the draft:
http://www.phyast.pitt.edu/~micheles/python/classinitializer.html

   Michele Simionato

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


Re: import

2006-12-18 Thread Bruno Desthuilliers
Gert Cuykens a écrit :
 I would like to lauch a server from outside the side package directory
 how do i specify a path with import

http://docs.python.org/tut/node8.html#SECTION00811

(snip)


 if __name__ == '__main__':  # ??? dont know what is this for

When a module is used as a program (ie python myprog.py), the 
module-level magic variable '__name__' is set to main. If the module is 
imported by another  one, this variable is set to the name of the 
module. This allow a module to have different behaviours according to 
how it is used.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: trees

2006-12-18 Thread Bruno Desthuilliers
Raymond Hettinger a écrit :
 vertigo wrote:
 
What library/functions/classes could i use to create trees ?
 
 
 Start with random.seed, login as root, use svn to download the trunk
 and branches, when Spring arrives, the leaves will fill-in ;-)

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


Re: Class and instance question

2006-12-18 Thread Bruno Desthuilliers
Marco Wahl a écrit :
(snip)
 The __new__ method should return the class. 

s/class/instance/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why there isn't a sort method for array ?

2006-12-18 Thread James Stroud
John Machin wrote:
 Tim Roberts wrote:
 [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 It seems that an array acts like an list very much, except it doesn't
 have a method sort.
 What do you mean by array?  There is no such beast in the Python
 language.  Do you mean the library module array?

 
 Indubitably the OP means objects created by the array function in the
 array module. Does that help you answer his question?
 
 Cheers,
 John
 

Yep. Seems like there should be a sort() for array.array objects, 
especially since they implement pop(), insert(), extend(), etc. Also, 
all data types corresponding to array typecodes can be compared in a 
sort: http://docs.python.org/lib/module-array.html.

In the mean time, try

my_sorted_array = array.array(my_array.typecode, sorted(my_array))

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


Re: Dictionary, iterate update objects

2006-12-18 Thread Bruno Desthuilliers
jansenh a écrit :
 hi comp.lang.python.
 
 I need some newbe advice on idiomatic use of Python dictionaries.
 
 I have service with a dictionary which holds a bunch of objects as
 values, and an ID as key to each object. Then I want to change an
 objects state based on its key.

class MyObj(object):
   def __init__(self, foo):
 self.foo = foo

objs = {
   'foo': MyObj('foo'),
   'bar', MyObj('bar'),
   }

objs['foo'].foo = 42

for key, obj in objs:
   print %s : %s % (key, obj.foo)

 The way I am doing this now is by using
 'fromkeys' and copying my object over in a temporary dictionary, then
 manipulating the object, and then I do an 'update' back to the main
 dictionary..  :-0

My my my...

 There has to be a smarter way?

Indeed. Usually, with Python, smarter = simplest

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


Re: merits of Lisp vs Python

2006-12-18 Thread André Thieme
Paul Rubin schrieb:

 GC also gets rid of programs.  There are programs you can write in C
 but not in Lisp, like device drivers that poke specific machine
 addresses.

You are talking about an ANSI Common Lisp implementation.
But nothing stops a vendor to deliver its CL with libs that support
the writing of device drivers.
When Naughty Dog programmed games for the Play Station 2 the used
Common Lisp to develop a Lisp called GOAL (Game Oriented Assembly
Lisp) that was specialized for writing PS2 games.


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


Re: parsing a dictionary from a string

2006-12-18 Thread Benjamin Georgi

Fredrik Lundh wrote:
 Benjamin Georgi wrote:
 
 I could use some help extracting the keys/values of a list of 
 dictionaries from a string that is just the str() representation of the 
 list (the problem is related to some flat file format I'm using for file 
 IO).

 Example:
   s = str(dict_list)
   s
 '[{0: [2], 1: []}, {0: [], 1: [], 2: []}, {0: [1, 2]}]'

 Then, what I want to do is to reconstruct dict_list given s.
 Now, one possible solution would be

   dict_list = eval(s)

 but since the content of s cannot be blindly trusted I`d rather not do 
 it that way. Basically my question is whether there is another solution 
 which is simpler than using regular expressions.
 
 here are a couple of cut-and-paste alternatives:
 
 use the tokenizer and a simple parser pattern:
 
http://groups.google.com/group/comp.lang.python/msg/a34397ba74892b4e
 
 use the compiler module and analyze the parse tree:
 
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/364469
 
 note that you cannot parse Python's expression syntax with plain regular 
 expressions; RE's are only good enough for lexical analysis.
 
 /F
 
Problem solved. Thanks to everybody who answered.

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


Re: merits of Lisp vs Python

2006-12-18 Thread Rob Warnock
[EMAIL PROTECTED] wrote:
+---
| Paul Rubin wrote:
|  [...]  There are programs you can write in C but not in Lisp,
|  like device drivers that poke specific machine addresses.
| 
| I should assume you meant Common Lisp, but there isn't really any
| reason you couldn't
|  (poke destination (peek source))
| in some version of Lisp that was meant for writing device drivers
| (perhaps under a Lisp machine or something).
+---

I do this kind of thing *every day* in CMUCL!! It's my primary
user-mode hardware debugging tool. Here's a typical utility function:

;;; Used for things like polling for a done flag.
;;; BUG: Assumes contents of ADDR will change within fixnum polls.
(defun spin-until-change (addr)
  (declare (optimize (speed 3) (debug 0) (safety 0)))
  (loop with v0 of-type (unsigned-byte 32) = (r32 addr)
with counts fixnum = 0
while (= v0 (r32 addr))
 do (setf counts (the fixnum (1+ counts)))
 finally (return counts)))

+---
| SIOD actually has (%%% memref address) for peek.
+---

CMUCL has SYSTEM:SAP-REF-{8,16,32} and SETFs of same. The R32
above is just my convenience wrapper around SYSTEM:SAP-REF-32:

(declaim (inline r32))

(defun r32 (addr)
  (declare (optimize (speed 3) (debug 0) (safety 0)))
  (system:sap-ref-32 (system:int-sap addr) 0))

(defun w32 (addr rest values)
  (declare (optimize (speed 3) (debug 0) (safety 0)))
  (loop for i fixnum from 0 by 4
and v of-type (unsigned-byte 32) in values
do (setf (system:sap-ref-32 (system:int-sap addr) i) v))
  (values))

Most other Common Lisp implementations surely have something similar.


-Rob

-
Rob Warnock [EMAIL PROTECTED]
627 26th Avenue URL:http://rpw3.org/
San Mateo, CA 94403 (650)572-2607

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


Re: Metaclass uses?

2006-12-18 Thread Bruno Desthuilliers
Nathan Harmston a écrit :
(snip)
 Also is there anymore interesting OO stuff that Python has apart from Java.

Quite a lot. Everything (well, except statements and expressions...) in 
Python is an object, including classes, modules and functions, and 
Python objects are really 'dynamic', ie you can modify them at runtime - 
and when I say 'modify', I mean things like adding/replacing/removing 
attributes, including methods and class (which are attributes too...).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Core dump revisited

2006-12-18 Thread Gabriel Genellina
On 17 dic, 07:01, Sheldon [EMAIL PROTECTED] wrote:

 I have a python script that uses a C extention. I keep getting a
 recurring problem that causes a core dump a few lines after the C
 extention return data back tp python. I tried using pbd and gdb but I

Most probably the error is inside the C extension, not in Python code.
Contact the author.

-- 
Gabriel Genellina

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


Re: New os.path.exists() behavior - bug or feature?

2006-12-18 Thread Martin v. Löwis
klappnase schrieb:
 When I insert a floppy into A: os.path.exists('A:\\') will return True
 on Python-2.5, too.
 Does anyone know, is this inconsistent behavior a bug or a new feature?

Neither, nor. In both cases, the operating system is asked, and gives
this answer. However, in the Windows API, there is no exists function
(nor is there on Unix); instead, exists is implemented by calling
several underlying functions. The precise set of functions used did
change between 2.4 and 2.5.

It is quite difficult to investigate the precise nature of the change
that leads to this change in observable behavior. If you think this is
a bug, it would be best if you could also investigate a patch.

 I also noticed that the Tix binaries are no longer present in 2.5, does
 anyone know if it is
 planned to remove them pemanently?

That was a mistake, I'll add it back in 2.5.1.

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


Re: Need Simple Way To Determine If File Is Executable

2006-12-18 Thread Gabriel Genellina
On 17 dic, 19:21, Roger Upole [EMAIL PROTECTED] wrote:

 os.stat(selected)[ST_MODE]  (S_IXUSR|S_IXGRP|S_IXOTH

 This will tell you that x.exe is executable, even if x.exe contains
  nothing but zeros.

  Isn't the same with any other recipe, portable or not? Unless the OS
  actually tries to load and examine the file contents, which the OS's
  I'm aware of, don't do.

 On windows, you can use win32file.GetBinaryType to check if a file is actually
 a binary executable.

A similar function exists on Linux too. But even if a file has the
right file format, if it does not have the execute bit set, won't run.
And you could set that bit on a JPG image too - and nothing good would
happen, I presume. So one must determine first what means the file is
executable.

-- 
Gabriel Genellina

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


connecting webservers through HTTP port using python

2006-12-18 Thread pradeep kumar

hii iam working on socket programming,
i've to connect webservers through HTTP port and send/receive data..
so currently i'm installed apache server and trying to connect that server
using python.
so any tell me how to connect the apache server by python code.
give suggestions..
-- 
http://mail.python.org/mailman/listinfo/python-list

Can a Tkinter GUI check for abort script:

2006-12-18 Thread Michael Yanowitz
Hello:

   I have successfully implemented a Tkinter GUI which has
this (simplified here for explanation):
+-+
|  filename: [./test3.py] |
| |
|  [Run Script]   |
+-+

   But, now what I would like to do while the script is
running, is replace the Run Script with Abort Script.  

+-+
|  filename: [./test3.py] |
| |
|  [Abort Script] |
+-+

   So, every tenth of a seconds or ??? better time, I
would like to 'return' to the GUI and check if the
Abort Script button has been pressed.
   How do I do this? Or is there a better way to
implement this?

Thanks in advance:
Michael Yanowitz


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


How to replace a comma

2006-12-18 Thread Lad
In a text I need to
add a blank(space) after a comma but only if there was no blank(space)
after the comman
If there was a blank(space), no change is made.

I think it could be a task for regular expression but can not figure
out the correct regular expression.
Can anyone help, please?
Thank you
L.

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


creating generic class

2006-12-18 Thread Divya Prakash
Hi,

 

 

 

I want to create a generic class to convert . java
  file  into xml file (validated against xsd / dtd).

 

 What is the best approach to do this with jython or python ?

 

 

 

 

 

Regards 

 

Divya

 

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

Re: merits of Lisp vs Python

2006-12-18 Thread Paul Rubin
Bruno Desthuilliers [EMAIL PROTECTED] writes:
 Strictly speaking, only first-class functions are required, and
 tail-recursion optimisation is only an implentation detail. Now it's
 obvious that when it comes to real-life-size programs, this is a
 *very* important detail !-)

I don't buy this.  One of my favorite quotes about specifications
(http://www.sgi.com/tech/stl/drdobbs-interview.html):

Let's take an example. Consider an abstract data type stack. It's not
enough to have Push and Pop connected with the axiom wherein you push
something onto the stack and after you pop the stack you get the same
thing back. It is of paramount importance that pushing the stack is a
constant time operation regardless of the size of the stack. If I
implement the stack so that every time I push it becomes slower and
slower, no one will want to use this stack.

We need to separate the implementation from the interface but not at
the cost of totally ignoring complexity. Complexity has to be and is a
part of the unwritten contract between the module and its user. The
reason for introducing the notion of abstract data types was to allow
interchangeable software modules. You cannot have interchangeable
modules unless these modules share similar complexity behavior. If I
replace one module with another module with the same functional
behavior but with different complexity tradeoffs, the user of this
code will be unpleasantly surprised. I could tell him anything I like
about data abstraction, and he still would not want to use the
code. Complexity assertions have to be part of the interface.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to replace a comma

2006-12-18 Thread Peter Otten
Lad wrote:

 In a text I need to
 add a blank(space) after a comma but only if there was no blank(space)
 after the comman
 If there was a blank(space), no change is made.

 s = alpha, beta,gamma,  delta
 , .join(t.replace(,, , ) for t in s.split(, ))
'alpha, beta, gamma,  delta'

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


Re: How to replace a comma

2006-12-18 Thread Jon Clements

Lad wrote:

 In a text I need to
 add a blank(space) after a comma but only if there was no blank(space)
 after the comman
 If there was a blank(space), no change is made.

 I think it could be a task for regular expression but can not figure
 out the correct regular expression.
 Can anyone help, please?
 Thank you
 L.

Off the top of my head, something like re.sub(', *', ', ', 'a,
b,c,d,e, f'), meets your requirements (it also ensures the number of
spaces after the comma is one). However, you may need to refine the
rules depending on what you really want to achieve. For instance, what
happens with: a comma appearing before any text, consecutive commas (ie
,,,), or commas within quotes?

hth
Jon.

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


How to get a substring with variable indices

2006-12-18 Thread Станислав Ягло
Hello all!

I have a string named text. I need to extract a substring from it 
starting by variable 's' and ending by 'e'.

text[s:e] generates the following error:

TypeError: slice indices must be integers or None


How to be? :)

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


Re: Good Looking UI for a stand alone application

2006-12-18 Thread Chris Mellon
On 12/17/06, Christophe Cavalaria [EMAIL PROTECTED] wrote:
 Sandra-24 wrote:

  On 12/16/06, The Night Blogger [EMAIL PROTECTED] wrote:
  Can someone recommend me a good API for writing a sexy looking (Rich UI
  like WinForms) shrink wrap application
 
  My requirement is that the application needs to look as good on Windows
  as on the Apple Mac
 
  wxPython or something layered on it would be the way to go. I tried all
  the popular toolkits (except qt) and nothing else comes close for cross
  platform gui work. Don't let people persuade you otherwise, that caused
  me a lot of trouble.

 Well, you should try qt too ;)

 BTW, does wxWindow/wxPython have something that allows you to switch the OK
 and Cancel button position according to the current machine GUI guidelines?


Yes. See wxDialog.CreateButtonSizer, which will return a sizer
(probably, on some embedded platforms it might not create actual
buttons, see docs) that has ok/cancel buttons in the standard position
for the platform, and with the correct stock graphics and text on
those platforms that have such a concept (like Gtk/GNOME).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: convert from date string to epoch

2006-12-18 Thread Stefan Antonelli
Amit Khemka khemkaamit at gmail.com writes:
 
 Check out timegm function in calendar module. The following function
 converts mm/dd/ formats into epoch value, you can hack it for
 your date formats.
 
 def convertToEpoch(date):
  tup = map(int,date.split('/'))
  l = (tup[2], tup[0], tup[1], 0, 0, 0)
  epochs = calendar.timegm(l)
  return (int(epochs))


Thanks for your suggestion... For me this was the Solutions:

# convert '-mm-dd hh:mm:ss' to epoch
def toEpoch(timestamp):
  split = str(timestamp).split(' ')
  tdate = map(int,split[0].split('-'))
  ttime = map(int,split[1].split(':'))
  tcode = (tdate[0], tdate[1], tdate[2], ttime[0], ttime[1], ttime[2])
  epoch = timegm(tcode)
  return (int(epoch))

Stefan.

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


Re: How to get a substring with variable indices

2006-12-18 Thread Paul Rubin
ÁâÐÝØáÛÐÒ ÏÓÛÞ [EMAIL PROTECTED] writes:
 text[s:e] generates the following error:
 TypeError: slice indices must be integers or None
 
 How to be? :)

s and e both have to be integers or None.  Try printing them out just
before your slice to see if their values are reasonable.

 s = 2
 e = 4
 python[s:e]
'th'
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get a substring with variable indices

2006-12-18 Thread Tim Chase
 I have a string named text. I need to extract a substring from it 
 starting by variable 's' and ending by 'e'.
 
 text[s:e] generates the following error:
 
 TypeError: slice indices must be integers or None

Your syntax is correct...the error you get back is the clue: 
either s or e fails to meet the criteria of being integers 
or None.  Check your values/types of those two variables before 
this call and you'll likely find that one or both is some other 
data-type.

  text=hello world
  s = 4
  e = 5
  text[s:e]
'o'

Darn those error messages that give away the answer... ;)

-tkc



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


Re: How to replace a comma

2006-12-18 Thread Hendrik van Rooyen
From: Lad [EMAIL PROTECTED] wrote:


 In a text I need to
 add a blank(space) after a comma but only if there was no blank(space)
 after the comman
 If there was a blank(space), no change is made.
 
 I think it could be a task for regular expression but can not figure
 out the correct regular expression.

re's are a pain.  Do this instead:

 s = hello, goodbye,boo
 s.replace(', ',',')
'hello,goodbye,boo'
 _.replace(',',', ')
'hello, goodbye, boo'
 

Hope this helps - Hendrik

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


Re: Can a Tkinter GUI check for abort script:

2006-12-18 Thread Hendrik van Rooyen
Michael Yanowitz [EMAIL PROTECTED] Wrote:


 Hello:
 
I have successfully implemented a Tkinter GUI which has
 this (simplified here for explanation):
 +-+
 |  filename: [./test3.py] |
 | |
 |  [Run Script]   |
 +-+
 
But, now what I would like to do while the script is
 running, is replace the Run Script with Abort Script.  
 
 +-+
 |  filename: [./test3.py] |
 | |
 |  [Abort Script] |
 +-+
 
So, every tenth of a seconds or ??? better time, I
 would like to 'return' to the GUI and check if the
 Abort Script button has been pressed.
How do I do this? Or is there a better way to
 implement this?

Use the configure method to change the command of the button,
to point away from run to abort, as the first thing done in run.

You can change the text too to read correctly, at the same time, 
as well as the background colour to red...

- Hendrik


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


Re: How to get a substring with variable indices

2006-12-18 Thread Станислав Ягло
Tim Chase wrotes:
 I have a string named text. I need to extract a substring from it 
 starting by variable 's' and ending by 'e'.

 text[s:e] generates the following error:

 TypeError: slice indices must be integers or None

 Your syntax is correct...the error you get back is the clue: either 
 s or e fails to meet the criteria of being integers or None.  
 Check your values/types of those two variables before this call and 
 you'll likely find that one or both is some other data-type.

  text=hello world
  s = 4
  e = 5
  text[s:e]
 'o'

 Darn those error messages that give away the answer... ;)

 -tkc





Yeah, you're right! I've already found that stupid error. I've entagled 
variable names.
-- 
http://mail.python.org/mailman/listinfo/python-list


Shed Skin - Does it break any Python assumptions?

2006-12-18 Thread skip
I just noticed the announcement of Shed Skin 0.0.16 on Freshmeat with this
(partial) change announcement:

Changes: frozenset was added. time.sleep now works on Win32.

Given Python's highly dynamic nature it's unclear to me how Shed Skin could
know enough about the semantics of time.sleep to know whether or not it's
broken on Win32.  This suggests that to gain speedups it probably implements
a more static language than Python.  For example, does Shed Skin handle a
case like this?

 import time
 time.sleep(1)
 def _sleep(n):
...   print sleeping for, n, seconds
...   time._sleep(n)
...
 time._sleep = time.sleep
 time.sleep = _sleep
 time.sleep(1)
sleeping for 1 seconds

What does this phrase in the announcement mean?  ... pure but implicitly
statically typed Python   Where does the static typing begin and end?
Can one module tweak another module's attributes?  Can a class's attributes
be modified from outside the class?  What about the attributes of a class
instance?

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


Re: Shed Skin - Does it break any Python assumptions?

2006-12-18 Thread Jean-Paul Calderone
On Mon, 18 Dec 2006 08:07:59 -0600, [EMAIL PROTECTED] wrote:
I just noticed the announcement of Shed Skin 0.0.16 on Freshmeat with this
(partial) change announcement:

Changes: frozenset was added. time.sleep now works on Win32.

Given Python's highly dynamic nature it's unclear to me how Shed Skin could
know enough about the semantics of time.sleep to know whether or not it's
broken on Win32.

Actually, this could just mean that on Windows, there is no suitable
implementation of the stdlib function time.sleep, and so attempts to
use it will result in bad behavior of some sort.

It does not necessarily mean that ShedSkin is doing anything which
might prevent the attribute `sleep' from being rebound on a module
importable as `time' to some other function which behaves differently.

Of course, what is not necessarily the case may still be the case. ;)

This suggests that to gain speedups it probably implements
a more static language than Python.  For example, does Shed Skin handle a
case like this?

 import time
 time.sleep(1)
 def _sleep(n):
...   print sleeping for, n, seconds
...   time._sleep(n)
...
 time._sleep = time.sleep
 time.sleep = _sleep
 time.sleep(1)
sleeping for 1 seconds

What does this phrase in the announcement mean?  ... pure but implicitly
statically typed Python   Where does the static typing begin and end?
Can one module tweak another module's attributes?  Can a class's attributes
be modified from outside the class?  What about the attributes of a class
instance?

From the ShedSkin README:

Do not use:
  ...
  -reflection (getattr, hasattr), eval, or other really dynamic stuff
  ...

I would say that the example you presented above falls into the really
dynamic stuff category. ;)

And in fact, attempting to compile a program somewhat like the one above
results in this:

[EMAIL PROTECTED]:~/Scratch/Source/shedskin-0.0.16$ make
g++ -O3  -I./lib ./lib/builtin.cpp ./lib/time.cpp foo.cpp -lgc  -o foo
foo.cpp: In function ‘int __foo__::__main()’:
foo.cpp:6: error: assignment of function ‘void __time__::sleep(double)’
foo.cpp:6: error: cannot convert ‘unsigned int ()(unsigned int)’ to ‘void 
()(double)’ in assignment
make: *** [foo] Error 1
[EMAIL PROTECTED]:~/Scratch/Source/shedskin-0.0.16$ 

So yes, it seems that what ShedSkin supports is pretty distant from what
a seasoned Python developer might expect, aside from syntactic constructs.

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

Re: How to replace a comma

2006-12-18 Thread Lad


Thank you for ALL for help.
Hendrik,
your solution works great but
what is `_`  in
_.replace(',',', ')

for?
Thank you
La.

 re's are a pain.  Do this instead:

  s = hello, goodbye,boo
  s.replace(', ',',')
 'hello,goodbye,boo'
  _.replace(',',', ')
 'hello, goodbye, boo'
  
 
 Hope this helps - Hendrik

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


Re: How to replace a comma

2006-12-18 Thread Nick Craig-Wood
Lad [EMAIL PROTECTED] wrote:
  In a text I need to add a blank(space) after a comma but only if
  there was no blank(space) after the comman If there was a
  blank(space), no change is made.
 
  I think it could be a task for regular expression but can not
  figure out the correct regular expression.

You can do it with a zero width negative lookahead assertion, eg

   import re
   s=One, Two,Three,Four, File
   re.sub(r,(?!\s), , , s)
  'One, Two, Three, Four, File'
   

From the help :-

  (?!...)
  Matches if ... doesn't match next. This is a negative lookahead
  assertion. For example, Isaac (?!Asimov) will match 'Isaac ' only if
  it's not followed by 'Asimov'

Or in a more straightforward but less efficient and accurate style -
this matches the next character which gets added back into the string.

   re.sub(r,([^\s]), r, \1, s)
  'One, Two, Three, Four, File'
   

This shows a fundamental difference between the two methods

   t = ,
   re.sub(r,(?!\s), , , t)
  ', , , , , '
   re.sub(r,([^\s]), r, \1, t)
  ', ,, ,,'
  

-- 
Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Core dump revisited

2006-12-18 Thread Nick Craig-Wood
Sheldon [EMAIL PROTECTED] wrote:
  gdb msgppscomp.py core.3203

Run

  gdb python

Then type

  run msgppscomp.py

at the gdb prompt.

When it crashes, type bt for a back trace.  This will pinpoint
exactly where it crashes.

Hopefully that will make things clearer.  If not post the output.

-- 
Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Script to upload Files via http/cgi

2006-12-18 Thread Richard Konrad
Hi folks!

Does anyone know about a python-script to upload Files via http/cgi?

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


Strange error with getattr() function

2006-12-18 Thread Hole
Hi There!

I'm trying to use Zope and the product OpenFlow.

I got the following error while I was using the built-in function
getattr() to retrieve an OpenFlow object:

attribute name must be string


Actually, I surely pass a string as attribute name to getattr()

The code:

#following instruction returns me the string WorkFlowTest
openflow_id=container.aq_parent.id

if (hasattr(container,openflow_id):
#the interpreter enter in this block, so
#it's sure that container has an attribute called WorkFlowTest
openflow=getattr(container,openflow_id)

At this point, I got the error: attribute name must be string

The *strange* is that I get the same error even if I pass the attribute
name to the getattr() function as pure string:

getattr(container,WorkFlowTest)

(sic!)

I'm a lot confused!
Thanks in advance.

-- 
H0le

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


Re: How to replace a comma

2006-12-18 Thread Duncan Booth
Hendrik van Rooyen [EMAIL PROTECTED] wrote:

 From: Lad [EMAIL PROTECTED] wrote:
 
 
 In a text I need to
 add a blank(space) after a comma but only if there was no blank(space)
 after the comman
 If there was a blank(space), no change is made.
 
 I think it could be a task for regular expression but can not figure
 out the correct regular expression.
 
 re's are a pain.  Do this instead:
 
 s = hello, goodbye,boo
 s.replace(', ',',')
 'hello,goodbye,boo'
 _.replace(',',', ')
 'hello, goodbye, boo'
 
 
Personally I'd go one step further and regularise the whitespace around the 
commas completely (otherwise what if you have spaces before commas, or 
multiple spaces after them:

 s = hello, goodbye ,  boo
 print ', '.join(t.strip() for t in s.split(','))
hello, goodbye, boo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can a Tkinter GUI check for abort script:

2006-12-18 Thread Mohammad Tayseer
To view a button  hide the other, call .pack_forget() on the button you want 
to hide  pack() on the button you want to show

test3.py should contains a main() function that returns the new window. if you 
press 'Abort script' button you should call new_window.destroy(), pack_forget() 
the current button  pack() the 'run script' button



 __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com -- 
http://mail.python.org/mailman/listinfo/python-list

Re: How to replace a comma

2006-12-18 Thread Jussi Salmela
Lad kirjoitti:
 
 Thank you for ALL for help.
 Hendrik,
 your solution works great but
 what is `_`  in
 _.replace(',',', ')
 
 for?
When you are trying things out in the Python shell IDLE, _ is a 
shorthand way to use the last value printed by IDLE.

Thus when
s.replace(', ',',')
prints out
'hello,goodbye,boo'
_ refers to that value so the replace operation
_.replace(',',', ')

manipulates that value.

Cheers
Jussi
 Thank you
 La.
 
 re's are a pain.  Do this instead:

 s = hello, goodbye,boo
 s.replace(', ',',')
 'hello,goodbye,boo'
 _.replace(',',', ')
 'hello, goodbye, boo'
 Hope this helps - Hendrik
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Over my head with descriptors

2006-12-18 Thread Sarcastic Zombie
  Is there a reason you don't just use __init__ instead of __new__, and use
  self.age and self.weight and so on?I was asking myself the same thing...

 Chris

A lack of understanding, he answered sheepishly.

There are attributes (ie, question._qtext) that I do want to be the
same for every instance and thus don't want the extra memory overhead
of storing it anew for each instance.

Using the instance reference as you guys suggested, I'm now storing
the instance-specific information that the descriptors validate by
cramming it into instance._foo. Works great now!

Thanks for the additional understanding. It's a lot to wrap one's head
around at first.

-SZ

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


Re: How to replace a comma

2006-12-18 Thread Lad

Nick Craig-Wood wrote:
 Lad [EMAIL PROTECTED] wrote:
   In a text I need to add a blank(space) after a comma but only if
   there was no blank(space) after the comman If there was a
   blank(space), no change is made.
 
   I think it could be a task for regular expression but can not
   figure out the correct regular expression.

 You can do it with a zero width negative lookahead assertion, eg

import re
s=One, Two,Three,Four, File
re.sub(r,(?!\s), , , s)
   'One, Two, Three, Four, File'
   

 From the help :-

   (?!...)
   Matches if ... doesn't match next. This is a negative lookahead
   assertion. For example, Isaac (?!Asimov) will match 'Isaac ' only if
   it's not followed by 'Asimov'

 Or in a more straightforward but less efficient and accurate style -
 this matches the next character which gets added back into the string.

re.sub(r,([^\s]), r, \1, s)
   'One, Two, Three, Four, File'
   

 This shows a fundamental difference between the two methods

t = ,
re.sub(r,(?!\s), , , t)
   ', , , , , '
re.sub(r,([^\s]), r, \1, t)
   ', ,, ,,'
   
 Nick,
Thanks a lot.It works GREAT!
La.

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


RE: Can a Tkinter GUI check for abort script:

2006-12-18 Thread Michael Yanowitz
  Thank you (and Thanks to Hendrik). Both good ideas. I will need to do
those or something similar too.
But what I really want to know is what I need to do when pressing the Run
Script button, so that I
'return' to the GUI every once in a while, like every 100 milliseconds to
check if the Abort Script
button is pressed.
   Presently what happens is that the script takes over and all the buttons
on the GUI disappear
as the GUI is not given any cpu time to refresh or check if any activity in
the dialog.

Thanks in advance:
Michael Yanowitz
  -Original Message-
  From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
Mohammad Tayseer
  Sent: Monday, December 18, 2006 10:40 AM
  To: python-list@python.org
  Subject: Re: Can a Tkinter GUI check for abort script:


  To view a button  hide the other, call .pack_forget() on the button you
want to hide  pack() on the button you want to show

  test3.py should contains a main() function that returns the new window. if
you press 'Abort script' button you should call new_window.destroy(),
pack_forget() the current button  pack() the 'run script' button



  __
  Do You Yahoo!?
  Tired of spam? Yahoo! Mail has the best spam protection around
  http://mail.yahoo.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Windows Authetication vs seperate process

2006-12-18 Thread imageguy1206
I was wondering of someone could steer me in the right direction.

We have a package that we would like to secure so that only specific
individuals can access specific portions of the application.  Our
wxPython application will revolve around updating a central database
with information submitted from the app.  We will eventually have a web
front end fo rsome aspects of the app.

With several packages I have seen options to Use Windows
Authentication, which seems to mean that If the user has
authenticated and signed onto Windows, then our application will use
their windows userid and we will just focus on the the tasks within our
application the user is authorized to perform

Does anyone have any experience using this type of authentication
scheme ?

Any related tips or suggestions ?

I have found a few wikipedia entries, but they seem to be more related
to webpages, etc.

Thanks.

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


Re: Strange error with getattr() function

2006-12-18 Thread Hole

Hole ha scritto:

 Hi There!

 I'm trying to use Zope and the product OpenFlow.

 I got the following error while I was using the built-in function
 getattr() to retrieve an OpenFlow object:

 attribute name must be string


 Actually, I surely pass a string as attribute name to getattr()

 The code:

 #following instruction returns me the string WorkFlowTest
 openflow_id=container.aq_parent.id

 if (hasattr(container,openflow_id):
 #the interpreter enter in this block, so
 #it's sure that container has an attribute called WorkFlowTest
 openflow=getattr(container,openflow_id)

 At this point, I got the error: attribute name must be string


I'm wondering if the exception is raised in a hidden function and not
in the explicit call to getattr(). How can I view the traceback in a
script running in zope??

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


Re: Is there a way to push data into Ical from Python ?

2006-12-18 Thread has
dwhall wrote:

 One way would be to use
 Python's tie-ins to Applescript_ and apple events (AE).  As you will
 read, this support isn't as strong as it used to be.

What gave you that impression, if you don't mind my asking?

It's true that Python's built-in application scripting support
(aetools+gensuitemodule) has become increasingly broken on OS X and
should be avoided. Third-party support has been continually improving
over the last few years, however, and these days is pretty much on-par
with AppleScript in terms of functionality. See
http://appscript.sourceforge.net for more information and downloads.


 Another idea that would require more effort, but earn you some hacker
 points, is to use PyObjC_ and access iCal's public programming
 interface.

The CALCore framework is private in OS X 10.4, so the usual disclaimers
apply w.r.t. using that. See http://www.cocoadev.com/index.pl?CALCore
for a basic example of use. Scuttlebutt says there'll be a public iCal
framework in 10.5, although that won't help the OP right now unless
they're a paid-up ADC member.

has
-- 
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org

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


Re: Need Simple Way To Determine If File Is Executable

2006-12-18 Thread Tim Daneliuk
Gabriel Genellina wrote:
 On 17 dic, 19:21, Roger Upole [EMAIL PROTECTED] wrote:
 
   os.stat(selected)[ST_MODE]  (S_IXUSR|S_IXGRP|S_IXOTH
 This will tell you that x.exe is executable, even if x.exe contains
 nothing but zeros.
 Isn't the same with any other recipe, portable or not? Unless the OS
 actually tries to load and examine the file contents, which the OS's
 I'm aware of, don't do.
 On windows, you can use win32file.GetBinaryType to check if a file is 
 actually
 a binary executable.
 
 A similar function exists on Linux too. But even if a file has the
 right file format, if it does not have the execute bit set, won't run.
 And you could set that bit on a JPG image too - and nothing good would
 happen, I presume. So one must determine first what means the file is
 executable.
 

Well... sure, but that isn't the point. Here is the problem I was
trying to solve:

I wrote and maintain the 'twander' cross-platform file browser:

   http://www.tundraware.com/Software/twander/

I was working on a new release and wanted to add file associations
to it.  That is, if the user selected a file and double clicked or
pressed Enter, I wanted the following behavior (in the following
steps, type means nothing more than a file whose name ends with
a particular string):

1) If an association for that file type exists, run the associated program.

2) If an association for that file type does not exist:

a) If the file is not executable, see if there is a default
   association defined and run that program if there is.

b) If the file *is* executable, run it.


So ... all I really needed to know is whether or not the OS thinks the
file is executable.  Obvious - and this is true on most any system -
you can create the situation where the file appear executable from
the OS's point of view, but it is not actually.  But this is a pathology
that no application should really be expected to cope with...

-- 

Tim Daneliuk [EMAIL PROTECTED]
PGP Key: http://www.tundraware.com/PGP/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Roundtrip SQL data especially datetime

2006-12-18 Thread John Nagle
GHUM wrote:
One side effect of this being third party code is that hosting
services may not have it available, even when they have both Python
and MySQL up.  This is never a problem with Perl or PHP, so that's
a negative for Python.
 
 
 I for one think it is a good thing to not have MySQL adapters
 integrated into Python core. Neither the philopsophie, nor the licence
 of the two products fit together.

It's a wire protocol.  At one end of a socket, there's MySQL, and
at the other end, there's a client.  Neither side needs code from
the other.  The protocol is published.  So there's no license issue.

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


Re: Shed Skin - Does it break any Python assumptions?

2006-12-18 Thread bearophileHUGS
Jean-Paul Calderone:
 So yes, it seems that what ShedSkin supports is pretty distant from what
 a seasoned Python developer might expect, aside from syntactic constructs.

At the moment SS doesn't allow to change the type of a variable during
its lifetime, but SS is a moving target, maybe in the (far) future it
will split it into two variables...
I'm sure Mark likes to receive practical suggestions on how to improve
SS to make it closer to Python. (And I think he likes to receive
patches too, but usually it's better for people to start from simpler
things, like speeding up a lib written with C++, etc).

Bye,
bearophile

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


Re: Is there a way to push data into Ical from Python ?

2006-12-18 Thread Philip Austin
The Night Blogger [EMAIL PROTECTED] writes:

 Is there a way to pull  push data into (Apple Mac OS X Calendar) Ical from
 Python ?


see: http://vobject.skyhouseconsulting.com/

-- regards, Phil
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: convert from date string to epoch

2006-12-18 Thread John Machin

Stefan Antonelli wrote:
 Amit Khemka khemkaamit at gmail.com writes:
 
  Check out timegm function in calendar module. The following function
  converts mm/dd/ formats into epoch value, you can hack it for
  your date formats.
 
  def convertToEpoch(date):
   tup = map(int,date.split('/'))
   l = (tup[2], tup[0], tup[1], 0, 0, 0)
   epochs = calendar.timegm(l)
   return (int(epochs))


 Thanks for your suggestion... For me this was the Solutions:

 # convert '-mm-dd hh:mm:ss' to epoch
 def toEpoch(timestamp):
   split = str(timestamp).split(' ')

Binding the name split to this result is not a good idea, because it
leads to ...

   tdate = map(int,split[0].split('-'))

... the above line being rather difficult to read without exclamations
:-)

   ttime = map(int,split[1].split(':'))
   tcode = (tdate[0], tdate[1], tdate[2], ttime[0], ttime[1], ttime[2])

... and the above causes the same problem.

tcode = ttime + tcode

might be better.

   epoch = timegm(tcode)
   return (int(epoch))


Try this:

 def toEpoch(timestamp):
  datestr, timestr = str(timestamp).split(' ')
  tdate = datestr.split('-')
  ttime = timestr.split(':')
  tcode = map(int, tdate + ttime)
  epoch = timegm(tcode)
  return int(epoch)

Note: the last 5 lines can be jammed into one line if you are desperate
:-)

HTH,
John

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


Re: merits of Lisp vs Python

2006-12-18 Thread jayessay
Paul Rubin http://[EMAIL PROTECTED] writes:

 [EMAIL PROTECTED] writes:
  I should assume you meant Common Lisp, but there isn't really any
  reason you couldn't
  
   (poke destination (peek source))
 
 That breaks the reliability of GC.  I'd say you're no longer writing
 in Lisp if you use something like that.

Please note: GC is not part of CL's definition.  It is likely not part
of any Lisp's definition (for reasons that should be obvious), and for
the same reasons likely not part of any language's definition.  So,
your point here is actually a category error...


/Jon

-- 
'j' - a n t h o n y at romeo/charley/november com
-- 
http://mail.python.org/mailman/listinfo/python-list


REPORT

2006-12-18 Thread mskelton
***
A virus (WORM_MYDOOM.GEN) was detected in the file (letter.zip/letter.html  

 .exe). Action taken = remove
***-***


Message could not be delivered


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

Re: Need Simple Way To Determine If File Is Executable

2006-12-18 Thread Gabriel Genellina

At Monday 18/12/2006 13:41, Tim Daneliuk wrote:


I was working on a new release and wanted to add file associations
to it.  That is, if the user selected a file and double clicked or
pressed Enter, I wanted the following behavior (in the following
steps, type means nothing more than a file whose name ends with
a particular string):

1) If an association for that file type exists, run the associated program.

2) If an association for that file type does not exist:

a) If the file is not executable, see if there is a default
   association defined and run that program if there is.

b) If the file *is* executable, run it.


This is what os.startfile does. The underlying Win32 functions would 
be ShellExecute, FindExecutable  their variants.

Will you maintain your own registry for associations?


--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: connecting webservers through HTTP port using python

2006-12-18 Thread Gabriel Genellina

At Monday 18/12/2006 09:28, pradeep kumar wrote:


hii iam working on socket programming,
i've to connect webservers through HTTP port and send/receive data..
so currently i'm installed apache server and trying to connect that 
server using python.

so any tell me how to connect the apache server by python code.
give suggestions..


See the httplib module


--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: connecting webservers through HTTP port using python

2006-12-18 Thread Jonathan Curran
On Monday 18 December 2006 06:28, pradeep kumar wrote:
 hii iam working on socket programming,
 i've to connect webservers through HTTP port and send/receive data..
 so currently i'm installed apache server and trying to connect that server
 using python.
 so any tell me how to connect the apache server by python code.
 give suggestions..

Pradeep, first of all you might want to formulate your sentences properly so 
that it is understandable by the people who read it. Secondly, take the time 
to describe what your question/goal is.

From what I've read  possibly misunderstood, it seems that you want to be 
able to retreive data from a web page. If so you might want to glance at 
http://diveintopython.org/http_web_services/ and also take a look at the SGML 
section that is mentioned earlier on in the book.

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


Re: Script to upload Files via http/cgi

2006-12-18 Thread Gabriel Genellina

At Monday 18/12/2006 12:30, Richard Konrad wrote:


Does anyone know about a python-script to upload Files via http/cgi?


See the urllib2 module.


--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Strange error with getattr() function

2006-12-18 Thread Gabriel Genellina

At Monday 18/12/2006 12:33, Hole wrote:


I'm trying to use Zope and the product OpenFlow.


Try posting in the Zope list, you surely will have more responses.


I got the following error while I was using the built-in function
getattr() to retrieve an OpenFlow object:

attribute name must be string


Actually, I surely pass a string as attribute name to getattr()

The code:

#following instruction returns me the string WorkFlowTest
openflow_id=container.aq_parent.id


Are you sure it's a string? Some objects have an id() method. You 
always should use getId().



if (hasattr(container,openflow_id):
#the interpreter enter in this block, so
#it's sure that container has an attribute called WorkFlowTest
openflow=getattr(container,openflow_id)

At this point, I got the error: attribute name must be string


getattr is acquisition-aware so you might be retrieving another thing...


The *strange* is that I get the same error even if I pass the attribute
name to the getattr() function as pure string:

getattr(container,WorkFlowTest)
(sic!)


If you're really sure of this, I think the error may occur inside 
another function in the getattr chain.




--
Gabriel Genellina
Softlab SRL 







__ 
Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas 

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

psp 2 game list

2006-12-18 Thread Charles Bishop
could you send me a list of games you have
 __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com -- 
http://mail.python.org/mailman/listinfo/python-list

Re: Strange error with getattr() function

2006-12-18 Thread Gabriel Genellina

At Monday 18/12/2006 13:25, Hole wrote:


 At this point, I got the error: attribute name must be string

I'm wondering if the exception is raised in a hidden function and not
in the explicit call to getattr(). How can I view the traceback in a
script running in zope??


(Which Zope version?)
If you don't catch the exception, an error page will be displayed, 
pointing to the error_log object.



--
Gabriel Genellina
Softlab SRL 







__ 
Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas 

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

Re: Dictionary, iterate update objects

2006-12-18 Thread Carl Banks

Dennis Lee Bieber wrote:
 On 16 Dec 2006 14:49:19 -0800, jansenh [EMAIL PROTECTED]
 declaimed the following in comp.lang.python:

  Yes.
  [... the temp object is by ref, and any manipulation of the temp object
  is to the object itself..? It really simplifies my first attempt]
 
   For all practical purposes, everything in Python is by ref and the
 difference is whether the object itself is mutable (dictionaries, lists,
 class instances, modules) or immutable (strings, tuples, numbers). A
 mutable object is basically something that contains references to other
 objects

Not at all.  It's not even generally true of Python.  Mutability is
orthogonal to containership.

arrays, files, cStringIO objects, mmap objects, thread locks, some
iterator types, etc., are mutable but do not contain Python objects
(__dict__ excepted).

tuples, frozensets, instancemethods, are immutable but do contain
Python objects.


Carl Banks

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


Re: Windows Authetication vs seperate process

2006-12-18 Thread Gabriel Genellina

At Monday 18/12/2006 13:24, [EMAIL PROTECTED] wrote:


With several packages I have seen options to Use Windows
Authentication, which seems to mean that If the user has
authenticated and signed onto Windows, then our application will use
their windows userid and we will just focus on the the tasks within our
application the user is authorized to perform


Search for SSPI. But it may be a bit tricky to get running.


--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Need Simple Way To Determine If File Is Executable

2006-12-18 Thread Tim Daneliuk
Gabriel Genellina wrote:
 At Monday 18/12/2006 13:41, Tim Daneliuk wrote:
 
 I was working on a new release and wanted to add file associations
 to it.  That is, if the user selected a file and double clicked or
 pressed Enter, I wanted the following behavior (in the following
 steps, type means nothing more than a file whose name ends with
 a particular string):

 1) If an association for that file type exists, run the associated 
 program.

 2) If an association for that file type does not exist:

 a) If the file is not executable, see if there is a default
association defined and run that program if there is.

 b) If the file *is* executable, run it.
 
 This is what os.startfile does. The underlying Win32 functions would be 

And on Windows, that's exactly what I use.

 ShellExecute, FindExecutable  their variants.
 Will you maintain your own registry for associations?

Yes, because I want common configuration syntax and runtime
semantics across FreeBSD, Linux, Windows, et al.  The only
semantic difference is that, on Windows, if my own association
is not found, then the Windows association will apply.  This
cannot be done in the *nix environment - at least not easily -
because there is no common association repository across the
various window managers, nor is there a startfile() type
call in the POSIX world.


This is implemented already and largely works as planned.
There are a few subtleties I want to work into the next
release, but things work as expected today...

-- 

Tim Daneliuk [EMAIL PROTECTED]
PGP Key: http://www.tundraware.com/PGP/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: trees

2006-12-18 Thread Martin Manns
John Nagle wrote:

SpeedTree, of course.
 
 http://www.speedtree.com
 
They have great downloadable demos.

And how do you distribute the code in a python program?
Is there a wrapper for an available static library
or do I have to compile the speedtree source when
running the python program?

:)

M
--
From the homepage:
What parts of SpeedTree can I distribute with my game?

Before any sort of distribution, a full license of SpeedTree must be purchased.
Following this, the SpeedTreeRT library must be fully integrated with your game
before distribution. This means that either a static library is used or the 
source
code must be built in (no DLLs may be distributed). No source code from the SDK 
can
be distributed, with some exceptions for modified wrapper classes from the 
samples
(contact [EMAIL PROTECTED] for verification).
-- 
http://mail.python.org/mailman/listinfo/python-list


Python-URL! - weekly Python news and links (Dec 18)

2006-12-18 Thread Paul Boddie
QOTW:  c.l.python is just a small speck at the outer parts of the python
universe. most python programmers don't even read this newsgroup, except,
perhaps, when they stumble upon it via a search engine. -- Fredrik Lundh
(on comp.lang.python, prompting the editor to offer greetings to those of
you who are not reading Python-URL! via that channel)
http://groups.google.com/group/comp.lang.python/msg/4d73a2da72c87226

That's the kind of features I have in mind, and the best thing is that 
conceptually a lot of the work consists of connecting dots that already out 
there. But as there are so many of them, a few extra pencils would be quite 
welcome wink -- Willem Broekema (on comp.lang.python, referring to the
ongoing CLPython - Python in Common Lisp - project)
http://groups.google.com/group/comp.lang.python/msg/b72788cc5569d778
http://trac.common-lisp.net/clpython/


Registration for PyCon (the North American Python conference) is now open:

http://pycon.blogspot.com/2006/12/registration-for-pycon-2007-is-now.html
http://us.pycon.org/TX2007/Registration

Meanwhile, the EuroPython planners get ahead of themselves, thinking about 
conference venues as far in the future as 2010, if not 20010!
http://mail.python.org/pipermail/europython/2006-December/006158.html
http://mail.python.org/pipermail/europython/2006-December/006161.html

PyMite - the embedded Python interpreter - gets an update:

http://groups.google.com/group/comp.lang.python.announce/msg/b335a476d4033292
http://pymite.python-hosting.com/

This week's Python advocacy discovery had to be the revelation that YouTube 
runs on Python, helping to diminish concerns about Python's suitability for 
large scale Internet applications and services:
http://sayspy.blogspot.com/2006/12/youtube-runs-on-python.html
http://www.python.org/about/quotes/#youtube-com

Of related things flexible and fast, development in the Cherokee Web
server community produces the 100% Python implementation of SCGI: the
logically named PySCGI.
http://www.alobbs.com/news/1193

And on the advocacy front, volunteers are sought to write informative 
materials (flyers, whitepapers) promoting Python in different domains:
http://wiki.python.org/moin/AdvocacyWritingTasks

Video conferencing on the OLPC (One Laptop Per Child) prototype takes
shape with a mixture of technologies and a few lines of Python:
http://www.robot101.net/2006/12/12/telepathy-and-olpc/

After an influx of competing XML technologies and now drifting free
without an appointed maintainer, is the era of PyXML over?
http://mail.python.org/pipermail/xml-sig/2006-December/011620.html

On a more administrative level, the Python Software Foundation (PSF)
invites nominations for new directors:

http://pyfound.blogspot.com/2006/12/call-for-nominations-of-psf-directors.html

The PSF also suggests that you might consider a donation towards their
work of protecting the Python copyrights and trademarks:
http://pyfound.blogspot.com/2006/12/remember-psf-in-your-year-end.html



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

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

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

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

The Python Papers aims to publish the efforts of Python enthusiats.
http://pythonpapers.org/

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

http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce

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

Steve Bethard continues the marvelous tradition early borne by
Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim
Lesher of intelligently summarizing action on the 

SQLObject 0.8.0b1

2006-12-18 Thread Oleg Broytmann
Hello!

I'm pleased to announce the 0.8.0b1 release of SQLObject. This is the first
beta of the new branch. Taking into account that it is a result of rather
large job the beta period will be prolonged. Meanwhile the stable 0.7
branch will be maintained, and there will be at least 0.7.3 release.


What is SQLObject
=

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, and
Firebird.  It also has newly added support for Sybase, MSSQL and MaxDB (also
known as SAPDB).


Where is SQLObject
==

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

Download:
http://cheeseshop.python.org/pypi/SQLObject/0.8.0b1

News and changes:
http://sqlobject.org/devel/News.html


What's New
==

Features  Interface


* It is now possible to create tables that reference each other.
  Constraints (in the DBMSes that support constraints) are added after the
  tables have been created.

* Added ``createSQL`` as an option for sqlmeta. Here you can add
  related SQL you want executed by sqlobject-admin create after table
  creation. createSQL expects a string, list, or dictionary. If using
  a dictionary the key should be a dbName value (ex. 'postgres') and
  the value should be a string or list.  Examples in
  sqlobject/tests/test_sqlobject_admin.py or at
  http://sqlobject.org/sqlobject-admin.html#the-create-command

* Added method ``sqlhub.doInTransaction(callable, *args, **kwargs)``,
  to be used like::

  sqlhub.doInTransaction(process_request, os.environ)

  This will run ``process_request(os.environ)``.  The return
  value will be preserved.

* Added method ``.getOne([default])`` to ``SelectResults`` (these are
  the objects returned by ``.select()`` and ``.selectBy()``).  This
  returns a single object, when the query is expected to return only
  one object.  The single argument is the value to return when zero
  results are found (more than one result is always an error).  If no
  default is given, it is an error if no such object exists.

* Added a WSGI middleware (in ``sqlobject.wsgi_middleware``) for
  configuring the database for the request.  Also handles
  transactions.  Available as ``egg:SQLObject`` in Paste Deploy
  configuration files.

* New joins! ManyToMany and OneToMany; not fully documented yet, but still
  more sensible and smarter.

* SELECT FOR UPDATE

* New module dberrors.py - a hierarchy of exceptions. Translation of DB API
  module's exceptions to the new hierarchy is performed for SQLite and MySQL.

* SQLiteConnection got a new keyword factory - a name or a reference to
  a factory function that returns a connection class; useful for
  implementing functions or aggregates. See test_select.py and
  test_sqlite_factory.py for examples.

* SQLObject now disallows columns with names that collide with existing
  variables and methods, such as _init, expire, set and so on.

Small Features
--

* Configurable client character set (encoding) for MySQL.

* Added a close option to .commit(), so you can close the transaction as
  you commit it.

* DecimalValidator.

* Added .expireAll() methods to sqlmeta and connection objects, to expire
  all instances in those cases.

* String IDs.

* FOREIGN KEY for MySQL.

* Support for sqlite3 (a builtin module in Python 2.5).

* SelectResults cannot be queried for truth value; in any case it was
  meaningless - the result was always True; now __nonzero__() raises
  NotImplementedError in case one tries bool(MyTable.select()) or
  if MyTable.select():...

Bug Fixes
-

* Fixed problem with sqlite and threads; connections are no longer shared
  between threads for sqlite (except for :memory:).

* The reference loop between SQLObject and SQLObjectState eliminated using
  weak references.

For a more complete list, please see the news:
http://sqlobject.org/devel/News.html

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Windows Authetication vs seperate process

2006-12-18 Thread Jonathan Curran
On Monday 18 December 2006 10:24, [EMAIL PROTECTED] wrote:
 I was wondering of someone could steer me in the right direction.

 We have a package that we would like to secure so that only specific
 individuals can access specific portions of the application.  Our
 wxPython application will revolve around updating a central database
 with information submitted from the app.  We will eventually have a web
 front end fo rsome aspects of the app.

 With several packages I have seen options to Use Windows
 Authentication, which seems to mean that If the user has
 authenticated and signed onto Windows, then our application will use
 their windows userid and we will just focus on the the tasks within our
 application the user is authorized to perform

 Does anyone have any experience using this type of authentication
 scheme ?

 Any related tips or suggestions ?

 I have found a few wikipedia entries, but they seem to be more related
 to webpages, etc.

 Thanks.

Using windows authentication IMHO should only be used if there is an Active 
Directory/LDAP server set up against which the users are authenticated. I 
googled for 'active directory python' and came across 
http://tgolden.sc.sabren.com/python/ad_cookbook.html It seems to be very 
simple to use.

If I were to implement an authentication system like you want. I would:
1. Check to see if the local machine was part of a domain. If not then inform 
the user that they need to be.
2. Check to see if the user who ran the application is part of a specific 
group in AD.

I would assign each group a certain 'level' of privilege and accordingly let 
the user do what they should be able to do.

I hope this is a good starting point.

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


def index(self):

2006-12-18 Thread Gert Cuykens
Is there a difference between

code
class HelloWorld:
 def index(self):
  index.exposed = True
  return Hello world!
/code

and

code
class HelloWorld:
 def index(self):
  self.exposed = True
  return Hello world!
/code
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: writing serial port data to the gzip file

2006-12-18 Thread jim-on-linux



If someone hasn't already commented, 

Aside from any other problems, the file you are 
trying to write to is (opened)?? in the w mode. 
Every time a file is opened in the 'w' mode, 
everything in the file is deleted.

If you open a file in the 'a' mode, then 
everything in the file is left untouched and the 
new data is appended to the end of the file.

Your while loop is deleting everything in the file 
on each loop with the 'w' mode.

try, 
vfile = open('vfile', 'a')
rather than 
vfile = open('vfile', 'w')

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


 while 1:
 g=gzip.GzipFile(/root/foofile.gz,w)
 while dataOnSerialPort():
 g.write(data)
 else: g.close()



On Sunday 17 December 2006 20:06, Petr Jakes 
wrote:
 I am trying to save data it is comming from the
 serial port continually for some period.
 (expect reading from serial port is 100% not a
 problem) Following is an example of the code I
 am trying to write. It works, but it produce an
 empty gz file (0kB size) even I am sure I am
 getting data from the serial port. It looks
 like g.close() does not close the gz file.
 I was reading in the doc:

 Calling a GzipFile object's close() method does
 not close fileobj, since you might wish to
 append more material after the compressed
 data...

 so I am completely lost now...

 thanks for your comments.
 Petr Jakes
  snippet of the code  
 def dataOnSerialPort():
 data=s.readLine()
 if data:
 return data
 else:
 return 0

 while 1:
 g=gzip.GzipFile(/root/foofile.gz,w)
 while dataOnSerialPort():
 g.write(data)
 else: g.close()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python-URL! - weekly Python news and links (Dec 18)

2006-12-18 Thread Kay Schluehr
Paul Boddie wrote:

 Meanwhile, the EuroPython planners get ahead of themselves, thinking about
 conference venues as far in the future as 2010, if not 20010!

Python 20010. It was a nice conference although a bit lame on the first
day. My favourite talks were:

Trevor Stent: Whitespace as a universal constant
Mathais Fendro: Snake gods and how they tamed chaons and simili
Taumaturg 7: Technologia inversa. A short history of holistic
semantics

There was also some interesting short talk about wormhole calculus.
Unfortunetely I've forgotten the name of the lecturer. Maybe I was just
too fascinated by his appeal as a small spinning bubble, shining in
rainbow colors.

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


Re: merits of Lisp vs Python

2006-12-18 Thread Bruno Desthuilliers
Paul Rubin a écrit :
 Bruno Desthuilliers [EMAIL PROTECTED] writes:
 
Strictly speaking, only first-class functions are required, and
tail-recursion optimisation is only an implentation detail. Now it's
obvious that when it comes to real-life-size programs, this is a
*very* important detail !-)
 
 
 I don't buy this. 

Fine - I'm not trying to sell it !-)

 One of my favorite quotes about specifications
 (http://www.sgi.com/tech/stl/drdobbs-interview.html):
 
(snip).

 From a purely logical POV, the fact that a stack implementation has 
constant-time access or not is totally irrelevant (real-time problems 
set aside). This doesn't mean it's not important in practice.
-- 
http://mail.python.org/mailman/listinfo/python-list


When Closure get external variable's value?

2006-12-18 Thread Huayang Xia
What will the following piece of code print? (10 or 15)

def testClosure(maxIndex) :

def closureTest():
return maxIndex

maxIndex += 5

return closureTest()

print testClosure(10)

My question is when the closure function gets value for maxindex? Run
time or compile time?

Thanks.

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


Re: Is there a way to push data into Ical from Python ?

2006-12-18 Thread Max M
has skrev:
 dwhall wrote:
 
 One way would be to use
 Python's tie-ins to Applescript_ and apple events (AE).  As you will
 read, this support isn't as strong as it used to be.
 
 What gave you that impression, if you don't mind my asking?


http://www.google.dk/search?q=python+icalendar


-- 

hilsen/regards Max M, Denmark

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


Re: Core dump revisited

2006-12-18 Thread Sheldon

Nick Craig-Wood skrev:

 Sheldon [EMAIL PROTECTED] wrote:
   gdb msgppscomp.py core.3203

 Run

   gdb python

 Then type

   run msgppscomp.py

 at the gdb prompt.

 When it crashes, type bt for a back trace.  This will pinpoint
 exactly where it crashes.

 Hopefully that will make things clearer.  If not post the output.

 --
 Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick

Wonderful! Now I know how to used gdb with python. The are results area
posted below. Since I am new at this I could used some help in
interpreting the problem. What I do know is this: my allocation of the
array is good but when freeing the array, a problem arises. The problem
is given below but since I am new as well to C I sure could use some
help.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1077321856 (LWP 32710)]
0x40297b83 in mallopt () from /lib/tls/libc.so.6
(gdb) bt
#0  0x40297b83 in mallopt () from /lib/tls/libc.so.6
#1  0x402958ba in free () from /lib/tls/libc.so.6
#2  0x405e070a in MemoryFreeOrd () at msgppsmodule_area.c:1675
#3  0x405dae0a in msgppsarea (self=0x0, args=0x4042aa7c, kwargs=0x0) at
msgppsmodule_area.c:328
#4  0x40073b16 in PyCFunction_Call () from /usr/lib/libpython2.3.so.1.0


I appreciate your help so far and could use some more.

/S

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


Is htmlGen still alive?

2006-12-18 Thread kgmuller
Does anybody know whether htmlGen, the Python-class library for
generating HTML, is still being maintained? Or from where it can be
downloaded? The Starship site where it used to be hosted is dead.

Thanks for your help!

Klaus Muller

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


Re: When Closure get external variable's value?

2006-12-18 Thread Huayang Xia
It will print 15. The closure gets the value at run time.

Could we treat closure as part of the external function and it shares
the local variable with its holder function?

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


Re: skip last line in loops

2006-12-18 Thread tobiah
 See the documentation for xreadlines.
 
 James

Hmm...

This method returns the same thing as iter(f). New in version 2.1.
Deprecated since release 2.3. Use for line in file instead.

-- 
Posted via a free Usenet account from http://www.teranews.com

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


Re: Good Looking UI for a stand alone application

2006-12-18 Thread Luc Heinrich
Peter Decker [EMAIL PROTECTED] wrote:

 You're full of it. I routinely write GUI apps in Dabo for both Windows
 and Linux users, and they look just fine on both platforms.

Oh, I'm sure you do. Now go try to run one of your Dabo apps on a Mac
and see how it looks/feels... :

Here's a hint directly taken from the Dabo homepage: It also suffers
from the same display limitations on some platforms (most notably OS X),
but these should improve as the underlying toolkits improve.

 Using sizers is the key; layouts just 'look right' no matter what the native
 fonts and control sizes are.

No, sizers are a tiny part of a much bigger problem. Sizers might be the
key to solve parts of the look problem, they don't address any of the
feel problem.

But you clearly have a point here, so let me rephrase: Crossplatform
toolkits/frameworks suck. All of them. No exception. UNLESS you only
target the lowest common denominator, aka Windows and its Linux
followers.

Now, the OP *explicitely* said that [his] requirement is that the
application needs to look as good on Windows as on the Apple Mac, so
the rephrasing does not apply in this case. So here's a last try:

Crossplatform toolkits/frameworks suck. All of them. No exception.
ESPECIALLY if one of your target is Mac OS.

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


Re: def index(self):

2006-12-18 Thread Jussi Salmela
Gert Cuykens kirjoitti:
 Is there a difference between
 
 code
 class HelloWorld:
 def index(self):
  index.exposed = True
  return Hello world!
 /code
 
 and
 
 code
 class HelloWorld:
 def index(self):
  self.exposed = True
  return Hello world!
 /code

The resident experts seemingly being absent for a while, I'll strike:

Yes: the first gives a runtime error and the second is OK.
I've renamed the second class to HelloWorld2 and then:

  hw = HelloWorld()
  hw2 = HelloWorld2()

  hw.index()
Traceback (most recent call last):
   File pyshell#144, line 1, in module
 hw.index()
   File C:\Python\Dive into Python\Py\apihelper.py, line 40, in index
 index.exposed = True
NameError: global name 'index' is not defined

  hw2.index()
'Hello world!'

The error message shows that the Python compiler has interpreted the 
construction 'index.exposed' to refer to a global variable 'index' that 
doesn't exist at run time. The second class succesfully defines an 
instance attribute 'exposed' as can be seen by:

  print hw2.exposed
True

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


Re: def index(self):

2006-12-18 Thread Chris Lambacher
On Mon, Dec 18, 2006 at 08:40:13PM +0100, Gert Cuykens wrote:
 Is there a difference between
Yes. The first one causes an exception and the second one doesn't.
 
 code
 class HelloWorld:
  def index(self):
   index.exposed = True
index is not defined. HelloWorld.index is and self.index is, but index is not.
   return Hello world!
 /code
 
 and
 
 code
 class HelloWorld:
  def index(self):
   self.exposed = True
   return Hello world!
 /code

If you are just starting to explore Python, the console is great for trying
stuff out.

-Chris


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


Re: def index(self):

2006-12-18 Thread Bruno Desthuilliers
Gert Cuykens a écrit :
 Is there a difference between
 
 code
 class HelloWorld:
 def index(self):
  index.exposed = True
  return Hello world!
 /code
 
 and
 
 code
 class HelloWorld:
 def index(self):
  self.exposed = True
  return Hello world!
 /code

Ask yourself what are the names 'index' and 'self' refering to in the 
context of this function, and you'll have the answer. And if you can't 
answer, then it may be time to learn Python...

FWIW, the first version raises an exception (unless of course the name 
'index' is already bound in the enclosing scope). And the second won't 
probably work as expected with CherryPy.



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

Re: sha, PyCrypto, SHA-256

2006-12-18 Thread Klaas

Dennis Benzinger wrote:

 Python 2.5 comes with SHA-256 in the hashlib module.
 So you could install Python 2.5 instead of the PyCrypto module.

You can download the python2.5 hashlib module for use with python2.4

-MIke

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


Re: Core dump revisited

2006-12-18 Thread Sheldon

Nick Craig-Wood skrev:

 Sheldon [EMAIL PROTECTED] wrote:
   gdb msgppscomp.py core.3203

 Run

   gdb python

 Then type

   run msgppscomp.py

 at the gdb prompt.

 When it crashes, type bt for a back trace.  This will pinpoint
 exactly where it crashes.

 Hopefully that will make things clearer.  If not post the output.

 --
 Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick

Wonderful! Now I know how to used gdb with python. The are results area
posted below. Since I am new at this I could used some help in
interpreting the problem. What I do know is this: my allocation of the
array is good but when freeing the array, a problem arises. The problem
is given below but since I am new as well to C I sure could use some
help.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1077321856 (LWP 32710)]
0x40297b83 in mallopt () from /lib/tls/libc.so.6
(gdb) bt
#0  0x40297b83 in mallopt () from /lib/tls/libc.so.6
#1  0x402958ba in free () from /lib/tls/libc.so.6
#2  0x405e070a in MemoryFreeOrd () at msgppsmodule_area.c:1675
#3  0x405dae0a in msgppsarea (self=0x0, args=0x4042aa7c, kwargs=0x0) at
msgppsmodule_area.c:328
#4  0x40073b16 in PyCFunction_Call () from /usr/lib/libpython2.3.so.1.0


I appreciate your help so far and could use some more.

/S

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


pyExcelerator question

2006-12-18 Thread Gerry

I'd like to word wrap some cells, but not others, in an Excel
spreadsheet, using pyExcelerator and Excel 2003, SP1, under XP.

The code below creates the spreadsheet, but both cells are
word-wrapped.

As far as I can tell, the second call to XFStyle() overwrites a GLOBAL
wrap setting, and affects even cells written before the call to
XFStyle.

Can anyone shed any light?

Thanks,

Gerry


from pyExcelerator import *


w   = Workbook()
ws  = w.add_sheet(alpha)

style   = XFStyle()
style.alignment.wrap= Alignment.NOT_WRAP_AT_RIGHT
ws.write(1,1,Not wrapped + - * 50, style)

style2   = XFStyle()
style2.alignment.wrap= Alignment.WRAP_AT_RIGHT
ws.write(2,1,Wrapped + - * 50, style2)

w.save(test.xls)

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


Re: When Closure get external variable's value?

2006-12-18 Thread Jussi Salmela
Huayang Xia kirjoitti:
 It will print 15. The closure gets the value at run time.
 
 Could we treat closure as part of the external function and it shares
 the local variable with its holder function?
 

I don't quite get what you are trying to tell us but if you think that 
in your example code:

 def testClosure(maxIndex) :

 def closureTest():
 return maxIndex

 maxIndex += 5

 return closureTest()

 print testClosure(10)

you are returning a callable function you are all wrong. This can be 
easily seen by:

  type(testClosure(10))
15
type 'int'

The mistake is that you shouldn't return closureTest() but closureTest 
instead. The correct way would be:

  def testClosure2(maxIndex):
def closureTest():
return maxIndex
maxIndex += 5
return closureTest

  f2 = testClosure2(10)
function closureTest at 0x00D82530
  type(f2)
type 'function'
  print f2()
15

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


  1   2   >