[ANN] Last day for early bird rate - Python-Workshop in Leipzig, Germany, September 7, 2007

2007-08-31 Thread Mike Müller
The following announcement is in German.
Despite this we would like to post it here, because many
German speaking Python users read this group/list.

Heute ist der letzte Tag, an dem die ermäßigte Anmeldegebühr
gilt. Ab 1. September wird es teurer.

Anmelden kann man sich hier:
http://www.python-academy.de/workshop/anmeldung.html


=== Workshop Python im deutschsprachigen Raum ===

Am 7. September 2007 findet in Leipzig der zweite Workshop
Python im deutschsprachigen Raum statt. Der erste Workshop
2006 war erfolgreich, so dass es auch dieses Jahr einen 
geben wird. 

Der Workshop ist als Ergänzung zu den internationalen und 
europäischen Python-Zusammenkünften gedacht. Die Themen-
palette der Vorträge ist sehr weit gefasst und kann alles
einschließen, was mit Python im deutschsprachigen Raum zu
tun hat.

Eine ausführliche Beschreibung der Ziele des Workshops, der
Workshop-Themen sowie Details zu Organisation und Anmeldung
sind unter http://www.python-academy.de/workshop zu finden.

=== Wichtige Termine ===

31.08.2007 Letzter Termin für Frühbucherrabatt
07.09.2007 Workshop
15.09.2007 Letzter Termin für die Einreichung der
   publikationsfähigen Beiträge
Dezember 2007  Veröffentlichung des Tagungsbandes


=== Bitte weitersagen ===

Der Workshop soll auch Leute ansprechen, die bisher nicht
mit Python arbeiten. Wer mithelfen möchte, den Workshop
bekannt zu machen, kann einen Link auf
http://www.python-academy.de/workshop
setzen.
Auch außerhalb des Internets kann der Workshop durch den Flyer
http://www.python-academy.de/download/workshop_call_for_papers.pdf
oder das Poster
http://www.python-academy.de/download/poster_python_workshop_2007.pdf
bekannt gemacht werden.

Den Flyer einfach doppelseitig ausdrucken oder kopieren. Das
Poster möglichst auf A3 ausdrucken oder von A4 auf A3 kopieren. 
Gern schicken wir auch die gewünschte Menge Flyer oder Poster
im A3-Format per Post zu. Dann ein Poster zusammen mit ein
paar Flyern am Schwarzen Brett von Universitäten, Firmen,
Organisationen usw. aushängen. Ideen, wie wir auch Leute
erreichen, die Python-Websites oder -Listen nicht
frequentieren, sind immer willkommen.


Wir freuen uns auf eine rege Teilnahme,
Mike Müller
Stefan Schwarzer

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

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


Python 3000 released as 3.0a1

2007-08-31 Thread Guido van Rossum
[Bcc: [EMAIL PROTECTED]

The first Python 3000 release is out -- Python 3.0a1. Be the first one
on your block to download it!

   http://python.org/download/releases/3.0/

Excerpts:

Python 3000 (a.k.a. Py3k, and released as Python 3.0) is a new
version of the language that is incompatible with the 2.x line of
releases. The language is mostly the same, but many details,
especially how built-in objects like dictionaries and strings work,
have changed considerably, and a lot of deprecated features have
finally been removed.

This is an ongoing project; the cleanup isn't expected to be complete
until 2008. In particular there are plans to reorganize the standard
library namespace.

The release plan is to have a series of alpha releases in 2007, beta
releases in 2008, and a final release in August 2008. The alpha
releases are primarily aimed at developers who want a sneak peek at
the new langauge, especially those folks who plan to port their code
to Python 3000. The hope is that by the time of the final release,
many 3rd party packages will already be available in a 3.0-compatible
form.

More links:

* Online docs: http://docs.python.org/dev/3.0/
* What's new: http://docs.python.org/dev/3.0/whatsnew/3.0.html

* Source tar ball: http://python.org/ftp/python/3.0/Python-3.0a1.tgz
* Windows MSI installer: http://python.org/ftp/python/3.0/python-3.0a1.msi

* PEP 3000: http://python.org/dev/peps/pep-3000/
* Issue tracker: http://bugs.python.org/
* Py3k dev list: http://mail.python.org/mailman/listinfo/python-3000/
* Conversion tool for Python 2.x code:
  http://svn.python.org/view/sandbox/trunk/2to3/

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Wing IDE 3.0 beta2 released

2007-08-31 Thread Wingware
Hi,

I'm happy to announce the release of Wing IDE 3.0 beta 2.  It is available from
http://wingware.com/wingide/beta

Changes since the previous beta release include:

* Stackless Python 2.4 and 2.5 are now supported
* Python 2.5 for 64-bit Windows is now supported
* Fixed Zope WingDBG so it will connect back to IDE
* Improved auto-completion coverage for imports and end cases
* Up to 10% speed-up when running in debugger
* Fixed many other bugs, particularly source browser, OS commands,
   testing tool, and source assistant (*)

In addition, we have introduced Wing IDE 101, a free scaled back version
of Wing IDE designed for teaching introductory programming courses.

The CHANGELOG.txt file in the installation provides additional details.

The major new features introduced in Wing 3.0 are:

* Multi-threaded debugger
* Debug value tooltips in editor, debug probe, and interactive shell
* Autocompletion in debug probe and interactive shell
* Automatically updating project directories
* Testing tool, currently supporting unittest derived tests (*)
* OS Commands tool for executing and interacting with external commands (*)
* Rewritten indentation analysis and conversion (*)
* Introduction of Wing IDE 101, a free edition for beginning programmers
* Available as a .deb package for Debian and Ubuntu
* Support for Stackless Python
* Support for 64 bit Python on Windows and Linux

(*)'d items are available in Wing IDE Professional only.

System requirements are Windows 2000 or later, OS X 10.3.9 or later for PPC or
Intel (requires X11 Server), or a recent Linux system (either 32 or 64 bit).

Compatibility Notes
---

The file pattern in the Testing tab of Project Properties will need
to be re-entered if the project was saved with one of the 3.0 alpha
releases.

Reporting Bugs
--

Please report bugs using the Submit Bug Report item in the Help menu or by
emailing support at wingware dot com.  This is beta quality software that
installs side-by-side with Wing 2.x or 1.x. We advise you to make frequent
backups of your work when using any pre-release version of Wing IDE.

Upgrading
-

To upgrade a 2.x license or purchase a new 3.x license:

Upgradehttps://wingware.com/store/upgrade
Purchase   https://wingware.com/store/purchase

Any 2.x license sold after May 2nd 2006 is free to upgrade; others cost
1/2 the normal price to upgrade.

If you are not ready to upgrade, feel free to keep using a series of trial
licenses. There will be no limit on the number of trials until 3.0 final is out.

Thanks!

The Wingware Team
Wingware | Python IDE
Advancing Software Development

www.wingware.com

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

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


Re: status of Programming by Contract (PEP 316)?

2007-08-31 Thread Russ

 Python really isn't suitable for in-flight controls  for various
 reasons, and mission critical concerns is a minor one (systems with

Do you know anything about the FAA certification process for flight-
critical systems? I am not an expert on it, but I know it is very
expensive. If I am not mistaken, getting such code certified is more
expensive than developing it in the first place. Why would that be so
if, as you claim, mission critical concerns is a minor one?

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


Coding Standards

2007-08-31 Thread [EMAIL PROTECTED]
'Good code' is code that works, is bug free, and is readable and
maintainable. Standards need to be followed for coding. Read more...

http://brsx.co.uk/SWtesting/FAQs/FAQs012.asp

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


What's on at APL 2007, Montreal, October 21, (Tutorials) 22, 23 (Program)

2007-08-31 Thread Mike Kent
( Details and abstracts coming to the APL 2007 web page

   http://www.sigapl.org/apl2007.html

   shortly.  In the meantime ... )


Tutorials and workshops

 Introduction to APL (Ray Polivka)

 OO for APLers, APL for OOers (Dan Baronet)

 ... others in the works


Presentations

No Experience Necessary:
Hire for Aptitude - Train for Skills
 (Brooke Allen)

 Compiling APL with APEX
 (Robert Bernecky)

 APL, Bioinformatics, Cancer Research
 (Ken Fordyce)

 Generic Programming on Nesting Structure
 (Stephan Herhut, Sven-Bodo Scholz, Clemens Grelck)

 Interactive Array-Based Languages and Financial Research
 (Devon McCormick)

 Array vs Non-Array Approaches to Programming Problems
 (Devon McCormick)

 Design Issues in APL/OO Interfacing
 (Richard Nabavi)

 Arrays of Objects, or Arrays within Objects
 (Richard Nabavi)

 Competing, with J
 (John Randall)



Plus representatives of vendors:

Dyalog  --  IBM  --  MicroAPL
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: fcntl problems

2007-08-31 Thread Miles
On 8/30/07, mhearne808 wrote:
 I'm having a number of problems with the fcntl module.

Read this first: http://linux.die.net/man/2/flock

 First of all, if I try this:
 file = open(counter.txt,w+)
 fcntl.flock(file.fileno(), fcntl.LOCK_NB)

 I get this:
 ---
 type 'exceptions.IOError'   Traceback (most recent call
 last)
 /Users/mhearne/src/python/ipython console in module()
 type 'exceptions.IOError': [Errno 9] Bad file descriptor

That should be:
 fcntl.flock(f.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)

 Proceeding forward with the locked file, let's say I do the above in
 Python interactive Process A.  Then in python interactive Process B, I
 repeat the open function on the same file with the same
 permissions.  Then, in each process, I write some text to the file
 using the write() method.  After closing the file in both processes,
 the only text I see in the file is from Process B!

This is due to two issues: caching and file position.  When you open
the file in both processes as 'w+', they are both positioned at the
*current* EOF, but from that point on the offset is not externally
influenced.  The correct sequence of events should be:
- open file in mode w+
- obtain exclusive lock
- f.seek(0, 2) # (to end of file)
- write to file
- f.flush() # or f.close()
- release lock

 Is this my lack of understanding, or have I discovered a bug?

If you find yourself asking this question, it's too often the former :)

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


Re: fcntl problems

2007-08-31 Thread Miles
Sorry, that last quote-only reply was accidental. :)

On 8/30/07, mhearne808 wrote:
 I've been doing some experiments, and here are some specific examples
 to try.

[snipped examples]

 From these last two experiments I can only conclude that file locking
 isn't doing a durned thing.

 What's going on?

File locking isn't doing a durned thing in those cases because you're
only obtaining the lock from a single process.

 According to my Python Cookbook:
 Exclusive lock: This denies all _other_ processes both read and write
 access to the file.

This is only for mandatory locking; POSIX flock is advisory locking,
which states: Only one process may hold an exclusive lock for a given
file at a given time.  Advisory locks don't have any effect on
processes that don't use locks.  Mandatory locks are kernel enforced,
but non-POSIX and not available in Mac OS X.

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


Re: list index()

2007-08-31 Thread Terry Reedy

Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
| On Thu, 30 Aug 2007 17:09:36 +1000, Ben Finney wrote:
|
|  [EMAIL PROTECTED] writes:
| 
|  What's with the index() function of lists throwing an exception on not
|  found?
| 
|  It's letting you know that the item isn't in the list. There's no
|  sensible return value from an index function in that condition.
|
| What about -1?  C programmers do this all the time.  :-)

Because they do not have exceptions. 



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


Re: Coding Standards

2007-08-31 Thread Laurent Pointal
[EMAIL PROTECTED] a écrit :
 'Good code' is code that works, is bug free, and is readable and
 maintainable. Standards need to be followed for coding. Read more...
 
 http://brsx.co.uk/SWtesting/FAQs/FAQs012.asp

You misstyped your URL and referenced a C++ related document, for Python 
its here:

http://www.python.org/dev/peps/pep-0008/

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


Re: status of Programming by Contract (PEP 316)?

2007-08-31 Thread Carl Banks
On Fri, 31 Aug 2007 01:15:04 -0400, Roy Smith wrote:

 Carl Banks [EMAIL PROTECTED] wrote:
 Python really isn't suitable for in-flight controls for various
 reasons, and mission critical concerns is a minor one (systems with
 less underlying complexity tend to have fewer failure modes).  But
 mostly it's raw throughput: Python is just too slow.  Flight control
 computers have to be powerful enough make a ton of mathematical
 calculations in a matter of milliseconds, and under strict weight and
 power constraints.  The cost of running 100 times slower than optimal
 is just too high.
 
 I'm not convinced that's true for all avionics uses.

Of course it's not.  I was talking about flight control, not avionics in 
general.  (Perhaps when single-engine Cessnas go digital we'll even see 
flight controllers in Python.)


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


Re: list index()

2007-08-31 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit :
 On Aug 30, 4:28 pm, Ben Finney [EMAIL PROTECTED]
 wrote:
 [EMAIL PROTECTED] writes:
 On Aug 30, 12:09 am, Ben Finney [EMAIL PROTECTED]
 wrote:
 It's letting you know that the item isn't in the list. There's no
 sensible return value from an index function in that condition.
 for str:
 find(  sub[, start[, end]])
 [...]
 Return -1 if sub is not found.
 -1 is used in other languages as well.
 It is no more sensible there than in the 'str.find' method, which is a
 historical wart.
 
 One man's sensible is another man's insensible. For instance, some
 people feel -1 as a valid index into a list is sensible. Other's find
 it insensible.

Python 2.5.1 (r251:54863, May  2 2007, 16:56:35)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type help, copyright, credits or license for more information.
  print sensible[-1]
e
 

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


Re: Creating a multi-tier client/server application

2007-08-31 Thread Paul Rubin
Jeff [EMAIL PROTECTED] writes:
 Granted.  But what I will be writing really will take a lot of extra
 work to get even close to the level of usability needed on the web vs.
 a desktop app.  And I'll try not to write a crappy GUI ;-)

