Wing IDE 3.1beta3 released

2008-04-29 Thread Wingware

Hi,

Wingware has released version 3.1 beta3 of Wing IDE, an integrated development
environment for the Python programming language. It is available from:

http://wingware.com/wingide/beta

This release includes the following changes:

* How-To and improvements for using Wing IDE with Google App Engine
* Scan for sys.path changes in main debug file (e.g. for Zope buildouts)
* Preference to auto-strip trailing white space on save
* Many vi mode improvements
* Testing tool enhancements, including better support for test names
  that are not method names
* Sped up stepping in the debugger
* Set encoding for stdin/out/err in debug processes for better handling
  of non-ascii input and output
* Fixed problems with debugging stackless tasklets
* Python Shell allows spawned threads to run, rather than stopping all threads
* Improved support for debugging code invoked by execfile()
* Better autocompletion support for an x defined by 'import x.y.z'
* More bug fixes, including also all those found in Wing 3.0.5

Please see the change log for a detailed list of changes:

http://wingware.com/pub/wingide/prerelease/3.1.0-b3/CHANGELOG.txt

Version 3.1 introduces a number of new features and includes bug fixes not
found in the 3.0 series, as follows:

* Files within .zip or .egg files can be displayed in the editor
* Support for pkg_resources based namespace packages
* Support for doctest and nose unit test frameworks (**)
* Updated code analysis support for Python 2.5 constructs
* Improved support for tasklets in Stackless Python
* In-line argument entry of code templates/snippets (tab and back tab to
  traverse fields; arrow keys to change template indent, Esc to exit data
  entry mode) (**)
* Include templates by name in autocompleter (**)
* Simple word list driven auto-completion when working in non-Python files (*)
* Open from Project for quick selection of files from the Project by
  typing a fragment (*)
* Find Symbol for quick Goto-Definition for symbols in the current Python
  file by typing a fragment (*)
* Show gi_running and gi_frame in Stack Data for generators
* Sort menus and lists using more natural sorting so x2.py comes before x10.py
* Preference to strip trailing white space on save
* Scan for straightforward sys.path changes in main debug file
* How-To and improvements for using Wing IDE with Google App Engine
* Many bug fixes not in Wing 3.0.x

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

*About Wing IDE*

Wing IDE is an integrated development environment for the Python programming
language.  It provides powerful debugging, editing, code intelligence,
testing, and search capabilities that reduce development and debugging
time, cut down on coding errors, and make it easier to understand
and navigate Python code.

Wing IDE is available in three product levels:  Wing IDE Professional is
the full-featured Python IDE, Wing IDE Personal offers a reduced feature
set at a low price, and Wing IDE 101 is a free scaled back version designed
for teaching entry level programming courses with Python.

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).

*Purchasing  Upgrading*

Wing IDE Professional  Wing IDE Personal are commercial software and require
a license to run. Wing 3.1 is a free upgrade for all Wing IDE 3.0 users. Any
2.x license sold after May 2nd 2006 is free to upgrade; others cost 1/2 the
normal price to upgrade.

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

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

--

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


VIFF 0.5

2008-04-29 Thread Martin Geisler
On behalf of the VIFF Development Team, I am very happy to announce the
release of VIFF 0.5:

  Tar/GZ:  http://viff.dk/release/viff-0.5.tar.gz
  Tar/BZ2: http://viff.dk/release/viff-0.5.tar.bz2
  Zip: http://viff.dk/release/viff-0.5.zip
  Exe: http://viff.dk/release/viff-0.5.win32.exe

Changes since version 0.4:

  Added preliminary support for preprocessing and an efficient
  multiplication protocol which is secure against active adversaries.
  The Runtime class has been split into several parts and two new mixin
  classes provide different comparison protocols. Several coercion
  problems were fixed. The Runtime.callback method was renamed to
  Runtime.schedule_callback. VIFF was tested on Python 2.6 and some
  small problems were fixed. If python-gnutls is unavailable, players
  now automatically fallback to TCP connections. The installation guide
  was updated for Windows Vista. A new example program was added and the
  documentation was updated. Changed license to LGPL.

About VIFF:

  Virtual Ideal Functionality Framework is a framework for creating
  efficient and secure multi-party computations (SMPC). Players, who do
  not trust each other, participate in a joint computation based on
  their private inputs. The computation is done using a cryptographic
  protocol which allows them to obtain a correct answer without
  revealing their inputs. Operations supported include addition,
  multiplication, and comparison, all with Shamir secret shared outputs.


-- 
Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multi-Party Computation) to Python. See: http://viff.dk/.


pgpyIQdHNYY11.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-announce-list

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


CodeInvestigator 0.10.0 released.

2008-04-29 Thread Martien Friedeman

CodeInvestigator version 0.10.0 was released on April 28.


This release fixes 2 bugs:

   Exceptions were not handled correctly.
   Recursive programs were not handled correctly.

   Thank you Sze Meng for reporting these!

A usability change was made:

   Until now you could only go to a specific iteration by clicking  
the '' tab.

   This becomes a nuisance when there are many iterations.
   Now, when there are many iterations to choose from, you can click  
a selection tab that allows you to jump.



CodeInvestigator is a tracing tool for Python programs.

Running a program through CodeInvestigator creates a recording.  
Program flow, function calls, variable values and conditions are all  
stored for every line the program executes.
The recording is then viewed with an interface consisting of the  
code. The code can be clicked: A clicked variable displays its value,  
a clicked loop displays its iterations.
You read code, and have at your disposal all the run time details of  
that code. A computerized desk check tool and another way to learn  
about your program.


http://sourceforge.net/project/showfiles.php?group_id=183942

--
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.5 released

2008-04-29 Thread Wingware

Hi,

We're happy to announce version 3.0.5 of Wing IDE, an integrated development
environment for the Python programming language. It is available from:

http://wingware.com/downloads

Version 3.0.5 is a bug fix release that adds many vi mode improvements,
improves stability, and fixes other usability bugs.

See the change log at http://wingware.com/pub/wingide/3.0.5/CHANGELOG.txt
for details.

It is a free upgrade for all Wing 3.0 users.

*About Wing IDE*

Wing IDE is an integrated development environment for the Python programming
language.  It provides powerful debugging, editing, code intelligence,
testing, and search capabilities that reduce development and debugging
time, cut down on coding errors, and make it easier to understand
and navigate Python code.

New features added in Wing 3.0 include:

* Multi-threaded debugger
* Debug value tooltips in editor, debug probe, and interactive shell
* Autocompletion and call tips 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).

*Purchasing and Upgrading*

Wing IDE Professional  Wing IDE Personal are commercial software and require
a license  to run.  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.

--

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


Python-URL! - weekly Python news and links (Apr 28)

2008-04-29 Thread Gabriel Genellina
QOTW:  Posting to comp.lang.python is pair programming with the entire
internet ;-) - Nick Craig-Wood
http://groups.google.com/group/comp.lang.python/msg/6f13cfca8a92c1a2

When it got to the point where managers were asking, 'Why didn't you use
the config check tool?', it was a done deal. - Roy Smith, on Python adoption
http://mail.python.org/pipermail/advocacy/2008-April/000575.html


Ideas to design a Python client/server application involving many
aynchronous queries and real-time display of data:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/5e46184e940886b9/

Explicit variable declaration for functions:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/6c4a508edd2fbe04/

An example showing the difference between inheritance and composition:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/44612866d4d2fedb/

Lists: item and slice assignment are confusing for a novice Python
programmer:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/d00b0c848a3003fc/

Converting xhtml to html isn't as trivial as one might expect:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/4bbbcecf89693a74/

Using the subprocess module with non-blocking pipes:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/a6dd7b98211bbd4c/

Calling Python from PHP

http://groups.google.com/group/comp.lang.python/browse_thread/thread/ffb9d476ee4cd523/

People worried about code breakage in Python 3.0 (continued from last week)

http://groups.google.com/group/comp.lang.python/browse_thread/thread/f07feff4f01be76f/

Python Advocacy: success stories

http://groups.google.com/group/comp.lang.python/browse_thread/thread/1bd91aca0c86c57c/



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

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

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

Just beginning with Python?  This page is a great place to start:
http://wiki.python.org/moin/BeginnersGuide/Programmers

The Python Papers aims to publish the efforts of Python enthusiats:
http://pythonpapers.org/
The Python Magazine is a technical monthly devoted to Python:
http://pythonmagazine.com

Readers have recommended the Planet sites:
http://planetpython.org
http://planet.python.org

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

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

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

Steve Bethard continues the marvelous tradition early borne by
Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim
Lesher of intelligently summarizing action on the python-dev mailing
list once every other week.
http://www.python.org/dev/summary/

The Python Package Index catalogues packages.
http://www.python.org/pypi/

The somewhat older Vaults of Parnassus ambitiously collects references
to all sorts of Python resources.
http://www.vex.net/~x/parnassus/

Much of Python's real work takes place on Special-Interest Group
mailing lists
http://www.python.org/sigs/

Python Success Stories--from air-traffic control to on-line
match-making--can inspire you or decision-makers to whom you're
subject with a vision of what the language makes practical.
http://www.pythonology.com/success

The Python Software Foundation (PSF) has replaced the Python
Consortium as an independent nexus of activity.  It has official
responsibility for Python's development and maintenance.
http://www.python.org/psf/
Among the ways you can support PSF is with a donation.
http://www.python.org/psf/donate.html

Kurt B. Kaiser publishes a weekly report on faults and patches.
http://www.google.com/groups?as_usubject=weekly%20python%20patch

Although unmaintained since 2002, the Cetus collection of Python
hyperlinks retains a few gems.

Re: python script as executable

2008-04-29 Thread sandipm
thanks it worked

On Apr 29, 10:49 am, Eric Wertman [EMAIL PROTECTED] wrote:
 Try to ftp it in ascii mode, or find a dos2unix utility .. the file
 has probably got \r\n (windows) line terminators in it.. causes
 problems.   I guess it's also possible that /usr/bin/env doesn't
 exist... not likely though.

 On Tue, Apr 29, 2008 at 1:36 AM, sandipm [EMAIL PROTECTED] wrote:
  Hi,
   I have written a python script to run from cron.
   I  have put #!/usr/bin/env python at top. file executes correctly when
   I run using python filename.py but
   it fails to execute when try to run it like script/command.
   it throws error:
   :No such file or directory

   I am editing file from eclipse for python from windows. and then
   uploading on linus machine to run it.

   any pointers?

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

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


