Elisa Media Center 0.5.33 Release

2009-03-24 Thread Olivier Tilloy
Dear Python users,

The Elisa team is happy to announce the release of Elisa Media Center
0.5.33, code-named Surrounded.

Elisa is a cross-platform and open-source Media Center written in Python.
It uses GStreamer [1] for media playback and pigment [2] to create an
appealing and intuitive user interface.

This release is a lightweight release, meaning it is pushed through
our automatic plugin update system. Additionally a windows installer is
available for download on our website. This installer fixes various
crash at startup problems.
As usual, for users running a version of Elisa = 0.5.27, the upgrade to
0.5.33 should be done automatically via the plugin repository.

As usual, tarballs are provided for distribution packagers.

A complete list of the issues fixed can be found at:

http://bugs.launchpad.net/elisa/+milestone/0.5.33

This is also summarised in the (attached) release notes.

Installers and sources can be downloaded from
http://elisa.fluendo.com/download/

Bug reports and feature requests are welcome at
http://bugs.launchpad.net/elisa/+filebug


Have a media-centered evening,


Olivier, for the Elisa team


[1] http://www.gstreamer.net/
[2] https://code.fluendo.com/pigment/trac
Elisa 0.5.33 Surrounded
=

This is Elisa 0.5.33, thirty-third release of the 0.5 branch.

Bugs fixed since 0.5.32:

- 337788: The core depends on plugins
- 341199: [win32] Elisa crashes at startup if gstreamer is in the path
- 341686: [win32] Elisa crashes at startup if GST_PLUGIN_PATH is set
- 251606: [win32] elisa.exe should be able to open a debug console
- 263697: installing elisa breaks the unit tests of unrelated Python packages
- 304433: Black screen at startup without feedback
- 318691: Drag'n dropped pictures cannot be rotated
- 330491: [linux] Cannot play TV Shows with question marks in their filename
- 347182: Elisa 0.5.32 tarballs README shows older version of pigment


Download

You can find source releases of Elisa on the download page:
http://elisa.fluendo.com/download


Elisa Homepage

More details can be found on the project's website: http://elisa.fluendo.com


Support and Bugs

We use Launchpad for bug reports and feature requests:
https://bugs.launchpad.net/elisa/+filebug


Developers

All code is in a Bazaar branch and can be checked out from there.
It is hosted on Launchpad: https://code.launchpad.net/elisa


Contributors to this release:

- Anna Wojdel
- David McLeod
- Florian Boucault
- Guillaume Emont
- Jesús Corrius
- Lionel Martin
- Marc Garcia
- Maxwell Young
- Olivier Tilloy
- Philippe Normand
--
http://mail.python.org/mailman/listinfo/python-announce-list

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


Wing IDE 3.1.8 released

2009-03-24 Thread Wingware

Hi,

Wingware has released version 3.1.8 of Wing IDE, a bug-fix release for all
three product levels of Wing IDE.

*Release Highlights*

This release includes the following:

* Fixed problems seen with Subversion 1.4+
* Properly ignore settrace exception on x64 systems
* Fixed perforce submit for some Perforce versions
* Show meaningful error when debug a main file within a zip or egg
* Fixed cursor color in search fields when editor background is not white
* Use .chm file on Windows for python manual, when available
* Upgraded Wing's private copy of Python to 2.5.4 (includes security patches)
* About 5 other bug fixes: see the change log for details:
  http://wingware.com/pub/wingide/3.1.8/CHANGELOG.txt

*Downloads*

Wing IDE Professional and Wing IDE Personal are commercial software and
require a license to run. A free trial license can be obtained directly from
the product when launched.

Wing IDE Pro 3.1.8http://wingware.com/downloads/wingide/3.1

Wing IDE Personal 3.1.8   http://wingware.com/downloads/wingide-personal/3.1

Wing IDE 101 3.1.8http://wingware.com/downloads/wingide-101/3.1

*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 simplified 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).
Wing IDE 3.1 supports Python versions 2.0.x through 2.5.x.

*New Features in Wing 3.1*

This release adds the following features not found in Wing 3.0.x:

* Support for zip archives
* Support for pkg_resources name spaces and eggs
* Support for doctest and nose style unit tests (*)
* Scan for sys.path changes such as those used in buildout
* How-To and support for Google App Engine
* Inline context appropriate templates/snippets integrated with autocompleter 
(*)
* Word list driven auto-completion in non-Python files (**)
* Quick navigation to files and symbols by typing a fragment (**)
* Improved support for Stackless Python
* Preference to strip trailing white space on save
* Display gi_running and gi_frame for generators
* Improved code analysis for Python 2.5
* Other minor features and bug fixes not found in Wing 3.0.x

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

Please see the change log for a detailed list of changes:
http://wingware.com/pub/wingide/3.1.8/CHANGELOG.txt

*Purchasing and Upgrading*

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

Upgrade a 2.x license: https://wingware.com/store/upgrade

Purchase a 3.x license: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


ETS 3.2.0 Released

2009-03-24 Thread Dave Peterson

Hello,

I'm pleased to announce that Enthought Tool Suite (ETS) version 3.2.0 
has been tagged and released!


Source distributions (.tar.gz) have been uploaded to PyPi, and Windows 
binaries will be follow shortly. A full install of ETS can be done using 
Setuptools via a command like:

easy_install -U ets[nonets] = 3.2.0

NOTE 1: Users of an old ETS release will need to first uninstall prior 
to installing the new ETS.


NOTE 2: If you get a 'SandboxViolation' error, simply re-run the command 
again -- it may take multiple invocations to get everything installed. 
(This error appears to be a long-standing incompatibility between 
numpy.distutils and setuptools.)


Please see below for a list of what's new in this release.


What Is ETS?
===

The Enthought Tool Suite (ETS) is a collection of components developed 
by Enthought and the open-source community, which we use every day to 
construct custom scientific applications. It includes a wide variety of 
components, including:

* an extensible application framework
* application building blocks
* 2-D and 3-D graphics libraries
* scientific and math libraries
* developer tools
The cornerstone on which these tools rest is the Traits package, which 
provides explicit type declarations in Python; its features include 
initialization, validation, delegation, notification, and visualization 
of typed attributes.


More information on ETS is available from the development home page:
http://code.enthought.com/projects/index.php


Changelog
=

ETS 3.2.0 is a feature-added update to ETS 3.1.0, including numerous
bug-fixes. Some of the notable changes include:

Chaco
-

* Domain limits - Mappers now can declare the limits of their valid 
domain. PanTool and ZoomTool respect these limits. (pwang)


* Adding hide_grids parameter to Plot.img_plot() and 
Plot.contour_plot() so users can override the default behavior of hiding 
grids. (pwang)


* Refactored examples to declare a Demo object so they can be be run 
with the demo.py example launcher. (vibha)


* Adding chaco.overlays package with some canned SVG overlays. (bhendrix)

* DragZoom now can scale both X and Y axes independently corresponding 
to the mouse cursor motion along the X and Y axes (similar to the zoom 
behavior in Matplotlib). (pwang)


* New Examples:
* world map (bhendrix)
* more financial plots (pwang)
* scatter_toggle (pwang)
* stacked_axis (pwang)

* Fixing the chaco.scales TimeFormatter to use the built-in localtime() 
instead of the one in the safetime.py module due to Daylight Savings 
Time issues with timedelta. (r23231, pwang)


* Improved behavior of ScatterPlot when it doesn't get the type of 
metadata it expects in its selections and selection_masks metadata 
keys (r23121, pwang)


* Setting the .range2d attribute on GridMapper now properly sets the two 
DataRange1D instances of its sub-mappers. (r23119, pwang)


* ScatterPlot.map_index() now respects the index_only flag (r23060, pwang)

* Fixed occasional traceback/bug in LinePlot that occurred when data was 
completely outside the visible range (r23059, pwang)


* Implementing is_in() on legends to account for padding and alignment 
(caused by tools that move the legend) (r23052, bhendrix)


* Legend behaves properly when there are no plots to display (r23012, judah)

* Fixed LogScale in the chaco.scales package to correctly handle the 
case when the length of the interval is less than a decade (r22907, 
warren.weckesser)


* Fixed traceback when calling copy_traits() on a DataView (r22894, vibha)

* Scatter plots generated by Plot.plot() now properly use the auto 
coloring feature of Plot. (r22727, pwang)


* Reduced the size of screenshots in the user manual. (r22720, rkern)


Mayavi
--

* 17, 18 March, 2009 (PR):
* NEW: A simple example to show how one can use TVTK’s visual module 
with mlab. [23250]
* BUG: The size trait was being overridden and was different from the 
parent causing a bug with resizing the viewer. [23243]


* 15 March, 2009 (GV):
* ENH: Add a volume factory to mlab that knows how to set color, vmin 
and vmax for the volume module [23221].


* 14 March, 2009 (PR):
* API/TEST: Added a new testing entry point: ‘mayavi -t’ now runs tests 
in separate process, for isolation. Added enthought.mayavi.api.test to 
allow for simple testing from the interpreter [23195]...[23200], 
[23213], [23214], [23223].
* BUG: The volume module was directly importing the wx_gradient_editor 
leading to an import error when no wxPython is available. This has been 
tested and fixed. Thanks to Christoph Bohme for reporting this issue. 
[23191]


* 14 March, 2009 (GV):
* BUG: [mlab]: fix positioning for titles [23194], and opacity for 
titles and text [23193].
* ENH: Add the mlab_source attribute on all objects created by mlab, 
when possible [23201], [23209].
* ENH: Add a message to help the first-time user, using the new banner 
feature of the IPython shell view [23208].


* 13 March, 2009 (PR):
* NEW/API: Adding a 

[ANN]: circuits 1.1.1 - a Lightweight, Event driven Framework with a strong Component Architecture.

2009-03-24 Thread James Mills
Hi,

I'm pleased to announce the 1.1.1 release
of circuits: http://trac.softcircuit.com.au/circuits/

This is a minor bug fix release.

== Links ==
 Home Page:: http://trac.softcircuit.com.au/circuits/
 Mailing list:: http://groups.google.com.au/group/circuits-users/
 Download:: http://trac.softcircuit.com.au/circuits/downloads/
 Library Reference::
http://trac.softcircuit.com.au/circuits/export/tip/docs/html/index.html

cheers

James

--
-- Problems are solved by method
--
http://mail.python.org/mailman/listinfo/python-announce-list

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


User athentication in Python/wxpython

2009-03-24 Thread jai_python
Hi friends,
I  need to do one client side application which is for uploading files
to remote server with ude ftp. only authenticated users are permitted
to access it, how can i pass the ftp connection in different py files?

Help would be thankful
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the difference between generating a value and returning a value?

2009-03-24 Thread alex23
On Mar 24, 3:10 pm, John Yeung gallium.arsen...@gmail.com wrote:
 In my opinion, it's especially poor form to use the term
 generate in that context when the language you are using to explain
 these concepts has very specific things called generators.

In its defense, I'm pretty sure 'How to Think Like a Computer
Scientist' predates the introduction of generators to Python.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Does Python have certificate?

2009-03-24 Thread Kay Schluehr
On 24 Mrz., 05:30, Steve Holden st...@holdenweb.com wrote:

  No, there is no certification for Python. Maybe in the future...

 O'Reilly School of Technology have plans to offer a Python
 certification. But I have to write the courses first :)

If you're done with it I'd additionally suggest the honory title of a
VIPP: Very Important Python Programmer. VIPPs receive a sticker with a
Python logo and are immediately spotted this way by their numerous
fans.

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


Re: Query regarding Python sybase module

2009-03-24 Thread Kushal Kumaran
On Tue, 24 Mar 2009 09:53:02 +0530 (IST)
srinivasan srinivas sri_anna...@yahoo.co.in wrote:

 
 Hi,
 Does Sybase Python driver module implement multiple result sets from
 a single command? Could anyone guide e in finding answer for this?
 
 

The site http://python-sybase.sourceforge.net/sybase/ has the
documentation for the python sybase module.  See the documentation of
the Cursor object to find out how to use multiple result sets.

-- 
kushal


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


Re: how to convert from Decimal('1.23456789') to Decimal('1.234')

2009-03-24 Thread Steven D'Aprano
On Mon, 23 Mar 2009 17:19:48 -0700, Mensanator wrote:

  And it also gives different results to my function: my function
  rounds to places decimal places, yours to i digits. Very
  different things.

  Yeah, I know all about that. I work in Environmental Remediation.
  That's real science, where rounding to decimal places is strictly
  forbidden, significant digits must be preserved. That means rounding
  to digits.

 Okay, so in other words you solved your problem rather than the OP's
 problem.
 
 People other than the OP read these threads. Do you want to give people
 the impression that quantize is the only option?