OK.  In the discussion with Chris, one factor that came up is how much
time users will spend in front of the app and the amount of data
they'll physically enter.  If it's a lot, that weighs in favor of a
desktop app.  If it's not much, then maybe some gain in UI
responsiveness isn't worth the downside of a client installation.

 Sorting certainly doesn't have to be done on the server side--in fact,
 in most cases I can think of where it would be useful for this app, it
 wouldn't have to be--in which case it's more responsive.  Certainly
 exporting, importing and printing can all be done through the web--
 I've done this plenty of times.  But there is a huge amount of
 flexibility (and, in the case of printing, guaranteed style/quality/
 layout) to be gained on the desktop.

This I don't understand at all.  How is the least bit of flexibility
or style or quality guarantees gained by a desktop app?  If you want
fancy formatting, just use Reportlab to generate a pdf on the server
and send it to the browser.

 All that said, I am most likely going to go with a desktop
 application.  In reality, I will have to do whatever my client wants.
 Thank you *very* much for all of your input--one of the first things I
 have to do is make them a list of the pros and cons of web vs. desktop
 apps--and this will help a lot.

Yes, that sounds like a good idea.  

 vanrpeter-whatever: Thanks for the support :-)  What did you use for
 networking?  What ORMs did you try (or did you skip them altogether?)

Have you ever written a serious GUI app before?  I've never done any
really fancy ones, but even the relatively simple ones I've done have
turned out to be far more time consuming than I expected.  Have you
done much concurrent programming, either with threads or something
like twisted?  You're going to have to do that to keep your gui
responsive, so you might put that on your list of things to study (in
addition to networking and databases).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list index()

2007-08-31 Thread Hendrik van Rooyen
Carsten Haese car...ys.com wrote:

 .. If we start labeling
 people, this thread will earn you a label that rhymes with roll.

weird this - maybe a native English speaker can comment - 
when I pronounce what fishermen do - it rhymes with roll,
but when I am talking about the thing that lives under bridges
and munches goats, the O sound is shorter, and more 
towards the back of my mouth.

- Hendrik

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


Re: list index()

2007-08-31 Thread Erik Max Francis
Hendrik van Rooyen wrote:

 weird this - maybe a native English speaker can comment - 
 when I pronounce what fishermen do - it rhymes with roll,
 but when I am talking about the thing that lives under bridges
 and munches goats, the O sound is shorter, and more 
 towards the back of my mouth.

Native English accents vary as well, but _roll_ rhymes with _troll_, not 
_trawl_.  _Trawl_ would rhyme with _fall_, and _fall_ definitely doesn't 
rhyme with _roll_.

-- 
Erik Max Francis  [EMAIL PROTECTED]  http://www.alcyone.com/max/
  San Jose, CA, USA  37 20 N 121 53 W  AIM, Y!M erikmaxfrancis
   I do not like work even when someone else does it.
-- Mark Twain
-- 
http://mail.python.org/mailman/listinfo/python-list


Requirement-HEAD OF TECHNOLOGY

2007-08-31 Thread SAWVEQ
Senior Position Vacant for www.123greetings.com



   Head of Technology
  (Kolkata, India)

Responsibilities:

To Scale the website to handle large volumes of user traffic.
To lead the development team for Alexa Top 100 Web Property.
To Manage Relationships with DataCenters, CDN/Bandwidth providers,
ESP's etc.
To Implement next generation of web technologies.

Deliverables

Increase User Access Speed of the Website

* Implement Distributed DNS
* Implement Web Catching/Acceleration

Increase Website Uptime

* Implement Load Balancing to handle 600 web servers
* Manage servers spread across 5 Datacenters in 3 geographies
* Implement Blade Servers/Web Farm

Website Management

* Improve Content Management System to update 50,000 WebPages
daily.

Website Features

* Implement Web 2.0 Features to increase stickiness of the
website.
* Implement latest flash  streaming technologies for content
delivery.

Data Mining  Warehousing

* To Collect  Store huge volumes of user data.
* To Structure  Mine user data for trend, data analysis.

Requirements:

Profile

Exp:-10Years In related field

Required to manage  lead the development team consist of PHP  Perl
Programmers, Project Managers, Action Script Developers, JavaScript
Developers, Server Administrators.
Website Technologies

Operating Systems: Linux /Apache/FreeBSD; No Microsoft Technologies
Development Languages: Open Source Technologies (Perl/PHP/MySQL) Front
End languages: JavaScript, AJAX, HTML, CSS, Flash ActionScript
Developers.


Interested Candidate plz contact - [EMAIL PROTECTED]
or visit  http://www.123greetings.com/careers/form.html for more
details

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


MySQLdb ImportError

2007-08-31 Thread Sjoerd
Hello!

When I try to import the MySQLdb lib python generates an error:

Traceback (most recent call last):
  File pyshell#0, line 1, in module
import MySQLdb
  File C:\Python25\lib\site-packages\MySQLdb\__init__.py, line 19,
in module
import _mysql
ImportError: DLL load failed with error code 193

This is on a AMD64 bit machine, when I import it on a 32 bit machine
it works fine.
Is there anyway to fix this? Is there a build for AMD64 bit machines
or is there simply no way
that I can get MySQLdb working on it?

Thanks in advance,
Sjoerd

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


Re: status of Programming by Contract (PEP 316)?

2007-08-31 Thread Russ
On Aug 30, 7:20 pm, [EMAIL PROTECTED] (Alex Martelli) wrote:
 Russ [EMAIL PROTECTED] wrote:

...

  programs. Any idea how much Python is used for flight control systems
  in commercial
  transport aircraft or jet fighters?


Hi Alex. I've always enjoyed your Piggies talks at
Google (although I missed he last one because I was out
of town). I'm disappointed to see that you seem to have
taken personal offense from remarks I made to someone else who
attacked
me first. I will take issue with some of your remarks,
bit none of it is intended to be personal, and I sincerely hope
you don't take it that way.


 Are there differences in reliability requirements between the parts of
 such control systems that run on aircraft themselves, and those that run
 in airports' control towers?  Because Python *IS* used in the latter
 case, cfr http://www.python.org/about/success/frequentis/ ... if
 on-plane control SW requires hard-real-time response, that might be a
 more credible reason why Python would be inappropriate (any garbage
 collected language is NOT a candidate for hard-real-time SW!) than your
 implied aspersions against Python's reliability.


I've seen that site before. They have a nice product
that was developed in Python, but it is not clear to me
that is actually safety-critical. It appears to be a
GUI designer for displays at air traffic control towers.
I can't tell if this is just a development tool, or if it
the python-based product is actually used directly by
controllers. Also, this product does not seem to actually
display aircraft to controllers. It seems to be more of
a semi-static display of runway conditions. Not to
minimize its importance, but I don't know if this product
actually qualifies as safety critical, and if it does,
it probably does so only marginally.


 According to
 http://uptime.pingdom.com/site/month_summary/site_name/www.google.com,
 Google's current uptime is around 99.99%, with many months at 100% and a
 few at 99.98% -- and that's on *cheap*, not-that-reliable commodity HW,
 and in real-world conditions where power can go away, network cables can
 accidentally get cut, etc.  I'm Uber Tech Lead for Production Systems at
 Google -- i.e., the groups I uber-lead are responsible for some software
 which (partly by automating things as much as possible) empowers our
 wondrous Site Reliability Engineers and network specialists to achieve
 that uptime in face of all the Bad Stuff the world can and does throw at
 us.  Guess what programming language I'm a well-known expert of...?


I certainly cannot deny the success of Google, but I
don't think that a high uptime with thousands of servers
is comparable to reliable safety-critical software. You
can't put thousands of flight management computers on
an airplane and just switch over to another as they go
fail. And if a web server gives bogus results nobody
worries much, but if a flight computer gives bogus
outputs, some people worry a lot.

By the way, I use Google Groups, and it has a few
annoying glitches. For example, I couldn't read your
post without scrolling horizontally. With all the money
and manpower at Google's disposal, couldn't you fix that
problem? Another problem I have had for months is that
when I write a message to post, I get no auto scrolling,
so I have to add manual line breaks to keep the text from
running out of the window -- then the reader sees all
those ugly misplaced line breaks in the output. These are
just annoyances, but why hasn't Google fixed them yet?

The point I am trying to make is that, while Google does
great things, and is very successful commercially, the
quality of its code could certainly use some improvement.
Microsoft is also very successful commercially, but
certainly you wouldn't argue that is is a result of the
quality of its software, I hope.

I may have a simplistic view, but I have always thought
that the requirements of most Google code are the very
antithesis of the requirements of safety critical code.
When I do a search, I
fully expect most of the results to be crap. It's a
scattershot approach. If I get one good result, I am
usually happy. Safety critical software is exactly the
opposite: if you get one *bad* result, you could be in
a heap of something nasty.



  The important question is this: why do I waste my time with bozos like
  you?

 Yeah, good question indeed, and I'm asking myself that -- somebody who
 posts to this group in order to attack the reliability of the language
 the group is about (and appears to be supremely ignorant about its use


I am sorry that you took offense at my pointing out the
weaknesses of Python. It's a great language for certain
kinds of applications, but it is not necessarily
appropriate for everything. I am personally using it for
prototyping a safety critical system that, if it is
ultimately fielded, will affect the safety of
millions of people, including you. However, my Python
prototype is for research and design purposes. The
ultimate 

Re: Setting a read-only attribute

2007-08-31 Thread Alexandre Badez
On Aug 30, 11:35 pm, [EMAIL PROTECTED] [EMAIL PROTECTED]
wrote:
 I have an object and wish to set an attribute on it which,
 unfortunately for me, is read-only.

 How can I go about this?

 Cheers.
 -T


Could you show the object you want to set his attribute?
Until that, it's difficult to answer to you.

PS: If the attribut is on read only, their must a good reason for
that ;)

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


Re: status of Programming by Contract (PEP 316)?