Re: File IO Issues, help :(

2008-04-29 Thread Peter Otten
Kevin K wrote:

 On Apr 29, 12:38 am, Eric Wertman [EMAIL PROTECTED] wrote:
 chuck in a jsfile.close().  The buffer isn't flushing with what you
 are doing now.  jsfile.flush() might work... not sure.  Closing and
 re-opening the file for sure will help though.

 
 Yeah sorry I forgot to include the close() in the quote but its there.
 In fact I moved it up a bit and still no luck heres the new code:
 
 jsfile = open(../timeline.js, r+)
 jscontent = jsfile.readlines()
 jsfile.truncate()
 
 for line in jscontent:
 if re.search('var d =', line):
 line = var d = \+mint['1'].ascdate()+\\n
 print line
 jsfile.write(line)
 jsfile.close()
 
 I tried this can got the same result...??


truncate(...)
truncate([size]) - None.  Truncate the file to at most size bytes.

Size defaults to the current file position, as returned by tell().


After the readlines() call the current file position is at the end of the
file. Try jsfile.truncate(0).

Also note that readlines() reads the whole file into memory. For large files
it would therefore be better to write to a new file and rename it
afterwards.

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


Re: File IO Issues, help :(

2008-04-29 Thread Kevin K
On Apr 29, 12:55 am, Peter Otten [EMAIL PROTECTED] wrote:
 Kevin K wrote:
  On Apr 29, 12:38 am, Eric Wertman [EMAIL PROTECTED] wrote:
  chuck in a jsfile.close().  The buffer isn't flushing with what you
  are doing now.  jsfile.flush() might work... not sure.  Closing and
  re-opening the file for sure will help though.

  Yeah sorry I forgot to include the close() in the quote but its there.
  In fact I moved it up a bit and still no luck heres the new code:

  jsfile = open(../timeline.js, r+)
  jscontent = jsfile.readlines()
  jsfile.truncate()

  for line in jscontent:
  if re.search('var d =', line):
  line = var d = \+mint['1'].ascdate()+\\n
  print line
  jsfile.write(line)
  jsfile.close()

  I tried this can got the same result...??

 
 truncate(...)
 truncate([size]) - None.  Truncate the file to at most size bytes.

 Size defaults to the current file position, as returned by tell().
 

 After the readlines() call the current file position is at the end of the
 file. Try jsfile.truncate(0).

 Also note that readlines() reads the whole file into memory. For large files
 it would therefore be better to write to a new file and rename it
 afterwards.

 Peter

Thanks Peter that seemed to be most of the problem, however I now have
a bunch of null characters in the file. Could it be an unwanted line
in the list that im writing?

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


Re: python script as executable

2008-04-29 Thread Arnaud Delobelle
sandipm [EMAIL PROTECTED] writes:

 Hi,
 I have written a python script to run from cron.
 I  have put #!/usr/bin/env python at top. file executes correctly when
 I run using python filename.py but
 it fails to execute when try to run it like script/command.
 it throws error:
 :No such file or directory

 I am editing file from eclipse for python from windows. and then
 uploading on linus machine to run it.


 any pointers?

Have you made your file executable (man chmod)?

-- 
Arnaud

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


Re: Sphinx 0.2 released

2008-04-29 Thread Stefan Behnel
Hi Georg,

Georg Brandl wrote:
 I'm pleased to announce the release 0.2 of Sphinx, the Python documentation
 generation tool. There were some intermediate smaller releases in the 0.1
 series, but for 0.2 there are quite a lot new features and fixes.
 
 What is it?
 ===
 
 Sphinx is a tool that makes it easy to create intelligent and beautiful
 documentation for Python projects (or other documents consisting of
 multiple reStructuredText source files).

I'm wondering, would there be any way to bridge to epydoc? It would be cool to
have the two integrated so that you could generate API docs and written docs
in one step, with the same look-and-feel.

(BTW: yes, I'm advocating not to implement another API documentation tool, but
to integrate with an existing one. I would think epydoc matches the
requirements quite well here).

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


Re: File IO Issues, help :(

2008-04-29 Thread Peter Otten
Kevin K wrote:

 On Apr 29, 12:55 am, Peter Otten [EMAIL PROTECTED] wrote:
 Kevin K wrote:
  On Apr 29, 12:38 am, Eric Wertman [EMAIL PROTECTED] wrote:
  chuck in a jsfile.close().  The buffer isn't flushing with what you
  are doing now.  jsfile.flush() might work... not sure.  Closing and
  re-opening the file for sure will help though.

  Yeah sorry I forgot to include the close() in the quote but its there.
  In fact I moved it up a bit and still no luck heres the new code:

  jsfile = open(../timeline.js, r+)
  jscontent = jsfile.readlines()
  jsfile.truncate()

  for line in jscontent:
  if re.search('var d =', line):
  line = var d = \+mint['1'].ascdate()+\\n
  print line
  jsfile.write(line)
  jsfile.close()

  I tried this can got the same result...??

 
 truncate(...)
 truncate([size]) - None.  Truncate the file to at most size bytes.

 Size defaults to the current file position, as returned by tell().
 

 After the readlines() call the current file position is at the end of the
 file. Try jsfile.truncate(0).

 Also note that readlines() reads the whole file into memory. For large
 files it would therefore be better to write to a new file and rename it
 afterwards.

 Peter
 
 Thanks Peter that seemed to be most of the problem, however I now have
 a bunch of null characters in the file. Could it be an unwanted line
 in the list that im writing?

Oops, truncate() doesn't affect the file position. You probably need

jsfile.truncate(0)
jsfile.seek(0)

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


Re: descriptor docstring

2008-04-29 Thread Gabriel Genellina
En Tue, 29 Apr 2008 01:29:40 -0300, George Sakkis  
[EMAIL PROTECTED] escribió:

On Apr 28, 10:59 pm, Gabriel Genellina


def property_default(prop_name, default_value=None, doc=None):

     attr_name = '_'+prop_name

     def fget(self, attr_name=attr_name,
                    default_value=default_value):
         return getattr(self, attr_name, default_value)

     def fset(self, value,
                    attr_name=attr_name,
                    default_value=default_value):
         if value == default_value:
             delattr(self, attr_name)
         else:
             setattr(self, attr_name, value)

     return property(fget=fget, fset=fset, doc=doc)

When setting the same value as the default, the instance attribute is  
removed (so the default will be used when retrieving the value later).  
I think this is what you intended to do.


Note that this will fail if the value is already equal to the default
and you try to reset it to the default, so it needs an extra
hasattr(self, attr_name) before the delattr. Regardless, I would be
surprised with the following behaviour:


r = Rectangle()
r.length = 4
type(r.length)

type 'int'

r.length = 12
type(r.length)

type 'float'


Yep, probably the best thing to do is to always call setattr and avoid  
special cases.



Another simpler alternative would be to (ab)use a decorator:

def defaultproperty(func):
attr = '_' + func.__name__
default = func.func_defaults[0]
return property(
fget = lambda self: getattr(self, attr, default),
fset = lambda self,value: setattr(self, attr, value),
doc = func.__doc__)


class Rectangle(object):
'''A beautiful Rectangle'''

@defaultproperty
def length(default=12.0):
'''This is the length property'''



Nice, although that empty function looks somewhat strange...

--
Gabriel Genellina

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


Acer Aspire 4520NWXMi Athlon LX.AHS0C.011LE Notebook

2008-04-29 Thread santoshanmsoft
Features:

* Based on the powerful and affordable AMD Turion™ 64 X2 Mobile
Technology, the Aspire 4520 is well suited for any home computing
environment. Featuring impressive graphics solutions from NVIDIA®, a
14.1Acer CrystalBrite™ display, ultra-realistic Dolby® surround
sound, they excel at video/audio playback, gaming and multitasking.
Packaged in Acer's cool new chassis design, The Aspire 4520 is a
vibrant beacon of style and class that are sure to become a focal
point of the home or office. Processor AMD Athlon X2 TK53
* 1024MB DDR2 533MHz Memory (1GB)
* 160GB Hard Disk Drive
* 8X DVD-Super Multi double-layer drive
* 14.1-inch (35.81 cm) WXGA TFT LCD.

Specifications:

* Operating System Linux
* Processor: AMD Athlon X2 TK53
* Chipset: NVIDIA nForce
* Memory: 1024MB DDR2 667MHz Memory
* Screen Size 35.81 cms (14.1 wide)
* Optical Drive 8X DVD Super Multi double layer drive
* Hard Disk Drive: 160 GB HDD
* Bluetooth Integrated bluetooth 2.0+EDR
* Card Reader 5-in-1 Card reader
* LAN: Gigabit LAN
* Camera: Acer Crystal Eye Webcam supporting Primalite Technology
* Ports  Others: Four USB 2.0 Ports, Dolby Stereo Speakers

Warranty: Standard warranty on Notebooks - 1 year Carry-In local
(India) warranty and 1 year International Travellers Warranty (Both
run concurrently).
Features:

* Based on the powerful and affordable AMD Turion™ 64 X2 Mobile
Technology, the Aspire 4520 is well suited for any home computing
environment. Featuring impressive graphics solutions from NVIDIA®, a
14.1Acer CrystalBrite™ display, ultra-realistic Dolby® surround
sound, they excel at video/audio playback, gaming and multitasking.
Packaged in Acer's cool new chassis design, The Aspire 4520 is a
vibrant beacon of style and class that are sure to become a focal
point of the home or office. Processor AMD Athlon X2 TK53
* 1024MB DDR2 533MHz Memory (1GB)
* 160GB Hard Disk Drive
* 8X DVD-Super Multi double-layer drive
* 14.1-inch (35.81 cm) WXGA TFT LCD.

Specifications:

* Operating System Linux
* Processor: AMD Athlon X2 TK53
* Chipset: NVIDIA nForce
* Memory: 1024MB DDR2 667MHz Memory
* Screen Size 35.81 cms (14.1 wide)
* Optical Drive 8X DVD Super Multi double layer drive
* Hard Disk Drive: 160 GB HDD
* Bluetooth Integrated bluetooth 2.0+EDR
* Card Reader 5-in-1 Card reader
* LAN: Gigabit LAN
* Camera: Acer Crystal Eye Webcam supporting Primalite Technology
* Ports  Others: Four USB 2.0 Ports, Dolby Stereo Speakers

Warranty: Standard warranty on Notebooks - 1 year Carry-In local
(India) warranty and 1 year International Travellers Warranty (Both
run concurrently). 
http://homeshop18.com/shop/faces/tiles/product.jsp?productID=20265catalogueID=2categoryID=920
--
http://mail.python.org/mailman/listinfo/python-list


Re: cytpes **int

2008-04-29 Thread Diez B. Roggisch

Gabriel Genellina schrieb:
En Mon, 28 Apr 2008 18:55:15 -0300, Diez B. Roggisch 
[EMAIL PROTECTED] escribió:

VernM schrieb:

I am using ctypes to wrap a set of functions in a DLL. It has been
going very well, and I am very impressed with ctypes. I want to call a
c function with a signature of: void func(int **cube), where the array
if ints in cube is modified by func. I want to setup cube with int
values, and access them after the call to func. I unerstand how to
setup the ctypes array, but how do I pass **cube to the function, and
how do I access the results?


it should be simple.

use something like (untestet):

b = POINTER(c_int)()
func(byref(b))


[snip two other similar alternatives]

That's true for a pointer to a pointer to int, and it's valid if the 
functions references **b or b[0][0] - but in this case int** probably 
means [pointer to] an array of arrays of int and presumibly the 
function will try to access b[3][2] (or whatever indices are in range).
The duality pointer/array in C is dangerous when defining interfases - 
you have to know how the value is intended to be accessed.
(I assume the function modifies the integer values, but not the pointers 
themselves)


# build an array of 10x10 ints
Arr10int = c_int * 10
Pint = POINTER(c_int)
PPint = POINTER(Pint)
Arr10pint = Pint * 10
a = Arr10pint()
for i in range(10):
a[i] = Arr10int()
... initialize the array ...
... load the function ...
# call the function
somefunction.argtypes = (PPint,)
somefunction.restype = None
somefunction(a)



Yup, you are right - I somehow missed the access description and thought 
of the pointer-to-a-pointer as out-parameter-spec.


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


simple chemistry in python

2008-04-29 Thread Astan Chee

Hi,
Im looking for a python module to do simple chemistry things. Things 
like, finding the name of elements given the atomic number (and vice 
versa); what state the given matter is in depending on certain 
parameters; maybe even color of certain elements or even calculating the 
result of combining certain elements.
I was looking for something simple, but everything I see seems to be a 
full blown chemistry set.
I know I can probably spend a day doing this one element at a time, but 
I was wondering if there is already something like this done in a small 
scale?

Thanks for any information
Astan

--
Formulations of number theory: Complete, Consistent, Non-trivial. Choose two.


Animal Logic
http://www.animallogic.com

Please think of the environment before printing this email.

This email and any attachments may be confidential and/or privileged. If you 
are not the intended recipient of this email, you must not disclose or use the 
information contained in it. Please notify the sender immediately and delete 
this document if you have received it in error. We do not guarantee this email 
is error or virus free.



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


]ANN[ Vellum 0.16: Lots Of Documentation and Watching

2008-04-29 Thread Zed A. Shaw
Hi Everyone,

Just putting out an announcement that I've released a new version of
Vellum numbered 0.16.  This version should be ready for people to use
as not much of the internal structure has changed in a great many
commits and it contains all the latest bug fixes.

It also has the beginning of an extensive PDF document describing how
to use it.  This is still an in-progress work, so it has grammar
mistakes and spelling errors, but it does show off some nice
documentation wizardy I'm experimenting with in LaTeX.

Finally there's a new watch feature which is very handy described
further down.  It simply watches a file and reruns your targets when
the file changes.


GETTING IT

Honestly, the easiest way is just:

  sudo easy_install zapps vellum

If you want to build the book yourself and have all of TeX Live
installed then you'd also need:

  sudo easy_install pygments idiopidae

You can also hit the http://launchpad.net/vellum/ page to grab source
tarballs and other goodies.


THE BOOK OF VELLUM

You can grab the most recent draft of the book at:

  http://zedshaw.com/projects/vellum/manual-final.pdf

Any corrections or comments on how it is written are more than
welcome.  Suggestions for improving the TeX are also helpful since I'm
not a TeX expert yet.

The software I'm using to build that book is fully available to anyone
looking to document their projects.  You can grab Idiopidae, Pygments,
and TeX from the interwebs.  You can then grab the whole source and all
the LaTeX goodness from my Bazaar repository:

  bzr pull http://zedshaw.com/repository/vellum/

Look in the doc/ directory for all the fun.  You'll notice that
the .tex files have *no* code in them, and that it's all imported by
Idiopidae.  Look at the doc/book.vel file to see how it's all merged
and massaged together, and you can reuse this book.vel file to start
your own books.


CRAZY NICE WATCH FEATURE

I added a feature to Vellum that is one of those duh features.  You
can tell Vellum to watch a file, and if it changes Vellum will rerun
some targets.  When I work on the manual.tex file, I do this:

  vellum -w doc/manual.tex book.draft book.view

It just keeps looping, and if you hit CTRL-C you can force a build with
ENTER or quit with CTRL-C.  Then I use the evince PDF viewer under
linux, which has similar Vim key bindings and reloads the PDF when it
changes.

The net effect of this is, whenever I change my manual.tex file, Vellum
runs my build for the manual and evince redisplays it for me to see.

You could use this simple feature to also continually run unit tests
whenever a file changes that you are working on.

GPLv3?

How do people feel about Vellum's GPLv3 status?  It actually doesn't
impact anyone unless you embed Vellum into a project/product or you
create commands (which you should give back anyway).  Even then if you
never release your build to your users then you don't need to release
the commands.

However, I'm curious to get other people's thoughts.

Thanks a bunch folks.

-- 
Zed A. Shaw
- Hate: http://savingtheinternetwithhate.com/
- Good: http://www.zedshaw.com/
- Evil: http://yearofevil.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Question regarding Queue object

2008-04-29 Thread bockman
On 27 Apr, 12:27, Terry [EMAIL PROTECTED] wrote:
 Hello!

 I'm trying to implement a message queue among threads using Queue. The
 message queue has two operations:
 PutMsg(id, msg) #  this is simple, just combine the id and msg as one
 and put it into the Queue.
 WaitMsg(ids, msg) # this is the hard part

 WaitMsg will get only msg with certain ids, but this is not possible
 in Queue object, because Queue provides no method to peek into the
 message queue and fetch only matched item.

 Now I'm using an ugly solution, fetch all the messages and put the not
 used ones back to the queue. But I want a better performance. Is there
 any alternative out there?

 This is my current solution:

     def _get_with_ids(self,wait, timeout, ids):
         to = timeout
         msg = None
         saved = []
         while True:
             start = time.clock()
             msg =self.q.get(wait, to)
             if msg and msg['id'] in ids:
                 break;
             # not the expecting message, save it.
             saved.append(msg)
             to = to - (time.clock()-start)
             if to = 0:
                 break
         # put the saved messages back to the queue
         for m in saved:
             self.q.put(m, True)
         return msg

 br, Terry

Wy put them back in the queue?
You could have a defaultdict with the id as key and a list of
unprocessed messages with that id as items.
Your _get_by_ids function could first look into the unprocessed
messages for items with that ids and then
look into the queue, putting any unprocessed item in the dictionary,
for later processing.
This should improve the performances, with a little complication of
the method code (but way simpler
that implementing your own priority-based queue).

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


Re: list.reverse()

2008-04-29 Thread Bruno Desthuilliers

Mark Bryan Yu a écrit :

This set of codes works:


x = range(5)
x.reverse()
x

[4, 3, 2, 1, 0]

But this doesn't:


x = range(5).reverse()
print x

None


This works just as expected - at least for anyone having read the doc.


Please explain this behavior. range(5) returns a list from 0 to 4 and
reverse just reverses the items on the list that is returned by
range(5). Why is x None (null)?


Because that's what list.reverse() returns. Call it a wart if you want 
(FWIW, I do), but at least that's well documented.

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


patch barracks

2008-04-29 Thread ivory91044
patch barracks







http://crack.cracksofts.com

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


cooking up crack

2008-04-29 Thread ivory91044
cooking up crack







http://crack.cracksofts.com

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


driver detective crack keygen

2008-04-29 Thread ivory91044
driver detective crack keygen







http://crack.cracksofts.com

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


autocad crack

2008-04-29 Thread ivory91044
autocad crack







http://crack.cracksofts.com

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


Re: Given a string - execute a function by the same name

2008-04-29 Thread Bruno Desthuilliers

[EMAIL PROTECTED] a écrit :

I'm parsing a simple file and given a line's keyword, would like to call
the equivalently named function.

There are 3 ways I can think to do this (other than a long if/elif
construct):

1. eval() 


2. Convert my functions to methods and use getattr( myClass, method )

3. Place all my functions in dictionary and lookup the function to be
called



4. Place all your functions in a module and use getattr(the_module, func)

5. use globals().get(func)

 Any suggestions on the best way to do this?

#1 is the worst possible solution, and #2 doesn't make sens if you don't 
need methods.


#4 is simple but can be problematic since these functions are not 
necessarily related enough to make for a module with hi cohesion and low 
coupling.


#5 is the simplest solution, but can be dangerous, since just any 
function in the global namespace (which includes the builtins...) can be 
called.


#3 is a bit heaviest to setup and maintain, but much more secure since 
you explicitely choose the availables functions.


Depending on the context (ie: where this 'simple file' comes from), I'd 
choose #3 or #5.


My 2 cents...
--
http://mail.python.org/mailman/listinfo/python-list


SWIG Python undefined reference

2008-04-29 Thread Soren
Hi,

I went through the SWIG tutorial for the example named simple.

I managed to get to the first step, creating example_wrap.c using
swig, and doing:
gcc -fpic -c example_wrap.c -IC:\python24\include  to create
example_wrap.o

But when I needed to compile the library file using:
gcc -shared example_wrap.o -o examplemodule.so I received a lot of
undefined reference compiler errors like:

example_wrap.o(.text+0x35a5):example_wrap.c: undefined reference to
`_imp__PyErr
_SetString'

there are many other similar errors all prefaced with _imp__Py, so I
am assuming there is a linker error with the python libraries. I have
adjusted my PATH variable to include all the python directories (libs/
dlls).

Does anyone here have any suggestions?

FILES FROM TUTORIAL:


//example.c
#include time.h
double My_variable = 3.0;

int fact(int n) {
if (n = 1) return 1;
else return n*fact(n-1);
}

int my_mod(int x, int y) {
return (x%y);
}

char *get_time()
{
time_t ltime;
time(ltime);
return ctime(ltime);
}
//***

//example.i
%module example
%{
/* Put header files here or function declarations like below */
extern double My_variable;
extern int fact(int n);
extern int my_mod(int x, int y);
extern char *get_time();
%}

extern double My_variable;
extern int fact(int n);
extern int my_mod(int x, int y);
extern char *get_time();
//***

//setup.py
from distutils.core import setup, Extension

setup(name='example',
version = '1.0',
ext_modules=[
Extension('example', ['example.c', 'example.i'])
])
--
http://mail.python.org/mailman/listinfo/python-list


sims patch

2008-04-29 Thread jean11821cleme
sims patch

















http://crack.cracksofts.com

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


Re: How to unget a line when reading from a file/stream iterator/generator?

2008-04-29 Thread Duncan Booth
George Sakkis [EMAIL PROTECTED] wrote:

 On Apr 28, 10:10 pm, [EMAIL PROTECTED] wrote:
 George,

  Is there an elegant way to unget a line when reading from a
  file/stream 
 iterator/generator?

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

 That's exactly what I was looking for!

 For those following this thread, the above recipe creates a generic
 object that wraps any iterator with an 'unget' (push) capability.
 Clean and elegant!

 Thank you,
 Malcolm
 
 A small suggestion: since unget is expected to be called infrequently,
 next should better be faster for the common case instead of penalizing
 it with a try/except:
 
 def next(self):
 if not self.pushed_back:
 return self.it.next()
 else:
 return self.pushed_back.pop()
 

If speed is an issue then it may be better to avoid the test altogether:

def __init__(self, it):
self.it = it
self.pushed_back = []
self.nextfn = it.next

def __iter__(self):
return self

def __nonzero__(self):
if self.pushed_back:
return True

try:
self.pushback(self.nextfn())
except StopIteration:
return False
else:
return True

def popfn(self):
lst = self.pushed_back
res = lst.pop()
if not lst:
self.nextfn = self.it.next
return res

def next(self):
return self.nextfn()

def pushback(self, item):
self.pushed_back.append(item)
self.nextfn = self.popfn
--
http://mail.python.org/mailman/listinfo/python-list


Re: So you think PythonCard is old? Here's new wine in an old bottle.

2008-04-29 Thread Panyasan
Hi,

I am one of the two developers working on the xml-to-javascript
converter (qxtransformer) John has mentioned and we are thrilled that
our project has found a use in the PythonCard community.

However, we have a problem getting PythonCard to work on our Macs (Mac
OS 10.5 Leopard). We should probably be asking this on the PythonCard
help list, but since the list seems to be somewhat deserted (very few
posts) and John is active here and people seem to be using PythonCard,
maybe someone has an idea. It might be very simple and stupid - I have
never worked with python before.

I am using
- PythonCard 0.8.2 release on Leopard, which is copied by setup.py to /
Library/Python/2.5/site-packages
- John's layoutEditor package, (http://qxtransformer.googlegroups.com/
web/layoutEditor.zip)

PythonCard email list says that Leopard and PythonCard 0.8.2 seem to
like each other generally:

http://sourceforge.net/mailarchive/forum.php?thread_name=EE5213D5-A005-4ED0-9512-111B6D4F06A7%40bu.eduforum_name=pythoncard-users

and I can get the examples working. However, when I start John's
modified layoutEditor.py, I get an empty window and the following
error is thrown:

no resource file for /Users/bibliograph/Programme/PythonCard/tools/
layoutEditor/multipropertyEditor
Traceback (most recent call last):
  File /BinaryCache/wxWidgets/wxWidgets-11~57/Root/System/Library/
Frameworks/Python.framework/Versions/2.5/Extras/lib/python/wx-2.8-mac-
unicode/wx/_core.py, line 14095, in lambda
  File /Library/Python/2.5/site-packages/PythonCard/tools/
layoutEditor/layoutEditor.py, line 153, in on_initialize
self.propertyEditorWindow = model.childWindow(self,
PropertyEditor)
  File /Library/Python/2.5/site-packages/PythonCard/model.py, line
213, in childWindow
rsrc = resource.ResourceFile(filename).getResource()
  File /Library/Python/2.5/site-packages/PythonCard/resource.py,
line 45, in __init__
self.dictionary = util.readAndEvalFile(rsrcFileName)
  File /Library/Python/2.5/site-packages/PythonCard/util.py, line
39, in readAndEvalFile
f = open(filename)
TypeError: coercing to Unicode: need string or buffer, NoneType found

there is a file PythonCard/tools/layoutEditor/modules/
multipropertyEditor.rsrc.py

When I resize the window, I get the following errors

Tue Apr 29 10:48:08 noname Python[40440] Error: CGContextConcatCTM:
invalid context
Tue Apr 29 10:48:08 noname Python[40440] Error: CGContextSaveGState:
invalid context
Tue Apr 29 10:48:08 noname Python[40440] Error: doClip: invalid
context
Tue Apr 29 10:48:08 noname Python[40440] Error: CGContextSaveGState:
invalid context
Tue Apr 29 10:48:08 noname Python[40440] Error:
CGContextSetBlendMode: invalid context
Tue Apr 29 10:48:08 noname Python[40440] Error:
CGContextSetShouldAntialias: invalid context
Traceback (most recent call last):
  File /Library/Python/2.5/site-packages/PythonCard/model.py, line
884, in _dispatch
handler(background, aWxEvent)
  File /Library/Python/2.5/site-packages/PythonCard/tools/
layoutEditor/layoutEditor.py, line 560, in on_size
self.createDC()
  File /Library/Python/2.5/site-packages/PythonCard/tools/
layoutEditor/layoutEditor.py, line 556, in createDC
dc.SetLogicalFunction(wx.INVERT)
  File /BinaryCache/wxWidgets/wxWidgets-11~57/Root/System/Library/
Frameworks/Python.framework/Versions/2.5/Extras/lib/python/wx-2.8-mac-
unicode/wx/_gdi.py, line 4079, in SetLogicalFunction
wx._core.PyAssertionError: C++ assertion status == noErr failed
at ../src/mac/carbon/graphics.cpp(1324) in EnsureIsValid(): Cannot
nest wxDCs on the same window

Thanks for any pointers,

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


my personal translator crack

2008-04-29 Thread ivory91044
my personal translator crack







http://crack.cracksofts.com

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


Re: Question regarding Queue object

2008-04-29 Thread Nick Craig-Wood
Terry [EMAIL PROTECTED] wrote:
  On Apr 28, 5:30 pm, Nick Craig-Wood [EMAIL PROTECTED] wrote:
  David [EMAIL PROTECTED] wrote:
Another idea would be to have multiple queues, one per thread or per
message type group. The producer thread pushes into the appropriate
queues (through an intelligent PutMsg function), and the consumer
threads pull from the queues they're interested in and ignore the
others.
 
  Unfortunately a thread can only wait on one Queue at once (without
  polling).  So really the only efficient solution is one Queue per
  thread.
 
  Make an intelligent PutMsg function which knows which Queue (or
  Queues) each message needs to be put in and all the threads will have
  to do is Queue.get() and be sure they've got a message they can deal
  with.
 
  I do have one Queue per thread. The problem is the thread can not peek
  into the Queue and select msg with certain ID first.

My point is don't put messages that the thread doesn't need in the
queue in the first place.  Ie move that logic into PutMsg.

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


Re: Receive data from socket stream

2008-04-29 Thread Nick Craig-Wood
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
  But as I said in my first post, it's simple when you know the amount
  of data that you're going to receive, or when you'll receive data
  until the remote peer closes the connection. But what about receiving
  a message with undetermined length in a connection that you don't want
  to close?

You obviously need some sort of protocol.  Here is some code (taken
from a real project and modified a bit) which returns \r\n seperated
lines from a socket as they arrive which is a very simple (but
widespread) protocol.

self.rx_buf is set to  in the initialisation
self.sock is the socket

def rx_line(self):
message = None
while 1:
pos = self.rx_buf.find(\r\n)
if pos = 0:
message = self.rx_buf[:pos]
self.rx_buf = self.rx_buf[pos+2:]
break
try:
rx = self.sock.recv(4096)
except socket.error, e:
self.sock = None
raise ServerNetworkException(e)
if len(rx) == 0:
self.sock = None
raise ServerDisconnectedException()
self.rx_buf += rx
return message

Sorry I mis-understood your original post!

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


Re: SWIG Python undefined reference

2008-04-29 Thread Soren

Ok I found out how to do it using:

gcc -Ic:\python24\include -Lc:\python24\libs --shared example_wrap.c
example.c -lpython24 -o _example.pyd

but now I get a dynamic module does not define init function error
when I try to import it into python..

Anyone??

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


Re: Why is None = 0

2008-04-29 Thread Duncan Booth
=?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?= [EMAIL PROTECTED] wrote:

 (FWIW, in 2.x, x=4?, it's None  numbers  anything else;
 numbers are ordered by value, everything else is ordered
 by type name, then by address, unless comparison functions
 are implemented).

Quite apart from Jon pointing out that this isn't true for all cases when 
copmparing against None, the other half also isn't true:

 class C: pass

 C()  5
True

That happens at least in Python 2.5.2 on win32. Yet another reason to avoid 
old-style classes.

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


Re: Receive data from socket stream

2008-04-29 Thread Nick Craig-Wood
Hrvoje Niksic [EMAIL PROTECTED] wrote:
  Nick Craig-Wood [EMAIL PROTECTED] writes:
 
   Note that appending to a string is almost never a good idea, since it
   can result in quadratic allocation.
 
  My aim was clear exposition rather than the ultimate performance!
 
  That would normally be fine.  My post wasn't supposed to pick
  performance nits, but to point out potentially quadratic behavior.
 
  Anyway str += was optimised in python 2.4 or 2.5 (forget which) wasn't
  it?
 
  That optimization works only in certain cases, when working with
  uninterned strings with a reference count of 1, and then only when the
  strings are in stored local variables, rather than in global vars or
  in slots.  And then, it only works in CPython, not in other
  implementations.  The optimization works by cheating -- breaking the
  immutable string abstraction in the specific cases in which it is
  provably safe to do so.
  http://utcc.utoronto.ca/~cks/space/blog/python/ExaminingStringConcatOpt
  examines it in some detail.

Ah, I didn't realise that - thanks for the interesting link.

For the example I gave, just a simple local variable the optimisation
kicks in.  I can see how you could easily migrate that to an instance
variable and the optimisation would no longer work, eg

$ python -m timeit -s 's=' 'for i in xrange(1): s+=x'
1000 loops, best of 3: 1.04 msec per loop

$ python -m timeit -s 'class A: pass' -s 'a=A(); a.s=' 'for i in 
xrange(1): a.s+=x'
10 loops, best of 3: 160 msec per loop

  Guido was reluctant to accept the patch that implements the
  optimization because he thought it would change the way people write
  code, a sentiment expressed in
  http://mail.python.org/pipermail/python-dev/2004-August/046702.html
  This discussion shows that he was quite right in retrospect.  (I'm not
  saying that the optimization is a bad thing, just that it is changing
  the recommended way of writing Python in a way that other
  implementations cannot follow.)

Certainly something I wasn't aware of before - thanks!

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


Re: SWIG Python undefined reference

2008-04-29 Thread Soren
On Apr 29, 11:31 am, Soren [EMAIL PROTECTED] wrote:
 Ok I found out how to do it using:

 gcc -Ic:\python24\include -Lc:\python24\libs --shared example_wrap.c
 example.c -lpython24 -o _example.pyd

 but now I get a dynamic module does not define init function error
 when I try to import it into python..

 Anyone??

 Soren

In case anyone is having the same problem the solution for me was:

gcc example.c example_wrap.c -Ic:\python24\include -Lc:\python24\libs -
lpython24 -Xlinker -expoert-dynamic -shared -o _example.pyd

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


Пояса массажеры с термо-эффе ктом

2008-04-29 Thread Золотой Клон
Неопреновый пояс для похудения из высококачественного материала
тонизирует тело и заставляет досадные жировые складки исчезать с
невероятной скоростью.
Принцип воздействия саунта-белта схож с давно известными неопреновыми
поясами для похудения. Но для того, чтобы неопреновый пояс помогал
худеть, в нем нужно интенсивно заниматься физической нагрузкой, тогда
идет быстрое расщепление жира в том месте, где надет неопреновый пояс.
Сауна-белт нужно всего лишь включить в розетку - все остальное он
сделает сам. Никаких физических нагрузок! При этом скорость
расщепления жира в несколько раз быстрее, чем при физической нагрузке
в неопреновом поясе!

Пояса массажеры с термо-эффектом http://shopbody.ru/poyas_pohudenia.0.0.html
--
http://mail.python.org/mailman/listinfo/python-list

Learn python packaging for Ubuntu and Debian in the Ubuntu Open Week

2008-04-29 Thread SPE - Stani's Python Editor
Hi All,

If you wrote some python code that you want to package or know a cool
python application of which you like to make a deb installer, the
python packaging session is all for you! Do you develop some cross-
platform open source software and you want to give its popularity a
boost by bringing it to Ubuntu and Debian, read on! (Packages are what
installers are for Windows.)

This session will be hosted by the respected Emilio (pochu). I've
worked closely together with him (and others of the Debian PAPT team
like POX  ScottK) to make sure these packages landed well in Ubuntu
Hardy and Debian Unstable:
- Phatch (sudo apt-get install phatch, http://photobatch.stani.be)
- SPE (sudo apt-get install spe, http://pythonide.stani.be)

I've requested this session as I found there was almost no information
available tailored for python coders. I hope many people will attend.
The logs will be available here:
https://wiki.ubuntu.com/MeetingLogs/openweekhardy/PythonPackaging

The complete program of the Ubuntu Open Week is available here:
https://wiki.ubuntu.com/UbuntuOpenWeek

Feel free to comment or questions ahead of this session on this
thread. I am sure Emilio will read this thread.

See you there!
Stani
--
http://mail.python.org/mailman/listinfo/python-list


Re: SWIG Python undefined reference

2008-04-29 Thread Paul Melis
Instead of manually trying to get all the options to gcc correct you 
might want to look at using distutils for compiling your extension.
See the SWIG documentation, section 30.2.2 
(http://www.swig.org/Doc1.3/Python.html#Python_nn6)


Paul

Soren wrote:

Hi,

I went through the SWIG tutorial for the example named simple.

I managed to get to the first step, creating example_wrap.c using
swig, and doing:
gcc -fpic -c example_wrap.c -IC:\python24\include  to create
example_wrap.o

But when I needed to compile the library file using:
gcc -shared example_wrap.o -o examplemodule.so I received a lot of
undefined reference compiler errors like:

example_wrap.o(.text+0x35a5):example_wrap.c: undefined reference to
`_imp__PyErr
_SetString'

there are many other similar errors all prefaced with _imp__Py, so I
am assuming there is a linker error with the python libraries. I have
adjusted my PATH variable to include all the python directories (libs/
dlls).

Does anyone here have any suggestions?

FILES FROM TUTORIAL:


//example.c
#include time.h
double My_variable = 3.0;

int fact(int n) {
if (n = 1) return 1;
else return n*fact(n-1);
}

int my_mod(int x, int y) {
return (x%y);
}

char *get_time()
{
time_t ltime;
time(ltime);
return ctime(ltime);
}
//***

//example.i
%module example
%{
/* Put header files here or function declarations like below */
extern double My_variable;
extern int fact(int n);
extern int my_mod(int x, int y);
extern char *get_time();
%}

extern double My_variable;
extern int fact(int n);
extern int my_mod(int x, int y);
extern char *get_time();
//***

//setup.py
from distutils.core import setup, Extension

setup(name='example',
version = '1.0',
ext_modules=[
Extension('example', ['example.c', 'example.i'])
])

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


Re: Learn python packaging for Ubuntu and Debian in the Ubuntu Open Week

2008-04-29 Thread SPE - Stani's Python Editor
I forgot an important detail...

This session will be hosted Thu 1 May at 21.00 UTC on IRC in #ubuntu-
classroom.
--
http://mail.python.org/mailman/listinfo/python-list


Zope/DTML Infuriating...

2008-04-29 Thread Jens
Hello Everyone.

I am relatively new to Zope(using it for a work project) and I was
wondering if someone here could help me out or at least refer me to a
decent documentationg for Zope/DTML/Python (at the detail level of
php.net or Java API reference).  
http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/
isn't really detailed enough for my taste. if it doesn't contain a
exhautive description of all available base classes it's simply no
good as a reference resource.

Anyway I have the following problem. I'm using zope 2.9 and I would
expect the following dtml code to yield a list containing main1, main2
etc.

dtml-let prefix='main'
ul
dtml-in expr=_.range(1,10)
  lidtml-var expr=_['prefix'] + _['sequence-item']/li
/dtml-in
/ul
/dtml-let

But it doesn't work(and yes i know that i could simply do ... dtml-
var prefixdtml-var sequence-item..., but that's not what i need).
I've the checked that i'm referring to the variables correctly, so the
only explanation i can come up with, is that '+' doesn't result in a
string concatenation (with implicit typecast to string of the integer
variable(this is a interpreted language after all)). It apparently
works in other cases but for some reason not here. I get the following
cryptical error message which makes me none the wiser.

An error was encountered while publishing this resource.

Error Type: AttributeError
Error Value: 'NoneType' object has no attribute 'group'

I would appreciate any feedback you might have regarding this. Thanks
in Advance.


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


Re: Zope/DTML Infuriating...

2008-04-29 Thread Marco Mariani

Jens wrote:


I've the checked that i'm referring to the variables correctly, so the
only explanation i can come up with, is that '+' doesn't result in a
string concatenation (with implicit typecast to string of the integer
variable(this is a interpreted language after all)).


No, sorry. You really need to read the python tutorial at the very least.
You might have wrong assumptions from previous PHP experiences.

 'x'+4
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: cannot concatenate 'str' and 'int' objects


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


Bollywood, Asian, Indie Films And More.

2008-04-29 Thread sureka

Bollywood, Asian, Indie Films And More.

http://besthotmovies.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Given a string - execute a function by the same name

2008-04-29 Thread python
Bruno,

Thank you for your detailed analysis. I learned a lot about Python
reading everyone's responses.

For development I'm using #5: globals().get(func) because its
seamless to add additional functionality.

But when I release into production I'm going to shift to #3: Place all
my functions in dictionary and lookup the function to be called. This
technique will allow me to precisely control the dynamic nature of my
application.

Thanks again to everyone who contributed on this thread.

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


Re: Zope/DTML Infuriating...

2008-04-29 Thread Jens
On Apr 29, 1:59 pm, Marco Mariani [EMAIL PROTECTED] wrote:
 Jens wrote:
  I've the checked that i'm referring to the variables correctly, so the
  only explanation i can come up with, is that '+' doesn't result in a
  string concatenation (with implicit typecast to string of the integer
  variable(this is a interpreted language after all)).

 No, sorry. You really need to read the python tutorial at the very least.
 You might have wrong assumptions from previous PHP experiences.

   'x'+4
 Traceback (most recent call last):
    File stdin, line 1, in module
 TypeError: cannot concatenate 'str' and 'int' objects
  
... and the non snobby answer would have been:

...  dtml-var expr=_['prefix'] + str(_['sequence-item'])
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to unget a line when reading from a file/stream iterator/generator?

2008-04-29 Thread python
Duncan,

 If speed is an issue then it may be better to avoid the test altogether ... 
 snipped

Thanks for your suggestion.

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


Re: Zope/DTML Infuriating...

2008-04-29 Thread Jens
On Apr 29, 1:59 pm, Marco Mariani [EMAIL PROTECTED] wrote:
 Jens wrote:
  I've the checked that i'm referring to the variables correctly, so the
  only explanation i can come up with, is that '+' doesn't result in a
  string concatenation (with implicit typecast to string of the integer
  variable(this is a interpreted language after all)).

 No, sorry. You really need to read the python tutorial at the very least.
 You might have wrong assumptions from previous PHP experiences.

   'x'+4
 Traceback (most recent call last):
    File stdin, line 1, in module
 TypeError: cannot concatenate 'str' and 'int' objects
  
... and the non snobby answer would have been:

...  dtml-var expr=_['prefix'] + str(_['sequence-item'])
--
http://mail.python.org/mailman/listinfo/python-list


Re: simple chemistry in python

2008-04-29 Thread baoilleach
If you are familiar with parsing XML, much of the data you need is
stored in the following file:
http://bodr.svn.sourceforge.net/viewvc/*checkout*/bodr/trunk/bodr/elements/elements.xml?revision=34content-type=text%2Fplain

This file is part of the Blue Obelisk Data Repository, an effort by
several chemistry software developers to share common information. If
you have any further questions, please email blueobelisk-
[EMAIL PROTECTED]

Noel

On Apr 29, 8:48 am, Astan Chee [EMAIL PROTECTED] wrote:
 Hi,
 Im looking for a python module to do simple chemistry things. Things
 like, finding the name of elements given the atomic number (and vice
 versa); what state the given matter is in depending on certain
 parameters; maybe even color of certain elements or even calculating the
 result of combining certain elements.
 I was looking for something simple, but everything I see seems to be a
 full blown chemistry set.
 I know I can probably spend a day doing this one element at a time, but
 I was wondering if there is already something like this done in a small
 scale?
 Thanks for any information
 Astan

 --
 Formulations of number theory: Complete, Consistent, Non-trivial. Choose 
 two.

 Animal Logichttp://www.animallogic.com

 Please think of the environment before printing this email.

 This email and any attachments may be confidential and/or privileged. If you 
 are not the intended recipient of this email, you must not disclose or use 
 the information contained in it. Please notify the sender immediately and 
 delete this document if you have received it in error. We do not guarantee 
 this email is error or virus free.

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


Re: Zope/DTML Infuriating...

2008-04-29 Thread Marco Mariani

Jens wrote:


You might have wrong assumptions from previous PHP experiences.

  'x'+4
Traceback (most recent call last):
   File stdin, line 1, in module
TypeError: cannot concatenate 'str' and 'int' objects
 

... and the non snobby answer would have been:

...  dtml-var expr=_['prefix'] + str(_['sequence-item'])



Sorry. Not trying to be snobbish, only in a hurry.

That answer would have been less useful, because there are TONS of 
details in the python tutorial, that set the language apart from its 
scripting cousins.
Reading the syntax and thinking yeah, got it, boring, next chapter is 
a common mistake I've also made sometime, especially with python when 
I've been deceived by its apparent simplicity.

Then, later, the same happened with Javascript, of course.
And it's bound to happen again, as much as I'll try to be careful :-(
--
http://mail.python.org/mailman/listinfo/python-list


Re: Given a string - execute a function by the same name

2008-04-29 Thread Arnaud Delobelle
On 29 Apr, 13:10, [EMAIL PROTECTED] wrote:
 Bruno,

 Thank you for your detailed analysis. I learned a lot about Python
 reading everyone's responses.

 For development I'm using #5: globals().get(func) because its
 seamless to add additional functionality.

 But when I release into production I'm going to shift to #3: Place all
 my functions in dictionary and lookup the function to be called. This
 technique will allow me to precisely control the dynamic nature of my
 application.

 Thanks again to everyone who contributed on this thread.

 Regards,
 Malcolm

You could avoid #5 from the start using a decorator:

functions = {}

def register(func):
functions[func.__name__] = func
return func

@register
def foo(): print Foo!

@register
def bar(): print Bar!


 functions
{'foo': function foo at 0x6f2f0, 'bar': function bar at 0x6f330}
 functions['bar']()
Bar!

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


Using Python to verify streaming tv/radio station links

2008-04-29 Thread donnyf
Hi guys. I've put together a website ( http://worldwidemediaproject.com
) that is a database of internet streaming tv/radio stations from
around the world. I have built the site with all users in mind. The
site should be Linux, Unix, Mac, Win, etc friendly as I do not hide
the actual stream link or force the user to use an embedded player to
view/listen to the streams. In fact, you can even download the streams
you like as a playlist that you can load into your player of choice
(and even a few PVR software plugins).

In building the site, I have enabled the user to report stations that
are nonfunctional. In addition to this, I would like to automate the
checking of the links in the database as well as any user submitted
links. What I am wanting to do is to script this with a simple for
loop which would loop through a file containing the station stream
link as well as the station id. I'd like to pass each through some
kind of verification function and if a connection is made then the
stream is good and move on to the next. If the connection fails then
the stream is bad, I would like to add the station id to a file
containing all 'nonfunctional' streams that I can later automate to
flag the stations.

Is there an easy way to use python to verify a stream exists? I've
done a little experimenting with sockets and was able to connect to my
usenet server and talk to it, but I don't really know what's involved
with connecting to streaming windows media, real media and winamp
servers or what to expect as far as connection status messages.   I am
not unfamiliar with python, but I am far from an expert. If anyone
could give me a hand with this or give me a push in the right
direction I would greatly appreciate it!

Many thanks!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Goodbying Spaces

2008-04-29 Thread Victor Subervi
On Fri, Apr 25, 2008 at 4:29 PM, Luis Zarrabeitia [EMAIL PROTECTED] wrote:


 Whats the result of using id.strip()?:

 In [1]:  asdfasdf   .strip()
 Out[1]: 'asdfasdf'

 It should work, I guess...


It didn´t for some reason. That was the first thing I tried.



 Btw, you can write your code without using len in a cleaner way:

 try:
  if id[0] == ' ':
id = id[1:]   # Note this slice notation...
 except:
  pass

 try:
  if id[-1] == ' ':   # id[-1] would be the last character
id = id[:-1]  # Again, a slice with only one argument
 except:
  pass


Oh, yeah. Forgot about that. Thanks!
Victor
--
http://mail.python.org/mailman/listinfo/python-list

Re: Given a string - execute a function by the same name

2008-04-29 Thread Max M

[EMAIL PROTECTED] skrev:

Bruno,




But when I release into production I'm going to shift to #3: Place all
my functions in dictionary and lookup the function to be called. This
technique will allow me to precisely control the dynamic nature of my
application.


Just one tiny note: What you will be doing is a variation of the factory 
pattern.


So this search might give you some new ideas:

http://www.google.dk/search?hl=enq=python+factory+pattern


--

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science

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


Re: Zope/DTML Infuriating...

2008-04-29 Thread Jens
On Apr 29, 2:45 pm, Marco Mariani [EMAIL PROTECTED] wrote:
 Jens wrote:
  You might have wrong assumptions from previous PHP experiences.

    'x'+4
  Traceback (most recent call last):
     File stdin, line 1, in module
  TypeError: cannot concatenate 'str' and 'int' objects

  ... and the non snobby answer would have been:

  ...  dtml-var expr=_['prefix'] + str(_['sequence-item'])

 Sorry. Not trying to be snobbish, only in a hurry.

 That answer would have been less useful, because there are TONS of
 details in the python tutorial, that set the language apart from its
 scripting cousins.
 Reading the syntax and thinking yeah, got it, boring, next chapter is
 a common mistake I've also made sometime, especially with python when
 I've been deceived by its apparent simplicity.
 Then, later, the same happened with Javascript, of course.
 And it's bound to happen again, as much as I'll try to be careful :-(

Hey no worriest. Is this the tutorial you're referring to:

http://docs.python.org/lib/typesmapping.html

Is there anything better? I miss the discussion and examples that
accompany
most entries in php.net.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Zope/DTML Infuriating...

2008-04-29 Thread Jens
On Apr 29, 2:45 pm, Marco Mariani [EMAIL PROTECTED] wrote:
 Jens wrote:
  You might have wrong assumptions from previous PHP experiences.

    'x'+4
  Traceback (most recent call last):
     File stdin, line 1, in module
  TypeError: cannot concatenate 'str' and 'int' objects

  ... and the non snobby answer would have been:

  ...  dtml-var expr=_['prefix'] + str(_['sequence-item'])

 Sorry. Not trying to be snobbish, only in a hurry.

 That answer would have been less useful, because there are TONS of
 details in the python tutorial, that set the language apart from its
 scripting cousins.
 Reading the syntax and thinking yeah, got it, boring, next chapter is
 a common mistake I've also made sometime, especially with python when
 I've been deceived by its apparent simplicity.
 Then, later, the same happened with Javascript, of course.
 And it's bound to happen again, as much as I'll try to be careful :-(

Hey no worriest. Is this the tutorial you're referring to:

http://docs.python.org/lib/typesmapping.html

Is there anything better? I miss the discussion and examples that
accompany
most entries in php.net.
--
http://mail.python.org/mailman/listinfo/python-list


Simple TK Question - refreshing the canvas when not in focus

2008-04-29 Thread blaine
Hey everyone!
  I'm not very good with Tk, and I am using a very simple canvas to
draw some pictures (this relates to that nokia screen emulator I had a
post about a few days ago).

Anyway, all is well, except one thing.  When I am not in the program,
and the program receives a draw command (from a FIFO pipe), the canvas
does not refresh until I click into the program. How do I force it to
refresh, or force the window to gain focus?  It seems like pretty
common behavior, but a few things that I've tried have not worked.

Class screen():
def __init__(self):
self.root = Tkinter.Tk()
self.root.title('Nokia Canvas')
self.canvas = Tkinter.Canvas(self.root, width =130,
height=130)
self.canvas.pack()
self.root.mainloop()

Then somewhere a long the line I do:
self.canvas.create_line(args[0], args[1], args[2],
args[3], fill=color)
self.canvas.pack()

I've tried self.root.set_focus(), self.root.force_focus(),
self.canvas.update(), etc. but I can't get it.
Thanks!
Blaine
--
http://mail.python.org/mailman/listinfo/python-list


Re: Zope/DTML Infuriating...

2008-04-29 Thread Jens
On Apr 29, 2:45 pm, Marco Mariani [EMAIL PROTECTED] wrote:
 Jens wrote:
  You might have wrong assumptions from previous PHP experiences.

    'x'+4
  Traceback (most recent call last):
     File stdin, line 1, in module
  TypeError: cannot concatenate 'str' and 'int' objects

  ... and the non snobby answer would have been:

  ...  dtml-var expr=_['prefix'] + str(_['sequence-item'])

 Sorry. Not trying to be snobbish, only in a hurry.

 That answer would have been less useful, because there are TONS of
 details in the python tutorial, that set the language apart from its
 scripting cousins.
 Reading the syntax and thinking yeah, got it, boring, next chapter is
 a common mistake I've also made sometime, especially with python when
 I've been deceived by its apparent simplicity.
 Then, later, the same happened with Javascript, of course.
 And it's bound to happen again, as much as I'll try to be careful :-(

Hey no worriest. Is this the tutorial you're referring to:

http://docs.python.org/lib/typesmapping.html

Is there anything better? I miss the discussion and examples that
accompany
most entries in php.net.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why is None = 0

2008-04-29 Thread blaine
On Apr 29, 5:32 am, Duncan Booth [EMAIL PROTECTED] wrote:
 =?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?= [EMAIL PROTECTED] wrote:
  (FWIW, in 2.x, x=4?, it's None  numbers  anything else;
  numbers are ordered by value, everything else is ordered
  by type name, then by address, unless comparison functions
  are implemented).

 Quite apart from Jon pointing out that this isn't true for all cases when
 copmparing against None, the other half also isn't true:

  class C: pass
  C()  5

 True

 That happens at least in Python 2.5.2 on win32. Yet another reason to avoid
 old-style classes.

Sorry - but what are new style classes?
--
http://mail.python.org/mailman/listinfo/python-list


Windows Printing using win32print

2008-04-29 Thread José Roberto
Olá KellyK!
I have read your comentary about how to print with python in windows using 
win32print. 
I have trying to use in my problem : print a figure (.jpg, .png...etc) could 
you help me?
Thanks a lot
JRoberto--
http://mail.python.org/mailman/listinfo/python-list

Re: list.reverse()

2008-04-29 Thread Roy Smith
In article [EMAIL PROTECTED],
 Bruno Desthuilliers [EMAIL PROTECTED] wrote:

 Mark Bryan Yu a écrit :
  This set of codes works:
  
  x = range(5)
  x.reverse()
  x
  [4, 3, 2, 1, 0]
  
  But this doesn't:
  
  x = range(5).reverse()
  print x
  None
 
 This works just as expected - at least for anyone having read the doc.
 
  Please explain this behavior. range(5) returns a list from 0 to 4 and
  reverse just reverses the items on the list that is returned by
  range(5). Why is x None (null)?
 
 Because that's what list.reverse() returns. Call it a wart if you want 
 (FWIW, I do), but at least that's well documented.

The reasoning goes along the lines of, reverse in place is an expensive 
operation, so we don't want to make it too easy for people to do.  At 
least that's the gist of what I got out of the argument the many times it 
has come up.

And, yes, I agree with Bruno that it's a wart.

What you want to do is look at the reversed() function.  Not only does it 
return something (other than Null), but it is much faster because it 
doesn't have to store the reversed list anywhere.  What it returns is an 
iterator which walks the list in reverse order.  If you really want it as a 
list, you can turn it into one (with the list() constructor), or you can 
just iterate over it with a for loop.

Same with list.sort() vs. the global sorted().

 range(5)
[0, 1, 2, 3, 4]

 reversed(range(5))
listreverseiterator object at 0x6f8d0

 list(reversed(range(5)))
[4, 3, 2, 1, 0]

 for i in reversed(range(5)):
... print i
... 
4
3
2
1
0

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

Re: list.reverse()

2008-04-29 Thread blaine
On Apr 29, 9:32 am, Roy Smith [EMAIL PROTECTED] wrote:
 In article [EMAIL PROTECTED],
  Bruno Desthuilliers [EMAIL PROTECTED] wrote:



  Mark Bryan Yu a écrit :
   This set of codes works:

   x = range(5)
   x.reverse()
   x
   [4, 3, 2, 1, 0]

   But this doesn't:

   x = range(5).reverse()
   print x
   None

  This works just as expected - at least for anyone having read the doc.

   Please explain this behavior. range(5) returns a list from 0 to 4 and
   reverse just reverses the items on the list that is returned by
   range(5). Why is x None (null)?

  Because that's what list.reverse() returns. Call it a wart if you want
  (FWIW, I do), but at least that's well documented.

 The reasoning goes along the lines of, reverse in place is an expensive
 operation, so we don't want to make it too easy for people to do.  At
 least that's the gist of what I got out of the argument the many times it
 has come up.

 And, yes, I agree with Bruno that it's a wart.

 What you want to do is look at the reversed() function.  Not only does it
 return something (other than Null), but it is much faster because it
 doesn't have to store the reversed list anywhere.  What it returns is an
 iterator which walks the list in reverse order.  If you really want it as a
 list, you can turn it into one (with the list() constructor), or you can
 just iterate over it with a for loop.

 Same with list.sort() vs. the global sorted().

  range(5)

 [0, 1, 2, 3, 4]

  reversed(range(5))

 listreverseiterator object at 0x6f8d0

  list(reversed(range(5)))

 [4, 3, 2, 1, 0]

  for i in reversed(range(5)):

 ... print i
 ...
 4
 3
 2
 1
 0



Check out this cool little trick I recently learned:
 x=range(5)
 x.reverse() or x
[4, 3, 2, 1, 0]

Useful for returning lists that you need to sort or reverse without
wasting that precious extra line :)

What it does: x.reverse() does the reverse and returns None.  or is
bitwise, so it sees that 'None' is not 'True' and then continues to
process the next operand, x.  x or'd with None will always be x (and x
has just been changed by the reverse()).  So you get the new value of
x :)

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


Re: Windows Printing using win32print

2008-04-29 Thread Tim Golden

José Roberto wrote:

Olá KellyK!
I have read your comentary about how to print with python in windows using win32print. 
I have trying to use in my problem : print a figure (.jpg, .png...etc) could you help me?


Does this help?

http://timgolden.me.uk/python/win32_how_do_i/print.html#rough_and_ready

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


Re: Simple unicode-safe version of str(exception)?

2008-04-29 Thread Bjoern Schliessmann
Martin v. Löwis wrote:

 e is an exception object, not a Unicode object.

Er, sure, thanks for pointing that out. At first sight he should
substitute e with e.message then since he tries to convert to
string (for display?).

Regards,


Björn

-- 
BOFH excuse #366:

ATM cell has no roaming feature turned on, notebooks can't connect

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


Issue with regular expressions

2008-04-29 Thread Julien
Hi,

I'm fairly new in Python and I haven't used the regular expressions
enough to be able to achieve what I want.
I'd like to select terms in a string, so I can then do a search in my
database.

query = ' some words  with and withoutquotes '
p = re.compile(magic_regular_expression)   $ --- the magic happens
m = p.match(query)

I'd like m.groups() to return:
('some words', 'with', 'and', 'without quotes')

Is that achievable with a single regular expression, and if so, what
would it be?

Any help would be much appreciated.

Thanks!!

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


Re: Zope/DTML Infuriating...

2008-04-29 Thread Marco Mariani

Jens wrote:


Hey no worriest. Is this the tutorial you're referring to:

http://docs.python.org/lib/typesmapping.html

Is there anything better?


That's the library reference - the one to keep under the pillow.
It also documents the core -- i.e. builtin objects.


As for the language semantics, I suggest the whole of

http://docs.python.org/tut/

then a bit of

http://docs.python.org/ref/ref.html

A good alternative could be the new edition of Python in a Nutshell.
The author has a very clear style and leaves no corners uncovered.



I miss the discussion and examples that accompany most entries in php.net.


This is a post + comments about strong/weak typing, although not an 
in-depth analyses.


http://www.artima.com/forums/flat.jsp?forum=106thread=7590

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


Re: list.reverse()

2008-04-29 Thread Bruno Desthuilliers

Roy Smith a écrit :
(snip)

The reasoning goes along the lines of, reverse in place is an expensive 
operation, so we don't want to make it too easy for people to do.  At 
least that's the gist of what I got out of the argument the many times it 
has come up.


IIRC, it's more along the line of reverse in place is a *destructive* 
operation, so we don't want to make it too easy for people to forget 
about it.


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


SSL through python. possible ?

2008-04-29 Thread TkNeo
I need to do SSL file transfer using python? Is there a library i can
use ?

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


Re: Zope/DTML Infuriating...

2008-04-29 Thread Christian Heimes
Jens schrieb:
 Hello Everyone.
 
 I am relatively new to Zope(using it for a work project) and I was
 wondering if someone here could help me out or at least refer me to a
 decent documentationg for Zope/DTML/Python (at the detail level of
 php.net or Java API reference).  
 http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/
 isn't really detailed enough for my taste. if it doesn't contain a
 exhautive description of all available base classes it's simply no
 good as a reference resource.

Are you forced to use DTML for the job? ZPT are far superior and easier
to work with, if you have to output HTML.

Christian

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


Re: simple chemistry in python

2008-04-29 Thread Aaron Watters
On Apr 29, 8:41 am, baoilleach [EMAIL PROTECTED] wrote:
 This file is part of the Blue Obelisk Data Repository, an effort by
 several chemistry software developers to share common information

This ref is incredibly cool.  Is there a guide or
meta-index for similar open scientific data repositories
(not web search forms: downloadable complete data)?
   -- Aaron Watters

===
http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=valence
--
http://mail.python.org/mailman/listinfo/python-list


Re: SSL through python. possible ?

2008-04-29 Thread Mike Driscoll
On Apr 29, 8:56 am, TkNeo [EMAIL PROTECTED] wrote:
 I need to do SSL file transfer using python? Is there a library i can
 use ?

 Thanks.

Did you try Google? Here's a few links that look like possibilities:

http://sandbox.rulemaker.net/ngps/m2/
http://pypgsql.sourceforge.net/misc/python-ssl.html
http://pypi.python.org/pypi/ssl/
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/117004

HTH

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


Re: So you think PythonCard is old? Here's new wine in an old bottle.

2008-04-29 Thread John Henry
On Apr 29, 1:57 am, Panyasan [EMAIL PROTECTED] wrote:
 Hi,

 I am one of the two developers working on the xml-to-javascript
 converter (qxtransformer) John has mentioned and we are thrilled that
 our project has found a use in the PythonCard community.

 However, we have a problem getting PythonCard to work on our Macs (Mac
 OS 10.5 Leopard). We should probably be asking this on the PythonCard
 help list, but since the list seems to be somewhat deserted (very few
 posts) and John is active here and people seem to be using PythonCard,
 maybe someone has an idea. It might be very simple and stupid - I have
 never worked with python before.

 I am using
 - PythonCard 0.8.2 release on Leopard, which is copied by setup.py to /
 Library/Python/2.5/site-packages
 - John's layoutEditor package, (http://qxtransformer.googlegroups.com/
 web/layoutEditor.zip)

 PythonCard email list says that Leopard and PythonCard 0.8.2 seem to
 like each other generally:

 http://sourceforge.net/mailarchive/forum.php?thread_name=EE5213D5-A00...

 and I can get the examples working. However, when I start John's
 modified layoutEditor.py, I get an empty window and the following
 error is thrown:

 no resource file for /Users/bibliograph/Programme/PythonCard/tools/
 layoutEditor/multipropertyEditor
 Traceback (most recent call last):
   File /BinaryCache/wxWidgets/wxWidgets-11~57/Root/System/Library/
 Frameworks/Python.framework/Versions/2.5/Extras/lib/python/wx-2.8-mac-
 unicode/wx/_core.py, line 14095, in lambda
   File /Library/Python/2.5/site-packages/PythonCard/tools/
 layoutEditor/layoutEditor.py, line 153, in on_initialize
 self.propertyEditorWindow = model.childWindow(self,
 PropertyEditor)
   File /Library/Python/2.5/site-packages/PythonCard/model.py, line
 213, in childWindow
 rsrc = resource.ResourceFile(filename).getResource()
   File /Library/Python/2.5/site-packages/PythonCard/resource.py,
 line 45, in __init__
 self.dictionary = util.readAndEvalFile(rsrcFileName)
   File /Library/Python/2.5/site-packages/PythonCard/util.py, line
 39, in readAndEvalFile
 f = open(filename)
 TypeError: coercing to Unicode: need string or buffer, NoneType found

 there is a file PythonCard/tools/layoutEditor/modules/
 multipropertyEditor.rsrc.py

 When I resize the window, I get the following errors

 Tue Apr 29 10:48:08 noname Python[40440] Error: CGContextConcatCTM:
 invalid context
 Tue Apr 29 10:48:08 noname Python[40440] Error: CGContextSaveGState:
 invalid context
 Tue Apr 29 10:48:08 noname Python[40440] Error: doClip: invalid
 context
 Tue Apr 29 10:48:08 noname Python[40440] Error: CGContextSaveGState:
 invalid context
 Tue Apr 29 10:48:08 noname Python[40440] Error:
 CGContextSetBlendMode: invalid context
 Tue Apr 29 10:48:08 noname Python[40440] Error:
 CGContextSetShouldAntialias: invalid context
 Traceback (most recent call last):
   File /Library/Python/2.5/site-packages/PythonCard/model.py, line
 884, in _dispatch
 handler(background, aWxEvent)
   File /Library/Python/2.5/site-packages/PythonCard/tools/
 layoutEditor/layoutEditor.py, line 560, in on_size
 self.createDC()
   File /Library/Python/2.5/site-packages/PythonCard/tools/
 layoutEditor/layoutEditor.py, line 556, in createDC
 dc.SetLogicalFunction(wx.INVERT)
   File /BinaryCache/wxWidgets/wxWidgets-11~57/Root/System/Library/
 Frameworks/Python.framework/Versions/2.5/Extras/lib/python/wx-2.8-mac-
 unicode/wx/_gdi.py, line 4079, in SetLogicalFunction
 wx._core.PyAssertionError: C++ assertion status == noErr failed
 at ../src/mac/carbon/graphics.cpp(1324) in EnsureIsValid(): Cannot
 nest wxDCs on the same window

 Thanks for any pointers,

 Christian

Christian,

It appears you're missing a file.  Where did you placed my program?  I
see that there are two places being mentioned:

 no resource file for /Users/bibliograph/Programme/PythonCard/tools/
 layoutEditor/multipropertyEditor

and

 File /Library/Python/2.5/site-packages/PythonCard/tools/
 layoutEditor/layoutEditor.py, line 556, in createDC

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


Re: Issue with regular expressions

2008-04-29 Thread Paul McGuire
On Apr 29, 8:46 am, Julien [EMAIL PROTECTED] wrote:
 I'd like to select terms in a string, so I can then do a search in my
 database.

 query = '     some words  with and without    quotes     '
 p = re.compile(magic_regular_expression)   $ --- the magic happens
 m = p.match(query)

 I'd like m.groups() to return:
 ('some words', 'with', 'and', 'without quotes')

 Is that achievable with a single regular expression, and if so, what
 would it be?


Julien -

I dabbled with re's for a few minutes trying to get your solution,
then punted and used pyparsing instead.  Pyparsing will run slower
than re, but many people find it much easier to work with readable
class names and instances rather than re's typoglyphics:

from pyparsing import OneOrMore, Word, printables, dblQuotedString,
removeQuotes

# when a quoted string is found, remove the quotes,
# then strip whitespace from the contents
dblQuotedString.setParseAction(removeQuotes,
   lambda s:s[0].strip())

# define terms to be found in query string
term = dblQuotedString | Word(printables)
query_terms = OneOrMore(term)

# parse query string to extract terms
query = ' some words  with and withoutquotes '
print tuple(query_terms.parseString(query))

Gives:
('some words', 'with', 'and', 'withoutquotes')

The pyparsing wiki is at http://pyparsing.wikispaces.com.  You'll find
an examples page that includes a search query parser, and pointers to
a number of online documentation and presentation sources.

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


Re: list.reverse()

2008-04-29 Thread Paul McGuire
On Apr 28, 1:12 pm, Mark Bryan Yu [EMAIL PROTECTED] wrote:
 This set of codes works:

  x = range(5)
  x.reverse()
  x

 [4, 3, 2, 1, 0]


You can also use list slicing to get a reversed list:

 x = range(5)
 x
[0, 1, 2, 3, 4]
 x[::-1]
[4, 3, 2, 1, 0]

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


Colors for Rows

2008-04-29 Thread Victor Subervi
Hi;

why doesn't this work?

z = 3

for d in id:

  z += 1

  if z % 4 == 0:

bg = '#ff'

  elif z % 4 == 1:

bg = '#d2d2d2'

  elif z % 4 == 2:

bg = '#F6E5DF'

  else:

bg = '#EAF8D5'

try:

  print 'tr bgcolor=%s\n' % bg

except:

  print 'tr\n'



It never increments z! Yet, if I print z, it will increment and change the
bgcolor! Why?!

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

Re: Simple TK Question - refreshing the canvas when not in focus

2008-04-29 Thread Eric Brunel

On Tue, 29 Apr 2008 15:22:12 +0200, blaine [EMAIL PROTECTED] wrote:


Hey everyone!
  I'm not very good with Tk, and I am using a very simple canvas to
draw some pictures (this relates to that nokia screen emulator I had a
post about a few days ago).

Anyway, all is well, except one thing.  When I am not in the program,
and the program receives a draw command (from a FIFO pipe), the canvas
does not refresh until I click into the program. How do I force it to
refresh, or force the window to gain focus?  It seems like pretty
common behavior, but a few things that I've tried have not worked.

Class screen():
def __init__(self):
self.root = Tkinter.Tk()
self.root.title('Nokia Canvas')
self.canvas = Tkinter.Canvas(self.root, width =130,
height=130)
self.canvas.pack()
self.root.mainloop()

Then somewhere a long the line I do:
self.canvas.create_line(args[0], args[1], args[2],
args[3], fill=color)
self.canvas.pack()


Unrelated question: why are you doing a .pack() again here? Packing the  
widget just inserts it at the right place in its container, so you only  
have to do it once. So the one you did in __init__ is enough.



I've tried self.root.set_focus(), self.root.force_focus(),
self.canvas.update(), etc. but I can't get it.


IIRC:
- self.root.set_focus() will only work if your application already has the  
focus, so it's not what you need here.
- self.root.force_focus() is usually considered as evil: it'll give the  
focus to your application whatever the user is doing, which is usually  
*really* annoying. So I guess a lot of window managers just refuse to do  
it; this may be what happens here.


But self.canvas.update() should work. If it doesn't, then there are  
probably limitations on your platform that prevents it to work... Do you  
happen to have other applications that can update their display while they  
don't have the focus? Do they have the same problem? If they do, it's  
probably a limitation on the platform and I guess you won't be able to do  
anything about it... BTW, what platform are you on?



Thanks!
Blaine


HTH
--
python -c print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])

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