The only option for what? Solving the OP's problem, or your problem, or 
some other problem? How many different problems are we going to solve in 
this thread?

At the very least, when taking a detour to solve a different problem, say 
so, and point out why your problem is a more interesting/useful problem 
to solve.


  Do
  you know what kind of hoops I have to jump through to get Access or
  Excel to round properly when doing unit conversion?

 I feel your pain.
 
 So surely you don't want to give the impression that all Decimal is good
 for is emulating Excel?

That's a non sequitor. It does not follow that just because I sympathize 
with your difficulties with Excel, that I therefore want to give the 
impression that Decimal is only good for emulating Excel.


  Surely you're not so maive that you think dividing by 1000 simply
  moves the decimal point three places?

 Of course it does, if you're using real numbers.
 
 Computers have real numbers?

You don't have to use computers to divide by 1000. As difficult as it is 
to believe, throughout history people have done mathematical calculations 
without the use of computing devices.


 If you're using floats,
 no, not quite, there are rounding issues involved, and underflow.
 
 And that's why we have Decimal, right?

I'm sure that the Decimal standard wasn't invented just so people can 
divide by 1000.



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


Re: file.read() doesn't read the whole file

2009-03-24 Thread Sreejith K
On Mar 24, 7:15 am, Gabriel Genellina gagsl-...@yahoo.com.ar
wrote:
 En Mon, 23 Mar 2009 21:37:14 -0300, R. David Murray  
 rdmur...@bitdance.com escribió:



  Steve Holden st...@holdenweb.com wrote:
  Sreejith K wrote:
   Try and write an example that shows the problem in fifteen lines or
   less. Much easier for us to focus on the issue that way.

   import os
   def read(length, offset):
     os.chdir('/mnt/gfs_local/')
     snap = open('mango.txt_snaps/snap1/0','r')
     snap.seek(offset)
     data = snap.read(length)
     print data

   read(4096,0)

   This code shows what actually happens inside the code I've written.
   This prints the 4096 bytes from the file '0' which is only 654 bytes.
   When we run the code we get the whole file. That's right. I also get
   it. But when this read() function becomes the file class read()
   function in fuse, the data printed is not the whole but only a few
   lines from the beginning.

  This is confusing. I presume you to mean that when you make this
  function a method of some class it stops operating correctly?

  But I am not sure.

  I am still struggling to understand your problem. Sorry,it's just a
  language thing. If we take our time we will understand each other in the
  end.

  You may be asking this question for pedagogical reasons, Steve, but
  in case not...the OP is apparently doing a 'less ' where  is
  the name of a file in a fuse filesystem (that is, a mounted filesystem
  whose back end is some application code written by the OP).
 [...]
  There are several steps between that 'snap.read' and less displaying on
  the terminal whatever bytes it got back from its read call in whatever
  way it is less chooses to display them

 And that's why everyone is asking for a *real* log. Assumptions like foo  
 must be 0 here aren't enough. One needs *evidence*: a log file showing  
 the value of foo right when it is used. Then, one can begin to infer  
 what happens -- first step would be to determine *which* layer is (or is  
 not) responsible for the misbehavior.

 In this case, I'd like to see file.tell(), the requested size and the  
 returned data length, *right*at*the*read()*call*.

 --
 Gabriel Genellina

R. David Murray understood the problem very well. As you've said I
logged the data returned and see that it actually the complete file.
But the problem is when 'less'ing only two lines are displayed. So its
not regarding the read() of python. Usually in fuse filesystems (as in
some examples), when some file read occurs fuse catch it and calls the
python-fuse's read(length, offset) function. For small files (when we
read using 'less'), this will be usually the first block i.e 4096 with
offset 0. We return what we read from the read() method of fuse-
python. But when I return the data I read, a 'less' operation in my
fuse filesystem shows some lines only, even if the returned data is
the whole file.

In my implementation of fuse-filesystem when a read is called, instead
of returning the data read from the original file, I return the data
read from another file ('0') which resides in original-file__snaps/
snap1 directory (I use this directory to store the blocks of original
files when write occurs. So each file here would be 4096 bytes). I'm
doing this because I want to make snapshots of files so that I can
restore the older file easily. The problem occurs when reading this
file and returning the read data.

Some flush/release functions are there in fuse to properly close the
opened file. When reading (less) the original file without snapshots,
there is no issue. But when reading the snapshot instead, the problem
occurs. I open the snapshot file with the same modes as the original
file. Is there anything I should do after read() like the flush() as
for the original file ? I tried it, but no success...

Log when reading from snapshot
===
Read length: 4096 offset: 0
Snapshot 0 opened..
Snap read
===Data Begin===
Getting started -- pdb.set_trace()

To start, I'll show you the very simplest way to use the Python
debugger.

   1. Let's start with a simple program, epdb1.py.

  # epdb1.py -- experiment with the Python debugger, pdb
  a = aaa
  b = bbb
  c = ccc
  final = a + b + c
  print final


   2. Insert the following statement at the beginning of your Python
program. This statement imports the Python debugger module, pdb.

  import pdb

   3. Now find a spot where you would like tracing to begin, and
insert the following code:

  pdb.set_trace()
===Data End
snap.tell(): 654
data size : 654
Original file flushed
Original file closed

data is the whole file, but 'less' gives only the two lines...
--
http://mail.python.org/mailman/listinfo/python-list


Re: Does Python have certificate?

2009-03-24 Thread Hendrik van Rooyen
Kay Schluehr ka..@gmx.net wrote:

 On 24 Mrz., 05:30, Steve Holden st...@holdenweb.com wrote:

  O'Reilly School of Technology have plans to offer a Python
  certification. But I have to write the courses first :)
 
 If you're done with it I'd additionally suggest the honory title of a
 VIPP: Very Important Python Programmer. VIPPs receive a sticker with a
 Python logo and are immediately spotted this way by their numerous
 fans.

I like the idea, but I would suggest that the award be
limited to the first 100 participants and that the title be:

Very Important Python Early Responder

- Hendrik

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


Re: Relative Imports, why the hell is it so hard?

2009-03-24 Thread CinnamonDonkey
Thanx Max - your explanation sorted it :-), and a big thank you to
everyone else also!

From the various posts, Python considers any directory containing the
__init__.py file to be a package. The top level package is the highest
directory (closest to root) with a __init__.py file.

Inter-package communication is not allowed unless the packages
themselves are contained by a parent package.

How does this relate to the site-packages folder? Is it a top level
package for all installed packages?

Let's say I have installed the Trac system which uses Genshi, they
are both packages. They are also both installed at the same level and
I know Trac uses Genshi to work. \Python25\Lib\site-packages does
not contain a __init__.py file so it is not a package (i.e. not a
parent package to Trac and Genshi) :0.


-=- bearophile -=-

Hi Bearophile,

Thanx for taking the time to post a response but I am afraid I feel
the need to point out that it is exactly this kind of response that I
find un-helpful. It is neither constructive nor educational.

It's a bit like saying If you don't know what a function is, then
maybe you don't need it. ... have you tried having a single block of
code?

The point of people coming to these forums is to LEARN and share
knowledge. Perhaps it's not the best solution for me right now but
without trying it I won't know when or how to apply it as a solution.

By the way, my project has about 50 files (modules) in it with a lot
of shared code that could be used across other projects... seems as
good a reason as any to try packages out ;-)

Thanx anyway :)


On 23 Mar, 18:57, bearophileh...@lycos.com wrote:
 CinnamonDonkey:

 what makes something a package?

 If you don't know what a package is, then maybe you don't need
 packages.

 In your project is it possible to avoid using packages and just use
 modules in the same directory?

 Bye,
 bearophile

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


Re: file.read() doesn't read the whole file

2009-03-24 Thread Ant
On Mar 24, 7:59 am, Sreejith K sreejith...@gmail.com wrote:
...
 data is the whole file, but 'less' gives only the two lines...

From this statement (that you are using less), it appears that you are
redirecting sys.stdout to a file or similar - if that is the case, you
may need to flush or close the output file before it picks up any
changes.
--
http://mail.python.org/mailman/listinfo/python-list


Re: udp package header

2009-03-24 Thread Nick Craig-Wood
mete metebilgi...@gmail.com wrote:
  I got a problem. İ want to send udp package and get this package (server and 
  clinet ). it's easy to python but i want to look the udp header how can i 
  do ?

There is pretty much nothing in a UDP packet header except
from_address, to_address, from_port and to_port.  You should already
know to_address and to_port and socket.recv will give you the
from_address and from_port

socket.recvfrom(bufsize[, flags])

Receive data from the socket. The return value is a pair (string,
address) where string is a string representing the data received
and address is the address of the socket sending the data.

-- 
Nick Craig-Wood n...@craig-wood.com -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list


Re: file.read() doesn't read the whole file

2009-03-24 Thread Sreejith K
On Mar 24, 2:12 pm, Ant ant...@gmail.com wrote:
 On Mar 24, 7:59 am, Sreejith K sreejith...@gmail.com wrote:
 ...

  data is the whole file, but 'less' gives only the two lines...

 From this statement (that you are using less), it appears that you are
 redirecting sys.stdout to a file or similar - if that is the case, you
 may need to flush or close the output file before it picks up any
 changes.

Yes, I did try a flush() and close on the file which is read, but the
result is the same. I think when a read comes in fuse redirecting the
actual path (original file) to some other file for reading causes some
issues like this. It would be really helpful if someone help me clear
this issue. The getattr() calls are actually called upon the original
file (doing an os.lstat()). Does this make any effect on the 'less'
output ?
--
http://mail.python.org/mailman/listinfo/python-list


importing modules from alternate path

2009-03-24 Thread Alexandru Moșoi
I'm trying with no succes to load modules from an alternate path. When
installing to default location (no --home specifed) everything works
as expected.

$ python setup.py install --home=~
running install
running build
running build_ext
running install_lib
running install_egg_info
Removing /home/voodoo/lib/python/PackageName-1.0-py2.6.egg-info
Writing /home/voodoo/lib/python/PackageName-1.0-py2.6.egg-info

$ printf import demo | PYTHONPATH=~ python
Traceback (most recent call last):
  File stdin, line 1, in module
ImportError: No module named demo

$ printf import demo | PYTHONHOME=~ python
Traceback (most recent call last):
  File stdin, line 1, in module
ImportError: No module named demo


Any idea why alternate path is not working?


- BEGIN OF setup.py
from distutils.core import setup, Extension

module1 = Extension('demo',
sources = ['demo.c'])

setup (name = 'PackageName',
   version = '1.0',
   description = 'This is a demo package',
   ext_modules = [module1])
- END OF end setup.py

- BEGIN OF demo.c
#include Python.h

static PyObject* demo_bla(PyObject *self) {
return Py_BuildValue(i, 666);
}
- END OF demo.c
--
http://mail.python.org/mailman/listinfo/python-list


Re: Does Python have certificate?

2009-03-24 Thread Paddy3118
On Mar 24, 1:50 am, Johannes Bauer dfnsonfsdu...@gmx.de wrote:
 Sebastian Bassi schrieb:

  No, there is no certification for Python. Maybe in the future...

 I'll hand out the Johannes Bauer Python Certificate of Total
 Awesomeness for anyone who can write a hello world in python and hands
 me $25000 in cash.

 This whole certified foobar programmer is complete crap IMHO.

 The above offer stands nontheless.

 Kind regards,
 Johannes

 --
 Meine Gegenklage gegen dich lautet dann auf bewusste Verlogenheit,
 verlästerung von Gott, Bibel und mir und bewusster Blasphemie.
          -- Prophet und Visionär Hans Joss aka HJP in de.sci.physik
                          48d8bf1d$0$7510$54022...@news.sunrise.ch

The Academy of Research into Science Education being a true leader in
the field offers acclaimed accreditation for Python programmers. Those
who pass our strict exams and pay our modest fees will earn our
prestigious certification.

Those who show promise can advance to our Winter Improve Python to
Expert program, for an additional fee, and, be given expert tutoring
to help you gain our exemplary A.R.S.E./W.I.P.E certification which is
guaranteed to attract certain types of employers by its name alone.

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


user site-packages, --prefix, --home and friends

2009-03-24 Thread Carl
I am very confused by PEP-370 per-user site-packages. It is not
mentioned at all in the document about installing Python modules :
http://docs.python.org/3.0/install/index.html.

It seems that --home or --prefix already provide per-user site-
packages capability. Can someone explain what are the differences and
what is the best practice in various situations?

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


Re: Does Python have certificate?

2009-03-24 Thread Johannes Bauer
Sebastian Bassi schrieb:

 No, there is no certification for Python. Maybe in the future...

I'll hand out the Johannes Bauer Python Certificate of Total
Awesomeness for anyone who can write a hello world in python and hands
me $25000 in cash.