2007-08-31 Thread Carl Banks
On Thu, 30 Aug 2007 22:56:54 -0700, Russ wrote:

 Python really isn't suitable for in-flight controls  for various
 reasons, and mission critical concerns is a minor one (systems with
 
 Do you know anything about the FAA certification process for flight-
 critical systems? I am not an expert on it, but I know it is very
 expensive. If I am not mistaken, getting such code certified is more
 expensive than developing it in the first place. Why would that be so
 if, as you claim, mission critical concerns is a minor one?

I made no such claim; you misconstrued what I wrote.  I wrote that 
mission critical concerns are a minor reason why Python is not used, not 
that mission critical concerns were minor.

As a matter of fact, FAA cert is a major pain, and they unit test the 
hell out of everything.  I'm not aware of any reason why Python couldn't 
be certified if it passed the tests, but it likely wouldn't pass as 
easily as a compiled language.  OTOH, spiffy features like design-by-
contract aren't going to improve your chances of getting FAA cert, either.


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


Re: list index()

2007-08-31 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit :
(snip)
 I don't think that is the definition used across computer science.
 
 It suddenly dawned on me that what would be best would be a contains()
 (or IN syntax for those who can't afford to wait) for lists.

No need to wait:

  'a' in ['a', 'b']
True
  ['a', 'b'].__contains__('a')
True


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


Re: Simple elementtree question

2007-08-31 Thread Stefan Behnel
IamIan wrote:
 Thank you very much! That did it.
 
 In the source XML item tags have rdf:about attributes with the link
 to the story, and it was here I planned on grabbing the link and
 matching it up with the title child text. After seeing the output of
 elmenttree's getiterator() though, it now looks like each item, title,
 description, and link is a separate element...
 
 I could use a dictionary or lists to match the first title to the
 first link, but is there a more elegant way in elementtree (or
 otherwise) to do this?

You can iterate over the channel Elements and then select the title child
(el.find()) to see if it's interesting.

You can also try lxml.etree, which supports XPath:

from lxml import etree
find_channel = etree.XPath(//channel[title = $title])

tree = etree.parse(http://somewhere/the_document.xml;)
channel = find_channel(tree, title=example title)

print channel.findtext(link)

or lxml.objectify:

from lxml import etree, objectify
find_channel = etree.XPath(//channel[title = $title])

tree = objectify.parse(http://somewhere/the_document.xml;)
channel = find_channel(tree, title=example title)

print channel.title, channel.link

http://codespeak.net/lxml

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


Do you have any complete example for creating msi file(doing file copying)

2007-08-31 Thread siddhatha veedaluru
Thank you for the help that you  are going to give me.
 
I have a project where in which i want to create a msi file just as 
python-package while installing python on the system. Just copying the files to 
the user given target directory.
 
i want to create similar msi file for my project that just copies the file.
 
Can you please help me in providing the complete procedure of creating the msi 
file using the python.
 
Does msilib library in the release 2.5 have this capability?
 
Please help me
Thanks
Sid
 



Get the freedom to save as many mails as you wish. Click here to know how.


  Once upon a time there was 1 GB storage in your inbox. To know the happy 
ending go to http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html-- 
http://mail.python.org/mailman/listinfo/python-list

Re: beginner, idomatic python 2

2007-08-31 Thread Bruno Desthuilliers
bambam a écrit :
 Bruno Desthuilliers [EMAIL PROTECTED] 
 wrote in message news:[EMAIL PROTECTED]
 As a side note, in Python, inheritance ...
 ... should usually not be used for typing.
 
 :~(
 I'm sorry, I don't even know what that means... The code I
 have inherited from someone only a little more knowledgeable
 than me, and is still full of development artifacts anyway.
 
 The Pwr and Psp classes inherit from the Device class not
 neccessarily because that is a Good Thing, more because
 the development process led to them being thought of that
 way. All devices have a mixture of common and differing
 attributes.
 
 What is 'typing'?
 

Mmm... Most CS experts don't really agree on this, and I'm certainly not 
one (expert). So I won't even try to explain it by myself, and let you 
google for type system, static typing, dynamic typing, duck 
typing etc...

Now what I meant here is that in Python, you don't have to make class B 
inherit from class A to let you use an instance of B where an instance 
of A was expected - all you need is that both objects share the set of 
attributes and methods you're going to use. Inheritence is only useful 
for sharing common code.

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


Re: status of Programming by Contract (PEP 316)?

2007-08-31 Thread Bruno Desthuilliers
Russ a écrit :
 Pre and post conditions applying to the class ? Now that's an
 interesting concept. IIRC, Eiffels pre and post conditions only apply to
 methods, and I fail to see how they could apply to a class. But since
 you're an expert on the subject, I don't doubt you'll enlighten us ?
 
 I made a simple mistake. Excuse me. Oh wait ... aren't you one of the
 sensitivity police who
 laid into me for criticizing someone else. 

Nope, I'm one of the regular citizens here that tried to make you 
realize you were acting as an arrogant clueless newbie.

 For the record, the guy I
 criticized
 made ridiculous assertions about DBC.

For the record, the guy you treaded as he was a retarted knows much more 
than you about both Python and DbC. Thinking that someone is ignorant 
or ridiculous because he does not happen to share your opinions on 
some subject is certainly not what's I'd call an intelligent, civilized, 
  respectful attitude.

  All I did was to make a simple
 mistake about
 an inconsequential matter.

All you did was persisting on being arrogant while showing your lack of 
knowledge on both Python and DbC.

 No, pre and post conditions obviously don't
 apply to classes,
 but all I said was that that's how it appeared to me at first
 glance.
 
 If you are upset about my criticism of one of your colleagues, please
 tell him to quite making
 outrageous assertions about something he obviously knows little about.
 

I'm not upset. I'm actually trying to help you realizing the dumbness of 
your attitude. But I'm afraid this is going to be a lost cause...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: status of Programming by Contract (PEP 316)?

2007-08-31 Thread Bruno Desthuilliers
Russ a écrit :
 FWIW, the Eiffel and SPARK Ada folks also brilliantly explained why
 one can not hope to write reliable programs without strict static
 declarative type-checking.
 
 And they are probably right.

And they are obviously wrong, by empiric experience.

 I don't think you understand what they mean by reliable
 programs.

I think you should stop over-estimating yourself, and start realizing 
that there are quite a lot of experimented programmers here.

 The important question is this: why do I waste my time with bozos like
 you?

The same question is probably crossing the mind of quite a lot of people 
here - but the 'bozo' might not be who you think.

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


Re: list index()

2007-08-31 Thread Paddy
On Aug 31, 8:47 am, Erik Max Francis [EMAIL PROTECTED] wrote:
 Hendrik van Rooyen wrote:
  weird this - maybe a native English speaker can comment -
  when I pronounce what fishermen do - it rhymes with roll,
  but when I am talking about the thing that lives under bridges
  and munches goats, the O sound is shorter, and more
  towards the back of my mouth.

 Native English accents vary as well, but _roll_ rhymes with _troll_, not
 _trawl_.  _Trawl_ would rhyme with _fall_, and _fall_ definitely doesn't
 rhyme with _roll_.

 --
 Erik Max Francis  [EMAIL PROTECTED] http://www.alcyone.com/max/
   San Jose, CA, USA  37 20 N 121 53 W  AIM, Y!M erikmaxfrancis
I do not like work even when someone else does it.
 -- Mark Twain

I say the 'oll' in troll like the 'ol' in frolic, and pronounce roll
and role similarly.

My accent is probably from the East Midlands of the UK, but is not
pronounced.

- Paddy.

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


Re: status of Programming by Contract (PEP 316)?

2007-08-31 Thread Michele Simionato
On Aug 31, 10:02 am, Russ [EMAIL PROTECTED] wrote:

 Hi Alex. I've always enjoyed your Piggies talks at
 Google (although I missed he last one because I was out
 of town). I'm disappointed to see that you seem to have
 taken personal offense from remarks I made to someone else who
 attacked me first.

I am curious. Why do you think I attacked you? The conversion went as
follows:

 On Aug 29, 7:21 am, Russ [EMAIL PROTECTED] wrote:
 Thanks for that information. That's too bad, because it seems like a
 strong positive capability to add to Python. I wonder why the cold
 reception. Were there problems with the idea itself or just the
 implementation? Or is it just a low priority?

 me:
 Why do you think that would ad a strong positive capability?
 To me at least it seems a big fat lot of over-engineering, not
 needed in 99% of programs. In the remaining 1%, it would still not
 be needed since Python provides out of the box very powerful
 metaprogramming capabilities so that you can implement
 yourself the checks you need, if you really need them.

Basically you said I think DbC is good and I said I don't think
so.
I would not call that an attack. If you want to see an attack, wait
for
Alex replying to you observations about the low quality of code at
Google! ;)

   Michele Simionato

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


Re: list index()

2007-08-31 Thread Erik Max Francis
Paddy wrote:

 I say the 'oll' in troll like the 'ol' in frolic, and pronounce roll
 and role similarly.

 My accent is probably from the East Midlands of the UK, but is not
 pronounced.

_Troll_ and _frolic_ aren't pronounced with the same o sound in any 
accent I've ever heard of.  Which you pronounce _boat_ and _bot_ the 
same way, too?

-- 
Erik Max Francis  [EMAIL PROTECTED]  http://www.alcyone.com/max/
  San Jose, CA, USA  37 20 N 121 53 W  AIM, Y!M erikmaxfrancis
   There are no dull subjects. There are only dull writers.
-- H.L. Mencken
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list index()

2007-08-31 Thread Tim Golden
Erik Max Francis wrote:
 Paddy wrote:
 
 I say the 'oll' in troll like the 'ol' in frolic, and pronounce roll
 and role similarly.

 My accent is probably from the East Midlands of the UK, but is not
 pronounced.
 
 _Troll_ and _frolic_ aren't pronounced with the same o sound in any 
 accent I've ever heard of.  Which you pronounce _boat_ and _bot_ the 
 same way, too?

[Amusingly contemplating a trolling war about the pronunciation of troll]

Well they sound the same in my more-or-less South London accent.
I can't write those funny phonetic symbols (and I hate to
imagine the Unicode encoding hoops I'd have to jump through
to make them readable anyway) but both os sound short to me.
Like bot rather than boat using your example.

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


Re: status of Programming by Contract (PEP 316)?

2007-08-31 Thread Paul Rubin
[EMAIL PROTECTED] (Alex Martelli) writes:
 Yeah, good question indeed, and I'm asking myself that -- somebody who
 posts to this group in order to attack the reliability of the language
 the group is about (and appears to be supremely ignorant about its use
 in air-traffic control and for high-reliability mission-critical
 applications such as Google's Production Systems software) might well
 be considered not worth responding to.  OTOH, you _did_ irritate me
 enough that I feel happier for venting in response;-)

Hi Alex, I'm a little confused: does Production Systems mean stuff
like the Google search engine, which (as you described further up in
your message) achieves its reliability at least partly by massive
redundancy and failover when something breaks?  In that case why is it
so important that the software be highly reliable?  Is a software
fault really worse than a hardware fault, especially if it's
permissible to sometimes let a transaction (like a search query) go
uncompleted (e.g. by displaying a try again later message)?  If you
get 1 billion queries in a month and a half dozen of them don't
complete (e.g. they give empty or incorrect results when there are
some good hits they should display) but the server is never actually
down, can you still claim 100% uptime?

There's a philosophy in Erlang described as let it crash,
i.e. programmers are told NOT to program defensively such as by
checking inputs for validity.  Instead they should just rely on the
fault tolerance and process restart stuff to get things going again if
their process fails.  Similarly if the Google search software hits
some fatal condition once in a while, maybe it's enough to just treat
it as a crashed box and let the failover mechanisms handle the
problem.  Of course then there's a second level system to manage the
restarts that has to be very reliable, but it doesn't have to deal
with much weird concocted input the way that a public-facing internet
application has to.

Therefore I think Russ's point stands, that we're talking about a
different sort of reliability in these highly redundant systems, than
in the systems Russ is describing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list index()

2007-08-31 Thread Jon Ribbens
On 2007-08-31, Erik Max Francis [EMAIL PROTECTED] wrote:
 I say the 'oll' in troll like the 'ol' in frolic, and pronounce roll
 and role similarly.

 My accent is probably from the East Midlands of the UK, but is not
 pronounced.

 _Troll_ and _frolic_ aren't pronounced with the same o sound in any 
 accent I've ever heard of.

Welcome to England!

 Which you pronounce _boat_ and _bot_ the same way, too?

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


Re: status of Programming by Contract (PEP 316)?

2007-08-31 Thread Paul Rubin
Michele Simionato [EMAIL PROTECTED] writes:
  http://archive.eiffel.com/doc/manuals/technology/contract/ariane/page...
 
 That paper contains only a good think: a link to the contrarian view
 http://home.flash.net/~kennieg/ariane.html#s3.1.5

I like the contrarian article much better than the Eiffel sales pitch.
-- 
http://mail.python.org/mailman/listinfo/python-list


OT: pronounciation [was: list index()]

2007-08-31 Thread Tim Golden
Tim Golden wrote:
 Erik Max Francis wrote:
 Paddy wrote:

 I say the 'oll' in troll like the 'ol' in frolic, and pronounce roll
 and role similarly.

 My accent is probably from the East Midlands of the UK, but is not
 pronounced.
 _Troll_ and _frolic_ aren't pronounced with the same o sound in any 
 accent I've ever heard of.  Which you pronounce _boat_ and _bot_ the 
 same way, too?
 
 [Amusingly contemplating a trolling war about the pronunciation of troll]
 
 Well they sound the same in my more-or-less South London accent.
 I can't write those funny phonetic symbols (and I hate to
 imagine the Unicode encoding hoops I'd have to jump through
 to make them readable anyway) but both os sound short to me.
 Like bot rather than boat using your example.

Since we're talking... I'm still a little startled when I listen
to some of the excellent webcasts that are being produced these
days (showmedo.com and friends) and hear American voices pronounce
Python... well, the way they do, with the stress and something of a
drawl on the second syllable. I'm sure it's just as amusing the other
way round: we pronounce it with the stress on the first syllable and
the characteristic short vowel sound in the second.
(Something like: Pie'thun).

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


Re: status of Programming by Contract (PEP 316)?

2007-08-31 Thread Ricardo Aráoz
Russ wrote:
 I've always wondered... Are the compilers (or interpreters), which take
 these programs to machine code, also formally proven correct?
 
 No, they are not formally proven correct (too complicated for that),
 but I believe they are certified to a higher level than your typical
 compiler. I think that Ada compilers used for certain safety-critical
 applications must meet higher standards than, say, GNU Ada, for
 example.
 
 And the OS
 in which those programs operate, are they also formally proven correct?
 
 Same as above, if I am not mistaken.
 
 And the hardware, microprocessor, electric supply, etc. are they also
 'proven correct'?
 
 I think the microprocessors used for flight control, for example, are
 certified to a higher level than standard microprocessors.
 
 How would you prove a power supply to be correct? I'm sure they meet
 higher reliability standards too.
 
 

In that case why don't we just 'certify to a higher level' the programs
and get done with this formal proofs? We should remember that the level
of security of a 'System' is the same as the level of security of it's
weakest component, so either we formally prove all those other very
important components (OS gets MUCH more use than the program (the
program uses it for almost every other action)) or get done with the
whole fuss.


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


Re: status of Programming by Contract (PEP 316)?

2007-08-31 Thread Paul Rubin
Ricardo Aráoz [EMAIL PROTECTED] writes:
 In that case why don't we just 'certify to a higher level' the programs
 and get done with this formal proofs? We should remember that the level
 of security of a 'System' is the same as the level of security of it's
 weakest component, so either we formally prove all those other very
 important components (OS gets MUCH more use than the program (the
 program uses it for almost every other action)) or get done with the
 whole fuss.

This url has some info on the topic of certification etc.:

http://www.dwheeler.com/essays/high-assurance-floss.html

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


Re: list index()

2007-08-31 Thread Richie Hindle

[Carsten]
 .. If we start labeling
 people, this thread will earn you a label that rhymes with roll.

[Hendrik]
 weird this - maybe a native English speaker can comment - 
 when I pronounce what fishermen do - it rhymes with roll,
 but when I am talking about the thing that lives under bridges
 and munches goats, the O sound is shorter, and more 
 towards the back of my mouth.

But - the word for someone who posts to the internet with the intention of
stirring up trouble derives from the word for what fishermen do, not from
the word for something that lives under a bridge.  It derives from trolling
for suckers or trolling for newbies.

-- 
Richie Hindle
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Registering a python function in C

2007-08-31 Thread Hrvoje Niksic
fernando [EMAIL PROTECTED] writes:

 Could someone post an example on how to register a python function as
 a callback in a C function?

If I understand correctly, your C function receives a Python function
(as a function object of type PyObject *), which you need to call from
C.  To do that, call PyObject_CallFunction(obj, format, args...) where
format and args are documented in
http://docs.python.org/api/arg-parsing.html.

Does that help?

Also note that there is a dedicated mailing list for the Python/C
API; see http://mail.python.org/mailman/listinfo/capi-sig .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list index()

2007-08-31 Thread Carsten Haese
On Thu, 30 Aug 2007 21:33:43 -0700, TheFlyingDutchman wrote
 On Aug 30, 9:06 pm, Carsten Haese [EMAIL PROTECTED] wrote:
  On Thu, 30 Aug 2007 20:17:00 -0700, zzbbaadd wrote
 
   Well IN was what I was looking for and would have saved this thread.
   However I don't believe IN showed up on the doc web page that has
   list methods, where I found index().
 
  They're not on the exact same page, but index() is in section 3.6.4 of the
  library reference (http://docs.python.org/lib/typesseq-mutable.html), 
  whereas
  in is in section 3.6 of the library reference
  (http://docs.python.org/lib/typesseq.html). I'm wondering how you managed to
  find subsection 3.6.4 without finding section 3.6.
 
 www.google.com
 
 search python list methods
 
 first search find:
 
 5. Data Structures
 The list methods make it very easy to use a list as a stack, where 
 the last element added  Another useful data type built into 
 Python is the dictionary. ... http://docs.python.org/tut/node7.html
 
 The list data type has some more methods. Here are all of the 
 methods of list objects:

Fair enough, but that's a tutorial. It would be foolish to demand that a
tutorial be a complete reference for everything that can be done with a list.
The page lists all methods of list objects, but there are more things one can
do with lists that don't look like method calls. For example, it doesn't say
that you can compare lists. It doesn't say that you can read and write
elements in the lists. Would you automatically assume that those things aren't
possible? I hope not. (Of course, those operations are handled by the magical
methods __eq__, __setitem__, __getitem__ etc, but I think one can forgive the
tutorial for not mentioning those in the interest of not confusing beginners.)

By your logic, no web page would be allowed to say anything about lists unless
it says *everything* about lists, and that wouldn't be very useful.

--
Carsten Haese
http://informixdb.sourceforge.net

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


Re: python + gcov

2007-08-31 Thread labrach

 I always bit the bullet and finally just did that.

and here the steps to follow ...
http://plexity.blogspot.com/2006/02/profiling-python-extensions.html

laurent


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


Pylons, SQLAlchemy, too many connections problem.

2007-08-31 Thread Adam Kubica
Hello.

I have pylons 0.96 (SVN) and current SQLAlchemy (0.3.10), and I have bug
that
doesn't exist earlier.

My connection code:
code
import sqlalchemy.mods.threadlocal
from sqlalchemy import DynamicMetaData, objectstore

metadata = DynamicMetaData( case_sensitive = False )

def db_connect( dsn ):
engine = create_engine( dsn, echo=False, echo_pool=False,
encoding='latin2',  convert_unicode=True )
metadata.connect( engine )
/code

command netstat -an|grep 5432|grep ESTABLISHED|wc -l displays one
more connection after each refresh of page until I have exceptions
such as:

sqlalchemy.exceptions.DBAPIError: (Connection failed)
(OperationalError) FATAL: sorry, too many clients already

What is wrong?

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


Re: Pylons, SQLAlchemy, too many connections problem.

2007-08-31 Thread Bruno Desthuilliers
Adam Kubica a écrit :
 Hello.
 
 I have pylons 0.96 (SVN) and current SQLAlchemy (0.3.10), and I have bug
 that
 doesn't exist earlier.
 
 My connection code:
 code
 import sqlalchemy.mods.threadlocal
 from sqlalchemy import DynamicMetaData, objectstore
 
 metadata = DynamicMetaData( case_sensitive = False )
 
 def db_connect( dsn ):
 engine = create_engine( dsn, echo=False, echo_pool=False,
 encoding='latin2',  convert_unicode=True )
 metadata.connect( engine )
 /code
 
 command netstat -an|grep 5432|grep ESTABLISHED|wc -l displays one
 more connection after each refresh of page until I have exceptions
 such as:
 
 sqlalchemy.exceptions.DBAPIError: (Connection failed)
 (OperationalError) FATAL: sorry, too many clients already
 
 What is wrong?
 
I don't know for sure, but I guess you'd get better answers posting 
either on the Pylons or SQLAlchemy's google groups.
-- 
http://mail.python.org/mailman/listinfo/python-list


win32com problem: more than one instance

2007-08-31 Thread Thomas Rademacher
Hello,

I start my script convert.py simultaneously in any dos-shells several
times. But I get every time the same solidworks instance.
I see in the proccess (task) manager only one solidworks.exe
Therefore I get for all simultaneous conversions the same output file.

I tested the same code with excel (test_excel.py) and her I get many
instances of excel in proccess (task) manager.
How can I get many instances of solidworks?

Is it a problem of python?
Or is it a problem of the Solidworks-COM-Implemention and I get the
same problem with an C++ client implementation?

Thanks for your help, Thomas

convert.py
   import pythoncom
   pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED)

   sldworks = gencache.EnsureModule('{83A33D31-27C5-11CE-
BFD4-00400513BB57}', 0x0, 13, 0)
   sw = sldworks.ISldWorks(DispatchEx('SldWorks.Application'))
   swmodel, errors, warnings = sw.OpenDoc6(sourceName,
constants.swDocPART, constants.swOpenDocOptions_Silent, )
   activeDoc = sw.ActiveDoc
   retval, errors, warnings = swmodel.SaveAs4(targetName,
constants.swSaveAsCurrentVersion ,
constants.swOpenDocOptions_Silent )

   pythoncom.CoUninitialize()

test_excel.py

   import pythoncom
   pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED)

   myExcel = win32com.client.DispatchEx('Excel.Application')
   myExcel.Visible = 1
   Excel = myExcel.Workbooks.Open(excelfile, 0, False, 2)
   Excel.Saved = 1
   Excel.Close()
   myExcel.Quit()
   del myExcel
   del Excel

   pythoncom.CoUninitialize()

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


Re: win32com problem: more than one instance

2007-08-31 Thread Tim Golden
Thomas Rademacher wrote:
 Hello,
 
 I start my script convert.py simultaneously in any dos-shells several
 times. But I get every time the same solidworks instance.
 I see in the proccess (task) manager only one solidworks.exe
 Therefore I get for all simultaneous conversions the same output file.

I *think* -- and I'm really hoping someone more knowledgeable
can chip in here -- that it's down to the particular COM
object implementation. ie Excel may choose to offer you
separate instances (or whatever they're called) while SolidWorks
may not.

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


Re: Pylons, SQLAlchemy, too many connections problem.

2007-08-31 Thread Adam Kubica
On Fri, 31 Aug 2007 14:03:48 +0200, Adam Kubica wrote:

 Hello.
 
 I have pylons 0.96 (SVN) and current SQLAlchemy (0.3.10), and I have bug
 that
 doesn't exist earlier.
 
 My connection code:
 code
 import sqlalchemy.mods.threadlocal
 from sqlalchemy import DynamicMetaData, objectstore
 
 metadata = DynamicMetaData( case_sensitive = False )
 
 def db_connect( dsn ):
 engine = create_engine( dsn, echo=False, echo_pool=False,
 encoding='latin2',  convert_unicode=True )
 metadata.connect( engine )
 /code
 
 command netstat -an|grep 5432|grep ESTABLISHED|wc -l displays one
 more connection after each refresh of page until I have exceptions
 such as:
 
 sqlalchemy.exceptions.DBAPIError: (Connection failed)
 (OperationalError) FATAL: sorry, too many clients already
 
 What is wrong?

Don't use DynamicMetaData(), use MetaData(), it's the problem.
-- 
http://mail.python.org/mailman/listinfo/python-list


Google spreadsheets

2007-08-31 Thread Michele Simionato
I would like to upload a tab-separated file to a Google spreadsheet
from Python. Does anybody
have a recipe handy? TIA,

Michele Simionato

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


Re: Python doesn't see the directories I create

2007-08-31 Thread Neil Cerutti
On 2007-08-31, Lawrence D'Oliveiro
[EMAIL PROTECTED] wrote:
 In message [EMAIL PROTECTED], Neil
 Cerutti wrote:
 Keeping in mind which came first, isn't it at least as
 accurate to attribute this problem to Python's choice of
 escape character?

 No, it's Microsoft's fault. The use of backslash as an escape
 character goes back to Unix systems in the early 1970s--long
 before Microsoft came on the scene.

 When Microsoft introduced MS-DOS 1.0 in 1981, it didn't have
 directory hierarchies. Commands used the slash character to
 delimit options. Then when MS-DOS 2.0 introduced subdirectories
 in 1983, they decided they couldn't use the slash as the path
 separator, so they used the backslash instead. That has been a
 source of confusion ever since then.

Going back and checking the Python History page, it seems I was
off by four years with when I thought Python was first released
(I was thinking 1995, when the first release was actually 1991).
That makes Python's choice of escape character way more practical
than I thought, since Microsoft hadn't yet conquered the desktop
computing world when Python was in it's infancy.

That strange whirring sound is me backpedaling furiously. Thanks
very much for all your patiences.

-- 
Neil Cerutti
If you throw at someone's head, it's very dangerous, because in the head is
the brain. --Pudge Rodriguez
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: status of Programming by Contract (PEP 316)?

2007-08-31 Thread Neil Cerutti
On 2007-08-31, Ricardo Aráoz [EMAIL PROTECTED] wrote:
 Russ wrote:
 Yes, thanks for reminding me about that. With SPARK Ada, it is
 possible for some real (non-trivial) applications to formally
 (i.e., mathematically) *prove* correctness by static analysis.
 I doubt that is possible without static declarative type-
 checking.
 
 SPARK Ada is for applications that really *must* be correct or
 people could die.

 I've always wondered... Are the compilers (or interpreters),
 which take these programs to machine code, also formally proven
 correct? And the OS in which those programs operate, are they
 also formally proven correct? And the hardware, microprocessor,
 electric supply, etc. are they also 'proven correct'?

Who watches the watchmen? The contracts are composed by the
programmers writing the code. Is it likely that the same person
who wrote a buggy function will know the right contract?

-- 
Neil Cerutti
The third verse of Blessed Assurance will be sung without musical
accomplishment. --Church Bulletin Blooper
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: reload(sys)

2007-08-31 Thread Sönmez Kartal
On 31 A ustos, 04:24, Steven Bethard [EMAIL PROTECTED] wrote:
 Sönmez Kartal wrote:
  I've had an encoding issue and solved it by
  sys.setdefaultencoding('utf-8')...

  My first try wasn't successful since setdefaultencoding is not named
  when I imported sys module. After, I import sys module, I needed to
  write reload(sys) also.

  I wonder why we need to call reload(sys) to get setdefaultencoding
  named?

 sys.setdefaultencoding is purposely deleted from the sys module after
 it's loaded because you really shouldn't be using it. The reload() call
 restores the deleted attribute.

 If you'd like a less brittle solution to your encoding issue, explain
 what the issue was, and people here can probably help you find a better
 solution.

 STeVe

I was using the XMLBuilder(xmlbuilder.py). I'm writing XML files as
f.write(str(xml)). At execution of that line, it gives error with
description, configure your default encoding... My operating system's
default is utf-8, and Emacs' is utf-8 too. Default of XMLBuilder is
utf-8 too. There were some characters interpreter may couldn't print
in ascii. I have tried to replace those characters like (TM) (R)... I
cannot remember them right now, but if necessary I can find them
easily...

This is the part of xmlbuilder.py which raises the error.

try:
if self.pretty:
# tabs are evil, so we will use two spaces
outstr = self._dom.toprettyxml(
,encoding=self.encoding)
else:
outstr = self._dom.toxml(encoding=self.encoding)
except UnicodeDecodeError:
sys.stderr.write('Decoding Error: You must configure
default encoding\n')
sys.exit()

What I can do instead of import sys; reload(sys);
sys.setdefaultencoding('utf-8')?

Happy coding

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

How to use Resource Editor in wxPython ?

2007-08-31 Thread codemania
Disappointing me extremely, with the generate python function within
Resource Editor, I only get a segment of python code which load
xrc(xml format) file, rather than real python code in which I could
append my own code.

Does that mean RE(Resource Editor) is of little use?

I hope not, maybe the way I use it is wrong? Tell me please.

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


Re: pure python for sms

2007-08-31 Thread Gerardo Herzig
Neil Hodgson wrote:

Gerardo Herzig:

  

Hi dudes. Im looking for a python implementation for sending sms to a 
cell phone. I was try using some free pages, but i want to use a python. 
Do i need a cellphone conected to my machine? Or can i send sms to some 
cell via some python library?



This is likely to cost some money similar to sending an SMS from a 
'phone. There are several companies that provide SMS sending services 
that can be accessed through HTTP. Have a look at www.clickatell.com and 
www.aql.com . Here is a library based on Clickatell:
http://www.powertrip.co.za/code/python/clickatell.py

Neil
  

Well, im not triyng to send a SMS `FROM' a cellphone, im trying to send 
a SMS `TO' a cellphone. Here (in Argentina) are several sites who lets 
you send a sms for free. You also can receive SMS responses via this page
http://sms.personal.com.ar/Mensajes/msn.htm

While my tries using this page via urllib failed, i dont want to depend 
on an external page anyway. The  python class you  send to me looks like 
a  pay site (if not, i dont see why the tokenpay() and getbalance() 
methods :)

I was also avaiable to send a sms in the form of an plain email 
[EMAIL PROTECTED], but it not seems to work 
this way no longer. Again, i dont want to do it that way anyway.

Thats why im looking for a python implementation of that funcionality.

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


Re: Let's Unite Against Jews and Mongrels!

2007-08-31 Thread Wildemar Wildenburger
Barry OGrady wrote:
 He has some wrong ideas. The blacks are victims of the jews as well.
 

And Jews are the victims of Christians. And Christians are the victims 
of Muslims.

Anybody not a victim of anyone else, please raise your hand!

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


Re: pure python for sms

2007-08-31 Thread Francesco Guerrieri
On 8/31/07, Gerardo Herzig [EMAIL PROTECTED] wrote:
 Well, im not triyng to send a SMS `FROM' a cellphone, im trying to send
 a SMS `TO' a cellphone. Here (in Argentina) are several sites who lets
 you send a sms for free. You also can receive SMS responses via this page
 http://sms.personal.com.ar/Mensajes/msn.htm

 While my tries using this page via urllib failed, i dont want to depend
 on an external page anyway. The  python class you  send to me looks like
 a  pay site (if not, i dont see why the tokenpay() and getbalance()
 methods :)

 I was also avaiable to send a sms in the form of an plain email
 [EMAIL PROTECTED], but it not seems to work
 this way no longer. Again, i dont want to do it that way anyway.

 Thats why im looking for a python implementation of that funcionality.

Well but sooner or later you will have to pass your sms through some
cellular system network whose services someone has to pay for...no?

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


Re: create Powerpoint via com

2007-08-31 Thread kyosohma
On Aug 30, 11:55 pm, Alan Isaac [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] wrote:
  code

 OK, creating bulleted lists, or tables,
 or adding pictures is all straightforward.
 How about chart creation (in Ppt 2003)?
 I do not see how to do this with Python.

 Thanks,
 Alan

Alan,

You probably need to browse the COM object using PythonWin, which is a
part of the ActiveState distro. You can also use Python's builtin
function, dir, to find out various methods of COM.

Here's some info in messing with charts in Excel, which should be
similar to chart manipulation in PowerPoint.

http://mail.python.org/pipermail/python-win32/2005-June/003511.html
http://mail.python.org/pipermail/python-win32/2003-March/000839.html
http://www.thescripts.com/forum/thread21565.html
http://mathieu.fenniak.net/plotting-in-excel-through-pythoncom/

Mike

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


Re: How to use Resource Editor in wxPython ?

2007-08-31 Thread kyosohma
On Aug 31, 7:49 am, codemania [EMAIL PROTECTED] wrote:
 Disappointing me extremely, with the generate python function within
 Resource Editor, I only get a segment of python code which load
 xrc(xml format) file, rather than real python code in which I could
 append my own code.

 Does that mean RE(Resource Editor) is of little use?

 I hope not, maybe the way I use it is wrong? Tell me please.

You can use the code generated with your wxPython code; but when using
XRCed, you need to do two-stage creation, which the generated code
mentions. It even provides a link: 
http://wiki.wxpython.org/index.cgi/TwoStageCreation

I thought this one was good reading too:
http://wiki.wxpython.org/index.cgi/UsingXmlResources

I like it depending on the complexity of the project. It can seriously
reduce GUI code clutter.

Mike

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


Re: fcntl problems

2007-08-31 Thread mhearne808[insert-at-sign-here]gmail[insert-dot-here]com
On Aug 31, 12:23 am, Miles [EMAIL PROTECTED] wrote:
 Sorry, that last quote-only reply was accidental. :)

 On 8/30/07, mhearne808 wrote:
  I've been doing some experiments, and here are some specific examples
  to try.

 [snipped examples]

  From these last two experiments I can only conclude that file locking
  isn't doing a durned thing.

  What's going on?

 File locking isn't doing a durned thing in those cases because you're
 only obtaining the lock from a single process.

  According to my Python Cookbook:
  Exclusive lock: This denies all _other_ processes both read and write
  access to the file.

 This is only for mandatory locking; POSIX flock is advisory locking,
 which states: Only one process may hold an exclusive lock for a given
 file at a given time.  Advisory locks don't have any effect on
 processes that don't use locks.  Mandatory locks are kernel enforced,
 but non-POSIX and not available in Mac OS X.

 -Miles

I think I'm still confused.  Maybe I should explain the behavior that
I want, and then figure out if it is possible.

I have a script that will be run from a cron job once a minute.  One
of the things this script will do is open a file to stash some
temporary results.  I expect that this script will always finish its
work in less than 15 seconds, but I didn't want to depend on that.
Thus I started to look into file locking, which I had hoped I could
use in the following fashion:

Process A opens file foo
Process A locks file foo
Process A takes more than a minute to do its work
Process B wakes up
Process B determines that file foo is locked
Process B quits in disgust
Process A finishes its work

Since I couldn't figure out file locking, I decided to just have
Process A create a pid file in the directory - analogous to the
Occupied sign on an airplane bathroom.  This works, but it seems a
little hacky.

--Mike

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


Re: pure python for sms

2007-08-31 Thread Paul Boddie
On 31 Aug, 15:36, Gerardo Herzig [EMAIL PROTECTED] wrote:
 Neil Hodgson wrote:
 This is likely to cost some money similar to sending an SMS from a
 'phone.

[...]

 Well, im not triyng to send a SMS `FROM' a cellphone, im trying to send
 a SMS `TO' a cellphone.

Yes, but he did write similar to, meaning that regardless of how the
message is prepared, sending it may cost someone some money - the
typical financial effect when you send a message from an actual
telephone.

 Here (in Argentina) are several sites who lets you send a sms for free. You 
 also can receive
 SMS responses via this pagehttp://sms.personal.com.ar/Mensajes/msn.htm

I guess you're thinking about a library like SMSLib:

http://smslib.org/

This seems to combine the two most obvious ways of sending such
messages: communicate with a device already located on the GSM
network; communicate with a gateway which relays messages to the GSM
network.

 While my tries using this page via urllib failed, i dont want to depend
 on an external page anyway. The  python class you  send to me looks like
 a  pay site (if not, i dont see why the tokenpay() and getbalance()
 methods :)

 I was also avaiable to send a sms in the form of an plain email
 [EMAIL PROTECTED], but it not seems to work
 this way no longer. Again, i dont want to do it that way anyway.

Yes, both of the above (use of a Web site or an e-mail relay) rely on
existing services. If you don't want to do that, you'll need to
connect directly to your own GSM-capable device, I imagine.

 Thats why im looking for a python implementation of that funcionality.

I don't know how well SMSLib works with Jython or whether you could
take a PyLucene-like approach and wrap it for CPython using SWIG or
some other wrapper technology in conjunction with gcj, but that's one
approach. Another is to look into libraries which communicate with
mobile devices: I extended one called t616hack [1] and made it almost
capable of telling my T610 telephone to send messages, but another
candidate would be python-gammu [2]. A while back someone stumbled
across a GSM hardware module which has embedded Python as a feature
[3], but I imagine that a lot of GSM-capable hardware uses AT-like
commands to support such activities.

Of course, I've probably covered an area that you're not directly
interested in, but someone has to provide a link to the GSM network,
either in the network infrastructure or by using some kind of GSM
device. If you're not a GSM network operator then it's likely that
you're either going to need to deal with a network operator, perhaps
indirectly, or you'll need to join the GSM network with a suitable
device in the normal way.

Paul

[1] http://www.python.org/pypi/t616hack
[2] http://cihar.com/gammu/python/
[3] http://www.telit.co.it/product.asp?productId=113

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


Re: list index()

2007-08-31 Thread TheFlyingDutchman


 Fair enough, but that's a tutorial. It would be foolish to demand that a
 tutorial be a complete reference for everything that can be done with a list.

I wasn't demanding anything of the page. I was pointing out how I made
the assumption there was no way to find out if a list has a value
other than by using index(). I am not used to having keywords in a
language operate on a data structure, in addition to its methods.

 The page lists all methods of list objects, but there are more things one can
 do with lists that don't look like method calls. For example, it doesn't say
 that you can compare lists. It doesn't say that you can read and write
 elements in the lists. Would you automatically assume that those things aren't
 possible? I hope not. (Of course, those operations are handled by the magical
 methods __eq__, __setitem__, __getitem__ etc, but I think one can forgive the
 tutorial for not mentioning those in the interest of not confusing beginners.)

 By your logic, no web page would be allowed to say anything about lists unless
 it says *everything* about lists, and that wouldn't be very useful.

As I just stated, I wasn't making a criticism of the page. But since
you are defending it, let's talk about Python documentation from the
perspective of an experienced programmer who is a new/casual user of
both Python and Java. If I am in the process of writing a little Java
program, java.sun.com provides documentation on its data structures
that show up right at the top of a google search for Java ArrayList,
Java Hashtable, etc.

If I am writing a little Python program and want to see what I can do
with a list, I google python list I get the tutorial page that has
been mentioned. Then the next query result is a page that is titled
the Python Language Reference. But in this reference page for
python str,unicode,list,tuple,buffer,xrange, I see operators that
work on lists and other data structures that I an mot concerned with,
but there is no list of list methods. But I do see navigational
arrows that I hopefully assume will take me to a page where I can find
all the list methods - but that is not the case. I go from 3.6
Sequence Types -- str, unicode, list, tuple, buffer, xrange to 3.6.1
String Methods to 3.6.2 String Formatting Operations to 3.6.3
XRange Type to 3.6.4 Mutable Sequence Types. And then I'm done with
3.6 of the Python Language Reference and I never saw a list of list
methods or a page devoted to lists. So I bounce out to the table of
contents assuming that there must be an entry for list that will
show all the list methods and operators and give me a summary ala Java
ArrayList. But all I find are entries for UserList and AddressList. :(

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


Re: list index()

2007-08-31 Thread BJörn Lindqvist
On 8/30/07, Carsten Haese [EMAIL PROTECTED] wrote:
 Is the Pythonic way

 try:
 i = somelist.index(thing)
 # Do something with i
 except IndexError:
 # Do something if thing not found

That is not the Pythonic way. # Do something with i might also raise
an IndexError and they you are screwed. The Pythonic way is something
like:

try:
i = somelist.index(thing)
except IndexError:
print Oh noes!
else:
# Do the thing with i

And for many cases this actually is worse/less readable than the
alternative would have been if list.index() returned -1.


-- 
mvh Björn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: reload(sys)

2007-08-31 Thread Marc 'BlackJack' Rintsch
On Fri, 31 Aug 2007 12:53:36 +, Sönmez Kartal wrote:

 On 31 A ustos, 04:24, Steven Bethard [EMAIL PROTECTED] wrote:
 Snmez Kartal wrote:
  I've had an encoding issue and solved it by
  sys.setdefaultencoding('utf-8')...

  My first try wasn't successful since setdefaultencoding is not named
  when I imported sys module. After, I import sys module, I needed to
  write reload(sys) also.

  I wonder why we need to call reload(sys) to get setdefaultencoding
  named?

 sys.setdefaultencoding is purposely deleted from the sys module after
 it's loaded because you really shouldn't be using it. The reload() call
 restores the deleted attribute.

 If you'd like a less brittle solution to your encoding issue, explain
 what the issue was, and people here can probably help you find a better
 solution.
 
 I was using the XMLBuilder(xmlbuilder.py). I'm writing XML files as
 f.write(str(xml)). At execution of that line, it gives error with
 description, configure your default encoding...

This doesn't help us that much.  What is `f` here and what is `xml`?

 This is the part of xmlbuilder.py which raises the error.
 
 try:
 if self.pretty:
 # tabs are evil, so we will use two spaces
 outstr = self._dom.toprettyxml(
 ,encoding=self.encoding)
 else:
 outstr = self._dom.toxml(encoding=self.encoding)
 except UnicodeDecodeError:
 sys.stderr.write('Decoding Error: You must configure
 default encoding\n')
 sys.exit()

So there is an attribute `self.encoding` on that object.  Is it set?  What
encoding is it?  And do you put byte strings with values outside ASCII
into your XML or unicode strings?

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

Re: create Powerpoint via com

2007-08-31 Thread Alan Isaac
How about chart creation (in Ppt 2003)?
I do not see how to do this with Python.

[EMAIL PROTECTED] wrote:
 You probably need to browse the COM object using PythonWin, which is a
 part of the ActiveState distro. You can also use Python's builtin
 function, dir, to find out various methods of COM.
 
 Here's some info in messing with charts in Excel, which should be
 similar to chart manipulation in PowerPoint.
 
 http://mail.python.org/pipermail/python-win32/2005-June/003511.html
 http://mail.python.org/pipermail/python-win32/2003-March/000839.html
 http://www.thescripts.com/forum/thread21565.html
 http://mathieu.fenniak.net/plotting-in-excel-through-pythoncom/


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


Re: fcntl problems

2007-08-31 Thread Miles
On 8/31/07, mhearne808 wrote:
 I have a script that will be run from a cron job once a minute.  One
 of the things this script will do is open a file to stash some
 temporary results.  I expect that this script will always finish its
 work in less than 15 seconds, but I didn't want to depend on that.
 Thus I started to look into file locking, which I had hoped I could
 use in the following fashion:

 Process A opens file foo
 Process A locks file foo
 Process A takes more than a minute to do its work
 Process B wakes up
 Process B determines that file foo is locked
 Process B quits in disgust
 Process A finishes its work

That would look like (untested):

import fcntl, sys
f = open('foo', 'w+')
try:
fcntl.flock(f.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
except IOError, e:
if e.args[0] == 35:
sys.exit(1)
else:
raise
f.seek(0, 2) # seek to end
# do your thing with the file
f.flush()
fcntl.flock(f.fileno(), fcntl.LOCK_UN)
f.close()

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


Question involving a Python app...

2007-08-31 Thread sberry
I am a Flash developer (also a Python dev) and I use an editor called
SEPY Actionscript Editor.  The latest release version does not support
Flash CS3, so I downloaded the source from subversion, edited it, and
recompiled to get a version that worked with CS3.  Right now, in order
to run the program I have to do a command line python main.pyw.

The question now is this:
Others in my company would like to use the version I have compiled
without installing Python, wxPython, 4suite, antlr, and a whole bunch
of other Python libs.  So, how do I create an executable (on Windows)
to install the program so it will run without the aforementioned
framework being installed?

I know this isn't really an entirely Pythonic question, but this
group has always been very helpful in the past.

Thanks

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


Re: Important Research Project

2007-08-31 Thread mecej4
E.D.G. wrote:
 dave_w [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 
 My main Perl program is presently about 3500 lines of code long and 160 KB
 in size. So I am not too anxious to translate it into another language.
 
Apparently, having painted himself into a corner, our warrior wants a 
few expert roofers to slither up and extricate him.

One of the best experiences that a programmer can have is that of 
admitting that the lovingly nurtured brainchild is now terminally ill, 
and showing enough fortitude to make a fresh start.

 The problem I am having is largely with the mechanics of linking modules to
 the Perl compiler etc.  So I am looking for experts who can help with
 cookbook instructions, start with step 1, step 2, step 3 etc.

Experts saintly enough to salvage the possibly hopeless would some idea 
of whether they are being asked to donate their time to work on a 
fundamentally flawed design.

 With trying to find a chart program to use for example, there appear to be a
 number of them.  But from examining their instructions it looks like most of
 them must also be linked to a third program called Gnuplot.  And that
 increases the complexity of getting something running.
 

Since Perl, as also most other general purpose languages, has no 
plotting primitives or intrinsics,
you will have to use _some_ graphics protocol -- there is no escaping that.

Gnuplot is by no means the only choice, but it is simple and provides
a wide selection of output devices. Your Perl program can write the plot 
script to a
file, and call Gnuplot to run that script.

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


Fatal Python error using ctypes python exceptions

2007-08-31 Thread mmacrobert
Hi Everyone,
I've created a 'C' dll that is accessed via ctypes library containing
a bunch of functions. I've successfully been able to use the
functions. However, I would like to throw python exceptions from some
of them.

I throw them using: ::PyErr_SetString(::PyExc_RuntimeError,
theErrorString);

I crash the console when this function is invoked in the 'C' domain. I
get an error stating:

Fatal Python error: PyThreadState_Get: no current thread

when the calling code in python is:

try:
cdll.MyDll.ThrowingFunction()
except:
print An error has occurred

The dll is just a plain win32 'C' dll, built with an MS compiler. How
do I throw python exceptions correctly? Is there some kind of init
function that needs to be called?

Any help much appreciated.

Thanks,
Martin

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


Re: Question involving a Python app...

2007-08-31 Thread Simon Brunning
On 8/31/07, sberry [EMAIL PROTECTED] wrote:
 So, how do I create an executable (on Windows)
 to install the program so it will run without the aforementioned
 framework being installed?

Check out py2exe.

-- 
Cheers,
Simon B.
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: strings (dollar.cents) into floats

2007-08-31 Thread Steve Holden
Ben Finney wrote:
 Wildemar Wildenburger [EMAIL PROTECTED] writes:
 
 But what use is there for floats, then? When is it OK to use them?
 
 When one is willing to sacrifice decimal precision for speed of
 calculation, and doesn't need the numbers to stay precise. E.g. when
 performing millions of calculations on real-world (analogue)
 measurements.
 
Traditionally, mainframe computers used BCD arithmetic to handle 
currency, and the Decimal module is probably the best way to proceed if 
your Python is recent enough to include it.

That isn't to say that currencies can't be handled using floating-point. 
The important thing then becomes to round after each calculation rather 
than allowing the errors to build up until they become significant 
enough to make a difference to the final result.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: MySQLdb ImportError

2007-08-31 Thread Steve Holden
Sjoerd wrote:
 Hello!
 
 When I try to import the MySQLdb lib python generates an error:
 
 Traceback (most recent call last):
   File pyshell#0, line 1, in module
 import MySQLdb
   File C:\Python25\lib\site-packages\MySQLdb\__init__.py, line 19,
 in module
 import _mysql
 ImportError: DLL load failed with error code 193
 
 This is on a AMD64 bit machine, when I import it on a 32 bit machine
 it works fine.
 Is there anyway to fix this? Is there a build for AMD64 bit machines
 or is there simply no way
 that I can get MySQLdb working on it?
 
 Thanks in advance,
 Sjoerd
 
I'm not aware of a current build for that architecture (and your 
assumption that the load fails because of the architecture mismatch is 
correct).

It is possible to build the module yourself if it's important enough. I 
remember doing this some time ago with the Microsoft free compiler kit, 
for example.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: Setting a read-only attribute

2007-08-31 Thread Steve Holden
[EMAIL PROTECTED] wrote:
 I have an object and wish to set an attribute on it which,
 unfortunately for me, is read-only.
 
 How can I go about this?
 
This seems like a bizarre requirement. Why is the attribute read-only in 
the first place? How is the read-only mechanism enforced? Is the object 
created in Python or in an extension module? Do you have any evidence 
that setting the attribute will effect the required change in the 
behavior of the object.

A little more information would be helpful.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: fcntl problems

2007-08-31 Thread Hrvoje Niksic
mhearne808[insert-at-sign-here]gmail[insert-dot-here]com [EMAIL PROTECTED] 
writes:

 I think I'm still confused.

What Miles tried to tell you is that you should call fcnt.flock from
both PA and PB.  In the example you posted, you failed to call it from
PB.  No lock call, so no locking happened.

 I have a script that will be run from a cron job once a minute.  One
 of the things this script will do is open a file to stash some
 temporary results.  I expect that this script will always finish its
 work in less than 15 seconds, but I didn't want to depend on that.
 
 Thus I started to look into file locking, which I had hoped I could
 use in the following fashion:

 Process A opens file foo
 Process A locks file foo
 Process A takes more than a minute to do its work
 Process B wakes up
 Process B determines that file foo is locked
 Process B quits in disgust
 Process A finishes its work

File locking supports that scenario, as you suspected.  You need to
use flock with LOCK_EX|LOCK_NB.  If the call succeeds, you got the
lock.  If you get an exception whose errno is EWOULDBLOCK, you quit in
disgust.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: fcntl problems

2007-08-31 Thread mhearne808[insert-at-sign-here]gmail[insert-dot-here]com
On Aug 31, 8:42 am, Miles [EMAIL PROTECTED] wrote:
 On 8/31/07, mhearne808 wrote:
  I have a script that will be run from a cron job once a minute.  One
  of the things this script will do is open a file to stash some
  temporary results.  I expect that this script will always finish its
  work in less than 15 seconds, but I didn't want to depend on that.
  Thus I started to look into file locking, which I had hoped I could
  use in the following fashion:

  Process A opens file foo
  Process A locks file foo
  Process A takes more than a minute to do its work
  Process B wakes up
  Process B determines that file foo is locked
  Process B quits in disgust
  Process A finishes its work

 That would look like (untested):

 importfcntl, sys
 f = open('foo', 'w+')
 try:
fcntl.flock(f.fileno(),fcntl.LOCK_EX |fcntl.LOCK_NB)
 except IOError, e:
 if e.args[0] == 35:
 sys.exit(1)
 else:
 raise
 f.seek(0, 2) # seek to end
 # do your thing with the file
 f.flush()fcntl.flock(f.fileno(),fcntl.LOCK_UN)
 f.close()

 -Miles

I tested that, and it works!  Thanks!

Looking at my flock(3) man page, I'm guessing that 35 is the error
code for EWOULDBLOCK.  Which system header file am I supposed to look
in to figure that magic number out?

I would make the argument that this module could be either more
pythonic, or simply documented more completely.  The open source
response, of course, would be go for it!.

--Mike

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


Re: Biased random?

2007-08-31 Thread Jeffrey Barish
Robert Kern wrote:

 Ivan Voras wrote:
 Jeffrey Barish wrote:
 
 If you take the difference between two uniformly distributed random
 variables, the probability density function forms an isosceles triangle
 centered at 0.  Take the absolute value of that variable and the pdf is
 a
 straight line with maximum value at 0 tapering to 0 at max.  Thus,

 z = abs(randint(0, max) - randint(0, max))

 ought to do the trick.
 
 It's elegant :)
 
 I've noticed something interesting in my test: the value 0 appears less
 often than other values (which behave as they should).
 
 The distribution of the difference (before the abs()) looks like this
 (max=4):
 
 #
###
   #
  ###
  ---0+++
  321 123
 
 Taking the absolute value doubles up the non-zero masses, but there's no
 negative 0 to add to the 0s stack.
 
   #
   #
  ###
  ###
  
  
  0123
 
 The method does not work because of that.
 
The math says that it works, so we must not be implementing it correctly.  I
suspect that our mistake is quantizing the random variable first and then
taking the difference and absolute value.  What result do you get when you
quantize once?  That is, obtain two random values (floats) with uniform
pdf.  Take the difference.  Abs. Round to int.  This way, everything in the
band from (-0.5, +0.5) goes to 0, and that's the highest part of the
triangle.
-- 
Jeffrey Barish

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


Re: Question involving a Python app...

2007-08-31 Thread kyosohma
On Aug 31, 9:52 am, sberry [EMAIL PROTECTED] wrote:
 I am a Flash developer (also a Python dev) and I use an editor called
 SEPY Actionscript Editor.  The latest release version does not support
 Flash CS3, so I downloaded the source from subversion, edited it, and
 recompiled to get a version that worked with CS3.  Right now, in order
 to run the program I have to do a command line python main.pyw.

 The question now is this:
 Others in my company would like to use the version I have compiled
 without installing Python, wxPython, 4suite, antlr, and a whole bunch
 of other Python libs.  So, how do I create an executable (on Windows)
 to install the program so it will run without the aforementioned
 framework being installed?

 I know this isn't really an entirely Pythonic question, but this
 group has always been very helpful in the past.

 Thanks

I find GUI2exe to be very easy to use. It's just py2exe with a GUI
frontend. See http://xoomer.alice.it/infinity77/main/GUI2Exe.html for
more information.

Mike

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


RE: win32com problem: more than one instance

2007-08-31 Thread Stefan Schukat
 
Hello Thomas, 

excel registers its COM objects with REGCLS_SINGLEUSE that means one COM
object is created
per process. In Solidworks it seems that that they register with
REGCLS_MULTIPLEUSE, which means
on process can serve more than one COM object. Hence you have no chance
to get multiple instances
running in any COM client. 

Stefan


 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of Tim Golden
 Sent: Friday, August 31, 2007 1:36 PM
 To: Thomas Rademacher
 Cc: python-list@python.org
 Subject: Re: win32com problem: more than one instance
 
 Thomas Rademacher wrote:
  Hello,
  
  I start my script convert.py simultaneously in any 
 dos-shells several 
  times. But I get every time the same solidworks instance.
  I see in the proccess (task) manager only one 
 solidworks.exe Therefore 
  I get for all simultaneous conversions the same output file.
 
 I *think* -- and I'm really hoping someone more knowledgeable 
 can chip in here -- that it's down to the particular COM 
 object implementation. ie Excel may choose to offer you 
 separate instances (or whatever they're called) while 
 SolidWorks may not.
 
 TJG
 --
 http://mail.python.org/mailman/listinfo/python-list
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Ayuda

2007-08-31 Thread Dr. José Contreras
Gente Inteligente y Distinguida, soy un aficionado y apelo a Ustedes, para
resolver éste problema. Para WebMaster de Google, me solicita instalar o
ejecución de pitón, cómo comprenderán no dispongo de ningún guru de web, por
lo que solicito en la medida de sus posibilidades me ayuden a ejecutar pitón
para WebMaster, para ingresar a sitemap.xlm. Les saludo con distinguida
consideración y respeto. José

 Si son tan amables, les agradeceré cualquiera sea la Repuesta, en Español o
castellano. Gracias 

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

Re: fcntl problems

2007-08-31 Thread Miles
On 8/31/07, mhearne808 wrote:
 Looking at my flock(3) man page, I'm guessing that 35 is the error
 code for EWOULDBLOCK.  Which system header file am I supposed to look
 in to figure that magic number out?

I got the error number by looking at the IOError exception raised when
playing with the interactive interpreter, but I really should have
written:

from errno import EWOULDBLOCK
...
if e.args[0] == EWOULDBLOCK:
...

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


Re: Setting a read-only attribute

2007-08-31 Thread [EMAIL PROTECTED]
On Aug 31, 6:14 pm, Alexandre Badez [EMAIL PROTECTED] wrote:
 On Aug 30, 11:35 pm, [EMAIL PROTECTED] [EMAIL PROTECTED]
 wrote:

  I have an object and wish to set an attribute on it which,
  unfortunately for me, is read-only.

  How can I go about this?

  Cheers.
  -T

 Could you show the object you want to set his attribute?
 Until that, it's difficult to answer to you.

 PS: If the attribut is on read only, their must a good reason for
 that ;)

Hi all,

Thanks for all the responses. What I'm trying to do is kludge around
something. sys.settrace takes a method whose arguments are (frame,
event, arg). I want to have a tracer class which can be instantiated
and listen in on these trace calls.

Another way to go about it *might* be to have a module-level list of
registered Tracer objects which a module-level trace method informs of
events. It would probably be easier. In fact, I'll go do that.

*That said*, I still think it makes sense to be able to have objects
register with sys.settrace.

So what I did then was declare a static method with the same pattern
expected by sys.settrace. I then want to use something like __dict__
or __setattr__ to give that method a reference to the owning object.
And this is what I'm trying to do -- declare a static method, then un-
static it by adding a reference to the callable object...

Here's some code:


import sys


class Tracer:
'''
Instantiate this in order to access program trace information.

'''

def _getcallback(self):

@staticmethod
def callback(frame, event, arg):
print tracing ..., tracerReference
#print line , frame.f_lineno, frame.f_locals

return callback

def startTrace(self):
callback = self._getcallback()
callback.__dict__['tracerReference'] = self
sys.settrace(callback)


def foo(dict):
for i in range(2):
pass

if __name__ == __main__:
t = Tracer()
t.startTrace()
foo({1 : 5})

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


Do you have any complete example for creating msi file(doing file copying)

2007-08-31 Thread siddhatha veedaluru
Thank you for the help that you  are going to give me.
 
I have a project where in which i want to create a msi file just as 
python-package while installing python on the system. Just copying the files to 
the user given target directory.
 
i want to create similar msi file for my project that just copies the file.
 
Can you please help me in providing the complete procedure of creating the msi 
file using the python.
 
Does msilib library in the release 2.5 have this capability?
 
Please help me
Thanks
Sid


  Unlimited freedom, unlimited storage. Get it now, on 
http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/-- 
http://mail.python.org/mailman/listinfo/python-list

Re: strings (dollar.cents) into floats

2007-08-31 Thread sturlamolden
On 31 Aug, 02:12, Wildemar Wildenburger
[EMAIL PROTECTED] wrote:

 I've heard (ok, read) that several times now and I understand the
 argument. But what use is there for floats, then? When is it OK to use them?

There are fractions that can be exactly represented by floats that
cannot be exactly represented by decimals. There are fractions that
can be exactly represented by decimals that cannot be exactly
represented by floats.

Which one is better? Which do we prefer?

What a float cannot do is to represent a decimal fractional number
(e.g. 1.1) exactly. If we need that, we cannot use floats. A notable
example is monetary computations, it covers 99% of the use for decimal
numbers in computers. For this reason, we should never use floats to
add 10 cents to a dollar. The use of decimals for monetary
calculations is mandatory.

Floats are written as decimal fractional numbers in program code, and
they are printed as decimal fractional numbers on the screen. A novice
programmer may for this reason easily mistake floats for being
decimals. But inside the computer floats are something very different.
Floats do not represent decimal fractional numbers. Floats represent
binary fractional numbers. Decimal numbers are base-10, binary numbers
are base-2. Floats and decimals are similar but different.

It is much easier to manipulate for computers than decimals. Digital
electronics by convention only has two states, TTL voltage levels 0.0
V and 5.0 V, which are taken to mean 0 and 1 in binary (or false and
true in boolean) respectively. Computers work internally with binary
numbers. Floats are preferred to decimals in e.g. numerical maths and
other scientific computing for their better performance speed wise.
Knowledge of the behaviour of floats, e.g. how they cause rounding and
truncation errors, is pivotal in that field of computer science. For
most purposes, we could replace floats with decimals. But then we
would suffer a major speed penalty.

Decimals are only precise if the input values can be represented
precisely by decimal fractions. If we typed 1.1 and took that to mean
one dollar and 10 cents, then certainly exactly 1.1 was what we
meant. But if we ment 1.1 centigrades read from a mercury
thermometer, we would actually (by convention) mean something
between 1.05 and 1.14 centigrades. Decimals also fail to be exact if
we try to compute things like 1.0/3.0. 1/3 does not have an exact
representation in decimal, and we get an approximation from the
computer.

For purposes where exact precision is not needed, decimals are neither
better nor worse than floats. This accounts for 99% of the cases where
fractional numbers are used on a computer.

More about floating point numbers here:
http://www.math.byu.edu/~schow/work/IEEEFloatingPoint.htm


Sturla Molden


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


escaping only double quotes

2007-08-31 Thread cesco
Hi,

I have a string which is constructed like this:

string = Butler's 15\ TV
s = my string goes here %s  % string

the single string, unfortunately, gets escaped which is something I
want to avoid because I have to load the data into a database using
the json format and I get an invalid escape error if the single
quote is escaped.

Is there a way to accomplish this?

Thanks and regards
Francesco

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


Re: Question involving a Python app...

2007-08-31 Thread sberry
On Aug 31, 8:25 am, [EMAIL PROTECTED] wrote:
 On Aug 31, 9:52 am, sberry [EMAIL PROTECTED] wrote:



  I am a Flash developer (also a Python dev) and I use an editor called
  SEPY Actionscript Editor.  The latest release version does not support
  Flash CS3, so I downloaded the source from subversion, edited it, and
  recompiled to get a version that worked with CS3.  Right now, in order
  to run the program I have to do a command line python main.pyw.

  The question now is this:
  Others in my company would like to use the version I have compiled
  without installing Python, wxPython, 4suite, antlr, and a whole bunch
  of other Python libs.  So, how do I create an executable (on Windows)
  to install the program so it will run without the aforementioned
  framework being installed?

  I know this isn't really an entirely Pythonic question, but this
  group has always been very helpful in the past.

  Thanks

 I find GUI2exe to be very easy to use. It's just py2exe with a GUI
 frontend. Seehttp://xoomer.alice.it/infinity77/main/GUI2Exe.htmlfor
 more information.

 Mike

Thanks for the help... and for giving it so quickly - I can always
count on this group.

Problems though... I was successful at creating the dist dir with my
executable file, but when I try to run it I get an error.log file with
the following:

type 'exceptions.IOError'
[Errno 9] Bad file descriptor
[53]: main.pyw
[29]: SEPY.pyo
[16]: core\__init__.pyo
[5]: core\documents\__init__.pyo
[11]: core\documents\compare.pyo
[15]: core\documents\editor.pyo
[13]: core\io\__init__.pyo
[6]: core\io\xml\__init__.pyo
[11]: core\io\xml\autoformat.pyo
[29]: Ft\Xml\Domlette.pyo
[355]: Ft\Xml\InputSource.pyo
[584]: Ft\Xml\Catalog.pyo
[62]: warnings.pyo
[126]: warnings.pyo
[122]: Ft\__init__.pyo


Can anyone help explain what I am missing here?

THANKS!

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


Looking for Delaunay triangulation module...

2007-08-31 Thread Grant Edwards
Can anybody point me to a Delaunay triangulation module (for
Win32)?  I'm currently using http://flub.stuffwillmade.org/delny/ under Linux, 
but I have
been unable to find a build for Windows. I don't have the tools
(or skills) to build libqhull and Pythion extensions on Win32).

I've also found the delaunay module in scipy's sandbox.  I
could never get that module to work under Linux, and I can't
build it for Windows anyway.

So for lack of a delaunay module, I'm stuck trying to port my
application to Win32.

I've spent some time Googling and found various references to
pur Python delaunay modules that were abandoned because they
were slow (though I haven't been able to find any of the actual
modules).  Slow is better than none. ;)

-- 
Grant Edwards   grante Yow! An air of FRENCH FRIES
  at   permeates my nostrils!!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


So what exactly is a complex number?

2007-08-31 Thread Lamonte Harris
Like in math where you put letters that represent numbers for place holders
to try to find the answer type complex numbers?
-- 
http://mail.python.org/mailman/listinfo/python-list

JavaScript

2007-08-31 Thread zowtar
Guys, anybody know if is possible to press a button linked a
javascript function using python?
My Firefox send something like that:

POST /msgs.aspx TOKEN=B8B83BGDBC191B9FE0A0BE1393294FABsig=gpaiOqbp0Nr
%2BoecRLF4FGGDOAao
%3DtoUserId=1331299rawAddedDate=118854fromUserId=23029Action.delete=Send
+data

python has modules for forms and other things... and for it?


Thank you for help...
zowtar

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


Re: Fatal Python error using ctypes python exceptions

2007-08-31 Thread Thomas Heller
mmacrobert schrieb:
 Hi Everyone,
 I've created a 'C' dll that is accessed via ctypes library containing
 a bunch of functions. I've successfully been able to use the
 functions. However, I would like to throw python exceptions from some
 of them.
 
 I throw them using: ::PyErr_SetString(::PyExc_RuntimeError,
 theErrorString);
 
 I crash the console when this function is invoked in the 'C' domain. I
 get an error stating:
 
 Fatal Python error: PyThreadState_Get: no current thread
 
 when the calling code in python is:
 
 try:
 cdll.MyDll.ThrowingFunction()
 except:
 print An error has occurred
 
 The dll is just a plain win32 'C' dll, built with an MS compiler. How
 do I throw python exceptions correctly? Is there some kind of init
 function that needs to be called?

For libraries loaded with cdll.MyDll or CDLL(MyDll) ctypes releases
the GIL before calling the function, and reacquires the GIL afterwards.

This has the consequence that you cannot use any Python api functions
inside the dll functions (because there is no ThreadState, just like
the error message says).

If you want to throw Python exceptions in the dlls functions, or use
other Python apis, you must use the 'Python calling convention'.
For this calling convention the GIL is NOT released and reacquired,
but after the function call returns PyErr_Occurred() is called and an
exception raised in the calling code - exactly what you want.

The 'Python calling convention' is used when you load the library
with pydll.MyDll or PyDLL(MyDll).

Additional remark:  You can have functions with different calling
conventions in the same dll, just load it with different library loaders
and you're fine.

Thomas

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


Re: status of Programming by Contract (PEP 316)?

2007-08-31 Thread Alex Martelli
Paul Rubin http://[EMAIL PROTECTED] wrote:
   ...
 Hi Alex, I'm a little confused: does Production Systems mean stuff
 like the Google search engine, which (as you described further up in
 your message) achieves its reliability at least partly by massive
 redundancy and failover when something breaks?

The infrastructure supporting that engine (and other things), yes.

  In that case why is it
 so important that the software be highly reliable?  Is a software

Think common-mode failures: if a program has a bug, so do all
identical copies of that program.  Redundancy works for cheap hardware
because the latter's unreliability is essentially free of common-mode
failures (when properly deployed): it wouldn't work against a design
mistake in the hardware units.  Think of the famous Pentium division
bug: no matter how many redundant but identical such buggy CPUs you
place in parallel to compute divisions, in the error cases they'll all
produce the same wrong results.  Software bugs generally work (or,
rather, fail to work;-) similarly to hardware design bugs.

There are (for both hw and sw) also classes of mistakes that don't quite
behave that way -- occasional glitches that are not necessarily
repeatable and are heavily state-dependent (race conditions in buggy
multitasking SW, for example; and many more examples for HW, where flaky
behavior may be triggered by, say, temperature situations).  Here, from
a systems viewpoint, you might have a system that _usually_ says that
10/2 is 5, but once in a while says it's 4 instead (as opposed to the
Pentium division bug case where it would always say 4) -- this is much
more likely to be caused by flaky HW, but might possibly be caused by
the SW running on it (or the microcode in between -- not that it makes
much of a difference one way or another from a systems viewpoint).

Catching such issues can, again, benefit from redundancy (and
monitoring, watchdog systems, health and sanity checks running in the
background, c).  Quis custodiet custodes is an interesting problem
here, since bugs or flakiness in the monitoring/watchdog infrastructure
have the potential to do substantial global harm; one approach is to
invest in giving that infrastructure an order of magnitude more
reliability than the systems it's overseeing (for example by using more
massive and *simple* redundancy, and extremely straightforward
architectures).  There's ample literature in the matter, but it
absolutely needs a *systems* approach: focusing just on the HW, just on
the SW, or just on the microcode in-between;-), just can't help much.

 some good hits they should display) but the server is never actually
 down, can you still claim 100% uptime?

I've claimed nothing (since all such measurements and methodologies
would no doubt be considered confidential unless and until cleared for
publication -- this has been done for a few whitepapers about some
aspects of Google's systems, but never to the best of my knowledge for
the metasystem as a whole), but rather pointed to
http://uptime.pingdom.com/site/month_summary/site_name/www.google.com,
a publically available site which does publish its methodology (at
http://uptime.pingdom.com/general/methodology); summarizing, as they
have no way to check that the results are right for the many sites
they keep an eye on, they rely on the HTTP result codes (as well as
validity of HTTP headers returned, and of course whether the site does
return a response at all).

 problem.  Of course then there's a second level system to manage the
 restarts that has to be very reliable, but it doesn't have to deal
 with much weird concocted input the way that a public-facing internet
 application has to.

Indeed, Production Systems' software does *not* have to deal with
input from the general public -- it's infrastructure, not user-facing
applications (except in as much as the users are Google engineers or
operators, say).  IOW, it's *exactly* the code that has to be very
reliable (nice to see that we agree on this;-), and therefore, if as
you then said Russ's point stands, would NOT be in Python -- but it
is. So, I disagree about the standing status of his so-called point.
 
 Therefore I think Russ's point stands, that we're talking about a
 different sort of reliability in these highly redundant systems, than
 in the systems Russ is describing.

Russ specifically mentioned *mission-critical applications* as being
outside of Python's possibilities; yet search IS mission critical to
Google.  Yes, reliability is obtained via a systems approach,
considering HW, microcode, SW, and other issues yet such as power
supplies, cooling units, network cables, etc, not as a single opaque big
box but as an articulated, extremely complex and large system that needs
testing, monitoring, watchdogging, etc, at many levels -- there is no
other real way to make systems reliable (you can't do it by just looking
at components in isolation).  Note that this does have costs and
therefore it needs to be 

Re: status of Programming by Contract (PEP 316)?

2007-08-31 Thread Alex Martelli
Michele Simionato [EMAIL PROTECTED] wrote:
   ...
 I would not call that an attack. If you want to see an attack, wait
 for
 Alex replying to you observations about the low quality of code at
 Google! ;)

I'm not going to deny that Google Groups has glitches, particularly in
its user interface (that's why I'm using MacSOUP instead, even though
Groups, were it perfect, would offer me a lot of convenience).

We have a LOT of products (see
http://www.google.com/intl/en/options/index.html, plus a few more at
http://labs.google.com/;
http://en.wikipedia.org/wiki/List_of_Google_products for an overview,
http://searchengineland.com/070220-091136.php for a list of more
lists...), arguably too many in the light of the It's best to do one
thing really, really well ``thing we've found to be true''; given the
70-20-10 rule we use (we spend 70% of our resources on search and ads
[and of course infrastructure supporting those;-)], 20% on adjacent
businesses such as News, Desktop and Maps, 10% on all the rest
combined), products in the other (10%) category may simply not receive
sufficient time, resources and attention.

We've recently officially raised Apps to the status of a third pillar
for Google (after Search and Ads), but I don't know which of our many
products are officially within these pillar-level Apps -- maybe a good
starting hint is what's currently included in the Premier Edition of
Google Apps, i.e.: Gmail (with 99.9% uptime guarantee), Google Talk,
Google Calendar, Docs  Spreadsheets, Page Creator and Start Page.

I do notice that Google Groups is currently not in that elite (but
then, neither are other products we also offer in for-pay editions, such
as Google Earth and Sketchup) but I have no insider information as to
what this means or portends for the future (of course not: if I _did_
have insider information, I could not talk about the subject!-).

Notice, however, that none of these points depend on use of Python vs
(or side by side with) other programming languages, DbC vs (or side by
side with) other methodologies, and other such technical and
technological issues: rather, these are strategical problems in the
optimal allocation of resources that (no matter how abundant they may
look on the outside) are always scarce compared to the bazillion ways
in which they _could_ be employed -- engineers' time and attention,
machines and networking infrastructure, and so forth.


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


Re: list index()

2007-08-31 Thread Alex Martelli
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
   ...
 Why wouldn't the one obvious way be:
 
  def inAnotB(A, B):
  inA  = set(os.listdir(A))
  inBs = set(os.listdir(B))
  return inA.difference(inBs)

If you want a set as the result, that's one possibility (although
possibly a bit wasteful as you're building one more set than necessary);
I read the original request as implying a sorted list result is wanted,
just like os.listdir returns (possibly sorted in case-independent order
depending on the underlying filesystem).  There's no real added value in
destroying inA's ordering by making it a set, when the list
comprehension just naturally keeps its ordering.


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


Re: So what exactly is a complex number?

2007-08-31 Thread Carsten Haese
On Thu, 2007-08-30 at 20:11 -0500, Lamonte Harris wrote:
 Like in math where you put letters that represent numbers for place
 holders to try to find the answer type complex numbers?

Is English your native language? I'm having a hard time decoding your
question.

-- 
Carsten Haese
http://informixdb.sourceforge.net


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


Complex Numbers

2007-08-31 Thread Greg Lindstrom
 -- Forwarded message --
 From: Lamonte Harris [EMAIL PROTECTED]
 To: python-list@python.org
 Date: Thu, 30 Aug 2007 20:11:14 -0500
 Subject: So what exactly is a complex number?
 Like in math where you put letters that represent numbers for place
 holders to try to find the answer type complex numbers?


Not quite.  Consider the square root of -1.  It's not real because you can't
square a real number and get a negative, so we define i (or, perhaps j)
to be the square root of -1.  An imaginary number is of the form Ai, where A
is real.  So 2i, -3.14i are imaginary.

Complex Numbers are of the form A + Bi  Where A and B are real (so they have
a real component and am imaginary component). So yo might see 2 + 3i,
etc.  You'll see them a lot in engineering.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: strings (dollar.cents) into floats

2007-08-31 Thread Steve Holden
sturlamolden wrote:
 On 31 Aug, 02:12, Wildemar Wildenburger
 [EMAIL PROTECTED] wrote:
 
 I've heard (ok, read) that several times now and I understand the
 argument. But what use is there for floats, then? When is it OK to use them?
 
 There are fractions that can be exactly represented by floats that
 cannot be exactly represented by decimals. 

Would you care to give an example?

 There are fractions that
 can be exactly represented by decimals that cannot be exactly
 represented by floats.
 
 Which one is better? Which do we prefer?
 
 What a float cannot do is to represent a decimal fractional number
 (e.g. 1.1) exactly. If we need that, we cannot use floats. A notable
 example is monetary computations, it covers 99% of the use for decimal
 numbers in computers. For this reason, we should never use floats to
 add 10 cents to a dollar. The use of decimals for monetary
 calculations is mandatory.
 
That last sentence is patent nonsense, and completely untrue. Many 
satisfactory financial applications have been written using only 
floating-point arithmetic. Indeed I believe the accountant's Swiss army 
knife, the Excel spreadsheet, uses floating-point numbers exclusively.

What you say about floating-point have speed advantages is true, but you 
go too far in claiming that decimal arithmetic is mandatory for monetary 
calculations. That's about as sensible as saying that base 12 and base 
20 arithmetic units were required to calculate in pounds, shillings and 
pence.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: So what exactly is a complex number?

2007-08-31 Thread Chris Mellon
On 8/31/07, Carsten Haese [EMAIL PROTECTED] wrote:
 On Thu, 2007-08-30 at 20:11 -0500, Lamonte Harris wrote:
  Like in math where you put letters that represent numbers for place
  holders to try to find the answer type complex numbers?

 Is English your native language? I'm having a hard time decoding your
 question.


I'm pretty sure he was describing middle school algebra.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Setting a read-only attribute

2007-08-31 Thread Steve Holden
[EMAIL PROTECTED] wrote:
 On Aug 31, 6:14 pm, Alexandre Badez [EMAIL PROTECTED] wrote:
 On Aug 30, 11:35 pm, [EMAIL PROTECTED] [EMAIL PROTECTED]
 wrote:

 I have an object and wish to set an attribute on it which,
 unfortunately for me, is read-only.
 How can I go about this?
 Cheers.
 -T
 Could you show the object you want to set his attribute?
 Until that, it's difficult to answer to you.

 PS: If the attribut is on read only, their must a good reason for
 that ;)
 
 Hi all,
 
 Thanks for all the responses. What I'm trying to do is kludge around
 something. sys.settrace takes a method whose arguments are (frame,
 event, arg). I want to have a tracer class which can be instantiated
 and listen in on these trace calls.
 
 Another way to go about it *might* be to have a module-level list of
 registered Tracer objects which a module-level trace method informs of
 events. It would probably be easier. In fact, I'll go do that.
 
 *That said*, I still think it makes sense to be able to have objects
 register with sys.settrace.
 
 So what I did then was declare a static method with the same pattern
 expected by sys.settrace. I then want to use something like __dict__
 or __setattr__ to give that method a reference to the owning object.
 And this is what I'm trying to do -- declare a static method, then un-
 static it by adding a reference to the callable object...
 
 Here's some code:
 
 
 import sys
 
 
 class Tracer:
 '''
 Instantiate this in order to access program trace information.
 
 '''
 
 def _getcallback(self):
 
 @staticmethod
 def callback(frame, event, arg):
 print tracing ..., tracerReference
 #print line , frame.f_lineno, frame.f_locals
 
 return callback
 
 def startTrace(self):
 callback = self._getcallback()
 callback.__dict__['tracerReference'] = self
 sys.settrace(callback)
 
 
 def foo(dict):
 for i in range(2):
 pass
 
 if __name__ == __main__:
 t = Tracer()
 t.startTrace()
 foo({1 : 5})
 