Re: Question regarding Queue object

2008-04-29 Thread Terry
On Apr 29, 3:01 pm, Dennis Lee Bieber [EMAIL PROTECTED] wrote:
 On Sun, 27 Apr 2008 03:27:59 -0700 (PDT), Terry [EMAIL PROTECTED]
 declaimed the following in comp.lang.python:

  I'm trying to implement a message queue among threads using Queue. The
  message queue has two operations:
  PutMsg(id, msg) #  this is simple, just combine the id and msg as one
  and put it into the Queue.
  WaitMsg(ids, msg) # this is the hard part

  WaitMsg will get only msg with certain ids, but this is not possible
  in Queue object, because Queue provides no method to peek into the
  message queue and fetch only matched item.

  Now I'm using an ugly solution, fetch all the messages and put the not
  used ones back to the queue. But I want a better performance. Is there
  any alternative out there?

 Create your own queue class -- including locking objects.

 Implement the queue itself (I've not looked at how Queue.Queue is
 really done) as a priority queue (that is, a simple list ordered by your
 ID -- new items are inserted after all existing items with the same or
 lower ID number).

 Surround list manipulations with a lock based on a Condition.

 Now, the trick -- the .get(ID) sequence being something like (this
 is pseudo-code):

 while True:
 self.condition.acquire()
 scan self.qlist for first entry with ID
 if found:
 remove entry from self.qlist
 self.condition.release()
 return entry
 self.condition.wait()

 -=-=-=-=-   the .put(ID, data) looks like

 self.condition.acquire()
 scan self.qlist for position to insert (ID, data)
 self.condition.notifyAll()
 self.condition.release()

 -=-=-=-=-

 Essentially, if the first pass over the list does not find an entry
 to return, it waits for a notify to occur... and notification will only
 occur when some other thread puts new data into the list.
 --
 WulfraedDennis Lee Bieber   KD6MOG
 [EMAIL PROTECTED]  [EMAIL PROTECTED]
 HTTP://wlfraed.home.netcom.com/
 (Bestiaria Support Staff:   [EMAIL PROTECTED])
 HTTP://www.bestiaria.com/