This whole certified foobar programmer is complete crap IMHO.

The above offer stands nontheless.

Kind regards,
Johannes

-- 
Meine Gegenklage gegen dich lautet dann auf bewusste Verlogenheit,
verlästerung von Gott, Bibel und mir und bewusster Blasphemie.
 -- Prophet und Visionär Hans Joss aka HJP in de.sci.physik
 48d8bf1d$0$7510$54022...@news.sunrise.ch
--
http://mail.python.org/mailman/listinfo/python-list


What's the difference between generating a value and returning a value?

2009-03-24 Thread grocery_stocker
Taken from the url

http://openbookproject.net/thinkCSpy/ch05.xhtml#index15

The built-in functions we have used, such as abs,
pow, and max, have produced results.  Calling each of
these functions generates a value, which we usually assign to a
variable or
use as part of an expression.


biggest = max(3, 7, 2, 5)
x = abs(3 - 11) + 10

But so far, none of the functions we have written has returned a
value.

In this chapter, we are going to write functions that return values,
which
we will call fruitful functions,

So what's the difference between generating a value and returning a
value?



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


how to get the summarized text from a given URL?

2009-03-24 Thread Rama Vadakattu
Is there any python library to solve the below problem?

FOr the below URL :
--
http://tinyurl.com/dzcwbg

Summarized text is :
---
By Roy Mark With sales plummeting and its smart phones failing to woo
new customers, Sony Ericsson follows its warning that first quarter
sales will be disappointing with the announcement that Najmi Jarwala,
president of Sony Ericsson USA and head of ...

~~
Usually summarized text is a  2 to 3 line description of the URL which
we usually obtain by fetching that html page , examining the  content
and  figuring out short description from that html markup.
~

Are there any python libraries which give summarized text for a given
url ?

It is ok even if the library  just gives  intial two lines of text
from the given URL Instead of summarization.
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the difference between generating a value and returning a value?

2009-03-24 Thread Daniel Dalton
On Mon, Mar 23, 2009 at 03:12:19PM -0700, grocery_stocker wrote:
 So what's the difference between generating a value and returning a
 value?

Well when you return, you would use the return keyword, I would
imagine... I guess generating could mean many things, you can generate a
value by operating on something, but I guess this does imply returning a
value, because the function returning the value is generating a new
value... But, I know for sure that when you return a value it is the
information the function returns to the caller after operating on either
no, or some arguments.

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


importing modules from alternate path

2009-03-24 Thread R. David Murray
=?UTF-8?Q?Alexandru__Mo=C8=99oi?= brtz...@gmail.com wrote:
 I'm trying with no succes to load modules from an alternate path. When
 installing to default location (no --home specifed) everything works
 as expected.
 
 $ python setup.py install --home=~
 running install
 running build
 running build_ext
 running install_lib
 running install_egg_info
 Removing /home/voodoo/lib/python/PackageName-1.0-py2.6.egg-info
 Writing /home/voodoo/lib/python/PackageName-1.0-py2.6.egg-info
 
 $ printf import demo | PYTHONPATH=~ python
 Traceback (most recent call last):
   File stdin, line 1, in module
 ImportError: No module named demo
 
 $ printf import demo | PYTHONHOME=~ python
 Traceback (most recent call last):
   File stdin, line 1, in module
 ImportError: No module named demo
 
 
 Any idea why alternate path is not working?

Possibly because the package gets installed into ~/lib/python, but
you haven't put that directory onto the PYTHONPATH.

--
R. David Murray   http://www.bitdance.com

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


Re: file.read() doesn't read the whole file

2009-03-24 Thread R. David Murray
Sreejith K sreejith...@gmail.com wrote:
 On Mar 24, 2:12 pm, Ant ant...@gmail.com wrote:
  On Mar 24, 7:59 am, Sreejith K sreejith...@gmail.com wrote:
  ...
 
   data is the whole file, but 'less' gives only the two lines...
 
  From this statement (that you are using less), it appears that you are
  redirecting sys.stdout to a file or similar - if that is the case, you
  may need to flush or close the output file before it picks up any
  changes.

It's not a redirect to a file.  Fuse calls the 'read' function on the
class, the read function does a 'return' of the data, and fuse passes
the data up through the OS layer to be the result of the 'read' call
made by less.

If you don't know what a fuse file system is, this all gets very confusing :)

 Yes, I did try a flush() and close on the file which is read, but the
 result is the same. I think when a read comes in fuse redirecting the
 actual path (original file) to some other file for reading causes some
 issues like this. It would be really helpful if someone help me clear
 this issue. The getattr() calls are actually called upon the original
 file (doing an os.lstat()). Does this make any effect on the 'less'
 output ?

I'm afraid we are getting beyond my level of fuse-foo here.  You'd
probably be better off finding a fuse or even fuse-python mailing list
and trying there.

If it were me, I'd start logging everything I could (take a look at
Python's 'logging' module to help you make that easy), and twidling
things.  What happens if you change what gets returned to lstat?
What happens for various sizes and contents of the '0' file?  What
happens if you use 'cat -v' or hexdump instead of less to read the file?
Run experiments until you gather enough clues to make a guess as to what
is going on, then test your theory.  Repeat until success :)

--
R. David Murray   http://www.bitdance.com

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


Re: What's the difference between generating a value and returning a value?

2009-03-24 Thread Dave Angel
Clearly, there's no difference, from the wording you quoted.  He uses 
three words more or less interchangeably, produced, generated and 
returned.


The distinction he's making is not between these words, but between the 
built-in functions, which are already returning values, and the ones 
that he has had the user write so far, that do not.


DaveA

grocery_stocker wrote:

Taken from the url

http://openbookproject.net/thinkCSpy/ch05.xhtml#index15

The built-in functions we have used, such as abs,
pow, and max, have produced results.  Calling each of
these functions generates a value, which we usually assign to a
variable or
use as part of an expression.


biggest = max(3, 7, 2, 5)
x = abs(3 - 11) + 10

But so far, none of the functions we have written has returned a
value.

In this chapter, we are going to write functions that return values,
which
we will call fruitful functions,

So what's the difference between generating a value and returning a
value?




  

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


Re: how to get the summarized text from a given URL?

2009-03-24 Thread Peter Otten
Rama Vadakattu wrote:

 Is there any python library to solve the below problem?
 
 FOr the below URL :
 --
 http://tinyurl.com/dzcwbg
 
 Summarized text is :
 ---
 By Roy Mark With sales plummeting and its smart phones failing to woo
 new customers, Sony Ericsson follows its warning that first quarter
 sales will be disappointing with the announcement that Najmi Jarwala,
 president of Sony Ericsson USA and head of ...
 
 ~~
 Usually summarized text is a  2 to 3 line description of the URL which
 we usually obtain by fetching that html page , examining the  content
 and  figuring out short description from that html markup.
 ~
 
 Are there any python libraries which give summarized text for a given
 url ?

BeautifulSoup makes it easy to access parts of a web page. 

import urllib2
from BeautifulSoup import BeautifulSoup

data = urllib2.urlopen(http://tinyurl.com/dzcwbg;).read()
bs = BeautifulSoup(data)
print bs.find(meta, dict(name=description))[content]

 It is ok even if the library  just gives  intial two lines of text
 from the given URL Instead of summarization.

The problem is how you identify the summary. Different web sites will put it
in different places using different markup.

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


Re: Relative Imports, why the hell is it so hard?

2009-03-24 Thread Maxim Khitrov
On Tue, Mar 24, 2009 at 5:05 AM, CinnamonDonkey
cinnamondon...@googlemail.com wrote:
 Thanx Max - your explanation sorted it :-), and a big thank you to
 everyone else also!

 From the various posts, Python considers any directory containing the
 __init__.py file to be a package. The top level package is the highest
 directory (closest to root) with a __init__.py file.

 Inter-package communication is not allowed unless the packages
 themselves are contained by a parent package.

 How does this relate to the site-packages folder? Is it a top level
 package for all installed packages?

 Let's say I have installed the Trac system which uses Genshi, they
 are both packages. They are also both installed at the same level and
 I know Trac uses Genshi to work. \Python25\Lib\site-packages does
 not contain a __init__.py file so it is not a package (i.e. not a
 parent package to Trac and Genshi) :0.

Trac does not use relative imports to access genshi. When relative
imports are not used, python goes through sys.path list to find
modules (with a small exception made when absolute_imports are not
enabled, but that should be default in 2.7). The site-packages
directory is added to sys.path, so when trac executes something like
from genshi import some_module, python will look in site-packages,
among other directories, for a directory called genshi that contains
an __init__.py file.

When you execute a script, the directory of that script is
automatically added to sys.path, so with your example you could have
used absolute imports between subpack1 and subpack2, with the \App
directory performing the same function as site-packages (Gabriel's
suggestion). This is for your original version of the code when
main.py was under App.

Once you moved main.py outside of \App, running import sybpack2
would no longer work. You can, however, append directories to
sys.path, so by doing the following in main.py you could again allow
non-relative imports between subpack1 and subpack2:

import os
import sys

sys.path.append(os.path.realpath('App'))

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


Re: Relative Imports, why the hell is it so hard?

2009-03-24 Thread R. David Murray
Top posting corrected for clarity.

CinnamonDonkey cinnamondon...@googlemail.com wrote:
 On 23 Mar, 18:57, bearophileh...@lycos.com wrote:
  CinnamonDonkey:
 
  what makes something a package?
 
  If you don't know what a package is, then maybe you don't need
  packages.
 
  In your project is it possible to avoid using packages and just use
  modules in the same directory?
 
  Bye,
  bearophile

 Hi Bearophile,
 
 Thanx for taking the time to post a response but I am afraid I feel
 the need to point out that it is exactly this kind of response that I
 find un-helpful. It is neither constructive nor educational.
 
 It's a bit like saying If you don't know what a function is, then
 maybe you don't need it. ... have you tried having a single block of
 code?
 
 The point of people coming to these forums is to LEARN and share
 knowledge. Perhaps it's not the best solution for me right now but
 without trying it I won't know when or how to apply it as a solution.
 
 By the way, my project has about 50 files (modules) in it with a lot
 of shared code that could be used across other projects... seems as
 good a reason as any to try packages out ;-)
 
 Thanx anyway :)

I think bearophile could have left out the first sentence, but otherwise
his question is perfectly sensible.  If you have a bunch of independent
modules, then you don't need to put them in packages.  Your example
only showed one module file in each package...I understand now that was
just for simplicity of the example, but we had no way of knowing that.
We've had newbies come in and think they _need_ to put a module file into
a subpackage even when they'd only have one module file per subdirectory
and they don't really know what a package is...thus bearophile's (perhaps
poorly phrased) question.

Now that you know what packages are and what the restrictions on relative
imports are, and you've told us that you have '50 modules' with a lot
of shared code that 'could be used across other projects', perhaps you
see why relative imports are generally discouraged.  If you use only
relative imports, the code _can't_ be shared across multiple projects,
because all that project code would have to be in one monster package,
and not be separate projects at all.

So now you'll know better where it makes Pythonic (as opposed to C++)
sense to use it and where not.

--
R. David Murray   http://www.bitdance.com

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


install pyPgSQL on Windows for python 2.5

2009-03-24 Thread someone
Hi,

does anyone know how to install pyPgSQL on Windows? There is no
package for Python 2.5 on Homepage:

http://sourceforge.net/project/showfiles.php?group_id=16528package_id=20458release_id=423036

I've tried to install running: python setup.py install
But getting errors python setup.py install -

running install
running build
running build_py
running build_ext
error: Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible
binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin
installed,
you can try compiling with MingW32, by passing -c mingw32 to
setup.py.


I've installed newest Visual C++ Studio 2008 from Microsoft, but still
no luck

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


Unit testing frameworks

2009-03-24 Thread grkuntzmd
I am looking for a unit testing framework for Python. I am aware of
nose, but was wondering if there are any others that will
automatically find and run all tests under a directory hierarchy.

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


Re: file.read() doesn't read the whole file

2009-03-24 Thread Sreejith K
On Mar 24, 4:45 pm, R. David Murray rdmur...@bitdance.com wrote:
 Sreejith K sreejith...@gmail.com wrote:
  On Mar 24, 2:12 pm, Ant ant...@gmail.com wrote:
   On Mar 24, 7:59 am, Sreejith K sreejith...@gmail.com wrote:
   ...