Surely the thing to do, if I understand you, is to declare callback as a 
standard method and then pass a reference to a bound method (the most 
obvious candidate being self.callback) to sys.settrace().

[EMAIL PROTECTED] ~/Projects/Python
$ cat test05.py
import sys


class Tracer:
 '''
 Instantiate this in order to access program trace information.

 '''


 def callback(self, frame, event, arg):
 print tracing ..., self
 print line , frame.f_lineno, frame.f_locals

 def startTrace(self):
 sys.settrace(self.callback)


def foo(dict):
 for i in range(2):
 pass

if __name__ == __main__:
 t = Tracer()
 t.startTrace()
 foo({1 : 5})

[EMAIL PROTECTED] ~/Projects/Python
$ python test05.py
tracing ... __main__.Tracer instance at 0x7ff2514c
line  19 {'dict': {1: 5}}

[EMAIL PROTECTED] ~/Projects/Python
$

Does this do what you want?

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: status of Programming by Contract (PEP 316)?

2007-08-31 Thread Steve Holden
Russ wrote:
 I've always wondered... Are the compilers (or interpreters), which take
 these programs to machine code, also formally proven correct?
 
 No, they are not formally proven correct (too complicated for that),
 but I believe they are certified to a higher level than your typical
 compiler. I think that Ada compilers used for certain safety-critical
 applications must meet higher standards than, say, GNU Ada, for
 example.
 
 And the OS
 in which those programs operate, are they also formally proven correct?
 
 Same as above, if I am not mistaken.
 
 And the hardware, microprocessor, electric supply, etc. are they also
 'proven correct'?
 
 I think the microprocessors used for flight control, for example, are
 certified to a higher level than standard microprocessors.
 
 How would you prove a power supply to be correct? I'm sure they meet
 higher reliability standards too.
 