Yes, now I have a similar solution in my code. But after read the
stackless python, I'm thinking if I can move to stackless, which might
improve the performance of my thread. Because I'm trying to simulate
some behavior of the real world (trading), I believe there will be a
lot of threads in the future in my program.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Issue with regular expressions

2008-04-29 Thread Robert Bossy

Julien wrote:

Hi,

I'm fairly new in Python and I haven't used the regular expressions
enough to be able to achieve what I want.
I'd like to select terms in a string, so I can then do a search in my
database.

query = ' some words  with and withoutquotes '
p = re.compile(magic_regular_expression)   $ --- the magic happens
m = p.match(query)

I'd like m.groups() to return:
('some words', 'with', 'and', 'without quotes')

Is that achievable with a single regular expression, and if so, what
would it be?

Any help would be much appreciated.
  

Hi,

I think re is not the best tool for you. Maybe there's a regular 
expression that does what you want but it will be quite complex and hard 
to maintain.


I suggest you split the query with the double quotes and process 
alternate inside/outside chunks. Something like:


import re

def spulit(s):
   inq = False
   for term in s.split(''):
   if inq:
   yield re.sub('\s+', ' ', term.strip())
   else:
   for word in term.split():
   yield word
   inq = not inq

for token in spulit(' some words  with and withoutquotes '):
   print token
  
 