data is the whole file, but 'less' gives only the two lines...

   From this statement (that you are using less), it appears that you are
   redirecting sys.stdout to a file or similar - if that is the case, you
   may need to flush or close the output file before it picks up any
   changes.

 It's not a redirect to a file.  Fuse calls the 'read' function on the
 class, the read function does a 'return' of the data, and fuse passes
 the data up through the OS layer to be the result of the 'read' call
 made by less.

 If you don't know what a fuse file system is, this all gets very confusing :)

  Yes, I did try a flush() and close on the file which is read, but the
  result is the same. I think when a read comes in fuse redirecting the
  actual path (original file) to some other file for reading causes some
  issues like this. It would be really helpful if someone help me clear
  this issue. The getattr() calls are actually called upon the original
  file (doing an os.lstat()). Does this make any effect on the 'less'
  output ?

 I'm afraid we are getting beyond my level of fuse-foo here.  You'd
 probably be better off finding a fuse or even fuse-python mailing list
 and trying there.

 If it were me, I'd start logging everything I could (take a look at
 Python's 'logging' module to help you make that easy), and twidling
 things.  What happens if you change what gets returned to lstat?
 What happens for various sizes and contents of the '0' file?  What
 happens if you use 'cat -v' or hexdump instead of less to read the file?
 Run experiments until you gather enough clues to make a guess as to what
 is going on, then test your theory.  Repeat until success :)

 --
 R. David Murray          http://www.bitdance.com

Thanks Murray, for your valuable opinions and suggestions. I'll try to
log everything from now on and find out what happens inside. :)
Surely I'll let you guys know what happened..
--
http://mail.python.org/mailman/listinfo/python-list


user site-packages, --prefix, --home and friends

2009-03-24 Thread R. David Murray
Carl tg2.u...@gmail.com wrote:
 I am very confused by PEP-370 per-user site-packages. It is not
 mentioned at all in the document about installing Python modules :
 http://docs.python.org/3.0/install/index.html.
 
 It seems that --home or --prefix already provide per-user site-
 packages capability. Can someone explain what are the differences and
 what is the best practice in various situations?

I'm by no means an authority, but by my reading of the PEP there are
two major items that differentiate --user from --prefix and --home:
automatic per-python-version installation, and handling of .pth files.

As for best practice, I would say whichever one meets your needs.
The PEP is addressing the needs of users who do not have root privs but
who want to install packages via distutils in such a way that they will
act as if they had been installed in the system site-packages directory.

--
R. David Murray   http://www.bitdance.com

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


Re: file.read() doesn't read the whole file

2009-03-24 Thread Sreejith K
 It's not a redirect to a file.  Fuse calls the 'read' function on the
 class, the read function does a 'return' of the data, and fuse passes
 the data up through the OS layer to be the result of the 'read' call
 made by less.

By redirection I meant reading the snapshot file instead of the
original file :). Sorry for making confusions
--
http://mail.python.org/mailman/listinfo/python-list


Re: Does Python have certificate?

2009-03-24 Thread ajaksu
Hendrik van Rooyen wrote:
 I like the idea, but I would suggest that the award be
 limited to the first 100 participants and that the title be:

 Very Important Python Early Responder

I'd pay good money for that if the 'I' could be customized to stand
for Ignorant :)

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


Bash-like brace expansion

2009-03-24 Thread Peter Waller
Okay, I got fed up with there not being any (obvious) good examples of
how to do bash-like brace expansion in Python, so I wrote it myself.
Here it is for all to enjoy!

If anyone has any better solutions or any other examples of how to do
this, I'd be glad to hear from them.

#~ BraceExpand.py - Bash-like brace expansion in Python
#~ Copyright (C) 2009 peter.wal...@gmail.com

#~ This program is free software: you can redistribute it and/or
modify
#~ it under the terms of the GNU Affero General Public License as
#~ published by the Free Software Foundation, either version 3 of the
#~ License, or (at your option) any later version.

#~ This program is distributed in the hope that it will be useful,
#~ but WITHOUT ANY WARRANTY; without even the implied warranty of
#~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#~ GNU Affero General Public License for more details.

#~ You should have received a copy of the GNU Affero General Public
License
#~ along with this program.  If not, see http://www.gnu.org/licenses/
.

import re
from itertools import imap

class NoBraces(Exception): pass

def BraceExpand(text, ordering = []):
Recursively brace expand text in a bash-like fashion.

See 'man 2 bash' under the heading 'Brace Expansion'

Example: /data/file{1..10}.root expands to file1.root ...
file9.root

Ordering allows changing the order of iteration. The rules for
this are
a little complicated. Ordering is a list of boolean values.
If it is possible to expand the postamble, the first value from
the list
is removed, and used to determine whether the postamble should be
iterated
over before iterating over the amble. The list is then passed
down
recursively to the next Brace.

What does this code do?

It is simpler than it looks.

There are three main steps:
  1) Split the string into three parts, consisting of pre-amble,
amble and
 post-amble. (This requires keeping track of nested {}'s.)
  2) In the amble, figure out which commas are not stuck in {}'s,
and
 split the string by those commas.
  3) For each part of this split string, Add together the pre-
amble, the
 string and the post-amble. Call BraceExpand() on this string
to deal
 with nested braces and any expansion required in the
postamble

Other things this code does which make it look more complicated:
  * Expand ranges along the lines of {1..10}
  * Allow for re-arranging the order of iteration

Todo/Not Implemented:
  * Escaping/quoting

Example C implementation from bash (inspiration for this):
http://www.oldlinux.org/Linux.old/bin/old/bash-1.11/braces.c


def FindMatchedBraces(text, position = -1):
Search for nested start and end brace in text starting from
position
braceDepth = 0
nextClose = -1
first = True

# Search for a {
# is it closer than the nearest } ?
#   Yes : increase brace depth
#   No  : decrease brace depth
# When we reach braceDepth == 0, we have found our close brace
while braceDepth or first:

nextOpen = text.find({, position+1)
nextClose = text.find(}, position+1)

if first and nextOpen = 0:
startBrace = nextOpen
first = False

if nextOpen  nextClose and nextOpen = 0:
braceDepth += 1
position = nextOpen
elif nextClose = 0:
braceDepth -= 1
position = nextClose
else:
raise NoBraces()

return startBrace, position

try: start, end = FindMatchedBraces(text)
except NoBraces:
# There are no braces! Nothing to expand!
return [text]

# Split the text into three bits, '{pre,,post}amble'. The 'pre' is
anything
# before expansion, the '' is the bit that needs expanding and
gluing to
# the pre and the post. After gluing together, we can recursively
expand
# again
preamble = text[:start]
amble = text[start+1:end]
postamble = text[end+1:]

def BareCommaSearcher(amble):
Search for commas which are not encapsulated in {}

haveBraces = True
try: start, end = FindMatchedBraces(amble)
except NoBraces: haveBraces = False

position = -1
while True:
position = amble.find(,, position+1)

if position  0:
# We didn't find any comma after 'position', finish
searching.
break

if haveBraces and start  position  end:
# We're inside some braces, skip to the end of them,
find the
# next set.
position = end

haveBraces = True
try: start, end = FindMatchedBraces(amble, position)
except NoBraces: haveBraces = False

continue

yield position

# Reached the end of 

Re: Bash-like brace expansion

2009-03-24 Thread Peter Waller
Okay, yuck. I didn't realise that posting would mangle the code so
badly. Is there any better way to attach code? I'm using google
groups.

On Mar 24, 12:28 pm, Peter Waller peter.wal...@gmail.com wrote:
 Okay, I got fed up with there not being any (obvious) good examples of
 how to do bash-like brace expansion in Python, so I wrote it myself.
 Here it is for all to enjoy!

 If anyone has any better solutions or any other examples of how to do
 this, I'd be glad to hear from them.

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


iPython 0.9.1 install under XP -- R6034

2009-03-24 Thread Esmail

Hello all,

I am having problems trying installing iPython under XP.
It works great under Linux and it would be great if I could
also use it when I have to be in Windows.

XP Professional SP2 + SP3 (tried different systems),
iPython-0.9.1, Python 2.6.1

During  Please wait while running postinstall script .. 
I get the following MS Visual C++ Runtime Error

R6034
An application has made an attempt to load th C runtime library incorrectly.
.

I get this message 4 or 5 times and eventually end up
with this:

*** run_installscript: internal error 0x ***

I've seen this error reported before while searching the web,
so I know I'm not the only one who has run into this problem,
but not seen any solutions.

Can anyone help?

Thanks,
Esmail


PS: I see a ipython users group, but I have been unable to post to
it despite trying for the last few days. Perhaps someone here
who uses iPython under XP can help.

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


Re: Relative Imports, why the hell is it so hard?

2009-03-24 Thread bearophileHUGS
CinnamonDonkey:
 It is neither constructive nor educational.

 It's a bit like saying If you don't know what a function is, then
 maybe you don't need it. ... have you tried having a single block of
 code?

 The point of people coming to these forums is to LEARN and share
 knowledge. Perhaps it's not the best solution for me right now but
 without trying it I won't know when or how to apply it as a solution.

 By the way, my project has about 50 files (modules) in it with a lot
 of shared code that could be used across other projects... seems as
 good a reason as any to try packages out ;-)

I don't agree. My answer can be wrong for your situation, but I can't
know much about you from the start, and for most people my answer was
the right one.

When a student asks me how to improve his/her usage of metaclasses I
usually answer that metaclasses aren't required to solve that small
problem.

Generally in engineering the simplest solution is the one you have to
try first (and often second and third), and only later, if practical
experience shows the simple solution doesn't work, you try a more
complex solution.

So I have suggested you a simple solution by default. If later you
see that you have many modules and you really need packages, then it's
easy to ignore my first answer.

Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list


Re: Bash-like brace expansion

2009-03-24 Thread bearophileHUGS
Peter Waller:
 Is there any better way to attach code?

This is a widely used place (but read the contract/disclaimer
first):
http://code.activestate.com/recipes/langs/python/

Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list


Re: Bash-like brace expansion

2009-03-24 Thread Peter Waller
2009/3/24 Tino Wildenhain t...@living-examples.com


 The simple {foo} expansion you mention should be quite easily handled
 with re.sub and a function as argument. So not much more then a few
 lines of code.


Could this approach be made to handle recursive expansion? From the example
with the script:

pprint(BraceExpand(electron_{n,{pt,eta,phi}[{1,2}]}, ordering = [True]))

Gives:

['electron_n',
 'electron_pt[1]',
 'electron_eta[1]',
 'electron_phi[1]',
 'electron_pt[2]',
 'electron_eta[2]',
 'electron_phi[2]']

Cheers,

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


Re: Bash-like brace expansion

2009-03-24 Thread Peter Waller
What one really wants is a re option capable of handling recursive
structures, something along the lines of what PHP has:

http://uk2.php.net/manual/en/regexp.reference.php

Under the 'Recursive Patterns' heading. As far as I am aware, no such thing
exists for Python (yet?).

2009/3/24 Peter Waller peter.wal...@gmail.com


 Could this approach be made to handle recursive expansion? From the example
 with the script:

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


Re: Query regarding Python sybase module

2009-03-24 Thread skip
Srini Does Sybase Python driver module implement multiple result sets
Srini from a single command?

I've used it to get multiple result sets from stored procedures, so I guess
the answer would be yes.  Something like this:

 params = curs.callproc('stored_procedure', params)
 while True:
...   rows = curs.fetchall()
...   print rows
...   if not curs.nextset():
... break

-- 
Skip Montanaro - s...@pobox.com - http://www.smontanaro.net/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Bash-like brace expansion

2009-03-24 Thread Tino Wildenhain

Peter Waller wrote:

Okay, I got fed up with there not being any (obvious) good examples of
how to do bash-like brace expansion in Python, so I wrote it myself.
Here it is for all to enjoy!

If anyone has any better solutions or any other examples of how to do
this, I'd be glad to hear from them.



It may be a funny experiment but I really fail to see the value in your
proposal.

The simple {foo} expansion you mention should be quite easily handled
with re.sub and a function as argument. So not much more then a few
lines of code.