... I believe ..., ... if I am not mistaken, I think 

Well, all this certainty you are expressing will surely allow this bozo 
to sleep more soundly in his bed.

Frankly I am getting a little tired of they way you are unable to even 
recognize that your readers may well have a sensible appreciation of the 
difficulties about which you write. As has been pointed out already, 
many readers here are extremely experienced programmers.

You said in an earlier post that's not an insult, but that isn't 
really up to you to decide. If it gives offense then it probably is, 
whether it was intended to do so or not. You don't seem to appreciate 
the insulting nature of your tone, and calling people bozos is not 
likely to endear you to most c.l.py readers since it comes off as arrogant.

Given that you now profess no absolute certainty on fairly simple 
matters connected to safety-critical systems I wish you'd step down off 
your platform and join the rest of us.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: strings (dollar.cents) into floats

2007-08-31 Thread Chris Mellon
On 8/31/07, Steve Holden [EMAIL PROTECTED] wrote:
 sturlamolden wrote:
  On 31 Aug, 02:12, Wildemar Wildenburger
  [EMAIL PROTECTED] wrote:
 
  I've heard (ok, read) that several times now and I understand the
  argument. But what use is there for floats, then? When is it OK to use 
  them?
 
  There are fractions that can be exactly represented by floats that
  cannot be exactly represented by decimals.

 Would you care to give an example?

  There are fractions that
  can be exactly represented by decimals that cannot be exactly
  represented by floats.
 
  Which one is better? Which do we prefer?
 
  What a float cannot do is to represent a decimal fractional number
  (e.g. 1.1) exactly. If we need that, we cannot use floats. A notable
  example is monetary computations, it covers 99% of the use for decimal
  numbers in computers. For this reason, we should never use floats to
  add 10 cents to a dollar. The use of decimals for monetary
  calculations is mandatory.
 
 That last sentence is patent nonsense, and completely untrue. Many
 satisfactory financial applications have been written using only
 floating-point arithmetic. Indeed I believe the accountant's Swiss army
 knife, the Excel spreadsheet, uses floating-point numbers exclusively.