Cheers,

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


Re: Question regarding Queue object

2008-04-29 Thread Terry
On Apr 29, 4:32 pm, [EMAIL PROTECTED] wrote:
 On 27 Apr, 12:27, Terry [EMAIL PROTECTED] wrote:



  Hello!

  I'm trying to implement a message queue among threads using Queue. The
  message queue has two operations:
  PutMsg(id, msg) #  this is simple, just combine the id and msg as one
  and put it into the Queue.
  WaitMsg(ids, msg) # this is the hard part

  WaitMsg will get only msg with certain ids, but this is not possible
  in Queue object, because Queue provides no method to peek into the
  message queue and fetch only matched item.

  Now I'm using an ugly solution, fetch all the messages and put the not
  used ones back to the queue. But I want a better performance. Is there
  any alternative out there?

  This is my current solution:

  def _get_with_ids(self,wait, timeout, ids):
  to = timeout
  msg = None
  saved = []
  while True:
  start = time.clock()
  msg =self.q.get(wait, to)
  if msg and msg['id'] in ids:
  break;
  # not the expecting message, save it.
  saved.append(msg)
  to = to - (time.clock()-start)
  if to = 0:
  break
  # put the saved messages back to the queue
  for m in saved:
  self.q.put(m, True)
  return msg

  br, Terry

 Wy put them back in the queue?
 You could have a defaultdict with the id as key and a list of
 unprocessed messages with that id as items.
 Your _get_by_ids function could first look into the unprocessed
 messages for items with that ids and then
 look into the queue, putting any unprocessed item in the dictionary,
 for later processing.
 This should improve the performances, with a little complication of
 the method code (but way simpler
 that implementing your own priority-based queue).

 Ciao
 -
 FB