Interesting could be to have {foo#bar} and {foo%bar} as well but again
I don't think the whole stuff would be very usefull anyway given the
%(foo)s form works quite well and has a host of options (for aligning
for example).

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


Re: Bash-like brace expansion

2009-03-24 Thread Ben Finney
Peter Waller peter.wal...@gmail.com writes:

 Okay, yuck. I didn't realise that posting would mangle the code so
 badly. Is there any better way to attach code?

Yes: Use a news client other than Google Groups.

 I'm using google groups.

Fix that, first.

-- 
 \ “Are you pondering what I'm pondering?” “I think so, Brain, but |
  `\why would anyone want a depressed tongue?” —_Pinky and The |
_o__)   Brain_ |
Ben Finney

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


Wiki syntax available when publishing on pypi

2009-03-24 Thread Luca
A non python, but pypi only related question:

Where I can find a reference guide about all what I can do with the
text infos about a pypi egg published?
Looking at others guys code I lear how to make links, bold text,
italic, lists...
For example one time I found how to insert an image in the text, but I
don't remember how.

There is a official refence about this?

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


Re: Wiki syntax available when publishing on pypi

2009-03-24 Thread andrew cooke

it's some form of restructured text, which is described at
http://docutils.sourceforge.net/rst.html

however, there seem to be various implementations; i don't know if pypi
exactly follows what is described there (i know i had a small problem with
some detail being inconsistent with that convention used in sphinx).

also - if there's any kind of syntax error, pypi displays the entire
description literally (and gives no other error feedback that i have
found).

andrew



Luca wrote:
 A non python, but pypi only related question:

 Where I can find a reference guide about all what I can do with the
 text infos about a pypi egg published?
 Looking at others guys code I lear how to make links, bold text,
 italic, lists...
 For example one time I found how to insert an image in the text, but I
 don't remember how.

 There is a official refence about this?

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




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


Re: Relative Imports, why the hell is it so hard?

2009-03-24 Thread CinnamonDonkey
Top responses guys! This has all helped increadibly.

Bearophile,

My applogies if I have offended you, but:

1. I can't know much about you from the start - Is kind of my point.
Perhaps it would be better to avoid jumping to conclusions and pre-
judging someones abilities simply because they are lacking knowledge
in a particular area.

Would it have been better if I had opened my thread with a copy of my
CV? I've got a Degree in Digital Systems Engineering (yes I am also an
Engineer)... I went on to do a Phd in AI and Robotics where I also
developed embedded systems. I bummed out on that after 3 years and
went on to work for a games company where I worked on 6 game titles
across 5 different platforms. I was a Lead Software Engineer for the
last 5 years. Before now moving on again.

2. I am also very much a follower of the K.I.S.S. approach, 9 times
out of 10 the simplest solution is often the best.

As an Engineer though I would also suggest that the best way to learn
is to try solving a problem being sure to constantly assess your
approach and then your final solution. By dismissing a possible avenue
you are dismissing a whole new path of knowledge. Is it not better to
try and fail than never try at all? Surely this is how we gain the
valuable experience we need.

By simply suggesting a simple default solution, I may never have
consider the alternatives nor understand why they are or are not
suitable.

3. I get your point about Students, sometimes there is such a thing as
too much knowledge or information overload. Whilst doing a PhD I had
to take labs and teach students... The approach I tried to take was
one off, You may not need packages, why do you think you need
packages? or This is how packages would be used and why they would
be used... do you still think you need packages or better still, for
a capable student, This is how packages work, try solving your
problem and then tell me if you think it was a good solution.


Going with R. David Murray, perhaps I also jumped too my own
conclusion too quickly and for that I appologise.

Cheers,
Shaun





On 24 Mar, 12:37, bearophileh...@lycos.com wrote:
 CinnamonDonkey:

  It is neither constructive nor educational.

  It's a bit like saying If you don't know what a function is, then
  maybe you don't need it. ... have you tried having a single block of
  code?

  The point of people coming to these forums is to LEARN and share
  knowledge. Perhaps it's not the best solution for me right now but
  without trying it I won't know when or how to apply it as a solution.

  By the way, my project has about 50 files (modules) in it with a lot
  of shared code that could be used across other projects... seems as
  good a reason as any to try packages out ;-)

 I don't agree. My answer can be wrong for your situation, but I can't
 know much about you from the start, and for most people my answer was
 the right one.

 When a student asks me how to improve his/her usage of metaclasses I
 usually answer that metaclasses aren't required to solve that small
 problem.

 Generally in engineering the simplest solution is the one you have to
 try first (and often second and third), and only later, if practical
 experience shows the simple solution doesn't work, you try a more
 complex solution.

 So I have suggested you a simple solution by default. If later you
 see that you have many modules and you really need packages, then it's
 easy to ignore my first answer.

 Bye,
 bearophile

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


Re: PEP 3143: Standard daemon process library

2009-03-24 Thread Jean-Paul Calderone

On Tue, 24 Mar 2009 15:42:46 +1100, Ben Finney 
bignose+hates-s...@benfinney.id.au wrote:

Jean-Paul Calderone exar...@divmod.com writes:

[snip]


An additional feature which would be useful for the library to
provide, however, would be the setting of euid and egid instead of
uid and gid. This is necessary, for example, to write an SSH daemon
which gives out user shells.


That sounds rather more specific than is needed for the generic
library being proposed here. I'm wary of adding features to an API
that is already quite complex.

Isn't setting the EUID and EGID something that is just as easily done
*after* the program achieves a daemon process?


That depends.

If you mean that one can ignore the uid and gid setting features of the
proposed library so that they are not changed during daemonization and
then make the appropriate calls from the application afterwards, then
yes.

Otherwise, no.  Since this means all of your daemon startup code is forced
to run as a privileged process when it might otherwise have run without
those privileges, I think it's worth the tiny additional complexity it
will bring to the API (and it really is pretty tiny, something on the order
of a new `set_effective=True´ flag).

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


Re: Unit testing frameworks

2009-03-24 Thread Jean-Paul Calderone

On Tue, 24 Mar 2009 05:06:47 -0700 (PDT), grkunt...@gmail.com wrote:

I am looking for a unit testing framework for Python. I am aware of
nose, but was wondering if there are any others that will
automatically find and run all tests under a directory hierarchy.


One such tool is trial, http://twistedmatrix.com/trac/wiki/TwistedTrial

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


Re: Unit testing frameworks

2009-03-24 Thread andrew cooke
grkunt...@gmail.com wrote:
 I am looking for a unit testing framework for Python. I am aware of
 nose, but was wondering if there are any others that will
 automatically find and run all tests under a directory hierarchy.

not exactly a framework, but useful while working on small projects - you
can run tests from inside eclipse (using the pydev plugin for python). 
it's easy to run all tests or some small subset (although it is a bit
buggy for 3.0).

andrew


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


Re: Another of those is issues.

2009-03-24 Thread J. Cliff Dyer
On Fri, 2009-03-20 at 11:20 -0700, Emanuele D'Arrigo wrote:
 Hi everybody,
 
 I was unit testing some code today and I eventually stumbled on one of
 those is issues quickly solved replacing the is with ==. Still,
 I don't quite see the sense of why these two cases are different:
 
  def aFunction():
 ... pass
 ...
  f = aFunction
  f is aFunction
 True   --- Ok, this seems reasonable. Nevertheless, I suspect I
 shouldn't quite rely on it.
 
  class MyClass(object):
 ... def myMethod(self):
 ... pass
 ...
  c = MyClass()
  m = c.myMethod
  m is c.myMethod
 False  --- What? Why is that?
 
 In my mind I was expecting that when the method is assigned to m all
 that it happens is that its address is assigned to the name m so
 that effectively the same address is now pointed to by two names, like
 in the function case. I googled around for some hint but I wouldn't
 exactly say I'm clear on the issue just yet...
 
 Can anybody shed some light? Or point to a resource to look at? Or
 what's the bit of python's source code that is responsible for dealing
 with those assignments?
 
 Manu
 

So here's a f'rinstance counterexample for you:

class TempAttributeClass(object):
  def __init__(self):
self.temp = True

  def foo(self, x):
return len(x) + 1

  def __getattribute__(self, attr):
attribute = object.__getattribute__(self,attr)
if hasattr(attribute, '__call__'):
  if object.__getattribute__(self, 'temp'):
self.temp = False
return len
  else:
return attribute
else:
  return attribute

The first time a method is accessed from an instance of this class, it
will return len instead.

 print TempAttributeClass.foo
unbound method TempAttributeClass.foo
 c = TempAttributeClass()
 l = [1,2,3]
 x = c.foo
 x(l) 
3
 c.foo
4
 x == c.foo
False
 print x
built-in function len
 print y
bound method TempAttributeClass.foo of __main__.TempAttributeClass
object at 0x7f672b35e290

c.foo is a bound attribute, but what has it been bound to?  Well, I
guess it technically, it's bound to the instance c, but what has it been
bound from?  That depends first on what it encounters when traversing
its base classes, and second on how it's accessing its attributes.  As
the example above shows, python is too dynamic to make any guarantees
about any of that.

Another way you could mess with that is by changing the __class__
attribute on c.

class A(object):
x = 4
def __init__(self):
self.y = 5

class B(object):
x = u'cow'
def __init__(self):
self.y = u'goat'

 c = A()
 c.x
4
 c.y
5
 c.__class__ = B
 # Note that neither c nor x were changed in the last step
... c.x # Class attribute found on B now
u'cow'
 c.y # Instance attribute: already initialized from A.__init__
5
 c.__init__() # Reinitialize c, now using B.__init__
 c.y # Re-initialized instance attribute
u'goat'


Cheers,
Cliff



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


Re: Bash-like brace expansion

2009-03-24 Thread Nick Craig-Wood
Peter Waller peter.wal...@gmail.com wrote:
  Okay, I got fed up with there not being any (obvious) good examples of
  how to do bash-like brace expansion in Python, so I wrote it myself.
  Here it is for all to enjoy!

Interesting!

Might I suggest some unit tests?  You can then test all the corner
cases (unmatched brackets, empty brackets, etc) and be sure it works
exactly as specified.  doctest is cool for this kind of stuff.

-- 
Nick Craig-Wood n...@craig-wood.com -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list


Re: Does Python have certificate?

2009-03-24 Thread MRAB

Johannes Bauer wrote:

Sebastian Bassi schrieb:


No, there is no certification for Python. Maybe in the future...


I'll hand out the Johannes Bauer Python Certificate of Total
Awesomeness for anyone who can write a hello world in python and hands
me $25000 in cash.

This whole certified foobar programmer is complete crap IMHO.

The above offer stands nontheless.


The Johannes Bauer Certificate of Really Awesome Python? ;-)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Unit testing frameworks

2009-03-24 Thread Maxim Khitrov
On Tue, Mar 24, 2009 at 8:06 AM,  grkunt...@gmail.com wrote:
 I am looking for a unit testing framework for Python. I am aware of
 nose, but was wondering if there are any others that will
 automatically find and run all tests under a directory hierarchy.

Have you already looked at the unittest module? Below is the code I
use for one of my current projects to load all test cases in package.
This code is sitting in __init__.py, and the test cases are in
separate files (util.py, util_threading.py, etc.). Those files can
contain as many TestCase classes as needed, all are loaded with
loadTestsFromModule. You could easily modify this code to
automatically generate the modules list if you want to.

# repo/pypaq/test/__init__.py
from unittest import TestSuite, defaultTestLoader

import logging
import sys

__all__ = ['all_tests']
modules = ['util', 'util_buffer', 'util_event', 'util_threading']

if not __debug__:
raise RuntimeError('test suite must be executed in debug mode')

all_tests = []

for name in modules:
module = __import__('pypaq.test', globals(), locals(), [name], 0)
tests  = defaultTestLoader.loadTestsFromModule(getattr(module, name))

__all__.append(name)
all_tests.append(tests)
setattr(sys.modules[__name__], name, tests)

logging.getLogger().setLevel(logging.INFO)
all_tests = TestSuite(all_tests)

I then have test_pypaq.py file under repo/, with which I can execute
all_tests or only the tests from a specific module:

# repo/test_pypaq.py
from unittest import TextTestRunner
from pypaq.test import *

TextTestRunner(verbosity=2).run(all_tests)

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


Re: iPython 0.9.1 install under XP -- R6034

2009-03-24 Thread David Cournapeau
On Tue, Mar 24, 2009 at 9:36 PM, Esmail ebo...@hotmail.com wrote:
 Hello all,

 I am having problems trying installing iPython under XP.
 It works great under Linux and it would be great if I could
 also use it when I have to be in Windows.

 XP Professional SP2 + SP3 (tried different systems),
 iPython-0.9.1, Python 2.6.1

 During  Please wait while running postinstall script .. 
 I get the following MS Visual C++ Runtime Error

 R6034
 An application has made an attempt to load th C runtime library incorrectly.
 .

I wonder whether this may be due to the python installer being link to
one version of the C runtime and python another (python 2.6 is linked
against the MSVCR 9.0).

If you need ipython quickly, I would simply try building the installer
myself from sources - as ipython does not have dependency and is pure
python, it should be straightfoward to do a python setup.py
bdist_wininst,

cheers,

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


Re: PEP 3143: Standard daemon process library