This is true, although Excel munges it's FP to provide expected results.

It depends on what you consider a financial application though.
Excel, while in extremely broad use, is not used to implement any of
the systems which actually define money, like the back end financial
systems at banks and credit unions.

In my experience, by far the most common method of calculating
financial numbers is actually using integer amounts, and then applying
well-defined rounding rules which I can't be bothered to look up the
name for.

For what it's worth, the work that I do with money (which is
middleware doing data transport, not calculations or billing) uses
either string representations or fixed point.

 What you say about floating-point have speed advantages is true, but you
 go too far in claiming that decimal arithmetic is mandatory for monetary
 calculations. That's about as sensible as saying that base 12 and base
 20 arithmetic units were required to calculate in pounds, shillings and
 pence.


I believe that to the degree that real accounting was done in those
currencies it did in fact use non-decimal bases. Just as people don't
use decimal time values (except us crazy computer folk), you're write
1 pound 4 shillings, not 1.333... pounds.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: escaping only double quotes

2007-08-31 Thread iapain

 string = Butler's 15\ TV
 s = my string goes here %s  % string

Couldn't find anything wrong in

string = Butler's 15\ TV
s = my string goes here %s % string

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


Re: escaping only double quotes

2007-08-31 Thread iapain
You could write a simple escape function.