Yes, this will improve the performance. And I can see there's a
problem in my current implementation. The order of the message might
be changed if I put the saved message back to the end of the queue.
This may cause some confusion later, though I don't want to depend too
much on the message orders.

And you remind me one thing -- I need to implement 'priority' for
messages, so that the message with highest priority will tend to be
fetched first. OMG, this is going to be much more complicated then I
have expected.

Thanks for your suggestion. And I hope this will also work when I move
to stackless.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Issue with regular expressions

2008-04-29 Thread cokofreedom
| #  Double Quote Text 
|# match a double quote
|(#  - Two Possiblities:
|\\.  # match two backslashes followed by anything
(include newline)
||# OR
|[^] # do not match a single quote
|)*   #  - from zero to many
|# finally match a double quote
|
||#  OR 
|
| #  Single Quote Text 
|'# match a single quote
|(#  - Two Possiblities:
|\\.  # match two backslashes followed by anything
(include newline)
||# OR
|[^'] # do not match a single quote
|)*   #  - from zero to many
|'# finally match a single quote
|, DOTALL|VERBOSE)

Used this before (minus those | at the beginning) to find double
quotes and single quotes in a file (there is more to this that looks
for C++ and C style quotes but that isn't needed here), perhaps you
can take it another step to not do changes to these matches?

r(\\.|[^])*|'(\\.|[^'])*', DOTALL)