2009-03-24 Thread Floris Bruynooghe
On Mar 21, 11:06 pm, Ben Finney ben+pyt...@benfinney.id.au wrote:
 Floris Bruynooghe floris.bruynoo...@gmail.com writes:
  Had a quick look at the PEP and it looks very nice IMHO.

 Thank you. I hope you can try the implementation and report feedback
 on that too.

  One of the things that might be interesting is keeping file
  descriptors from the logging module open by default.

 Hmm. I see that this would be a good idea. but it raises the question
 of how to manage the set of file handles that should not be closed on
 becoming a daemon.

 So far, the logic of closing the file descriptors is a little complex:

     * Close all open file descriptors. This excludes those listed in
       the `files_preserve` attribute, and those that correspond to the
       `stdin`, `stdout`, or `stderr` attributes.

 Extending that by saying “… and also any file descriptors for
 ``logging.FileHandler`` objects” starts to make the description too
 complex. I have a strong instinct that it the description is complex,
 the design might be bad.

 Can you suggest an alternative API that will ensure that all file
 descriptors get closed *except* those that should not be closed?

Not an answer yet, but I'll try to find time in the next few days to
play with this and tell you what I think.  logging.FileHandler would
be too narrow in any case I think.


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


Transition from urllibs to browser and keep session alive

2009-03-24 Thread JReed
Hello, I currently have a script that uses httplib2 to navigate through a
website and collect some cookies manually along the way.  It is an https
that requires a logon, then i navigate through a few pages and the end
result is to dump some info into a javascript and i display the returned
html in a browser.

  It works great if you just need to print that one page, but if someone
wants to click further into the page it wont work because it is just a local
copy of the returned html.  I would like to find a way to take the cookie
and session information and open the page in a browser after i have walked
through the pages and collected the cookies by means of a script, etc.  Just
looking for some recomendations on what modules would fit this scenerio
best.  Your responses are greatly appreciated, thanks!

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


Appending to sys.path

2009-03-24 Thread mhearne808[insert-at-sign-here]gmail[insert-dot-here]com
I have an application where I would like to append to the python path
dynamically.  Below is a test script I wrote.  Here's what I thought
would happen:

1) I run this script in a folder that is NOT already in PYTHONPATH
2) The script creates a subfolder called foo.
3) The script creates a file called foo.py, with a foo() method
defined in it.
4) The script attempts to import this module, which fails because the
current folder is not in PYTHONPATH.
5) The script then adds the current folder to the end of sys.path
6) The script again attempts to import foo.foo, and succeeds.

#6 never happens, but I can't figure out why.  I'm running on Mac OS
10.5, with python 2.5.1.

Anybody have any tips?

Thanks,

Mike

Here's the script:
#!/usr/bin/python

import sys
import os.path

txt = 'def foo(): print Hello world!\n'
if not os.path.isdir('foo'):
os.mkdir('foo')
f = open('foo/foo.py','wt')
f.write(txt)
f.close()

try:
__import__('foo.foo')
except ImportError:
homedir = os.path.abspath(sys.path[0]) #where is this script?
print 'Adding %s to sys.path' % (homedir)
sys.path.append(homedir)
try:
__import__('foo.foo')
print 'Import now successful'
except ImportError:
print Why didn't this work?
sys.exit(1)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Relative Imports, why the hell is it so hard?

2009-03-24 Thread Istvan Albert
On Mar 23, 10:16 am, CinnamonDonkey cinnamondon...@googlemail.com
wrote:

 I'm fairly new to Python so I still have a lot to learn. But I'd like
 to know how to correectly use relative imports.

Relative imports are *fundamentally* broken in python. You will soon
see that code using relative import will break if you attempt to run
the module on its own. Yes, it is mindboggling!

Why is it so you ask? It is one of those issue that would be trivial
to implement correctly (it is relative to the current file location,
duh!!!), would be tremendously useful yet  for some reason it is
controversial with those who would need to implement it.

It looks like they think that the expected mode of operation would
greatly confuse the 'rest' of us. So that is the reason you end up
with a broken implementation that is worse than not having it at all.
All I can do is recommend that you avoid relative imports.

The easiest way around the issue is to create a module named
pathfix.py like the one below and import it in all of your modules.
This is the only way to fix this issue in a way that does not come
back and bite you, it is ugly, you are repeating yourself in multiple
places, but it is still better than the alternative.

---

import os, sys

def path_join(*args):
return os.path.abspath(os.path.join(*args))

# adds base directory to import path to allow relative imports
__currdir = os.path.dirname( __file__ )
__basedir = path_join(__currdir, '..' )
if __basedir not in sys.path:
sys.path.append( __basedir )


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


Re: install pyPgSQL on Windows for python 2.5

2009-03-24 Thread Dietmar Schwertberger

someone wrote:

Hi,

does anyone know how to install pyPgSQL on Windows? There is no
package for Python 2.5 on Homepage:



I've installed newest Visual C++ Studio 2008 from Microsoft, but still
no luck


Hello Pet,

you need Visual Studio 2003 to compile extensions for Python 2.5
If you want, I can send you a binary.

Regards,

Dietmar

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


Re: Appending to sys.path

2009-03-24 Thread Peter Otten
mhearne808[insert-at-sign-here]gmail[insert-dot-here]com wrote:

 I have an application where I would like to append to the python path
 dynamically.  Below is a test script I wrote.  Here's what I thought
 would happen:
 
 1) I run this script in a folder that is NOT already in PYTHONPATH
 2) The script creates a subfolder called foo.
 3) The script creates a file called foo.py, with a foo() method
 defined in it.
 4) The script attempts to import this module, which fails because the
 current folder is not in PYTHONPATH.
 5) The script then adds the current folder to the end of sys.path
 6) The script again attempts to import foo.foo, and succeeds.
 
 #6 never happens, but I can't figure out why.  I'm running on Mac OS
 10.5, with python 2.5.1.
 
 Anybody have any tips?
 
 Thanks,
 
 Mike
 
 Here's the script:
 #!/usr/bin/python
 
 import sys
 import os.path
 
 txt = 'def foo(): print Hello world!\n'
 if not os.path.isdir('foo'):

Here you add a directory under the current working directory.

 os.mkdir('foo')
 f = open('foo/foo.py','wt')
 f.write(txt)
 f.close()

To turn the foo directory into a package you must also create a file
foo/__init__.py (may be empty).
 
 try:
 __import__('foo.foo')
 except ImportError:
 homedir = os.path.abspath(sys.path[0]) #where is this script?
 print 'Adding %s to sys.path' % (homedir)
 sys.path.append(homedir)

Here you add the directory to the path were the script is located, not the
cwd. Should be

 sys.path.append(.)

 try:
 __import__('foo.foo')
 print 'Import now successful'
 except ImportError:
 print Why didn't this work?
 sys.exit(1)

Peter

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


Re: Translating unicode data

2009-03-24 Thread CaptainMcCrank
On Mar 23, 4:16 pm, Peter Otten __pete...@web.de wrote:
 CaptainMcCrank wrote:
  I'm struggling with a problem analyzing large amounts of unicode data
  in an http wireshark capture.
  I've solved the problem with the interpreter, but I'm not sure how to
  do this in an automated fashion.

  I'd like to grab a line from a text file  translate the unicode
  sections of it to ascii.  So, for example
  I'd like to take
  \u003cb\u003eMar 17\u003c/b\u003e

  and turn it into

  bMar 17/b

  I can handle this from the interpreter as follows:

  import unicodedata
  mystring = u\u003cb\u003eMar 17\u003c/b\u003e
  print mystring
  bMar 17/b

  But I don't know what I need to do to automate this!  The data that is
  in the quotes from line 2 will have to come from a variable.  I am
  unable to figure out how to do this using a variable rather than a
  literal string.

 If wireshark uses the same escape codes as python you can use str.decode()
 or open the file with codecs.open():

  s = \u003cb\u003eMar 17\u003c/b\u003e
  s

 '\\u003cb\\u003eMar 17\\u003c/b\\u003e' s.decode(unicode-escape)

 u'bMar 17/b'

  open(tmp.txt, w).write(s)
  import codecs
  f = codecs.open(tmp.txt, r, encoding=unicode-escape)
  f.read()

 u'bMar 17/b'

 Peter

This is a workable solution!  Thank you Peter!
--
http://mail.python.org/mailman/listinfo/python-list


Re: parsing tab separated data efficiently into numpy/pylab arrays

2009-03-24 Thread mapb81
You could take a look/use the very handy csv2rec function in
matplotlib.mlab, which creates numpy struct arrays.

Marco

On Mar 13, 10:19 pm, per perfr...@gmail.com wrote:
 hi all,

 what's the most efficient / preferred python way ofparsingtab
 separated data intoarrays? for example if i have a file containing
 two columns one corresponding to names the other numbers:

 col1    \t     col 2
 joe    \t  12.3
 jane   \t 155.0

 i'd like to parse into an array() such that i can do: mydata[:, 0] and
 mydata[:, 1] to easily access all the columns.

 right now i can iterate through the file, parse it manually using the
 split('\t') command and construct a list out of it, then convert it toarrays. 
 but there must be a better way?

 also, my first column is just a name, and so it is variable in length
 -- is there still a way to store it as an array so i can access: mydata
 [:, 0] to get all the names (as a list)?

 thank you.

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


minor revision encoded in SONAME in libpython.so

2009-03-24 Thread szager
I'm wondering why the SONAME in libpython.so has a minor revision
encoded in it; for example (on Linux):

$ readelf -d libpython2.6.so | grep SONAME
 0x000e (SONAME) Library soname:
[libpython2.6.so.1.0]

Because of this, if I compile an app against this library (with '-L/
usr/lib -lpython2.6), the compiled app has a dependency in this
precise minor revision of libpython2.6.so:

$ readelf -d myApp | grep libpython
 0x0001 (NEEDED) Shared library:
[libpython2.6.so.1.0]

So, for example, if I upgrade to libpython2.6.so.1.1, my app will not
be able to run.  I am currently having this problem while integrating
a piece of third-party software that uses an embedded python
interpreter.

This is unusual for libraries of this kind.  Typically, the SONAME
will contain only the major revision, on the assumption that all the
minor revisions conform to the same public API, and are nominally
interchangeable.  Am I to assume that minor version iterations have
incompatible API's?

Thanks in advance for any guidance.

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


Re: install pyPgSQL on Windows for python 2.5

2009-03-24 Thread someon
On Mar 24, 4:57 pm, Dietmar Schwertberger n...@schwertberger.de
wrote:
 someone wrote:
  Hi,

  does anyone know how to install pyPgSQL on Windows? There is no
  package for Python 2.5 on Homepage:
  I've installed newest Visual C++ Studio 2008 from Microsoft, but still
  no luck

 Hello Pet,

 you need Visual Studio 2003 to compile extensions for Python 2.5
 If you want, I can send you a binary.

O, thank you very much!
Where should I put hole thing?


 Regards,

 Dietmar

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


Re: Async serial communication/threads sharing data

2009-03-24 Thread John Nagle

Hendrik van Rooyen wrote:

Nick Craig-Wood ni...g-wood.com wrote:


I wrote a serial port to TCP proxy (with logging) with twisted.  The
problem I had was that twisted serial ports didn't seem to have any
back pressure.  


Not sure if this is Twisted's fault - 
do python sockets have 
automatic back pressure?

Do Linux sockets have back pressure?


   Yes, and yes.

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


Re: Unit testing frameworks

2009-03-24 Thread pruebauno
On Mar 24, 8:06 am, grkunt...@gmail.com wrote:
 I am looking for a unit testing framework for Python. I am aware of
 nose, but was wondering if there are any others that will
 automatically find and run all tests under a directory hierarchy.

 Thanks, Ralph

*Nose
*Trial
*py.test
--
http://mail.python.org/mailman/listinfo/python-list


Re: Does Python have certificate?

2009-03-24 Thread Steve Holden
Johannes Bauer wrote:
 Sebastian Bassi schrieb:
 
 No, there is no certification for Python. Maybe in the future...
 
 I'll hand out the Johannes Bauer Python Certificate of Total
 Awesomeness for anyone who can write a hello world in python and hands
 me $25000 in cash.
 
 This whole certified foobar programmer is complete crap IMHO.
 
The certification kind of comes out in the wash from the O'Reilly
development process, it's not a primary goal.

 The above offer stands nontheless.
 
I'll trade you for a Steve Holden Information Technology certification ...

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Want to know? Come to PyCon - soon! http://us.pycon.org/

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


Re: Bash-like brace expansion

2009-03-24 Thread Peter Waller
Heh, thanks :)

Unit tests did cross my mind. I was kicking myself for not starting
out with them, there were several regressions during development, and
there could well still be lurking corner cases ;)

I've since heard that a 'better way' would be to use pyparsing. Also,
I saw that python has dropped the idea of having recursive regular
expressions at the moment.

http://bugs.python.org/msg83993

Maybe I might re-implement this with pyparsing and some unit tests.