def escape(html):
Return the given TEXT with ampersands, quotes and carets
encoded.
return html.replace('', 'amp;').replace('',
'lt;').replace('', 'gt;').replace('', 'quot;').replace(',
'#39;')

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


Re: JavaScript

2007-08-31 Thread iapain
python has modules for forms and other things... and for it?

Check out httplib and urlib2, it might be useful for you.

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


Is there a simple way to exit a while loop on keystroke?

2007-08-31 Thread gsxg
I am new to python, and have written a simple program to read a port
via telnet.  I would like it to run until any key is pressed.  Of
course I wouldn't mind requiring a specific keystroke in the future,
but I would think this is simpler for now.

I have used kbhit() and getch() many times in C, but I can't find
anything similar in  Python.  I am using Linux also, so the msvcrt
code isn't an option.  I have tried sys.stdin.read(), but that hangs
UNTIL a key is pressed.

Thanks

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


platform system may be Windows or Microsoft since Vista

2007-08-31 Thread p . lavarre
Let's suppose you get Python for Vista Windows today from
http://www.python.org/download/.

Should you then conclude that the tests:

if platform.system() in ('Windows', 'Microsoft'):
if not (platform.system() in ('Windows', 'Microsoft')):

are now exactly what you should write for that 2.5.1 Python, when you
must resort to os-specific tools like DeviceIoControl, in place of the
slightly simpler tests that worked before:

if platform.system() == 'Windows': # Microsoft
if platform.system() != 'Windows': # Microsoft

?

Curiously yours, thanks in advance,

P.S. Groups search assures me clp hasn't previously reviewed: platform
system Windows Microsoft

P.P.S. I ask because this August I rediscovered this 28 May Python
uname vs. Win kernel32.getVersionEx issue indexed by Google as
follows:

http://mail.python.org/pipermail/patches/2007-June/022947.html
...
 
Patches item #1726668, was opened at 2007-05-28 03:23
 
On Microsoft Vista platform.system() returns 'Microsoft' and
platform.release() returns 'Windows'
 
Under Microsoft Windows XP SP2 platform.system() returns 'Windows' and
platform.release() returns 'XP'.
 
This is problem was caused by a change in the output of the ver
command. In Windows XP SP2 ver outputted 'Microsoft Windows XP
[Version 5.1.2600]'  In Microsoft Vista ver outputted 'Microsoft
Windows [Version 6.0.6000]'. The lack of the 3rd word before version
causes _syscmd_ver(...) in platform.py to return 'Microsoft' for
system instead of 'Microsoft Windows'. This causes uname() to return
the incorrect values. Both system() and release() call uname().

...

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


  1   2   3   >