is it in a single line :)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Given a string - execute a function by the same name

2008-04-29 Thread python
Hi Max,

Thank you for pointing out the pattern of my request.

Using your google query
(http://www.google.dk/search?hl=enq=python+factory+pattern) I found the
following description of what I'm doing.

Command Dispatch Pattern
http://www.suttoncourtenay.org.uk/duncan/accu/pythonpatterns.html#id26

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


Re: Issue with regular expressions

2008-04-29 Thread Paul Melis

Julien wrote:

Hi,

I'm fairly new in Python and I haven't used the regular expressions
enough to be able to achieve what I want.
I'd like to select terms in a string, so I can then do a search in my
database.

query = ' some words  with and withoutquotes '
p = re.compile(magic_regular_expression)   $ --- the magic happens
m = p.match(query)

I'd like m.groups() to return:
('some words', 'with', 'and', 'without quotes')

Is that achievable with a single regular expression, and if so, what
would it be?


Here's one way with a single regexp plus an extra filter function.

 import re
 p = re.compile('(([^]+))|([^ \t]+)')
 m = p.findall(q)
 m
[('  some words', '  some words', ''), ('', '', 'with'), ('', '', 
'and'), ('withoutquotes   ', 'withoutquotes   ', '')]

 def f(t):
... if t[0] == '':
... return t[2]
... else:
... return t[1]
...
 map(f, m)
['  some words', 'with', 'and', 'withoutquotes   ']

If you want to strip away the leading/trailing whitespace from the 
quoted strings, then change the last return statement to

be return t[1].strip().

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


Re: list.reverse()

2008-04-29 Thread Diez B. Roggisch


The reasoning goes along the lines of, reverse in place is an expensive 
operation, so we don't want to make it too easy for people to do.  At 
least that's the gist of what I got out of the argument the many times it 
has come up.



It's not about the storage - it is about the in-place-modification. The 
reasioning is that people otherwise could assume that


a = [1, 2]
b = a.reverse()
assert a[0] == 1 and b[0] == 2

would hold, but instead of course a is changed.

Using reversed as

b = reversed(a)

will make that assumption hold.

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


Re: Issue with regular expressions

2008-04-29 Thread Hrvoje Niksic
Julien [EMAIL PROTECTED] writes:

 I'm fairly new in Python and I haven't used the regular expressions
 enough to be able to achieve what I want.
 I'd like to select terms in a string, so I can then do a search in my
 database.

 query = ' some words  with and withoutquotes '
 p = re.compile(magic_regular_expression)   $ --- the magic happens
 m = p.match(query)

I don't think you can achieve this with a single regular expression.
Your best bet is to use p.findall() to find all plausible matches, and
then rework them a bit.  For example:

p = re.compile(r'[^]*|[\S]+')
p.findall(query)
['  some words', 'with', 'and', 'withoutquotes   ']

At that point, you can easily iterate through the list and remove the
quotes and excess whitespace.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Issue with regular expressions

2008-04-29 Thread harvey . thomas
On Apr 29, 2:46 pm, Julien [EMAIL PROTECTED] wrote:
 Hi,

 I'm fairly new in Python and I haven't used the regular expressions
 enough to be able to achieve what I want.
 I'd like to select terms in a string, so I can then do a search in my
 database.

 query = '     some words  with and without    quotes     '
 p = re.compile(magic_regular_expression)   $ --- the magic happens
 m = p.match(query)

 I'd like m.groups() to return:
 ('some words', 'with', 'and', 'without quotes')

 Is that achievable with a single regular expression, and if so, what
 would it be?

 Any help would be much appreciated.

 Thanks!!

 Julien

You can't do it simply and completely with regular expressions alone
because of the requirement to strip the quotes and normalize
whitespace, but its not too hard to write a function to do it. Viz:

import re

wordre = re.compile('[^]+|[a-zA-Z]+').findall
def findwords(src):
ret = []
for x in wordre(src):
if x[0] == '':
#strip off the quotes and normalise spaces
ret.append(' '.join(x[1:-1].split()))
else:
ret.append(x)
return ret

query = ' Some words  withand withoutquotes '
print findwords(query)

Running this gives
['Some words', 'with', 'and', 'without quotes']

HTH

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


Re: Question regarding Queue object

2008-04-29 Thread Terry
On Apr 29, 5:30 pm, Nick Craig-Wood [EMAIL PROTECTED] wrote:
 Terry [EMAIL PROTECTED] wrote:
   On Apr 28, 5:30 pm, Nick Craig-Wood [EMAIL PROTECTED] wrote:
   David [EMAIL PROTECTED] wrote:
 Another idea would be to have multiple queues, one per thread or per
 message type group. The producer thread pushes into the appropriate
 queues (through an intelligent PutMsg function), and the consumer
 threads pull from the queues they're interested in and ignore the
 others.

   Unfortunately a thread can only wait on one Queue at once (without
   polling).  So really the only efficient solution is one Queue per
   thread.

   Make an intelligent PutMsg function which knows which Queue (or
   Queues) each message needs to be put in and all the threads will have
   to do is Queue.get() and be sure they've got a message they can deal
   with.

   I do have one Queue per thread. The problem is the thread can not peek
   into the Queue and select msg with certain ID first.

 My point is don't put messages that the thread doesn't need in the
 queue in the first place.  Ie move that logic into PutMsg.

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

Well, I'm simulating the real world. It's like that you wouldn't drop
or proceed a task when you already started your lunch, just save it
and process it later when you finish your lunch.
Of course the task sender can send the task again and again if he got
not ack from you. But that's  just one possible situation in the real
world, and not an efficient one.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Simple TK Question - refreshing the canvas when not in focus

2008-04-29 Thread blaine
On Apr 29, 10:36 am, Eric Brunel [EMAIL PROTECTED] wrote:
 On Tue, 29 Apr 2008 15:22:12 +0200, blaine [EMAIL PROTECTED] wrote:
  Hey everyone!
I'm not very good with Tk, and I am using a very simple canvas to
  draw some pictures (this relates to that nokia screen emulator I had a
  post about a few days ago).

  Anyway, all is well, except one thing.  When I am not in the program,
  and the program receives a draw command (from a FIFO pipe), the canvas
  does not refresh until I click into the program. How do I force it to
  refresh, or force the window to gain focus?  It seems like pretty
  common behavior, but a few things that I've tried have not worked.

  Class screen():
  def __init__(self):
  self.root = Tkinter.Tk()
  self.root.title('Nokia Canvas')
  self.canvas = Tkinter.Canvas(self.root, width =130,
  height=130)
  self.canvas.pack()
  self.root.mainloop()

  Then somewhere a long the line I do:
  self.canvas.create_line(args[0], args[1], args[2],
  args[3], fill=color)
  self.canvas.pack()

 Unrelated question: why are you doing a .pack() again here? Packing the
 widget just inserts it at the right place in its container, so you only
 have to do it once. So the one you did in __init__ is enough.

  I've tried self.root.set_focus(), self.root.force_focus(),
  self.canvas.update(), etc. but I can't get it.

 IIRC:
 - self.root.set_focus() will only work if your application already has the
 focus, so it's not what you need here.
 - self.root.force_focus() is usually considered as evil: it'll give the
 focus to your application whatever the user is doing, which is usually
 *really* annoying. So I guess a lot of window managers just refuse to do
 it; this may be what happens here.

 But self.canvas.update() should work. If it doesn't, then there are
 probably limitations on your platform that prevents it to work... Do you
 happen to have other applications that can update their display while they
 don't have the focus? Do they have the same problem? If they do, it's
 probably a limitation on the platform and I guess you won't be able to do
 anything about it... BTW, what platform are you on?

  Thanks!
  Blaine

 HTH
 --
 python -c print ''.join([chr(154 - ord(c)) for c in
 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])

Thanks a lot for the response! To answer your first question - I'm
using pack() there because I didn't mean to slip it in - this is
something I wrote very quickly and was playing around with... and
pack() should not be there, heh.

I'm just using OS X with Python 2.5.  For the record - I don't mind if
the application forces focus.  The only time I will be running this
emulator is when I'm trying to use it.

I'll try the update() again.  I would want to use that on the canvas
itself right? Not the root window?

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


Re: Why is None = 0

2008-04-29 Thread Duncan Booth
blaine [EMAIL PROTECTED] wrote:

 On Apr 29, 5:32 am, Duncan Booth [EMAIL PROTECTED] wrote:
 =?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?= [EMAIL PROTECTED]
 wrote: 
  (FWIW, in 2.x, x=4?, it's None  numbers  anything else;
  numbers are ordered by value, everything else is ordered
  by type name, then by address, unless comparison functions
  are implemented).

 Quite apart from Jon pointing out that this isn't true for all cases
 when copmparing against None, the other half also isn't true:

  class C: pass
  C()  5

 True

 That happens at least in Python 2.5.2 on win32. Yet another reason to
 avoid old-style classes.
 
 Sorry - but what are new style classes?
 
New style classes are anything type derived from object. e.g.

   class D(object): pass

or (since list is derived from object):

   class E(list): pass

Old style classes are those which either have old-style base classes or 
no base class at all (and no __metaclass__ either but don't worry about 
that for now) e.g. the class C above.

The problem with old style classes is that various things either work 
subtly differently or don't work at all, but you don't get much warning. 
So basically steer clear of them. An example of something which doesn't 
work with old style classes would be the @property decorator: you can 
get the property, but setting it simply overwrites the property with the 
new value.

See http://www.google.co.uk/search?q=python+%22new+style%22 for more 
information.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using Python to verify streaming tv/radio station links

2008-04-29 Thread alexelder
On Apr 29, 1:52 pm, [EMAIL PROTECTED] wrote:
 Hi guys. I've put together a website (http://worldwidemediaproject.com
 ) that is a database of internet streaming tv/radio stations from
 around the world. I have built the site with all users in mind. The
 site should be Linux, Unix, Mac, Win, etc friendly as I do not hide
 the actual stream link or force the user to use an embedded player to
 view/listen to the streams. In fact, you can even download the streams
 you like as a playlist that you can load into your player of choice
 (and even a few PVR software plugins).

 In building the site, I have enabled the user to report stations that
 are nonfunctional. In addition to this, I would like to automate the
 checking of the links in the database as well as any user submitted
 links. What I am wanting to do is to script this with a simple for
 loop which would loop through a file containing the station stream
 link as well as the station id. I'd like to pass each through some
 kind of verification function and if a connection is made then the
 stream is good and move on to the next. If the connection fails then
 the stream is bad, I would like to add the station id to a file
 containing all 'nonfunctional' streams that I can later automate to
 flag the stations.

 Is there an easy way to use python to verify a stream exists? I've
 done a little experimenting with sockets and was able to connect to my
 usenet server and talk to it, but I don't really know what's involved
 with connecting to streaming windows media, real media and winamp
 servers or what to expect as far as connection status messages.   I am
 not unfamiliar with python, but I am far from an expert. If anyone
 could give me a hand with this or give me a push in the right
 direction I would greatly appreciate it!

 Many thanks!

Hey!

With regards checking feeds, look into urllib (maybe) and the httplib
(definitely). They /could/ offer some sort of information regarding
the activity of your feeds. Without knowing anything about the
streaming protocols I wouldn't suggest my methods to necessarily be
the most helpful. You could, at least [maybe], establish whether a
feed is active if it can return a HTTP 200 response. If that's a
sufficient check I would suggest that httplib is the place to start.

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


Re: So you think PythonCard is old? Here's new wine in an old bottle.

2008-04-29 Thread Panyasan

 Christian,

 It appears you're missing a file.  Where did you placed my program?  I
 see that there are two places being mentioned:

  no resource file for /Users/bibliograph/Programme/PythonCard/tools/
  layoutEditor/multipropertyEditor

 and

  File /Library/Python/2.5/site-packages/PythonCard/tools/
  layoutEditor/layoutEditor.py, line 556, in createDC

I unzipped the folder you uploaded and placed it in the PythonCard/
tools folder. I get the same error if I try to start the default
resourceEditor.py or layoutEditor.py scripts, so it does not seem to
have to do with your modifications.
When I copy multipropertyEditor.rsrc.py files from PythodCard/tools/
resourceEditor/modules folder to PythodCard/tools/resourceEditor/, it
will throw the error about a different file - might this be some kind
of PATH error?

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


Re: Given a string - execute a function by the same name

2008-04-29 Thread python
Arnaud,

Just when I thought my solution couldn't get any better :)

Thanks for that great tip and for an excellent demonstration of using a
decorator.

Regards,
Malcolm

snip
You could avoid #5 from the start using a decorator:

functions = {}

def register(func):
functions[func.__name__] = func
return func

@register
def foo(): print Foo!

@register
def bar(): print Bar!


 functions
{'foo': function foo at 0x6f2f0, 'bar': function bar at 0x6f330}
 functions['bar']()
Bar!
/snip
--
http://mail.python.org/mailman/listinfo/python-list


PyExcerlerator details

2008-04-29 Thread A_H
Hi, I'm using PyExcelerator, and it's great, but I can't figure out a
few things:


(1)  I set the cell style to '0.00%' but the style does not work.

(2)  I want to place a border around the cells( x1, y1, x2, y2 ) but I
can't find any example of doing that.
Well I do see ONE example, but it erases the cells if I do it after,
or when I write to the cells that erases the outline.
Surely I don't have to tediously set each cells border?

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


Re: Zope/DTML Infuriating...