On Mar 24, 2:30 pm, Nick Craig-Wood n...@craig-wood.com wrote:
 Peter Waller peter.wal...@gmail.com wrote:
   Okay, I got fed up with there not being any (obvious) good examples of
   how to do bash-like brace expansion in Python, so I wrote it myself.
   Here it is for all to enjoy!

 Interesting!

 Might I suggest some unit tests?  You can then test all the corner
 cases (unmatched brackets, empty brackets, etc) and be sure it works
 exactly as specified.  doctest is cool for this kind of stuff.

 --
 Nick Craig-Wood n...@craig-wood.com --http://www.craig-wood.com/nick

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


Best GUI toolkit with Table support

2009-03-24 Thread deech
Hi all,
I am making a cross-platform frontend to a sqlite3 database. Which
python GUI toolkit has the best table support? Tkinter doesn't seem to
support them (without additional package installation).

The issue is that the application must run off a flash drive with a
vanilla Python install on both Windows and Linux. Or if there is a way
to store additional packages on the flash drive and call them in some
portable way, this would work too.

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


Re: Relative Imports, why the hell is it so hard?

2009-03-24 Thread Gabriel Genellina
En Tue, 24 Mar 2009 12:49:08 -0300, Istvan Albert  
istvan.alb...@gmail.com escribió:

On Mar 23, 10:16 am, CinnamonDonkey cinnamondon...@googlemail.com
wrote:


I'm fairly new to Python so I still have a lot to learn. But I'd like
to know how to correectly use relative imports.


Relative imports are *fundamentally* broken in python. You will soon
see that code using relative import will break if you attempt to run
the module on its own. Yes, it is mindboggling!


How import works in general is hard to grasp -- the semantics are rather  
complicated, partly because the import system has grown patch over patch  
over the years, and because it's mostly underdocumented.
But I would not say that relative imports are fundamentally broken --  
they're one of the best improvements to the import system!



Why is it so you ask? It is one of those issue that would be trivial
to implement correctly (it is relative to the current file location,
duh!!!), would be tremendously useful yet  for some reason it is
controversial with those who would need to implement it.


A module doesn't *have* to reside in the filesystem - so in the general  
case, there is no such thing as current file location. Packages provide  
such hierarchical disposition - and relative imports work with packages  
only.



It looks like they think that the expected mode of operation would
greatly confuse the 'rest' of us. So that is the reason you end up
with a broken implementation that is worse than not having it at all.
All I can do is recommend that you avoid relative imports.


I'd recommend the oposite - use relative (intra-package) imports when  
possible. Explicit is better than implicit - and starting with 2.7 -when  
absolute import semantics will be enabled by default- you'll *have* to  
use relative imports inside a package, or fail.



The easiest way around the issue is to create a module named
pathfix.py like the one below and import it in all of your modules.
This is the only way to fix this issue in a way that does not come
back and bite you, it is ugly, you are repeating yourself in multiple
places, but it is still better than the alternative.


import it in all of your modules?
Did you know, once a module is imported by the first time, subsequent  
imports simply return the same module instance? The initialization code is  
not executed again.



import os, sys

def path_join(*args):
return os.path.abspath(os.path.join(*args))

# adds base directory to import path to allow relative imports
__currdir = os.path.dirname( __file__ )
__basedir = path_join(__currdir, '..' )
if __basedir not in sys.path:
sys.path.append( __basedir )


I don't understand, how is this supposed to help relative imports?
Bindly inserting directories into sys.path can easily confuse the import  
system (and you!)


--
Gabriel Genellina

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


Re: Relative Imports, why the hell is it so hard?

2009-03-24 Thread Gabriel Genellina
En Tue, 24 Mar 2009 09:01:01 -0300, R. David Murray  
rdmur...@bitdance.com escribió:

CinnamonDonkey cinnamondon...@googlemail.com wrote:

On 23 Mar, 18:57, bearophileh...@lycos.com wrote:
 CinnamonDonkey:

 what makes something a package?

 If you don't know what a package is, then maybe you don't need
 packages.

Thanx for taking the time to post a response but I am afraid I feel
the need to point out that it is exactly this kind of response that I
find un-helpful. It is neither constructive nor educational.


I think bearophile could have left out the first sentence, but otherwise
his question is perfectly sensible.  If you have a bunch of independent
modules, then you don't need to put them in packages.  Your example
only showed one module file in each package...I understand now that was
just for simplicity of the example, but we had no way of knowing that.


Especially, since people coming from Java:

- think that they *have* to use a package
- think that they *have* to put a single class per file

Neither is true in Python. And from the example alone, one could infer the  
OP was making such mistakes. Glad to see it was not the case.


--
Gabriel Genellina

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


Re: Unit testing frameworks

2009-03-24 Thread Gabriel Genellina

En Tue, 24 Mar 2009 09:06:47 -0300, grkunt...@gmail.com escribió:


I am looking for a unit testing framework for Python. I am aware of
nose, but was wondering if there are any others that will
automatically find and run all tests under a directory hierarchy.


All known testing tools (and some unknown too):

http://pycheesecake.org/wiki/PythonTestingToolsTaxonomy

--
Gabriel Genellina

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


Re: Best GUI toolkit with Table support

2009-03-24 Thread Stef Mientki

deech wrote:

Hi all,
I am making a cross-platform frontend to a sqlite3 database. Which
python GUI toolkit has the best table support? Tkinter doesn't seem to
support them (without additional package installation).

The issue is that the application must run off a flash drive with a
vanilla Python install on both Windows and Linux. Or if there is a way
to store additional packages on the flash drive and call them in some
portable way, this would work too.

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

this one is build upon wxPython:

http://mientki.ruhosting.nl/data_www/pylab_works/pw_sqllite.html


cheers,
Stef
--
http://mail.python.org/mailman/listinfo/python-list


Re: Bash-like brace expansion

2009-03-24 Thread Paul McGuire
On Mar 24, 12:39 pm, Peter Waller peter.wal...@gmail.com wrote:

 Maybe I might re-implement this with pyparsing and some unit tests.


In your pyparsing efforts, you might draw some insights from this
regex inverter (that is, given an re such as [AB]\d, returns A0
through B9) on the pyparsing wiki: 
http://pyparsing.wikispaces.com/file/view/invRegex.py.

-- Paul

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


setting directory mod date

2009-03-24 Thread jyoung79
I've got some Python code (2.5.1) that's compressing folders 
on a Windows machine.  When the directories get 
compressed, their modification date changes.  Is it possible 
to grab the modification date of the folder before it's 
compressed, and then set it's modification date back to it's 
original state after it's compressed?  I've been reading 
different articles on-line about this, but nothing looks very 
promising.  I haven't tested os.utime() or win32file since 
others have said these won't work correctly with folders on 
Windows XP.

Thanks.

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


debuglevel for a HTTP request

2009-03-24 Thread Carbon Man
#Python 2.5
# from Dive Into Python 11.5

import httplib
httplib.HTTPConnection.debuglevel = 1
import urllib2
request = urllib2.Request('http://localhost/test/atom.xml')
opener = urllib2.build_opener()
feeddata = opener.open(request).read()

It doesn't show the debug output, any ideas? 


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


autocomplete and printing

2009-03-24 Thread vikram moule
Q1. I want to access a database and just by pressing the first alphabet will
showup a dropdown list of all the words starting from that alphabet how can
I do that ?
( I know how to access the database but the further problem is unsolved
hence)
Q2. How can I print a document for example bill or prescription through a
printer or network printer (both) using python ?

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


Re: autocomplete and printing

2009-03-24 Thread Gabriel Genellina
En Tue, 24 Mar 2009 17:56:26 -0300, vikram moule shivic...@gmail.com  
escribió:


Q1. I want to access a database and just by pressing the first alphabet  
will
showup a dropdown list of all the words starting from that alphabet how  
can

I do that ?
( I know how to access the database but the further problem is unsolved
hence)


Populate the dropdownlist with results from a query like this: SELECT XXX  
FROM YYY WHERE XXX LIKE 'A%'

(all rows where XXX starts with A).
You'll have to provide more info if you want more details (Which database?  
Which adapter? Is it a console application, a GUI application, a web one?  
Which toolkit/framework?)



Q2. How can I print a document for example bill or prescription through a
printer or network printer (both) using python ?


If you tell us how would you do that without Python, maybe someone  
suggests how to do the same thing with Python.


--
Gabriel Genellina

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


Re: minor revision encoded in SONAME in libpython.so

2009-03-24 Thread Martin v. Löwis
 So, for example, if I upgrade to libpython2.6.so.1.1

How do you do that? There won't ever be such a library. They
will always be called libpython2.6.so.1.0.

So no, no minor revision gets encoded into the SONAME.

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


file open fails.

2009-03-24 Thread Atul.
Hi I am using IDLE on Windows Vista and I have a small code.

title = 'C:\Thesis\refined_title.txt'
file = open(title)

I get the following error from Python.


file = open(title)
IOError: [Errno 22] invalid mode ('r') or filename: 'C:\\Thesis
\refined_title.txt'

Now, I can not understand the problem here I have all the permissions
set for the folder, file as well. I can not understand why would it
happen. Is it known on Windows Vista or am I missing something really
simple and stupid? Please help.

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


Re: PEP 3143: Standard daemon process library

2009-03-24 Thread Ben Finney
Jean-Paul Calderone exar...@divmod.com writes:

 On Tue, 24 Mar 2009 15:42:46 +1100, Ben Finney 
 bignose+hates-s...@benfinney.id.au wrote:
 That sounds rather more specific than is needed for the generic
 library being proposed here. I'm wary of adding features to an API
 that is already quite complex.
 
 Isn't setting the EUID and EGID something that is just as easily
 done *after* the program achieves a daemon process?
 
 That depends.
 
 If you mean that one can ignore the uid and gid setting features of the
 proposed library so that they are not changed during daemonization and
 then make the appropriate calls from the application afterwards, then
 yes.

Yes, that's what I meant.

 Otherwise, no. Since this means all of your daemon startup code is
 forced to run as a privileged process when it might otherwise have
 run without those privileges

Er? You can still set the real UID and GID via the DaemonContext API,
and then also set the EUID and EGID.

 I think it's worth the tiny additional complexity it will bring to
 the API (and it really is pretty tiny, something on the order of a
 new `set_effective=True´ flag).

It leads immediately to the request to set *both* real UID/GID *and*
effective UID/GID to separate values.

Can you describe the use case more, so I can understand better how
common it might be? In what circumstances must one not change the real
UID/GID but instead change the effective UID/GID, *and* must change
them during daemonisation?

-- 
 \  “One thing vampire children have to be taught early on is, |
  `\  don't run with a wooden stake.” —Jack Handey |
_o__)  |
Ben Finney

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


Re: file open fails.

2009-03-24 Thread Scott David Daniels

Atul. wrote:

title = 'C:\Thesis\refined_title.txt'
file = open(title)
I get the following error from Python.
file = open(title)
IOError: [Errno 22] invalid mode ('r') or filename: 'C:\\Thesis
\refined_title.txt'



Now, I can not understand the problem here ...

Repesat to yourself 1e4 tmes: I shall not put windows file
names in quotes w/o using 'r' (as in raw files).  Either
always use forward slashes, or get used to typing:
  title = r'C:\Thesis\refined_title.txt'

In your case, '\r' is a return (a single character), not two
characters long. I think its sad that 'C:\Thesis' doesn't cause
an error because there is no such character as '\T', but I am
probably excessively pedantic.

--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list


Re: setting directory mod date

2009-03-24 Thread MRAB

jyoun...@kc.rr.com wrote:
I've got some Python code (2.5.1) that's compressing folders 
on a Windows machine.  When the directories get 
compressed, their modification date changes.  Is it possible 
to grab the modification date of the folder before it's 
compressed, and then set it's modification date back to it's 
original state after it's compressed?  I've been reading 
different articles on-line about this, but nothing looks very 
promising.  I haven't tested os.utime() or win32file since 
others have said these won't work correctly with folders on 
Windows XP.



I've just tried it. os.utime() _does_ work correctly on folders.
--
http://mail.python.org/mailman/listinfo/python-list


Re: file open fails.

2009-03-24 Thread MRAB

Atul. wrote:

Hi I am using IDLE on Windows Vista and I have a small code.

title = 'C:\Thesis\refined_title.txt'
file = open(title)

I get the following error from Python.


file = open(title)
IOError: [Errno 22] invalid mode ('r') or filename: 'C:\\Thesis
\refined_title.txt'

Now, I can not understand the problem here I have all the permissions
set for the folder, file as well. I can not understand why would it
happen. Is it known on Windows Vista or am I missing something really
simple and stupid? Please help.


Backslash has a special meaning in string literals. Use a raw string
instead or double the backslashes:

title = r'C:\Thesis\refined_title.txt'

or:

title = 'C:\\Thesis\\refined_title.txt'

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


[ANN] mlabwrap-1.0.1 released