2008-04-29 Thread William Heymann
On Tuesday 29 April 2008, Jens wrote:
 Hello Everyone.


 dtml-let prefix='main'
 ul
 dtml-in expr=_.range(1,10)
   lidtml-var expr=_['prefix'] + _['sequence-item']/li
 /dtml-in
 /ul
 /dtml-let



I think you are going to really regret doing things this way, it is only going 
to make your life much harder regardless of if you are using zpt or dtml by 
doing stuff like this inside the template. The most correct way in zope to do 
this is to use a python script object and have the dtml call that.

For example your python script would have

return ['main%s' % i for i in range(1,10)]

and your dtml would have

ul
dtml-in path.to.you.script()
 lidtml-var sequence-item/li
/ul


This leads to much cleaner and easier to maintain systems.
--
http://mail.python.org/mailman/listinfo/python-list


Re: File IO Issues, help :(

2008-04-29 Thread Kevin K
On Apr 29, 1:07 am, Kevin K [EMAIL PROTECTED] wrote:
 On Apr 29, 12:55 am, Peter Otten [EMAIL PROTECTED] wrote:



  Kevin K wrote:
   On Apr 29, 12:38 am, Eric Wertman [EMAIL PROTECTED] wrote:
   chuck in a jsfile.close().  The buffer isn't flushing with what you
   are doing now.  jsfile.flush() might work... not sure.  Closing and
   re-opening the file for sure will help though.

   Yeah sorry I forgot to include the close() in the quote but its there.
   In fact I moved it up a bit and still no luck heres the new code:

   jsfile = open(../timeline.js, r+)
   jscontent = jsfile.readlines()
   jsfile.truncate()

   for line in jscontent:
   if re.search('var d =', line):
   line = var d = \+mint['1'].ascdate()+\\n
   print line
   jsfile.write(line)
   jsfile.close()

   I tried this can got the same result...??

  
  truncate(...)
  truncate([size]) - None.  Truncate the file to at most size bytes.

  Size defaults to the current file position, as returned by tell().
  

  After the readlines() call the current file position is at the end of the
  file. Try jsfile.truncate(0).

  Also note that readlines() reads the whole file into memory. For large files
  it would therefore be better to write to a new file and rename it
  afterwards.

  Peter

 Thanks Peter that seemed to be most of the problem, however I now have
 a bunch of null characters in the file. Could it be an unwanted line
 in the list that im writing?

 Thanks,
 Kevin

Awesome that seems to work fine! Thanks a lot for your help guys!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Zope/DTML Infuriating...

2008-04-29 Thread Jens
On Apr 29, 3:16 pm, Christian Heimes [EMAIL PROTECTED] wrote:
 Jens schrieb:

  Hello Everyone.

  I am relatively new to Zope(using it for a work project) and I was
  wondering if someone here could help me out or at least refer me to a
  decent documentationg for Zope/DTML/Python (at the detail level of
  php.net or Java API reference).  
  http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/
  isn't really detailed enough for my taste. if it doesn't contain a
  exhautive description of all available base classes it's simply no
  good as a reference resource.

 Are you forced to use DTML for the job? ZPT are far superior and easier
 to work with, if you have to output HTML.

 Christian

For now, I have to use DTML as I am building on an existing solution.
I might look into ZPT's but I have limited time and theres no to time
at this point to redo everything as ZPT. In the long run we're
probably
going in a completely different direction, but that a another story.

I like some aspects of zope but I find that it ends up sitting between
two chairs. On one hand it want's to be a templating language which is
easy to get into for novices, but on the other hand you really have be
familiar with python to be able to so stuff thats only slighty more
complicated
then standard SSI. And don't get me started on the whole security
philosophy.

@Marco:
Thanks for the links :-) Python may be one of those really elegant
languages, but the reference is really sub standard. Checkout the
layout
of php.net for comparison. Think what you will about php, but the
reference
is excellent. For that matter check out msdn section on old-school
asp, or
even the common-lisp documentation(http://www.lispworks.com/
documentation/HyperSpec/Front/Contents.htm)
It's  accessibility like that i'm missing. It shouldn't take 10 min
and a usenet
post to figure to how to basic stuff like string concatenation. And
theres
still plenty of unanswered questions after checking the reference:

- What is the exact definition of the operator e.g. op + (string,
string) - string, op + (int, int) : int, op + (float ...
- What is the exact operator precedence
- Why is it, when primitive data types seem to be objects (similar to
javascript), that type casting is done through build-in functions
rather than methods, e.g. String.toInt('5') or '5'.toInt() or x =
Integer.fromString('5').



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


Re: Zope/DTML Infuriating...

2008-04-29 Thread Jens
On Apr 29, 3:16 pm, Christian Heimes [EMAIL PROTECTED] wrote:
 Jens schrieb:

  Hello Everyone.

  I am relatively new to Zope(using it for a work project) and I was
  wondering if someone here could help me out or at least refer me to a
  decent documentationg for Zope/DTML/Python (at the detail level of
  php.net or Java API reference).  
  http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/
  isn't really detailed enough for my taste. if it doesn't contain a
  exhautive description of all available base classes it's simply no
  good as a reference resource.

 Are you forced to use DTML for the job? ZPT are far superior and easier
 to work with, if you have to output HTML.

 Christian

For now, I have to use DTML as I am building on an existing solution.
I might look into ZPT's but I have limited time and theres no to time
at this point to redo everything as ZPT. In the long run we're
probably
going in a completely different direction, but that a another story.

I like some aspects of zope but I find that it ends up sitting between
two chairs. On one hand it want's to be a templating language which is
easy to get into for novices, but on the other hand you really have be
familiar with python to be able to so stuff thats only slighty more
complicated
then standard SSI. And don't get me started on the whole security
philosophy.

@Marco:
Thanks for the links :-) Python may be one of those really elegant
languages, but the reference is really sub standard. Checkout the
layout
of php.net for comparison. Think what you will about php, but the
reference
is excellent. For that matter check out msdn section on old-school
asp, or
even the common-lisp documentation(http://www.lispworks.com/
documentation/HyperSpec/Front/Contents.htm)
It's  accessibility like that i'm missing. It shouldn't take 10 min
and a usenet
post to figure to how to basic stuff like string concatenation. And
theres
still plenty of unanswered questions after checking the reference:

- What is the exact definition of the operator e.g. op + (string,
string) - string, op + (int, int) : int, op + (float ...
- What is the exact operator precedence
- Why is it, when primitive data types seem to be objects (similar to
javascript), that type casting is done through build-in functions
rather than methods, e.g. String.toInt('5') or '5'.toInt() or x =
Integer.fromString('5').



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


Who makes up these rules, anyway? (was: Python-URL! - weekly Python news and links (Apr 28))

2008-04-29 Thread Cameron Laird
In article [EMAIL PROTECTED],
Gabriel Genellina [EMAIL PROTECTED] wrote:
.
.
.
Explicit variable declaration for functions:
   
http://groups.google.com/group/comp.lang.python/browse_thread/thread/6c4a508edd2fbe04/
.
.
.
A reader notes that this thread actually lived during 2004 (!)
(entirely during January 2004, in fact), and mildly questions 
its pertinence to what bills itself as weekly Python news ...

Well might the reader wonder.  Python-URL! has long chosen
to err on the side of INclusiveness in its categorizations,
even to the occasional point of apparent frivolity.  As Harlan
Ellison used to advise his readers, think of it as a bonus,
rather than a mistake.  It's our tradition, too.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Simple unicode-safe version of str(exception)?

2008-04-29 Thread Russell E. Owen
In article [EMAIL PROTECTED],
 Bjoern Schliessmann [EMAIL PROTECTED] 
 wrote:

 Martin v. Löwis wrote:
 
  e is an exception object, not a Unicode object.
 
 Er, sure, thanks for pointing that out. At first sight he should
 substitute e with e.message then since he tries to convert to
 string (for display?).

No. e.message is only set if the exeption object receives exactly one 
argument.

That is why my replacement code reads:
errStr = ,.join([unicode(s) for s in f.args])
self.setState(self.Failed, errStr)
(where e is an Exception of some kind)

Notice that I'm iterating over the args. But again, this is far messier 
than:
self.setState(self.Failed, str(e)

So...to repeat the original question, is there any simpler unicode-safe 
replacement for str(exception)?

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

Re: Colors for Rows

2008-04-29 Thread D'Arcy J.M. Cain
On Tue, 29 Apr 2008 09:33:32 -0500
Victor Subervi [EMAIL PROTECTED] wrote:
 why doesn't this work?

First, let me remove some blank lines to reduce scrolling.

 z = 3
 
 for d in (1,2,3,4,5,6):

I changed id to a sequence so that the example actually runs.  Please
run your examples first and cut and paste them into the message after
you are sure that it runs.

   z += 1
 
   if z % 4 == 0:
 bg = '#ff'
   elif z % 4 == 1:
 bg = '#d2d2d2'
   elif z % 4 == 2:
 bg = '#F6E5DF'
   else:
 bg = '#EAF8D5'
 
 try:
   print 'tr bgcolor=%s\n' % bg
 except:
   print 'tr\n'
 
 It never increments z! Yet, if I print z, it will increment and change the
 bgcolor! Why?!

I am not entirely sure what you are trying to do here.  First, what
error condition are you expecting in your try statement.  Second, don't
you want the print clause, with or without the try/except, in the
loop.  I assume that you want to print a line for each member of your
sequence in alternating colours but this only prints for the last one.
Try this:

z = 3

for d in (1,2,3,4,5,6):
  z += 1

  if z % 4 == 0:
bg = '#ff'
  elif z % 4 == 1:
bg = '#d2d2d2'
  elif z % 4 == 2:
bg = '#F6E5DF'
  else:
bg = '#EAF8D5'

  print 'tr bgcolor=%s' % bg, d

Or, tell us what you are trying to do.

In fact, you can replace all the tests and the print statement with
this after defining bg as a list of the four colours:

  print 'tr bgcolor=%s' % bg[z % 4], d

-- 
D'Arcy J.M. Cain [EMAIL PROTECTED] |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Who makes up these rules, anyway?

2008-04-29 Thread Roel Schroeven

Cameron Laird schreef:

In article [EMAIL PROTECTED],
Gabriel Genellina [EMAIL PROTECTED] wrote:
.
.
.

   Explicit variable declaration for functions:
  
http://groups.google.com/group/comp.lang.python/browse_thread/thread/6c4a508edd2fbe04/

.
.
.
A reader notes that this thread actually lived during 2004 (!)
(entirely during January 2004, in fact), and mildly questions 
its pertinence to what bills itself as weekly Python news ...


Well might the reader wonder.  Python-URL! has long chosen
to err on the side of INclusiveness in its categorizations,
even to the occasional point of apparent frivolity.  As Harlan
Ellison used to advise his readers, think of it as a bonus,
rather than a mistake.  It's our tradition, too.


I assumed it was a mix-up with the recent thread with the same name: 
http://groups.google.com/group/comp.lang.python/browse_thread/thread/f3832259c6da530



--
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
  -- Isaac Asimov

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


Re: Simple unicode-safe version of str(exception)?

2008-04-29 Thread Russell E. Owen
In article [EMAIL PROTECTED],
 Donn Cave [EMAIL PROTECTED] wrote:

 In article [EMAIL PROTECTED],
  Martin v. Löwis [EMAIL PROTECTED] wrote:
 
   I have code like this:
   except Exception, e:
  self.setState(self.Failed, str(e))
   which fails if the exception contains a unicode argument.
   
   Fails how?
  
  ASCII encoding error, I suppose. It fails only if a) one argument
  is a Unicode object, and b) that Unicode object contains non-ASCII
  parameters.
 
 Seem ironic that this fails even though pretty nearly anything
 else is a valid input to str() -- socket, dict, whatever?

I agree. In fact str(a) works if a is a dict or list that contains 
unicode data! Pity the same is not true of exceptions.

Should I report this as a bug? I suspect it's a misfeature.

 A sort of generic solution might be to follow str's behavior
 with respect to '__str__', extending it to fall back to repr()
 whatever goes wrong.
 
 
 def xtr(a):
 try:
 return str(a)
 except:
 return repr(a)

Yes. That is a more flexible alternative to what I've adopted:
def exStr(ex):
return ,.join([unicode(s) for s in f.args])
the latter gives better output for the case I'm interested in, but only 
handles exceptions.

Oh well. I'll stick to my solution and hope that Python 2.6 and 3.0 fix 
the problem in a more sensible fashion.

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

Re: So you think PythonCard is old? Here's new wine in an old bottle.

2008-04-29 Thread John Henry
On Apr 29, 8:28 am, Panyasan [EMAIL PROTECTED] wrote:
  Christian,

  It appears you're missing a file.  Where did you placed my program?  I
  see that there are two places being mentioned:

   no resource file for /Users/bibliograph/Programme/PythonCard/tools/
   layoutEditor/multipropertyEditor

  and

   File /Library/Python/2.5/site-packages/PythonCard/tools/
   layoutEditor/layoutEditor.py, line 556, in createDC

 I unzipped the folder you uploaded and placed it in the PythonCard/
 tools folder. I get the same error if I try to start the default
 resourceEditor.py or layoutEditor.py scripts, so it does not seem to
 have to do with your modifications.
 When I copy multipropertyEditor.rsrc.py files from PythodCard/tools/
 resourceEditor/modules folder to PythodCard/tools/resourceEditor/, it
 will throw the error about a different file - might this be some kind
 of PATH error?

 C.

It certainly looks like it's not finding a file.  Not knowing Mac or
Linux, I don't know how files are searched.

There are a whole bunch of test programs that comes with Pythoncard.
Do they work?  (Not all of them will work - some requires a database)
--
http://mail.python.org/mailman/listinfo/python-list


python command mis-interprets arrow keys

2008-04-29 Thread Rahul
My python command line seems messed up. I can't seem to be able to use my 
backspace key nor my arrow keys. 

I only get control characters: ^[[A^[[D^[[D^[[D^[[C^[[C^[[C etc.

I access my Linux box via  a SecureCRT console. Only after opening the 
python interpreter does this occur. Linux command like is OK. vim 
interprets keystrokes correctly. So do other interpreters e.g. gnuplot.

$LANG $TERM 
en_US xterm-color

Versions:
Python 2.4.4 
GCC 4.1.2 20070925 (Red Hat 4.1.2-33)


Any sugesstions? Google did not throw anything relevant. 


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


  1   2   3   >