2009-03-24 Thread Alexander Schmolck
Mlabwrap allows pythonistas to interface to Matlab(tm) in a very
straightforward fashion:

 from mlabwrap import mlab
 mlab.eig([[0,1],[1,1]])
array([[-0.61803399],
   [ 1.61803399]])

More at http://mlabwrap.sourceforge.net.

Mlabwrap 1.0.1 is just a maintenance release that fixes a few bugs and
simplifies installation (no more LD_LIBRARY_PATH hassles).

'as

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


Re: file open fails.

2009-03-24 Thread Wes James
On Tue, Mar 24, 2009 at 4:04 PM, Scott David Daniels
scott.dani...@acm.org wrote:
 Atul. wrote:

snip

 In your case, '\r' is a return (a single character), not two
 characters long. I think its sad that 'C:\Thesis' doesn't cause
 an error because there is no such character as '\T', but I am
 probably excessively pedantic.

\T might mean the same thing as \t (tab), but I thought it would be different...

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


Re: debuglevel for a HTTP request

2009-03-24 Thread cgoldberg
  It doesn't show the debug output, any ideas?

I think like this:
opener = urllib2.build_opener(urllib2.HTTPHandler(debuglevel=1))

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


Re: file open fails.

2009-03-24 Thread Wes James
On Tue, Mar 24, 2009 at 4:32 PM, Wes James compte...@gmail.com wrote:
 On Tue, Mar 24, 2009 at 4:04 PM, Scott David Daniels
 scott.dani...@acm.org wrote:
 Atul. wrote:

 snip

 In your case, '\r' is a return (a single character), not two
 characters long. I think its sad that 'C:\Thesis' doesn't cause
 an error because there is no such character as '\T', but I am
 probably excessively pedantic.

 \T might mean the same thing as \t (tab), but I thought it would be 
 different...


I guess not:

http://docs.python.org/reference/lexical_analysis.html#string-literals

Wonder why when I do print test\Ttest vs print test\ttest  \T just
get printed?

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


Re: Style question - defining immutable class data members

2009-03-24 Thread Aahz
In article mailman.1847.1237048379.11746.python-l...@python.org,
Maxim Khitrov  mkhit...@gmail.com wrote:

Very simple question on the preferred coding style. I frequently write
classes that have some data members initialized to immutable values.
For example:

class Test(object):
def __init__(self):
self.some_value = 0
self.another_value = None

Similar effect can be achieved by defining some_value and
another_value for the entire class, like so:

class Test(object):
some_value = 0
another_value = None

The advantage of doing this is that the assignments are evaluated once
and thus the creation of that class is a bit faster. Access is still
performed through self.some_value and self.another_value. Is there a
reason to prefer the first style over the second?

Well, as you can see from reading this whole thread, it can be the source
of some confusion.  Nevertheless, I personally sometimes use the style of
initializing at the class level.  I think it's probably worth creating a
style guide entry for this issue if you're using Python for your
employer.
-- 
Aahz (a...@pythoncraft.com)   * http://www.pythoncraft.com/

At Resolver we've found it useful to short-circuit any doubt and just
refer to comments in code as 'lies'. :-)
--Michael Foord paraphrases Christian Muirhead on python-dev, 2009-3-22
--
http://mail.python.org/mailman/listinfo/python-list


Python 3 consistency proposal

2009-03-24 Thread gert
Rename all built in classes with a capital letter
example Str() Int() Object()

Make () optional for a function definition
class Test:
pass

def test:
pass

Any chance Guido would approve this :-)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3 consistency proposal

2009-03-24 Thread Daniel Fetchinson
 Rename all built in classes with a capital letter
 example Str() Int() Object()

Why?

 Make () optional for a function definition
 class Test:
 pass

 def test:
 pass

Why?

 Any chance Guido would approve this :-)

In my estimation, the chance that Guido would approve this is less
than 10^(-26).

Cheers,
Daniel

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
--
http://mail.python.org/mailman/listinfo/python-list


Re: Best GUI toolkit with Table support

2009-03-24 Thread Todd Whiteman

deech wrote:

Hi all,
I am making a cross-platform frontend to a sqlite3 database. Which
python GUI toolkit has the best table support? Tkinter doesn't seem to
support them (without additional package installation).

The issue is that the application must run off a flash drive with a
vanilla Python install on both Windows and Linux. Or if there is a way
to store additional packages on the flash drive and call them in some
portable way, this would work too.


If you don't need custom sqlite functionality, you could use an existing 
sqlite manager app, such as SQLiteManager, which runs cross-platform as 
a Firefox extension, or can use XULRunner as a standalone (so it could 
run off a flash drive):

http://code.google.com/p/sqlite-manager/wiki/ScreenShots

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


Re: iPython 0.9.1 install under XP -- R6034

2009-03-24 Thread Esmail

Hello David,

David Cournapeau wrote:



If you need ipython quickly, I would simply try building the installer
myself from sources - as ipython does not have dependency and is pure
python, it should be straightfoward to do a 



python setup.py bdist_wininst,


Thanks for the suggestion, it seems to have worked, but I don't
think it created any of the .bat files or entries in the startup
menu etc. .. any idea how to those parts set up?

Also, how did you know about the bdist_wininst command line argument?
I looked around for this sort of information, but must have missed
it.

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


Re: Problem Python 2.6.1 vs 2.6 pyWin32

2009-03-24 Thread John Machin
Martin v. Löwis martin at v.loewis.de writes:

 
  Sorry for not being explicit. With installer I meant the binary
  Windows installer you create with command python setup.py
  bdist_wininst. In the past we've been able to use
  package-version.win32.exe files created with Python 2.5 on older
  version, but that doesn't seem to be case with 2.6.
 
 I see. This has nothing to do with the OP's question, then.
 
 For Python 2.6, we switched to VS 2008. Apparently, the bdist_msi
 installers now get linked with the VS 2008 CRT (msvcr90.dll), which
 must be present on the system (in WinSxS) for the installer to run;
 one way of installing the CRT is to install Python for all users,
 another is to install it just for me, and put \python26 into PATH
 (so that the installer can find msvcr90.dll).
 

Hi Martin,

Unfortunately this solution can't be used where the user is not permitted to
upgrade Python to 2.6 or where there appears to be an incompatible version of
msvcr90.dll in C:\windows\winsxs.

For example a user with no admin privileges on his work PC and stuck with Python
2.4.2 on Windows XP SP2 (not SP3) has the following problem when trying to run a
bdist_wininst .exe that was created for a pure-Python package using Python 
2.6.1:

the error message is the same as stated in this article:
http://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/xp-wont-run.html

presumably (given his locale) the German version of the error message, complete
with MS misspelling.

It would appear that the safest cover-most-bases option for a developer/packager
of pure-Python packages (especially one intended to be runnable on older
versions of Python, some as far back as 2.1) is to use Python 2.5 to make the
bdist_wininst (the exe is linked against msvcr71.dll which is widely available
and doesn't have SxS problems). Do you agree? If so, where is the best place to
propagate this advice?

Cheers,
John



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


Re: setting directory mod date

2009-03-24 Thread Gabriel Genellina
En Tue, 24 Mar 2009 19:10:50 -0300, MRAB goo...@mrabarnett.plus.com  
escribió:



jyoun...@kc.rr.com wrote:
I've got some Python code (2.5.1) that's compressing folders on a  
Windows machine.  When the directories get compressed, their  
modification date changes.  Is it possible to grab the modification  
date of the folder before it's compressed, and then set it's  
modification date back to it's original state after it's compressed?   
I've been reading different articles on-line about this, but nothing  
looks very promising.  I haven't tested os.utime() or win32file since  
others have said these won't work correctly with folders on Windows XP.



I've just tried it. os.utime() _does_ work correctly on folders.


But not on Python 2.5 :(

Using the pywin32 package:

py os.stat(cuchi)
(16895, 0L, 0, 0, 0, 0, 0L, 1237259905, 1235809285, 1235809278)
py from win32file import *
py hFile = CreateFile(cuchi, GENERIC_WRITE, 0,
... None, OPEN_EXISTING,
... FILE_FLAG_BACKUP_SEMANTICS, None)
py import time
py import pywintypes
py t = pywintypes.Time(time.localtime())
py win32file.SetFileTime(hFile, t, t, t)
py CloseHandle(hFile)
py os.stat(cuchi)
(16895, 0L, 0, 0, 0, 0, 0L, 1237940110, 1237940110, 1237940110)

--
Gabriel Genellina

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


Re: Python 3 consistency proposal

2009-03-24 Thread Steven D'Aprano
On Tue, 24 Mar 2009 16:45:26 -0700, gert wrote:

 Rename all built in classes with a capital letter example Str() Int()
 Object()
 
 Make () optional for a function definition class Test:
 pass
 
 def test:
 pass
 
 Any chance Guido would approve this :-)

Unless you're volunteering to produce a patch, the chances are zero.

If you *are* willing to do the work, the chances would still be pretty 
slim. Guido has just rejected a patch adding PEP 8 compliant aliases for 
types like datetime, so I think replacing built-ins have all-but zero 
chance. But if you want to pursue it, the right place is the python-ideas 
mailing list. Go for it ... but be prepared to justify the change, and 
not just for consistency. As Guido has quoted before, A foolish 
consistency is the hobgoblin of little minds.



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


Re: setting directory mod date

2009-03-24 Thread MRAB

Gabriel Genellina wrote:
En Tue, 24 Mar 2009 19:10:50 -0300, MRAB goo...@mrabarnett.plus.com 
escribió:



jyoun...@kc.rr.com wrote:
I've got some Python code (2.5.1) that's compressing folders on a 
Windows machine.  When the directories get compressed, their 
modification date changes.  Is it possible to grab the modification 
date of the folder before it's compressed, and then set it's 
modification date back to it's original state after it's compressed?  
I've been reading different articles on-line about this, but nothing 
looks very promising.  I haven't tested os.utime() or win32file since 
others have said these won't work correctly with folders on Windows XP.



I've just tried it. os.utime() _does_ work correctly on folders.


But not on Python 2.5 :(


Ah, missed that bit (I used Python 2.6.1). Sorry!


Using the pywin32 package:

py os.stat(cuchi)
(16895, 0L, 0, 0, 0, 0, 0L, 1237259905, 1235809285, 1235809278)
py from win32file import *
py hFile = CreateFile(cuchi, GENERIC_WRITE, 0,
... None, OPEN_EXISTING,
... FILE_FLAG_BACKUP_SEMANTICS, None)
py import time
py import pywintypes
py t = pywintypes.Time(time.localtime())
py win32file.SetFileTime(hFile, t, t, t)
py CloseHandle(hFile)
py os.stat(cuchi)
(16895, 0L, 0, 0, 0, 0, 0L, 1237940110, 1237940110, 1237940110)



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


Re: file open fails.

2009-03-24 Thread Steven D'Aprano
On Tue, 24 Mar 2009 16:48:30 -0600, Wes James wrote:

 On Tue, Mar 24, 2009 at 4:32 PM, Wes James compte...@gmail.com wrote:
 On Tue, Mar 24, 2009 at 4:04 PM, Scott David Daniels
 scott.dani...@acm.org wrote:
 Atul. wrote:

 snip

 In your case, '\r' is a return (a single character), not two
 characters long. I think its sad that 'C:\Thesis' doesn't cause an
 error because there is no such character as '\T', but I am probably
 excessively pedantic.

 \T might mean the same thing as \t (tab), but I thought it would be
 different...
 
 
 I guess not:
 
 http://docs.python.org/reference/lexical_analysis.html#string-literals
 
 Wonder why when I do print test\Ttest vs print test\ttest  \T just
 get printed?


Did you read the section you just linked to? It says so right there:

Unlike Standard C, all unrecognized escape sequences are left in the 
string unchanged, i.e., the backslash is left in the string. (This 
behavior is useful when debugging: if an escape sequence is mistyped, the 
resulting output is more easily recognized as broken.) It is also 
important to note that the escape sequences marked as “(Unicode only)” in 
the table above fall into the category of unrecognized escapes for non-
Unicode string literals.

Since there is no standard escape \T then it gets treated as a literal 
backslash + uppercase t.



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


Re: file open fails.

2009-03-24 Thread Rhodri James

On Tue, 24 Mar 2009 22:48:30 -, Wes James compte...@gmail.com wrote:


On Tue, Mar 24, 2009 at 4:32 PM, Wes James compte...@gmail.com wrote:
\T might mean the same thing as \t (tab), but I thought it would be  
different...



I guess not:

http://docs.python.org/reference/lexical_analysis.html#string-literals

Wonder why when I do print test\Ttest vs print test\ttest  \T just
get printed?


Because \T has no special meaning, so is just a two character sequence
like any other in the literal.  'print' just prints the string.

print repr(test\Ttest), repr(test\ttest)

might be illuminating?


--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   >