[ANN]: pdftools.pdfposter 0.4.5

2008-11-24 Thread Hartmut Goebel
I'm pleased to announce pdftools.pdfposter 0.4.5, a tool to scale and
tile PDF images/pages to print on multiple pages.

   http://pdfposter.origo.ethz.ch/download/

This version honors cropped pages (/ArtBoxes, /CropBox).

Starting with version 0.4.5, the package was renamed to
'pdftools.pdfposter'. This will allow integrating some other tools
(pdfnup, pdfsplit, etc.) into a larger toolset somewhen.

Download
---

:Quick Installation:
easy_install -U pdftools.pdfposter

:Tarballs:
http://pdfposter.origo.ethz.ch/download/


What is pdfposter?


Scale and tile PDF images/pages to print on multiple pages.

``Pdfposter`` can be used to create a large poster by building it from
multiple pages and/or printing it on large media. It expects as input a
PDF file, normally printing on a single page. The output is again a
PDF file, maybe containing multiple pages together building the
poster.
The input page will be scaled to obtain the desired size.

This is much like ``poster`` does for Postscript files, but working
with PDF. Since sometimes poster does not like your files converted
from PDF. :-) Indeed ``pdfposter`` was inspired by ``poster``.

For more information please refer to the manpage or visit
the `project homepage http://pdfposter.origo.ethz.ch/`_.


:Author:Hartmut Goebel [EMAIL PROTECTED]
:Copyright: GNU Public Licence v3 (GPLv3)
:Homepage:  http://pdfposter.origo.ethz.ch/
--
http://mail.python.org/mailman/listinfo/python-announce-list

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


Python-URL! - weekly Python news and links (Nov 24)

2008-11-24 Thread Gabriel Genellina
QOTW:  One of the reasons for Python's continue march towards world domina-
tion (allow me my fantasies) is its consistent simplicity. Those last two
words would be my candidate for the definition of 'Pythonicity'. - Steve
Holden
http://groups.google.com/group/comp.lang.python/msg/e2518ea8388ca1c5


The last Release Candidate (RC3) for Python 3.0 is available
http://groups.google.com/group/comp.lang.python/t/fbb62e9c9a08c817/

Survey: which dynamic features of Python do you use most?
http://groups.google.com/group/comp.lang.python/t/bdb39a1a4947cdd8/

Beginners looking for problems/challenges/exercises to do:
http://groups.google.com/group/comp.lang.python/t/2b8a0b4ffdbdffbf/

Call-by-Object strikes again! This time, a functional mind asks why
unrelated functions are allowed to modify the internal state of an object:
http://groups.google.com/group/comp.lang.python/t/35511397ad7748cc/

How to detect whether a dictionary has been modified
http://groups.google.com/group/comp.lang.python/t/3632f2407640e759/

Function default arguments are only evaluated when the function is
defined.  Is it intuitive? Ways to change the current behaviour.
http://groups.google.com/group/comp.lang.python/t/2e01cc9ce899eb6e/
http://groups.google.com/group/comp.lang.python/t/1209ebf18a5ec561/

Installing Python on Windows Vista may require using the Administrator
account
http://groups.google.com/group/comp.lang.python/t/a745ed3df47e1be9/

Elegant ways to execute a function at most n times or until succeeds:
http://groups.google.com/group/comp.lang.python/t/10d651c2a0eb082e/

__cmp__ is gone in Python 3 - how to implement a total ordering in
a simple way?
http://groups.google.com/group/comp.lang.python/t/2a672f960e595c76/



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

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

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily

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

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

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

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.
http://groups.google.com/group/comp.lang.python.announce/topics

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

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

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

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

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

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

The Summary of Python Tracker Issues is an automatically generated
report summarizing new bugs, closed ones, and patch submissions. 

http://search.gmane.org/?author=status%40bugs.python.orggroup=gmane.comp.python.develsort=date

Although unmaintained since 2002, the Cetus collection of Python
hyperlinks retains a few gems.
http://www.cetus-links.org/oo_python.html

Python FAQTS
http://python.faqts.com/

The Cookbook is a collaborative effort to capture useful and
interesting recipes.
http://code.activestate.com/recipes/langs/python/

Many Python conferences around the world are in preparation.
Watch this space for links to them.

Among several Python-oriented RSS/RDF feeds available, see:
http://www.python.org/channews.rdf
For more, see:

ANN: Resolver One 1.3 released

2008-11-24 Thread Giles Thomas
We are proud to announce the release of Resolver One, version 1.3.
Resolver One is a spreadsheet that allows you to write Python directly
in cells, and converts the spreadsheets you create into Python
programs.  It's based on IronPython, and runs on Windows.

For version 1.3, we've made two big changes:

* Our Web server, which (as you would expect) allows you to expose
your spreadsheets to other people as web applications, is now included
- it was previously a commercial-only product.
* We've added column- and row-level formulae.  With these, you can
specify one formula which is then used to fill in a whole column or
row, reducing duplication and starting to bring some of the benefits
of loops to the spreadsheet world.

We've done a screencast outlining both of these: http://
www.resolversystems.com/screencasts/release-1.3/

Michael Foord also did a great screencast describing how you can use
Python-syntax formulae with column-level formulae to do interesting
stuff: http://www.resolversystems.com/screencasts/column-formulae/

Resolver One is free for non-commercial use, so if you would like to
take a look, you can download it from our website: http://
www.resolversystems.com/download/


Best regards,

Giles
--
Giles Thomas
MD  CTO, Resolver Systems Ltd.
[EMAIL PROTECTED]
+44 (0) 20 7253 6372

17a Clerkenwell Road, London EC1M 5RD, UK
VAT No.: GB 893 5643 79 Registered in England and Wales as company
number 5467329.
Registered address: 843 Finchley Road, London NW11 8NA, UK
--
http://mail.python.org/mailman/listinfo/python-announce-list

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


Elisa Media Center 0.5.19 Release

2008-11-24 Thread Olivier Tilloy
Dear Python users,

The Elisa team is happy to announce the release of Elisa Media Center
0.5.19, code-named Walk Of Life.

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.

Among other things, this release features updated French translations
and important bug fixes for the plugins system.

A complete list of the bugs fixed by this release is available at:

https://bugs.launchpad.net/elisa/+milestone/0.5.19


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

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


Have a media-centered evening,

The Elisa team


[1] http://www.gstreamer.net/
[2] https://code.fluendo.com/pigment/trac
Elisa 0.5.19 Walk Of Life
===

This is Elisa 0.5.19, nineteenth release of the 0.5 branch.

New features since 0.5.18:

- Updated French translations

Bugs fixed since 0.5.18:

- 299071: ComponentsLoadedMessage sent too early in Application startup sequence
- 300318: Media scanning icon is not displayed on Elisa startup
- 245306: Platform specific plugins should only be loaded when it makes sense
- 298696: Managers not cleaning all the components
- 299885: search results list mouse interaction broken
- 300745: [linux] dbus service tries to access poblesec's main controller too 
early


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:

- Alessandro Decina
- Benjamin Kampmann
- David McLeod
- Florian Boucault
- Guido Amoruso
- Guillaume Emont
- Jesús Corrius
- Lionel Martin
- 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


CorePy 1.0 Release (x86, Cell BE, BSD!)

2008-11-24 Thread Chris Mueller

Announcing CorePy 1.0 - http://www.corepy.org  

We are pleased to announce the latest release of CorePy. CorePy is a
complete system for developing machine-level programs in Python.
CorePy lets developers build and execute assembly-level programs
interactively from the Python command prompt, embed them directly in
Python applications, or export them to standard assembly languages. 

CorePy's straightforward APIs enable the creation of complex,
high-performance applications that take advantage of processor
features usually inaccessible from high-level scripting languages,
such as multi-core execution and vector instruction sets (SSE, VMX,
SPU).  

This version addresses the two most frequently asked questions about
CorePy:

1) Does CorePy support x86 processors?
   Yes! CorePy now has extensive support for 32/64-bit x86 and SSE 
   ISAs on Linux and OS X*.

2) Is CorePy Open Source? 
   Yes!  CorePy now uses the standard BSD license.

Of course, CorePy still supports PowerPC and Cell BE SPU processors.
In fact, for this release, the Cell run-time was redesigned from the
ground up to remove the dependency on IBM's libspe and now uses the
system-level interfaces to work directly with the SPUs (and, CorePy is
still the most fun way to program the PS3).  

CorePy is written almost entirely in Python.  Its run-time system
does not rely on any external compilers or assemblers.

If you have the need to write tight, fast code from Python, want
to demystify machine-level code generation, or just miss the good-old 
days of assembly hacking, check out CorePy!

And, if you don't believe us, here's our favorite user quote:

CorePy makes assembly fun again! 


__credits__ = 
  CorePy is developed by Chris Mueller, Andrew Friedley, and Ben
  Martin and is supported by the Open Systems Lab at Indiana
  University. 

  Chris can be reached at cmueller[underscore]dev[at]yahoo[dot]com.


__footnote__ = 
  *Any volunteers for a Windows port? :)



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

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


Python Django Latex Permissions Problem

2008-11-24 Thread I-T
I have a python/django webapp running with apache2. It executes system
commands for getting a pdf generated by pdflatex from a .tex file and
a couple of image files which it also generates.

The permssions from ls-l for all the created files is:-
-rw-r--r-- 1 www-data www-data

The files are being created in /tmp/pdfscratch{id} created from the
script and so is the directory.

pdflatex fails with the following error message:-

This is pdfTeXk, Version 3.141592-1.40.3 (Web2C  7.5.6)
 %-line parsing enabled.
entering extended mode
! I can't write on file `uber.log'.
Please type another transcript file name:
! Emergency stop
!  == Fatal error occurred, no output PDF file  produced!

Its supposed to write to this directory. I have a feeling that
pdflatex is trying to generate files using some weird access
credentials that dont have access to /tmp/pdfscratch{id}

What do you guys think could be the problem/solution

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


Re: Python 3000

2008-11-24 Thread alex23
On Nov 24, 5:47 pm, Dokorek [EMAIL PROTECTED] wrote:
 Python 3000 (a.k.a. Py3k, and released as Python 3.0) is a new
 version of the language that is incompatible with the 2.x line of
 releases. The language is mostly the same, but many details,
 especially how built-in objects like dictionaries and strings work,
 have changed considerably, and a lot of deprecated features have
 finally been removed. Also, the standard library has been reorganized
 in a few prominent places.

This isn't stackoverflow. Posting items here that everyone is already
fully aware of doesn't do anything positive for your reputation.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using eval, or something like it...

2008-11-24 Thread Gabriel Genellina

En Fri, 21 Nov 2008 13:58:59 -0200, r0g [EMAIL PROTECTED]
escribió:


I hadn't really appreciated the consequences of this till now though
e.g. that an instance might do a = a + 1 without affecting it's siblings
but that b.append(fish) would affect b for everyone. I don't know if I
will find any uses for that kind of behaviour but it doesn't hurt to
understand it :-)

Isn't Python's behaviour a little peculiar in this respect though,
compared to classes in other languages? i.e. Are instances in other OO
languages like Smalltalk, C++ fully independent copies or do their
attribute names just point to one common object until reassigned like in
python? (Or have I still not it at all?!)


In C++, it depends on how you define the container object. It may contain
completely the other object inside it, or it may just hold a
pointer/reference (that is: Other o, Other* o, Other o are valid
alternatives). Unlike Python, the assignment `=` is an operator, and a=b
is an operation performed over the object `a` with argument `b` (because
`a` is a variable, pre-existent and pre-declared to be of a certain type).
In Object Pascal / Delphi, instance variables hold references to objects,
like Python (but basic types like integer, double, string aren't objects,
and you have to explicitely destroy objects when not needed anymore) [1].
a=b stores in `a`, a reference to the object `b`; you have no control over
its behavior.
In Smalltalk, things are like in Python I believe (my Smalltalk is
becoming more and more rusty). Objects hold references to other objects
(instance variables) - but encapsulation is strictly enforced, and they
can't be changed from the outside. Everything is resolved using message
passing between objects, except assignment: a:=b assigns the object `b` to
instance variable `a` directly.

[1] There was a way to declare objects which were not references (using
the 'object' keyword instead of 'class') but I'm not sure it is still
supported

--
Gabriel Genellina

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


Re: can the sequence of entries in a dictionary be depended on?

2008-11-24 Thread Rhamphoryncus
On Nov 23, 6:43 pm, John Machin [EMAIL PROTECTED] wrote:
 On Nov 24, 11:59 am, Carsten Haese [EMAIL PROTECTED] wrote:

  Diez B. Roggisch wrote:
   AFAIK the order is deterministic as long as you don't alter the dict 
   between
   iterations. However, this is an implementation detail.

  It's not an implementation detail. It's documented behavior. Thus 
  quothhttp://docs.python.org/library/stdtypes.html#mapping-types-dict:

  
  If items(), keys(), values(), iteritems(), iterkeys(), and itervalues()
  are called with no intervening modifications to the dictionary, the
  lists will directly correspond.
  

 Changing the value attached to an existing key is a modification to
 the dictionary, but it's hard to see how that would change the
 iteration order.

Although the referenced docs don't clarify it, changing the value
without adding or removing a key (even temporarily) does NOT reorder
the dict.  This has been declared officially on python-dev.


 the lists will directly correspond? What does that mean? Why not
 the lists will be equal i.e. list1 == list2?

 How about Provided that keys are neither added nor deleted, the order
 of iteration will not change?

Python 3.0 never returns lists directly (it provides views), so the
wording has already been tweaked.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Security implications of using open() on untrusted strings.

2008-11-24 Thread r0g
Steven D'Aprano wrote:
 On Mon, 24 Nov 2008 00:44:45 -0500, r0g wrote:
 
 Hi there,

 I'm trying to validate some user input which is for the most part simple
 regexery however I would like to check filenames and I would like this
 code to be multiplatform.

 I had hoped the os module would have a function that would tell me if a
 proposed filename would be valid on the host system but it seems not. I
 have considered whitelisting but it seems a bit unfair to make the rest
 of the world suffer the naming restrictions of windows. Moreover it
 seems both inelegant and hard work to research the valid file/directory
 naming conventions of every platform that this app could conceivably run
 on and write regex's for all of them so...
 
 That's probably why nobody has written a function for the os module to do 
 the same... and just wait until you get into the murky universe of cross-
 platform Unicode filenames.
 
 Honestly, I think your best bet is to just trust the file system to 
 recognize a bad file name and raise an exception. What counts as a bad 
 file name is surprisingly hard to define, especially if you want to be 
 cross-platform. See here for more details:
 
 
 http://stackoverflow.com/questions/295135/turn-a-string-into-a-valid-
 filename-in-python
 
 

Yep, I spotted that too which is why white-listing is my fallback plan.
My question is really about the security of using unfiltered data in a
filesystem function though. Are there particualar exploits that could
make use of such unfiltered calls? For example I'd imagine jailbreaking
might be a concern if the app isn't run under it's own restricted user
account. Do others here consider this when designing applications and
what techniques/modules, if any, do you use to sanitize path/filename input?

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


PIL (python imaging library) or Mathematics help both appreciated

2008-11-24 Thread amine
well, here is the background.  I have images of objects (cars,
clothes, ...) with a white background in most of the cases

I have to build a function with PIL that takes away the background.
it seems simple, just look for the white and make it transparent but
the problem is in reality much more complex:
1) the image could contain some white inside the object (e.g. shoes
with some white in between straps)
2) there are often pixels that are part of the background but have a
colour different from white which leaves a few points throughout the
image

to be more concrete:
here is a bit of code of what i've made so far

def transparent(im):
#i take all the images of the pixel
pixels = list(im.getdata())
#i convert the image into png
if im.mode != 'RGBA':
 im = im.convert('RGBA')
#i create a new image with the same dimension with one unique layer
for transparency
width , height = im.size
gradient = Image.new('L', (width,height))
white = { 'r' : 255 , 'g' : 255, 'b' : 255 }
#i browse the pixels of the image
for y in range(height):
 yp = y * width
 for x in range(width):
  xy = yp + x
  pix = pixels[xy]
  #the color of the current pixel
  c = { 'r' : pix[0] , 'g' : pix[1], 'b' : pix[2] }
  #i calculate the vectorial distance between the current color and
the color white
  d = sqrt( pow((c['r']- white['r'] ),2) + pow((c['g'] - white['g']),
2) + pow((c['b'] - white['b']),2) )
  if d  5 :
   #if it is more or less white, i make the pixel transparent
   gradient.putpixel((x,y) , 0 )
  else:
   #otherwise i show the color
   gradient.putpixel((x,y) , 255)

after the layer of transparency of the new image is done, the
algorithm works generally fine except there are some small but
noticeable quality issues.  i am just asking myself if there is maybe
not a better approach either in terms of algorithms or even
mathematics or maybe refine the algorithm that i've create.  anything
would help.

i know the function will not be 100% precise but I just hope the image
can be presentable and that the image is homogenous.

thank you in advance for your help.
--
http://mail.python.org/mailman/listinfo/python-list


Install modules with no root privilegies

2008-11-24 Thread Alfons Nonell-Canals
Hello,
Install python modules in a linux computer is really easy, it is because
the module is a package of the distribution or because the python
installation is really easy. But, in both situations, you need root
privilegies.

I would like to know how to install modules only for one user, with no
root privilegies. Do you know if it is possible and easy. I would like
to add that i need some modules only for my user and incly for one
progam.

Thanks in advance!

Alfons.

-- 

Alfons Nonell-Canals, PhD
Chemogenomics Lab
Research Group on Biomedical Informatics (GRIB) - IMIM/UPF
Barcelona Biomedical Research Park (PRBB)
C/ Doctor Aiguader, 88 - 08003 Barcelona 
[EMAIL PROTECTED] - http://cgl.imim.es
Tel. +34933160528

http://alfons.elmeuportal.cat
http://www.selenocisteina.info

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


Re: Install modules with no root privilegies

2008-11-24 Thread Philipp Pagel
Alfons Nonell-Canals [EMAIL PROTECTED] wrote:
 Install python modules in a linux computer is really easy, it is because
 the module is a package of the distribution or because the python
 installation is really easy. But, in both situations, you need root
 privilegies.

 I would like to know how to install modules only for one user, with no
 root privilegies. Do you know if it is possible and easy.

Yes, there is. You can choose among two strategies referred to as home scheme
and prefix scheme in the Installing Python Modules documentation:

http://docs.python.org/install/index.html

Have a look at Section 3 Alternate installation.

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl f. Genomorientierte Bioinformatik
Technische Universität München
http://mips.gsf.de/staff/pagel
--
http://mail.python.org/mailman/listinfo/python-list


Re: PIL (python imaging library) or Mathematics help both appreciated

2008-11-24 Thread Arnaud Delobelle
Well not much maths in my answers but...

On 24 Nov, 08:52, amine [EMAIL PROTECTED] wrote:
 well, here is the background.  I have images of objects (cars,
 clothes, ...) with a white background in most of the cases

 I have to build a function with PIL that takes away the background.
 it seems simple, just look for the white and make it transparent but
 the problem is in reality much more complex:
 1) the image could contain some white inside the object (e.g. shoes
 with some white in between straps)

A simple solution would be to start with a transparent pixel in the
top left corner say, then scan the image from left to right (line by
line): if the current pixel is white (or pale enough) and has a
transparent pixel above it or to its left, then make it transparent.

I remember when I was a kid playing graphical adventure games on my
C64, you could actually see this happening as the picture was being
built on the screen (as a floppy could only contain around 160k, you
couldn't store bitmaps unless you had very few pictures).

 2) there are often pixels that are part of the background but have a
 colour different from white which leaves a few points throughout the
 image

What you're doing is fine I think: calculate the distance to white.

HTH

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


3.0rc3: List of 'os.', 'os.path.' attribute redundencies ... !! ?

2008-11-24 Thread bMotu
IDLE 3.0rc3  (using XP)
 import os

 os.altsep
'/'
 os.path.altsep
'/'

 os.curdir
'.'
 os.path.curdir
'.'

 os.defpath
'.;C:\\bin'
 os.path.defpath
'.;C:\\bin'

 os.devnull
'nul'
 os.path.devnull
'nul'

 os.pardir
'..'
 os.path.pardir
'..'

 os.pathsep
';'
 os.path.pathsep
';'

 os.sep
'\\'
 os.path.sep
'\\'

these - me thinks - should go away:
   os.altsep
   os.path.curdir
   os.path.defpath
   os.pathsep
   os.sep

these I do not understand:
 os.devnull
'nul'
 os.path.devnull   # should probably go away
'nul'

 os.pardir
'..'
 os.path.pardir   # should probably go away
'..'

ciao, motu
--
http://mail.python.org/mailman/listinfo/python-list


Re: Module Structure/Import Design Problem

2008-11-24 Thread Rafe
On Nov 22, 2:39 am, Stef Mientki [EMAIL PROTECTED] wrote:
 Gabriel Genellina wrote:
  En Thu, 20 Nov 2008 17:36:11 -0200, Stef Mientki
  [EMAIL PROTECTED] escribió:

  I'm not an expert, I even don't fully understand your problem,
  but having struggled with imports in the past,
  I've a solution now, which seems to work quit well.

  That's not very helpful, is it? Were you planning to keep the solution
  secret?

  sorry slip of the keyboard ;-)
 http://mientki.ruhosting.nl/data_www/pylab_works/pw_importing.html

  May I reiterate my criticism to your solution posted last week?

 You're welcome,
 if there are better (even more important simpler) solutions, I'm in. I don't 
 think extending sys.path to include every directory under your
  project is a good idea. Basically, you're flattening the directory
  layout, removing any structure, like it was before Python 1.5 added
  package support.
  It is like dumping all your modules in a single directory, with no
  hierarchy and lots of name conflicts.

 Well I started at 2.4 and now arrived at 2.5, so I don't know what it
 was at 1.5.
 And I'm probably going to stay at 2.5 for a long time, upgrading is one
 of the few (maybe the only) disadvantages of Python ;-)
 For Python, I guess you're right, all files are in one flat directory, ...
 ... but it's just 1 program, so what's the objection ?
 For the program itself, which is highly dynamic, it can find sets of
 python-files in certain subpaths,
 so that's quit ordered I think ?

  Worse: because your proposal makes the same file reachable under many
  different names, the *same* source module will generate *different*
  module objects stored as *different* entries in sys.modules. Globals
  don't work anymore, subclasses aren't subclasses... lots of problems.

 Could you explain this a little more ...
 ... I'm just adding every subpath to the Pythonpath,
 so in my ignorant believe, every module is imported the same way, but I
 might be wrong.
  Globals not working , a good program doesn't have any globals ( said
 a non-programmer ;-)
 Subclasses aren't subclasses ? ( I always derive subclasses in the
 module itself, or in the same directory as the parentclass) Relative imports 
 (PEP328 [1]) were introduced -among other things- as
  an attempt to avoid such problems. You're going in the opposite
  direction. Please stop doing that - or at least keep us informed of
  where you work!

  [1]http://www.python.org/dev/peps/pep-0328

 Sorry I don't understand all that pep-talk (I'm not a programmer ;-)
 I read it starts with  For the second problem, it is proposed that all
 import statements be absolute by default (searching sys.path only) with
 special syntax (leading dots) for accessing package-relative imports.
 I think that's exactly what I'm doing: absolute imports.

 Please explain in simple language what I'm all doing wrong,
 or how I get a better solution.

 thanks,
 Stef

Hi Stef,

I'm not a programmer either (and still in my first year of using
python), so I understand a bit of where you are coming from. There is
some good info in this thread, but put simply...

- There is very rarely a reason to add things to the python path since
only the module, or package top folder, needs to be in the pthon path
for everything to work (which really means the parent folder is in the
path as python looks in the folder on the path for modules and
packages). If python can find the top folder in a package (folder
structure with __init__.py files in each folder), then you can access
everything easily.

- Use the simplest form of import that works for what you need. From
my reading on python standards, this is the simplest to use and read:
 import foo.bar as bar

Only use 'as' if the path is really long and you don't want to type it
every time (I often use modules if they are only two levels deep
without 'as'. It makes the code easier to read in many cases). It's
like creating a shortcut or alias.

The next most common is probably the from ... import ... form.

I'd say the general rule-of-thumb is to avoid situations where you
don't know where a name comes from. This is why from foo import * is
generally evil. I have only found a single case to use this and that
is when I have a globals module that is designed for use with 'import
*'. 99% of the time I use the standard 'import module path'

Examples:

If I have:
package
__init__.py  # Can be empty
subpackage
__init__.py  # Can be empty
module.py# has ClassA in it

I will almost always do this:
 import package.subpackage.module as module
 module.ClassA()

This makes it easy to understand where it is coming from (or at the
very least offers a clue to look for import statements). Worse is:
 from package.subpackage import module
 module.ClassA()

I'm not sure if there is any difference to the above, but again, I try
to use the simplest form possible, and this is just a more complicated
version of the same thing (IMO). It isn't 

Re: Python 3.0 - is this true?

2008-11-24 Thread Duncan Grisby
In article [EMAIL PROTECTED],
Terry Reedy  [EMAIL PROTECTED] wrote:

[...]
 l = []
 for line in open(bigfile.txt):
 x = random.randint(0,100)
 if x  4: l.append(None)
 else: l.append(line)

So use '' or '\0' instead of None for null lines.  Or replace None for 
the sort.

Both '' and '\0' could conceivably be valid data values. The problem
is that the data comes from a dynamically-typed database, so there is
no guarantee what the data values might be. This for loop with a file
is just an example that generates similar-looking data. It bears no
relation to the way the data is actually acquired.

 And maybe once in a while you end up with something not dissimilar to:
 
 l = []
 for line in open(bigfile.txt):
 x = random.randint(0,100)
 if x  4: l.append(None)
 elif x  5: l.append([line,line])
 else: l.append(line)
 
 In that kind of case it doesn't really matter what happens to list
 items in the sort order, but it's important it doesn't fail to sort
 the ones that are strings.

Replace the sublists with a coded string, such as '\0'+line.

Again, this is just an example. As I say, in the real application, the
data has come from a dynamically-typed database. There's no easy way
to coerce all the items to the same type, because the application
doesn't know up-front what the data is going to look like. In some
cases, it may be that all the data items are lists of strings. In
other cases, all or most of the data items will be integers, for
example.

If sorting is time (and space) critical, you want a straight string sort 
without key *or* cmp function.

That's exactly my point. Currently, the application just builds a list
of values retrieved from the database and asks Python to sort it. No
key or cmp function. With Python 3.0, it's going to require a lot more
work than that.

For my application, Python 3's comparison behaviour is a backwards
step. You can argue all you like that the new behaviour is the right
thing to do, and I'd be inclined to agree with you from a
philosophical point of view, but the fact is that it _will_ cause
problems for existing real code. The particularly ironic thing is that
the database's dynamic typing is closely modelled on Python, including
it's ability to gracefully handle mixed-type lists.

Cheers,

Duncan.

-- 
 -- Duncan Grisby --
  -- [EMAIL PROTECTED] --
   -- http://www.grisby.org --
--
http://mail.python.org/mailman/listinfo/python-list


Re: Can't find Python Library packages in Ubuntu (Debian)

2008-11-24 Thread Jerzy Jalocha N
On Fri, Nov 21, 2008 at 9:37 AM, David Cournapeau [EMAIL PROTECTED] wrote:
 I think most people using python as a development tool use the version
 available in their distribution. Personally, I mostly use the stock
 python of Ubuntu. Although building python itself is not difficult on
 the typical linux box, keep in mind that you will almost certainly
 need to re-build all the packages you need. Tt is not easy if at all
 possible to use extensions from one python interpreter to the other,
 in particular for packages which contain C code (things like pygtk,
 pyqt come to mind). If you want to use python 2.6, you don't have a
 choice, though, since it is not available on Ubuntu yet as you said.

David, I agree with you, that compiling all the additional packages could
become quite difficult, especially for an unexperienced guy like me.
Thus, I will keep using the stock install for everyday use, and use my
custom installation (standard python only, without additional packages)
for the missing unit-tests, and for testing upcoming 2.6/3.0 compatibility.

I will try to contact whoever is responsible for the packaging of Python
in Ubuntu (or Debian), and ask them if they are willing to support the
_complete_ Python release.

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


Re: 3.0rc3: 'os.extsep' gone ... ?

2008-11-24 Thread Paul Boddie
On 24 Nov, 08:43, Martin v. Löwis [EMAIL PROTECTED] wrote:

 That doesn't really explain it. It always was os.path.extsep,
 but it *also* was os.extsep.

I've always known it as the former; a perusal of the Python repository
would probably indicate when it became exposed in the os module
itself. Support for extension separators (extsep and splitext) has
always been somewhat lacklustre in the os(.path) module, perhaps due
to complicated filename syntax from operating systems like VMS, but
it'd be good to improve this support in future, I think.

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


Re: Can't find Python Library packages in Ubuntu (Debian)

2008-11-24 Thread Paul Boddie
On 24 Nov, 12:42, Jerzy Jalocha N [EMAIL PROTECTED] wrote:

 I will try to contact whoever is responsible for the packaging of Python
 in Ubuntu (or Debian), and ask them if they are willing to support the
 _complete_ Python release.

They may already do so, but I'd argue that they could document the
packages which provide the complete release a bit better if these are
not already mentioned in /usr/share/doc/python/README.Debian or some
similar file. By looking at the documentation for the Debian stable
source package, I did manage to find a list of generated packages:

http://packages.debian.org/source/etch/python-defaults

Perhaps one of these contains the test files. Although such files are
arguably only of use to people building Python, and such people would
therefore obtain the source package in order to perform the build
process, there could be some benefit in having a package which
provides these files separately. For example, one may wish to verify
the behaviour of an installed version or to test aspects of another
implementation. I don't see a problem with you (or someone else)
filing a bug about this, but then I'm not too familiar with the
packaging policies of Debian with respect to Python.

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


RE: Sphinx 0.5 released

2008-11-24 Thread kgmuller
Happy Birthday, Georg! Thanks for a great tool!

Klaus SimPy Muller 

 -Original Message-
 From: Georg Brandl [mailto:[EMAIL PROTECTED] 
 Sent: Sonntag, 23. November 2008 19:45
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Sphinx 0.5 released
 
 Hi all,
 
 I'm proud to announce the release of Sphinx 0.5 - Birthday 
 edition! [1]
 
 What is it?
 ===
 
 Sphinx is a tool that makes it easy to create intelligent and 
 beautiful documentation for Python projects (or other 
 documents consisting of multiple reStructuredText source files).
 
 Its website is at http://sphinx.pocoo.org/.
 
 Important changes
 =
 (full changelog at http://sphinx.pocoo.org/changes.html)
 
 There have been lots of changes since the 0.4 series.
 
 First of all, development moved to Mercurial and BitBucket.org.
 The new project page is http://www.bitbucket.org/birkenfeld/sphinx,
 which is also the repo URL.  See the Wiki there for more 
 information on Mercurial, issues and extensions.
 
 Highlights of new features -- in no particular order:
 
   - Added support for internationalization in generated text with the
 ``language`` and ``locale_dirs`` config values.  Many thanks to
 language contributors:
 
 * Horst Gutmann -- German
 * Pavel Kosina -- Czech
 * David Larlet -- French
 * Michal Kandulski -- Polish
 * Yasushi Masuda -- Japanese
 * Guillem Borrell -- Spanish
 * Luc Saffre and Peter Bertels -- Dutch
 * Fred Lin -- Traditional Chinese
 * Roger Demetrescu -- Brazilian Portuguese
 * Rok Garbas -- Slovenian
 
   - The new extensions ``sphinx.ext.jsmath`` and 
 ``sphinx.ext.pngmath``
 provide math support for both HTML and LaTeX builders.
 
   - The new extension ``sphinx.ext.intersphinx`` half-automatically
 creates links to Sphinx documentation of Python objects in other
 projects.
 
   - The new extension ``sphinx.ext.todo`` allows the insertion of
 To do directives whose visibility in the output can be toggled.
 It also adds a directive to compile a list of all todo items.
 
   - The JavaScript search now searches for objects before searching in
 the full text.
 
   - Citations are now global: all citation defined in any file can be
 referenced from any file.  Citations are collected in a 
 bibliography
 for LaTeX output.
 
   - Footnotes are now properly handled in the LaTeX builder: 
 they appear
 at the location of the footnote reference in text, not at 
 the end of
 a section.  Thanks to Andrew McNamara for the initial patch.
 
   - You can now document several programs and their options with the
 new ``program`` directive.
 
   - Figures with captions can now be referred to like section titles,
 using the ``:ref:`` role without an explicit link text.
 
   - Only generate a module index if there are some modules in the
 documentation.
 
   - The new config value ``latex_elements`` allows to 
 override all LaTeX
 snippets that Sphinx puts into the generated .tex file by default.
 
   - Added ``source_encoding`` config value to select input encoding.
 
   - sphinx.ext.autodoc has been improved considerably with respect to
 customization and extensibility.
 
   - Added a command-line switch ``-A``: it can be used to supply
 additional values into the HTML templates.
 
   - Added a command-line switch ``-C``: if it is given, no 
 configuration
 file ``conf.py`` is required.
 
   - Added a distutils command `build_sphinx`: When Sphinx is 
 installed,
 you can call ``python setup.py build_sphinx`` for 
 projects that have
 Sphinx documentation, which will build the docs and place them in
 the standard distutils build directory.
 
 Many thanks go to the many contributors, bug reporters and 
 discussion participants on the mailing list who helped shape 
 this release.
 
 Enjoy,
 Georg
 
 [1] Yes, it's my birthday today. Yes, I have a life. ;)
 
 
 

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


Re: Security implications of using open() on untrusted strings.

2008-11-24 Thread Thomas Bellman
r0g [EMAIL PROTECTED] wrote:

 Although it's a desktop (not internet facing) app I'm a little squeamish
 piping raw user input into a filesystem function like that and this app
 will be dealing with some particularly sensitive data so I want to be
 careful and minimize exposure where practical.

 Has programming PHP and Web stuff for years made me overly paranoid
 about this or do I should I still be scrubbing input like this before I
 feed it to filesystem functions?  If so does anyone know of a module
 that may help or have any other advice.

 Note: In this particular case the user input is only specifying the name
 of a file that will be opened for writing _not_ reading and the
 interface is GUI only (wxWidgets).

Is the user *running* the application the same as the user who
feeds it input?  If it is, then there is no need to filter the
filenames, since that user could just do rm bad-file (or DEL
BAD-FILE on MS-Windows) anyway to destroy it.

(Of course, if you are passing the filename to, e.g, os.system(),
you would need to quote it properly, but that is to avoid
surprising the user; it is one thing to let the user overwrite a
file named foo; rm -rf $HOME, quite another to pass that string
unquoted to /bin/sh when the user thought he was just typing a
filename.)


-- 
Thomas Bellman,   Lysator Computer Club,   Linköping University,  Sweden
I don't think [that word] means what you!  bellman @ lysator.liu.se
 think it means.   -- The Princess Bride!  Make Love -- Nicht Wahr!
--
http://mail.python.org/mailman/listinfo/python-list


Welcome to MultiHoster, a free image upload solution. Simply browse, select, and upload !!

2008-11-24 Thread jenny
http://www.effriend.com/index.php
--
http://mail.python.org/mailman/listinfo/python-list


Re: Estimating size of dictionary

2008-11-24 Thread python
Steven,

Wonderful! You and your references answered all my questions.

I had missed 2.6's new getsizeof() function. Yet another reason to do
the 2.5-to-2.6 upgrade.

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


[ANN]: pdftools.pdfposter 0.4.5

2008-11-24 Thread Hartmut Goebel
I'm pleased to announce pdftools.pdfposter 0.4.5, a tool to scale and
tile PDF images/pages to print on multiple pages.

   http://pdfposter.origo.ethz.ch/download/

This version honors cropped pages (/ArtBoxes, /CropBox).

Starting with version 0.4.5, the package was renamed to
'pdftools.pdfposter'. This will allow integrating some other tools
(pdfnup, pdfsplit, etc.) into a larger toolset somewhen.

Download
---

:Quick Installation:
easy_install -U pdftools.pdfposter

:Tarballs:
http://pdfposter.origo.ethz.ch/download/


What is pdfposter?


Scale and tile PDF images/pages to print on multiple pages.

``Pdfposter`` can be used to create a large poster by building it from
multiple pages and/or printing it on large media. It expects as input a
PDF file, normally printing on a single page. The output is again a
PDF file, maybe containing multiple pages together building the
poster.
The input page will be scaled to obtain the desired size.

This is much like ``poster`` does for Postscript files, but working
with PDF. Since sometimes poster does not like your files converted
from PDF. :-) Indeed ``pdfposter`` was inspired by ``poster``.

For more information please refer to the manpage or visit
the `project homepage http://pdfposter.origo.ethz.ch/`_.


:Author:Hartmut Goebel [EMAIL PROTECTED]
:Copyright: GNU Public Licence v3 (GPLv3)
:Homepage:  http://pdfposter.origo.ethz.ch/
--
http://mail.python.org/mailman/listinfo/python-list


Python-URL! - weekly Python news and links (Nov 24)

2008-11-24 Thread Gabriel Genellina
QOTW:  One of the reasons for Python's continue march towards world domina-
tion (allow me my fantasies) is its consistent simplicity. Those last two
words would be my candidate for the definition of 'Pythonicity'. - Steve
Holden
http://groups.google.com/group/comp.lang.python/msg/e2518ea8388ca1c5


The last Release Candidate (RC3) for Python 3.0 is available
http://groups.google.com/group/comp.lang.python/t/fbb62e9c9a08c817/

Survey: which dynamic features of Python do you use most?
http://groups.google.com/group/comp.lang.python/t/bdb39a1a4947cdd8/

Beginners looking for problems/challenges/exercises to do:
http://groups.google.com/group/comp.lang.python/t/2b8a0b4ffdbdffbf/

Call-by-Object strikes again! This time, a functional mind asks why
unrelated functions are allowed to modify the internal state of an object:
http://groups.google.com/group/comp.lang.python/t/35511397ad7748cc/

How to detect whether a dictionary has been modified
http://groups.google.com/group/comp.lang.python/t/3632f2407640e759/

Function default arguments are only evaluated when the function is
defined.  Is it intuitive? Ways to change the current behaviour.
http://groups.google.com/group/comp.lang.python/t/2e01cc9ce899eb6e/
http://groups.google.com/group/comp.lang.python/t/1209ebf18a5ec561/

Installing Python on Windows Vista may require using the Administrator
account
http://groups.google.com/group/comp.lang.python/t/a745ed3df47e1be9/

Elegant ways to execute a function at most n times or until succeeds:
http://groups.google.com/group/comp.lang.python/t/10d651c2a0eb082e/

__cmp__ is gone in Python 3 - how to implement a total ordering in
a simple way?
http://groups.google.com/group/comp.lang.python/t/2a672f960e595c76/



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

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

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily

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

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

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

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.
http://groups.google.com/group/comp.lang.python.announce/topics

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

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

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

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

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

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

The Summary of Python Tracker Issues is an automatically generated
report summarizing new bugs, closed ones, and patch submissions. 

http://search.gmane.org/?author=status%40bugs.python.orggroup=gmane.comp.python.develsort=date

Although unmaintained since 2002, the Cetus collection of Python
hyperlinks retains a few gems.
http://www.cetus-links.org/oo_python.html

Python FAQTS
http://python.faqts.com/

The Cookbook is a collaborative effort to capture useful and
interesting recipes.
http://code.activestate.com/recipes/langs/python/

Many Python conferences around the world are in preparation.
Watch this space for links to them.

Among several Python-oriented RSS/RDF feeds available, see:
http://www.python.org/channews.rdf
For more, see:

Re: PIL (python imaging library) or Mathematics help both appreciated

2008-11-24 Thread Jorgen Grahn
On Mon, 24 Nov 2008 00:52:02 -0800 (PST), amine [EMAIL PROTECTED] wrote:
 well, here is the background.  I have images of objects (cars,
 clothes, ...) with a white background in most of the cases

 I have to build a function with PIL that takes away the background.
 it seems simple, just look for the white and make it transparent but
 the problem is in reality much more complex:
 1) the image could contain some white inside the object (e.g. shoes
 with some white in between straps)
 2) there are often pixels that are part of the background but have a
 colour different from white which leaves a few points throughout the
 image

 to be more concrete:
 here is a bit of code of what i've made so far
...
 after the layer of transparency of the new image is done, the
 algorithm works generally fine except there are some small but
 noticeable quality issues.  i am just asking myself if there is maybe
 not a better approach either in terms of algorithms or even
 mathematics or maybe refine the algorithm that i've create.  anything
 would help.

 i know the function will not be 100% precise but I just hope the image
 can be presentable and that the image is homogenous.

How about calling on the Gimp? I haven't done it, but I seem to recall
it has a Python interface.  Hopefully that means you can use its
algorithms from a standalone Python program, with no GUI.

I guess in the Gimp you'd use a fuzzy select a continuous region
around this pixel with approximately this color algorithm. Then you'd
use another one which replaces the whiteness with transparency.

/Jorgen

-- 
  // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu
\X/ snipabacken.se  R'lyeh wgah'nagl fhtagn!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.0 - is this true?

2008-11-24 Thread Aahz
In article [EMAIL PROTECTED],
Duncan Grisby  [EMAIL PROTECTED] wrote:
In article [EMAIL PROTECTED],
Terry Reedy  [EMAIL PROTECTED] wrote:

Replace the sublists with a coded string, such as '\0'+line.

Again, this is just an example. As I say, in the real application, the
data has come from a dynamically-typed database. There's no easy way
to coerce all the items to the same type, because the application
doesn't know up-front what the data is going to look like. In some
cases, it may be that all the data items are lists of strings. In
other cases, all or most of the data items will be integers, for
example.

If sorting is time (and space) critical, you want a straight string sort 
without key *or* cmp function.

That's exactly my point. Currently, the application just builds a list
of values retrieved from the database and asks Python to sort it. No
key or cmp function. With Python 3.0, it's going to require a lot more
work than that.

Unless I misunderstand you, your application is broken already.  Complex
numbers have never been sortable.  If your application works more like a
SQL database, then any given column will have only one datatype and as
long as you avoid types that cannot be compared against themselves
you're safe.

(I'll agree that from some perspectives the new behavior of None is a
wart but I think that in the end I agree with people who say that
preventing None from being sorted except intentionally will trap more
bugs earlier.)

For my application, Python 3's comparison behaviour is a backwards
step. You can argue all you like that the new behaviour is the right
thing to do, and I'd be inclined to agree with you from a
philosophical point of view, but the fact is that it _will_ cause
problems for existing real code. The particularly ironic thing is that
the database's dynamic typing is closely modelled on Python, including
it's ability to gracefully handle mixed-type lists.

What I think people are arguing about is your use of the word backward.
I don't think anyone claims that fixing your application will be trivial,
but your application appears to be already broken, and Python 3.0 is
simply forcing you to confront it head-on.
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

It is easier to optimize correct code than to correct optimized code.
--Bill Harlan
--
http://mail.python.org/mailman/listinfo/python-list


Re: 3.0rc3: 'os.extsep' gone ... ?

2008-11-24 Thread Terry Reedy

Christian Heimes wrote:

bMotu wrote:

IDLE 2.6

import os
os.extsep

'.'
running XP this result is fine ... !

IDLE 3.0rc3

import os
os.extsep

Traceback (most recent call last):
  File pyshell#1, line 1, in module
os.extsep
AttributeError: 'module' object has no attribute 'extsep'

why is this attribute gone in 3.0rc3 ?

where is this documented ?


It's now os.path.extsep.


In 3.0, os.curdir, os.pardir, os.sep, os.altsep, os.pathsep, os.defpath, 
and os.devnull are also in os.path. (Hurray for set intersection.) 
os.extset was in os.path and is documented to still be so, but was 
removed.  os.linesep, inconsistently, never was in os.path.  I think 
either all or none should be duplicated.


The doc for os.path begins This module implements some useful functions 
on pathnames.  The duplication of the sysinfo constants is not 
mentioned!  So if they are only in one place, it should be os, not 
os.path.


The name 'stat' is in both, but is bound to different objects (built-in 
function versus module).


Terry Jan Reedy

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


ANN: Resolver One 1.3 released

2008-11-24 Thread Giles Thomas
We are proud to announce the release of Resolver One, version 1.3.
Resolver One is a spreadsheet that allows you to write Python directly
in cells, and converts the spreadsheets you create into Python
programs.  It's based on IronPython, and runs on Windows.

For version 1.3, we've made two big changes:

* Our Web server, which (as you would expect) allows you to expose
your spreadsheets to other people as web applications, is now included
- it was previously a commercial-only product.
* We've added column- and row-level formulae.  With these, you can
specify one formula which is then used to fill in a whole column or
row, reducing duplication and starting to bring some of the benefits
of loops to the spreadsheet world.

We've done a screencast outlining both of these: http://
www.resolversystems.com/screencasts/release-1.3/

Michael Foord also did a great screencast describing how you can use
Python-syntax formulae with column-level formulae to do interesting
stuff: http://www.resolversystems.com/screencasts/column-formulae/

Resolver One is free for non-commercial use, so if you would like to
take a look, you can download it from our website: http://
www.resolversystems.com/download/


Best regards,

Giles
--
Giles Thomas
MD  CTO, Resolver Systems Ltd.
[EMAIL PROTECTED]
+44 (0) 20 7253 6372

Try out Resolver One! http://www.resolversystems.com/get-it/

17a Clerkenwell Road, London EC1M 5RD, UK
VAT No.: GB 893 5643 79 Registered in England and Wales as company
number 5467329.
Registered address: 843 Finchley Road, London NW11 8NA, UK
--
http://mail.python.org/mailman/listinfo/python-list


Re: Security implications of using open() on untrusted strings.

2008-11-24 Thread Terry Reedy

r0g wrote:


Yep, I spotted that too which is why white-listing is my fallback plan.
My question is really about the security of using unfiltered data in a
filesystem function though. Are there particualar exploits that could
make use of such unfiltered calls?


The classic one would be submitting a filename such as 'a'*1000, but 
current OSes should be immune from that sort of thing by now.



 For example I'd imagine jailbreaking

might be a concern if the app isn't run under it's own restricted user
account. Do others here consider this when designing applications and
what techniques/modules, if any, do you use to sanitize path/filename input?


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


Re: Using dictionary to hold regex patterns?

2008-11-24 Thread Thomas Mlynarczyk

Dennis Lee Bieber schrieb:

Is [ ( name, regex ), ... ] really simpler than { name: regex, ... 
}? Intuitively, I would consider the dictionary to be the simpler 
structure.



Why, when you aren't /using/ the name to retrieve the expression...


So as soon as I start retrieving a regex by its name, the dict will be 
the most suitable structure?


Greetings,
Thomas

--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
--
http://mail.python.org/mailman/listinfo/python-list


Re: crack registration codes for pogo games

2008-11-24 Thread Kristie
your site doesn't come up. I was looking for crack registration codes for any 
pogo games.

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


Re: Python 3.0 - is this true?

2008-11-24 Thread Tim Rowe
2008/11/24 Aahz [EMAIL PROTECTED]:

 (I'll agree that from some perspectives the new behavior of None is a
 wart but I think that in the end I agree with people who say that
 preventing None from being sorted except intentionally will trap more
 bugs earlier.)

So will Python be introducing strong type checking and early binding,
so we can catch more bius earlier (compile rather than run time?) ;-)

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


Re: My first Python program -- a lexer

2008-11-24 Thread Thomas Mlynarczyk

John Machin schrieb:


*IF* you need to access the regex associated with a token in O(1)
time, a dict is indicated.


O(1) - Does that mean `mydict[mykey]` takes the same amount of time, no 
matter if mydict has 10 or 10 entries? How does this magic work? 
O(log n) I would understand, but constant time?



If you have *both* requirements simultaneously, then *both* list and
dict are indicated.


So I would have to duplicate my data and store it once in a list, once 
in a dict? Or should I decide for one way and accept that one type of 
access will not be optimal?


Greetings,
Thomas

--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
--
http://mail.python.org/mailman/listinfo/python-list


Re: RELEASED Python 3.0rc3

2008-11-24 Thread Trent Mick

And 2.6 is in final release? So when ActiveState speaks of 2.6.0.0
they mean a final release?


Yes. The first three parts of the ActivePython version are the same as 
the core Python version on which it is based.




So, if the IDLE from ActiveState comes up and says 2.6 (indicating
final release), shouldn't the copywrite message also say 2.6
instead of 2.6rc1 as shown here?

Python 2.6rc1 (r26rc1:66438, Sep 13 2008, 09:20:38) [MSC v.1500 32
bit
(Intel)] on win32
Type copyright, credits or license() for more information.


This is what I get when I run IDLE with ActivePython 2.6.0.0 installed:

-
Python 2.6 (r26:66714, Nov 11 2008, 10:21:19) [MSC v.1500 32 bit 
(Intel)] on win32

Type copyright, credits or license() for more information.
-

I ran it like this:

  C:\Python26 pythonw.exe Lib\idelib\idle.pyw


I believe there is a problem with your install. My guess is that your 
ActivePython install is using an older python26.dll sitting around 
somewhere.


Is there a python26.dll somewhere in your C:\Python26 directory, or 
wherever you installed ActivePython 2.6?




Trent

--
Trent Mick
trentm at activestate.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using dictionary to hold regex patterns?

2008-11-24 Thread Thomas Mlynarczyk

John Machin schrieb:


Rephrasing for clarity: Don't use a data structure that is more
complicated than that indicated by your requirements.


Could you please define complicated in this context? In terms of 
characters to type and reading, the dict is surely simpler. But I 
suppose that under the hood, it is less work for Python to deal with a 
list of tuples than a dict?



Judging which of two structures is simpler should not be independent
of those requirements. I don't see a role for intuition in this
process.


Maybe I should have said upon first sight / judging from the outer 
appearance instead of intuition.



Please see my belated response in your My first Python program -- a
lexer thread.


(See my answer there.) I think I should definitely read up a bit on the 
implementation details of those data structures in Python. (As it was 
suggested earlier in my lexer thread.)


Greetings,
Thomas

--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to dynamically instantiate an object inheriting from several classes?

2008-11-24 Thread Matimus
On Nov 21, 2:11 pm, Joe Strout [EMAIL PROTECTED] wrote:
 I have a function that takes a reference to a class, and then  
 instantiates that class (and then does several other things with the  
 new instance).  This is easy enough:

     item = cls(self, **itemArgs)

 where cls is the class reference, and itemArgs is obviously a set of  
 keyword arguments for its __init__ method.

 But now I want to generalize this to handle a set of mix-in classes.  
 Normally you use mixins by creating a class that derives from two or  
 more other classes, and then instantiate that custom class.  But in my  
 situation, I don't know ahead of time which mixins might be used and  
 in what combination.  So I'd like to take a list of class references,  
 and instantiate an object that derives from all of them, dynamically.

 Is this possible?  If so, how?

 Thanks,
 - Joe

I wrote this a while ago. I sort of regret it though. Mixins could
(and I will argue should) be avoided most of the time by delegating to
other objects with less functionality. Utilizing many mixin classes
tends to just make gigantic classes. This is a huge violation of the
Single Responsibility Principle. That isn't to say that I don't
think there is a place for multiple inheritance. Multiple inheritance
to the point where it is easier to write a metaclass to automatically
generate your __init__ method than it is to write it yourself is a
good indicator that you have gone too far. Which is what I did.

code:

import inspect

class AutoGenInitMetaError(Exception):
 Exception is raised if AutoGenInitMeta cannot auto-generate a
constructor for a class because of conflicting parameters in base
classes.

pass

class AutoGenInitMeta(type):
 Meta-Class for automatically generating __init__ method for a
class
with multiple mixin base classes.

def __new__(cls, name, bases, assoc):
if __init__ in assoc:
return super(AutoGenInitMeta, cls).__new__(cls, name,
bases, assoc)
args = ['self']
dargs = []
defaults = []
tmpl = []
varg = None
vkwarg = None
tmpl = [def __init__%s:\n]
for base in bases[::-1]:
a, va, vkw, d = argspec = inspect.getargspec
(base.__init__)
argspecfmt = inspect.formatargspec(*argspec[:3])
if d:
num_d = len(d)
args += a[1:-num_d]
defaults += d
dargs += a[-num_d:]
else:
# remember to stip off self
args += a[1:]
if va is not None:
if varg is not None:
raise AutoGenInitMetaError(
There must be only one `*` arg in base
constructors
)
varg = va

if vkw is not None:
if vkwarg is not None:
raise AutoGenInitMetaError(
There must be only one `**` arg in base
constructors
)
vkwarg = vkw
tmpl.append(%s.__init__%s\n%(base.__name__,
argspecfmt))
tmpl = .join(tmpl)
argspec = (args + dargs, varg, vkwarg, defaults)
exec tmpl%inspect.formatargspec(*argspec) in globals(), assoc

return super(AutoGenInitMeta, cls).__new__(cls, name, bases,
assoc)


How do you use it?

 class C(object):
... def __init__(self, a, b):
... self.a = a
... self.b = b
...
 class D(object):
... def __init__(self, c, d):
... self.c = c
... self.d = d
...
 class CD(C, D):
... __metaclass__ = AutoGenInitMeta
...

 x = CD(1,2,3,4)

 x.a
3
 x.b
4
 x.c
1
 x.d
2


Notice that the arguments to D came before C. So you have to list the
classes in reverse order of how you want the arguments listed.

I post it as an example of a neat python trick. Even the neat
might be self indulgence. I encourage anybody tempted to use this to
refactor/redesign instead.

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


Re: how to dynamically instantiate an object inheriting from several classes?

2008-11-24 Thread Joe Strout

On Nov 24, 2008, at 11:10 AM, Matimus wrote:


I wrote this a while ago. I sort of regret it though. Mixins could
(and I will argue should) be avoided most of the time by delegating to
other objects with less functionality. Utilizing many mixin classes
tends to just make gigantic classes. This is a huge violation of the
Single Responsibility Principle.


I see your point, but in this case, I'm building a layout/config tool  
for use with wxPython, and wx uses a fair number of mixins (especially  
for the list control).



That isn't to say that I don't
think there is a place for multiple inheritance. Multiple inheritance
to the point where it is easier to write a metaclass to automatically
generate your __init__ method than it is to write it yourself is a
good indicator that you have gone too far. Which is what I did.


I appreciate the sample code, and the thoughtful comments.  You do  
yourself credit.


Best,
- Joe

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


Re: Can't find Python Library packages in Ubuntu (Debian)

2008-11-24 Thread Scott David Daniels

Jerzy Jalocha N wrote:

I'm new in this list (and to Python), so I'd like to start saying
hello to everyone first. I am really enjoying this new language!

I am trying to use the standard tests (like test_list.py or
test_dict.py) from the standard library (Python2.5), but they aren't
available on a standard Ubuntu Hardy or Ibex installation

So, the first question is: How do I install the complete Python test
framework under Ubuntu (Debian)?

You could use BZR or SVN to get a copy of the full Lib/test tree.  Given
your long-disconnected running, I'd consider getting a full source set
for release25-maint.
Note that as of Python 2.6 / 3.0, if Python is not restricted to
system directories for security reasons (if sys.flags.no_user_site is
non-0), you may make a directory in your home directory to be searched.

See   http://docs.python.org/library/site.html
for details on USER_SITE and USER_BASE.

That will allow you to place a test subdirectory under site.USER_SITE
and get to test.test_list (for example) on your python search path.
Since it is a user-specific location, you can make a tester user with
the directory in his own space and not worry about affecting the
standard environment.


--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: My first Python program -- a lexer

2008-11-24 Thread Steve Holden
Thomas Mlynarczyk wrote:
 John Machin schrieb:
 
 *IF* you need to access the regex associated with a token in O(1)
 time, a dict is indicated.
 
 O(1) - Does that mean `mydict[mykey]` takes the same amount of time, no
 matter if mydict has 10 or 10 entries? How does this magic work?
 O(log n) I would understand, but constant time?
 
Basically it hashes the key values to locate the corresponding value.

This is a drastic simplification, but if you do a Google search for
hash tables you will get the basic idea. Tim Peters, among others, has
spent a lot of time optimizing dict behavior.

 If you have *both* requirements simultaneously, then *both* list and
 dict are indicated.
 
 So I would have to duplicate my data and store it once in a list, once
 in a dict? Or should I decide for one way and accept that one type of
 access will not be optimal?
 
Storing the data once in a dict and once in a list doesn't duplicate the
data, since both structures will (optimally: i.e. if you do it right)
refer to the same data objects.

Generally speaking, do what's convenient to do as a programmer, and work
on it if there are serious inadequacies.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: Install modules with no root privilegies

2008-11-24 Thread Scott David Daniels

Alfons Nonell-Canals wrote:

Hello,
Install python modules in a linux computer is really easy, it is because
the module is a package of the distribution or because the python
installation is really easy. But, in both situations, you need root
privilegies.

I would like to know how to install modules only for one user, with no
root privilegies. Do you know if it is possible and easy. I would like
to add that i need some modules only for my user and incly for one
progam.

Thanks in advance!

Alfons.


As I just replied to another user (thinking I was responding to this
post), as of Python 2.6 / 3.0, if Python is not restricted to system
directories for security reasons (if sys.flags.no_user_site is non-0),
you may make a directory in your home directory to be searched.  See
http://docs.python.org/library/site.html
for details on USER_SITE and USER_BASE.

That provides a searched location without having to cook up a custom
PYTHONPATH.

--Scott David Daniels
[EMAIL PROTECTED]

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


No complex rationals in Python 3.0

2008-11-24 Thread Rock
I appreciate the inclusion of the fractions module in Python 2.6 and
therefore in Python 3.0. But I feel there's something missing: no
possibility for complex rationals (or arbitrary precision) integers. I
was just checking the complex number support in Python, compared, for
instance, to Common Lisp and Scheme, and I realized that there was
this subtle omission. The inclusion of rationals and arbitrary
integers is cool, but the numeric tower (say, compared to Scheme) is
not complete. I don't think there would be a performance hit if
complex rationals were provided. Ordinary operations on complex
floats, in theory, should not be affected and handled separately. But
it would be nice to be able to do:

(3/4 + 1/2j) * (1/4 - j) = 11/16 - 5/8j

with no loss of precision.

Python is heavily used in math and science all over the world. We've
even got a recent symbolic math project (sympy) that looks very
promising, so I guess this could be an important issue.

Note: there exists a library that implements what I'm talking about:
http://calcrpnpy.sourceforge.net/clnum.html
but still I personally would have liked to see this stuff included
natively in the new Python 3.0.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Install modules with no root privilegies

2008-11-24 Thread Diez B. Roggisch
Philipp Pagel wrote:

 Alfons Nonell-Canals [EMAIL PROTECTED] wrote:
 Install python modules in a linux computer is really easy, it is because
 the module is a package of the distribution or because the python
 installation is really easy. But, in both situations, you need root
 privilegies.
 
 I would like to know how to install modules only for one user, with no
 root privilegies. Do you know if it is possible and easy.
 
 Yes, there is. You can choose among two strategies referred to as home
 scheme and prefix scheme in the Installing Python Modules
 documentation:
 
 http://docs.python.org/install/index.html
 
 Have a look at Section 3 Alternate installation.

That's way much more than is actually needed, as thus each user
would end up with a different installation.

Setting the PYTHONPATH-env-variable to a user writable location allows e.g.
easy_install and friends to install into that location. And installing
virtualenv globally, everybody can create a local
site-packages-directory.

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


Re: Building Python 2.5.2 for Itanium

2008-11-24 Thread Christopher
On Nov 21, 3:50 pm, Martin v. Löwis [EMAIL PROTECTED] wrote:
    I need to compile that module for that release and platform, but I
  have been unable to discover which MS compiler version and runtime was
  used to generate the binaries.  My understanding is that Python 2.5.2
  in general uses Visual Studio 2003, but MS does not appear to have
  shipped anItaniumcompiler with that version of VS.

 That's correct. See PCbuild/readme.txt for (somewhat) detailed
 instructions; in essence, you need to use vsextcomp, if you want to
 use the official build process.


I am trying to follow the official build process.  I installed
vsextcomp, and it appears to work fine.  However, I have a number of
resource errors when I try to build pythoncore.

My first error was:


Compiling resources...
\Python-2.5.2\Pc\python_nt.rc(35) : error RC2104 : undefined keyword
or key name: MS_DLL_ID

So I remarked out the String table section:

STRINGTABLE DISCARDABLE
BEGIN
1000,   MS_DLL_ID
END

then I got:

Compiling resources...
\Python-2.5.2\Pc\python_nt.rc(44) : error RC2104 : undefined keyword
or key name: FIELD3

So I removed FIELD3 from:

#define PYVERSION64 PY_MAJOR_VERSION, PY_MINOR_VERSION, FIELD3,
PYTHON_API_VERSION

Finally, I received:

Compiling resources...
\Python-2.5.2\Pc\python_nt.rc(65) : error RC2104 : undefined keyword
or key name: PYTHON_DLL_NAME



Having so many errors I began to suspect something else had failed.

Lo and behold! --

Performing Custom Build Step
'.\make_versioninfo.exe' is not recognized as an internal or external
command,
operable program or batch file.
Project : error PRJ0019: A tool returned an error code from
Performing Custom Build Step

---

I had to manually build make_version.exe, which seems to have
generated those fields.  I'm not sure what the problem was with the
build of make_version.  The only error I could find was unable to
create response file.

I experienced the same problem with make_buildinfo.  After manually
building it, I was able to build pythoncore.

I am now looking into getting ctypes to build correctly.  My
investigations show that ctypes supports ia64, so I may be able to
make some progress on this front.

-={C}=-


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


Re: Python 3000

2008-11-24 Thread Diez B. Roggisch
alex23 wrote:

 On Nov 24, 5:47 pm, Dokorek [EMAIL PROTECTED] wrote:
 Python 3000 (a.k.a. Py3k, and released as Python 3.0) is a new
 version of the language that is incompatible with the 2.x line of
 releases. The language is mostly the same, but many details,
 especially how built-in objects like dictionaries and strings work,
 have changed considerably, and a lot of deprecated features have
 finally been removed. Also, the standard library has been reorganized
 in a few prominent places.
 
 This isn't stackoverflow. Posting items here that everyone is already
 fully aware of doesn't do anything positive for your reputation.

But it get's the OP low rates on spam filters, and thus hopes to attract
visitors to the crappy site mentioned in the signature.

Let's hope this doesn't catch on, or we suffer additionally to the more than
repetitive subjects such as default function arguments, the removal of self
as first parameter and not to forget how to kill a thread.

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


Re: No complex rationals in Python 3.0

2008-11-24 Thread bearophileHUGS
Rock:
so I guess this could be an important issue.

What they can be useful for?

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


Re: No complex rationals in Python 3.0

2008-11-24 Thread Christian Heimes

Rock wrote:

I appreciate the inclusion of the fractions module in Python 2.6 and
therefore in Python 3.0. But I feel there's something missing: no
possibility for complex rationals (or arbitrary precision) integers. I
was just checking the complex number support in Python, compared, for
instance, to Common Lisp and Scheme, and I realized that there was
this subtle omission. The inclusion of rationals and arbitrary
integers is cool, but the numeric tower (say, compared to Scheme) is
not complete. I don't think there would be a performance hit if
complex rationals were provided. Ordinary operations on complex
floats, in theory, should not be affected and handled separately. But
it would be nice to be able to do:

(3/4 + 1/2j) * (1/4 - j) = 11/16 - 5/8j

with no loss of precision.

Python is heavily used in math and science all over the world. We've
even got a recent symbolic math project (sympy) that looks very
promising, so I guess this could be an important issue.


Nobody has submitted a PEP and patch to implement the feature in time. 
There is still Python 3.1, you know? If you like to contribute the 
feature then please start a discussion on the Python Ideas mailing list 
(not the developer lists!).



Note: there exists a library that implements what I'm talking about:
http://calcrpnpy.sourceforge.net/clnum.html
but still I personally would have liked to see this stuff included
natively in the new Python 3.0.


The code depends on the CLN library which isn't suited for the Python 
core. It's written in C++ and it's licensed under GPL. Neither GPL nor 
LGPL software can't be integrated into the core. We also require all 
code to be compatible with C89.


Christian

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


for loop specifying the amount of vars

2008-11-24 Thread Jules Stevenson
Hi,

I have a list which contains a folder structure, for instance:

dirs=['c:\', 'temp', 'foo', 'bar']

The length of the list can vary. I'd like to be able to construct a
os.path.join on the list, but as the list can vary in length I'm unsure how
to do this neatly. I figured I could use a for loop and build the whole
statement as a string and 'eval it', but I'm aware that this is not a good
idea. 

It strikes me that there probably is a very elegant way to achieve what I
want to do, any pointers much appreciated.

Cheers,

Jules

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


Re: for loop specifying the amount of vars

2008-11-24 Thread Benjamin Kaplan
On Mon, Nov 24, 2008 at 2:31 PM, Jules Stevenson [EMAIL PROTECTED] wrote:

 Hi,

 I have a list which contains a folder structure, for instance:

 dirs=['c:\', 'temp', 'foo', 'bar']

 The length of the list can vary. I'd like to be able to construct a
 os.path.join on the list, but as the list can vary in length I'm unsure how
 to do this neatly. I figured I could use a for loop and build the whole
 statement as a string and 'eval it', but I'm aware that this is not a good
 idea.

 It strikes me that there probably is a very elegant way to achieve what I
 want to do, any pointers much appreciated.

 Cheers,

 Jules



 dirs = ['c:','temp','foo','bar']
 os.path.join(*dirs)
'c:\\temp\\foo\\bar'
--
http://mail.python.org/mailman/listinfo/python-list


Re: for loop specifying the amount of vars

2008-11-24 Thread Tim Chase

I have a list which contains a folder structure, for instance:

dirs=['c:\', 'temp', 'foo', 'bar']

The length of the list can vary. I'd like to be able to construct a
os.path.join on the list, but as the list can vary in length I'm unsure how
to do this neatly. 


Sounds like you want argument unpacking:

   dirs=['c:\\', 'temp', 'foo', 'bar']
   print os.path.join(*dirs)
  c:\temp\foo\bar

(side note:  you can't have a single trailing backslash like your 
example assignment)


The asterisk instructs python to unpack the passed list as if 
each one was a positional argument.  You may occasionally see 
function definitions of the same form:


  def foo(*args):
for arg in args:
  print arg
  foo('hello')
  foo('hello', 'world')
  lst = ['hello', 'world']
  foo(*lst)

You can use ** for dictionary/keyword arguments as well.  Much 
more to be read at [1].


-tkc


[1]
http://www.network-theory.co.uk/docs/pytut/KeywordArguments.html


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


RE: for loop specifying the amount of vars

2008-11-24 Thread Jules Stevenson
Sorry for the noise, I found the * unpack operator. Perfect for what I need.

 
 Hi,
 
 I have a list which contains a folder structure, for instance:
 
 dirs=['c:\', 'temp', 'foo', 'bar']
 
 The length of the list can vary. I'd like to be able to construct a
 os.path.join on the list, but as the list can vary in length I'm unsure
 how
 to do this neatly. I figured I could use a for loop and build the whole
 statement as a string and 'eval it', but I'm aware that this is not a
 good
 idea.
 
 It strikes me that there probably is a very elegant way to achieve what
 I
 want to do, any pointers much appreciated.
 
 Cheers,
 
 Jules
 
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: No complex rationals in Python 3.0

2008-11-24 Thread Rock
On 24 Nov, 20:31, Christian Heimes [EMAIL PROTECTED] wrote:
 Rock wrote:
  I appreciate the inclusion of the fractions module in Python 2.6 and
  therefore in Python 3.0. But I feel there's something missing: no
  possibility for complex rationals (or arbitrary precision) integers. I
  was just checking the complex number support in Python, compared, for
  instance, to Common Lisp and Scheme, and I realized that there was
  this subtle omission. The inclusion of rationals and arbitrary
  integers is cool, but the numeric tower (say, compared to Scheme) is
  not complete. I don't think there would be a performance hit if
  complex rationals were provided. Ordinary operations on complex
  floats, in theory, should not be affected and handled separately. But
  it would be nice to be able to do:

  (3/4 + 1/2j) * (1/4 - j) = 11/16 - 5/8j

  with no loss of precision.

  Python is heavily used in math and science all over the world. We've
  even got a recent symbolic math project (sympy) that looks very
  promising, so I guess this could be an important issue.

 Nobody has submitted a PEP and patch to implement the feature in time.
 There is still Python 3.1, you know? If you like to contribute the
 feature then please start a discussion on the Python Ideas mailing list
 (not the developer lists!).

  Note: there exists a library that implements what I'm talking about:
 http://calcrpnpy.sourceforge.net/clnum.html
  but still I personally would have liked to see this stuff included
  natively in the new Python 3.0.

 The code depends on the CLN library which isn't suited for the Python
 core. It's written in C++ and it's licensed under GPL. Neither GPL nor
 LGPL software can't be integrated into the core. We also require all
 code to be compatible with C89.

 Christian

Thanks Christian, will do so as soon as possible.

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


Re: Security implications of using open() on untrusted strings.

2008-11-24 Thread Jorgen Grahn
On Mon, 24 Nov 2008 00:44:45 -0500, r0g [EMAIL PROTECTED] wrote:
 Hi there,

 I'm trying to validate some user input which is for the most part simple
 regexery however I would like to check filenames and I would like this
 code to be multiplatform.

 I had hoped the os module would have a function that would tell me if a
 proposed filename would be valid on the host system but it seems not. I
 have considered whitelisting but it seems a bit unfair to make the rest
 of the world suffer the naming restrictions of windows. Moreover it
 seems both inelegant and hard work to research the valid file/directory
 naming conventions of every platform that this app could conceivably run
 on and write regex's for all of them so...

 I'm tempted to go the witch dunking route, stick it in an open() between
 a Try:  Except: and see if it floats. However...

 Although it's a desktop (not internet facing) app I'm a little squeamish
 piping raw user input into a filesystem function like that and this app
 will be dealing with some particularly sensitive data so I want to be
 careful and minimize exposure where practical.

Take the Unix 'ls' command (or MS-DOS 'dir').  That's two programs
which let users pipe raw input into the filesystem functions, and they
certainly have handled some very sensitive data over the years.

 Has programming PHP and Web stuff for years made me overly paranoid
 about this [...]

Yes. ;-)

Please explain one thing: what are you looking for?  It's not
accesses a file outside the user's home directory, accesses an
infinite file like /dev/zero or something like that, or you would
have said so.  Nor seems the user input come from some other user
than the one your program is running as, nor from some input source
which the user cannot be held responsible for.

Seems to me you simply want to know beforehand that the reading will
work.  But you can never check that!  You can stat(2) the file, or
open-and-close it -- and then a microsecond later, someone deletes the
file, or replaces it with another one, or write-protects it, or mounts
a file system on top of its directory, or drops a nuke over the city,
or ...

Two more notes:

- os.open is not like os.system. If os.open ends up doing
  anything other than trying to open the file corresponding to the
  string you feed it, it's Python's fault, not yours.

  Compare with a language (does Perl allow this?) where if the string
  is rm -rf /|, open will run rm -rf / and start reading its output.
  *That* interface would have been 

- if the OS ends up doing something different when calling open(2) or
  creat(2) or whatever using that string, it's the OSes fault, not
  yours.

Or am I missing something?

/Jorgen

-- 
  // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu
\X/ snipabacken.se  R'lyeh wgah'nagl fhtagn!
--
http://mail.python.org/mailman/listinfo/python-list


recommended __future__ imports for 2.5?

2008-11-24 Thread Joe Strout
OK, this will probably be placed into the stupid question category  
by some, but I really am in need of a bit of guidance here.


I just rediscovered the gotcha of integer division in 2.5 and below,  
and found (to my delight) that this is fixed in 3.0, and fixable in  
older versions of Python with from __future__ import division.  Once  
I stumbled across that, I was able to find the relevant PEP (#238) and  
read more about it.  So now that import has become part of our  
standard boilerplate at the top of each file, along with the path to  
Python and the UTF-8 encoding declaration.


Now I'm wondering what other boilerplate I should be using.  I'm not  
yet ready to upgrade to Python 2.6 -- parts of our business model rely  
on using the standard Python installed with Mac OS X (which is  
currently 2.5.1).  But I would like our code to be as future-proof as  
possible, especially in cases like this where we're talking about  
changes to existing behavior, rather than the introduction of entirely  
new features (like the with statement).


I found http://www.python.org/doc/2.5.2/ref/future.html, which lists  
the available future imports, but doesn't link to any documentation on  
them.  Searching for each one on google turns up some probably- 
relevant PEPs, but it's hard for a relative newbie to tell for sure  
exactly what was implemented when and which is merely a summary of  
discussion.


So... besides division, are there any other imports you would  
recommend as standard for any new code written in 2.5?  And what else  
do you experienced gurus put at the top of every Python file?


Thanks,
- Joe



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


Re: for loop specifying the amount of vars

2008-11-24 Thread Steve Holden
Jules Stevenson wrote:
 Hi,
 
 I have a list which contains a folder structure, for instance:
 
 dirs=['c:\', 'temp', 'foo', 'bar']
 
Of course this should really be

  dirs=['c:\\', 'temp', 'foo', 'bar']

but we'll overlook your little syntax error ;-)

 The length of the list can vary. I'd like to be able to construct a
 os.path.join on the list, but as the list can vary in length I'm unsure how
 to do this neatly. I figured I could use a for loop and build the whole
 statement as a string and 'eval it', but I'm aware that this is not a good
 idea. 
 
 It strikes me that there probably is a very elegant way to achieve what I
 want to do, any pointers much appreciated.
 
Jules:

Don't reply to someone else's post with a new question, please: many
people use threaded readers, and will not even see your subject line.

What you need is

  os.path.join(*dirs)

which tells Python to take the list and turn it into separate arguments.
Fortunately os.path.join will take as many arguments as you care to pass it:

 os.path.join(*dirs)
'c:\\temp\\foo\\bar'


regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: recommended __future__ imports for 2.5?

2008-11-24 Thread Terry Reedy

Joe Strout wrote:
OK, this will probably be placed into the stupid question category by 
some, but I really am in need of a bit of guidance here.


I just rediscovered the gotcha of integer division in 2.5 and below, 
and found (to my delight) that this is fixed in 3.0, and fixable in 
older versions of Python with from __future__ import division.  Once I 
stumbled across that, I was able to find the relevant PEP (#238) and 
read more about it.  So now that import has become part of our standard 
boilerplate at the top of each file, along with the path to Python and 
the UTF-8 encoding declaration.


Now I'm wondering what other boilerplate I should be using.  I'm not yet 
ready to upgrade to Python 2.6 -- parts of our business model rely on 
using the standard Python installed with Mac OS X (which is currently 
2.5.1).  But I would like our code to be as future-proof as possible, 
especially in cases like this where we're talking about changes to 
existing behavior, rather than the introduction of entirely new features 
(like the with statement).


I found http://www.python.org/doc/2.5.2/ref/future.html, which lists 
the available future imports, but doesn't link to any documentation on 
them.  Searching for each one on google turns up some probably-relevant 
PEPs, but it's hard for a relative newbie to tell for sure exactly what 
was implemented when and which is merely a summary of discussion.


So... besides division, are there any other imports you would 
recommend as standard for any new code written in 2.5?  And what else do 
you experienced gurus put at the top of every Python file?


2.5 (and 2.3 and 2.2) already has 'generators' and 'nested_scopes', so 
forget those unless programming for 2.2-.

with_statement is needed if and only if you use a with statement.
absolute_import ? I don't know what difference that makes. The doc on 
the import statement might say.


tjr

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


Re: max(), sum(), next()

2008-11-24 Thread Scott David Daniels

David C. Ullrich wrote:

In article [EMAIL PROTECTED],
 Steven D'Aprano [EMAIL PROTECTED] wrote:

On Fri, 05 Sep 2008 10:22:22 -0500, David C. Ullrich wrote about why max 
and min shouldn't accept a default argument:



Think about all the previously elected female or black presidents of the
US. Which one was the tallest?

I know the answer to that one:

All of them!


Heh. Mysteries of the empty set.



_and_, as it turns out, sets of cardinality 1.

--Scott David Daniels   (pleased about the change in cardinality)
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using dictionary to hold regex patterns?

2008-11-24 Thread John Machin
On Nov 25, 4:38 am, Thomas Mlynarczyk [EMAIL PROTECTED]
wrote:
 John Machin schrieb:

  Rephrasing for clarity: Don't use a data structure that is more
  complicated than that indicated by your requirements.

 Could you please define complicated in this context? In terms of
 characters to type and reading, the dict is surely simpler. But I
 suppose that under the hood, it is less work for Python to deal with a
 list of tuples than a dict?

The two extra parentheses per item are a trivial cosmetic factor only
when the data is hard-coded i.e. don't exist if the data is read from
a file i.e nothing to do with complicated. The amount of work done
by Python under the hood is relevant only to a speed/memory
requirement. No, complicated is more related to unused features. In
the case of using an aeroplane to transport 3 passengers 10 km along
the autobahn, you aren't using the radar, wheel-retractability, wings,
pressurised cabin, etc. In your original notion of using a dict in
your lexer, you weren't using the mapping functionality of a dict at
all. In both cases you have perplexed bystanders asking Why use a
plane/dict when a car/list will do the job?.


  Judging which of two structures is simpler should not be independent
  of those requirements. I don't see a role for intuition in this
  process.

 Maybe I should have said upon first sight / judging from the outer
 appearance instead of intuition.

I don't see a role for upon first sight or judging from the outer
appearance either.

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


Re: Python 3.0 - is this true?

2008-11-24 Thread Duncan Grisby
In article [EMAIL PROTECTED], Aahz [EMAIL PROTECTED] wrote:

In article [EMAIL PROTECTED],
Duncan Grisby  [EMAIL PROTECTED] wrote:

[...]
That's exactly my point. Currently, the application just builds a list
of values retrieved from the database and asks Python to sort it. No
key or cmp function. With Python 3.0, it's going to require a lot more
work than that.

Unless I misunderstand you, your application is broken already.

You misunderstand me.

My application is not broken. It handles a wide range of data types,
_but they are all sortable_. It doesn't involve any complex numbers.
There is no way a complex number could be stored in the database, so
that is not an issue.

   Complex
numbers have never been sortable.  If your application works more like a
SQL database, then any given column will have only one datatype and as
long as you avoid types that cannot be compared against themselves
you're safe.

My database isn't like a SQL database. It's dynamically typed, just
like Python. The range of types is limited to things that can be
marshalled into the underlying storage, so I can absolutely guarantee
that they are all sortable in Python 2, even though the permitted
range or types is quite wide.

[...]
For my application, Python 3's comparison behaviour is a backwards
step. You can argue all you like that the new behaviour is the right
thing to do, and I'd be inclined to agree with you from a
philosophical point of view, but the fact is that it _will_ cause
problems for existing real code. The particularly ironic thing is that
the database's dynamic typing is closely modelled on Python, including
it's ability to gracefully handle mixed-type lists.

What I think people are arguing about is your use of the word backward.
I don't think anyone claims that fixing your application will be trivial,
but your application appears to be already broken, and Python 3.0 is
simply forcing you to confront it head-on.

The post you've quoted was the first time I used the word backwards.
I didn't start this thread, I merely chipped in when people claimed
there were no real applications that would be affected by this change
to Python. I do have a real, widely deployed application that will be
affected. Claiming that it is not affected, or that it is already
broken does not change that fact.

Several people _have_ in fact claimed that I can't possibly have a
hard problem to solve in this respect. In general, the responses can
be grouped into those people claiming that it's trivial to fix, and
those (like you) claiming that it's ok that it's hard to fix because
it's already broken. Neither are true.

This issue is not impossible to deal with, of course, it's just one of
several things that will mean it's hard for us to migrate to Python 3.
What I find disturbing is the attitude that this change to Python's
comparison behaviour can't possibly have any downsides and that anyone
claiming it does is wrong.

Cheers,

Duncan.

-- 
 -- Duncan Grisby --
  -- [EMAIL PROTECTED] --
   -- http://www.grisby.org --
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.0 - is this true?

2008-11-24 Thread Martin v. Löwis
 Sorry for the delay in replying. 

Thanks, and I'm in turn sorry myself, too. Here is my experiment:

I only looked at the first test case, where a bigfile.txt has
occasionally None lines. To run this test, I created a file with
33079296 and 704512 lines, by repeatedly cat'ing /etc/passwd.

I then ran this program:

import time,random
l = []

t=time.time()
for line in open(x):
x = random.randint(0,100)
if x  4: l.append(None)
else: l.append(line)
print(time.time()-t)

t=time.time()
for i in range(10):
L = l[:]
L.sort()
print(time.time()-t)

def key(n):
return n or 

t=time.time()
for i in range(10):
L = l[:]
L.sort(key=key)
print(time.time()-t)

This key function is based on the assumption that
there won't be any strings in l, which is reasonable,
because they are all lines read from the input file
(i.e. contain \n at least). If truly empty strings
where possible, I'd map them to chr(0), which I would
assume couldn't occur elsewhere in the input.

With 2.5, I get these results (rounded)

3.8s
7.6s
14.3s

So with the key function, the overhead appears to have doubled.
I think the ratio should decrease as lists grow larger (because
the key function is linear, and the sort is nlogn, assuming the
overhead is in computing the key function), but I haven'd done
any series varying the file size.

With 3.0(rc3), I get (omitting the key-less sorting, as it won't
work)

24.8s
15.9s

So now the IO is much larger than the actual sorting, which is
about the same in 2.5 and 3.0. If you wonder where the overhead
of IO comes from: part of it probably from the UTF-8 decoding,
that the IO library now does transparently.

I don't know whether this overhead qualifies as not
insignificant, most people probably would claim that a doubling
in time is indeed significant. OTOH, not knowing what the original
problem is (e.g. whether it's interactive or in a batch mode, and
whether bigfile.txt is much smaller or much larger than 32MiB),
I would probably
a) evaluate whether the increase in IO time is acceptable, and
b) if it is, just go with 3.0, as the increase in sorting time
   is much smaller than the increase in IO time.

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


Re: Building Python 2.5.2 for Itanium

2008-11-24 Thread Martin v. Löwis
 Lo and behold! --
 
 Performing Custom Build Step
 '.\make_versioninfo.exe' is not recognized as an internal or external
 command,
 operable program or batch file.
 Project : error PRJ0019: A tool returned an error code from
 Performing Custom Build Step

Hmm. make_versioninfo.exe should *not* be compiled with the Itanium
compiler - it should be an x86 binary.

 I had to manually build make_version.exe, which seems to have
 generated those fields.  I'm not sure what the problem was with the
 build of make_version.  The only error I could find was unable to
 create response file.

Unfortunately, debugging vsextcomp is quite tricky. Python was its
only application ever, so it hasn't seen much testing.

 I am now looking into getting ctypes to build correctly.  My
 investigations show that ctypes supports ia64, so I may be able to
 make some progress on this front.

Good luck!

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


Re: 3.0rc3: 'os.extsep' gone ... ?

2008-11-24 Thread Martin v. Löwis
 That doesn't really explain it. It always was os.path.extsep,
 but it *also* was os.extsep.
 
 I've always known it as the former

Same here, but see below.

 a perusal of the Python repository
 would probably indicate when it became exposed in the os module
 itself.

That's indeed easier to answer than finding out when it was removed
for 3k, and by whom. It was provided in its current form with

r31426 | montanaro | 2003-02-14 20:35:31 +0100 (Fr, 14. Feb 2003) | 3 lines
Migrate definitions of several platform-dependent path-related variables
into the relevant path modules.  See patch #686397.

So they were migrated *into* the specific modules in 2003.

Before, they were all conditionally defined based on the platform, in
os.py itself.

So I must be misremembering - in 2.2 and earlier, they were only
in the os module. So it was *not* always os.path.extsep.

Perhaps this gives the rationale for the change - migration into the
platform modules is now complete.

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


Re: Using dictionary to hold regex patterns?

2008-11-24 Thread Steve Holden
John Machin wrote:
 On Nov 25, 4:38 am, Thomas Mlynarczyk [EMAIL PROTECTED]
[...]
 Judging which of two structures is simpler should not be independent
 of those requirements. I don't see a role for intuition in this
 process.
 Maybe I should have said upon first sight / judging from the outer
 appearance instead of intuition.
 
 I don't see a role for upon first sight or judging from the outer
 appearance either.
 
They are all potentially (inadequate) substitutes for the knowledge and
experience you bring to the problem.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Printing digits in one place

2008-11-24 Thread Oltmans
I'm writing a file-transfer program and I'm receiving bytes
transferred in a function. Now I would like to print bytes transfered
in one place e.g.

Bytes Transfered so far X

and X will increase and cursor should stay at this position. I don't
want to use any 3rd party module for this. Can I somehow do that
without using any third-party module?

I've been able to do this with Console module available at
http://effbot.org/zone/console-handbook.htm but I would want to do
this without the Console module. Actually , I'm able to initialize the
Console module and print the bytes transferrred information but I
can't find a way to exit from Console module so that my other
functions can proceed with normal display using 'print' statement.

Any ideas will be appreciated.
--
http://mail.python.org/mailman/listinfo/python-list


Start learning 2.6 or wait for 3.0?

2008-11-24 Thread Alan Biddle
I am planning on learning Python, primarily for my own interest,
rather than any immediate need.  I am wondering whether I would be
wasting my time to start with the latest 2.6 version which has a lot
of good instructional material, or wait a bit for version 3.0?


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


Re: Printing digits in one place

2008-11-24 Thread Steve Holden
Oltmans wrote:
 I'm writing a file-transfer program and I'm receiving bytes
 transferred in a function. Now I would like to print bytes transfered
 in one place e.g.
 
 Bytes Transfered so far X
 
 and X will increase and cursor should stay at this position. I don't
 want to use any 3rd party module for this. Can I somehow do that
 without using any third-party module?
 
 I've been able to do this with Console module available at
 http://effbot.org/zone/console-handbook.htm but I would want to do
 this without the Console module. Actually , I'm able to initialize the
 Console module and print the bytes transferrred information but I
 can't find a way to exit from Console module so that my other
 functions can proceed with normal display using 'print' statement.
 
 Any ideas will be appreciated.

Try repeatedly writing something like

\r  \rBytes Transferred So Far %d \
  % count

Not the fastest approach, but probably fast enough.

If you *must* have the cursor on the number of bytes transferred
then try using backspaces after you have printed out the number. But
you'll need to track how long the number is to put out the right number
of backspaces. Something like (untested)

sys.stdout.write(Bytes Transferred So Far)
for ...
...
cs = str(count)
csl = len(cs)
sys.stdout.write(%s%s%s%s % (
 *csl, \b*csl, cs, \b*csl)

Use sys.stdout.write() for full control over spacing and newlines.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: Printing digits in one place

2008-11-24 Thread John Machin
On Nov 25, 10:21 am, Oltmans [EMAIL PROTECTED] wrote:
 I'm writing a file-transfer program and I'm receiving bytes
 transferred in a function. Now I would like to print bytes transfered
 in one place e.g.

 Bytes Transfered so far X

 and X will increase and cursor should stay at this position. I don't
 want to use any 3rd party module for this. Can I somehow do that
 without using any third-party module?

 I've been able to do this with Console module available 
 athttp://effbot.org/zone/console-handbook.htmbut I would want to do
 this without the Console module. Actually , I'm able to initialize the
 Console module and print the bytes transferrred information but I
 can't find a way to exit from Console module so that my other
 functions can proceed with normal display using 'print' statement.

 Any ideas will be appreciated.

Try using backspaces e.g. something like this:

|  import time, sys
|  msg = ''
|  for i in range(15):
| ...time.sleep(2.0)
| ...nbs = len(msg)
| ...msg = str(i)
| ...sys.stdout.write('\b' * nbs + msg)
| ...

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


Fwd: [wxpython-users] Setting up global keybindings without corresponding menu items

2008-11-24 Thread mercado mercado
Forwarded conversation
Subject: Setting up global keybindings without corresponding menu items


From: *mercado mercado* [EMAIL PROTECTED]
Date: Fri, Aug 1, 2008 at 4:15 PM
To: [EMAIL PROTECTED]


I'm trying to set up a global keyboard shortcut for my application.  I know
how to do this by associating the shortcut with a menu item, but I want to
do it without a corresponding menu item.  As per the instructions here (
http://lists.wxwidgets.org/pipermail/wxpython-users/2003-August/021655.html),
I should be able to do this with an accelerator table, but I can't get it to
work.

I've included a small, self-contained sample that attempts to bind an event
handler with the Ctrl-L shortcut.  Can anybody see what I'm doing wrong?
Thanks in advance.

I am running wxPython 2.8.8.1 on Ubuntu 8.04.1 Hardy.
-
import wx

class MainWindow(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__ (self, parent, -1, title, size=(500,200))
self.panel = wx.Panel(self, -1)

EVT_TEST_ID = wx.NewId()

wx.EVT_MENU(self, EVT_TEST_ID, self.OnTestEvent)

aTable = wx.AcceleratorTable([
(wx.ACCEL_CTRL, ord('L'), EVT_TEST_ID)
])

self.SetAcceleratorTable(aTable)

self.Show(True)

def OnTestEvent(self, event):
print OnTestEvent fired

app = wx.App()
frame = MainWindow(None, -1, Test)
app.MainLoop()

--
From: *Mike Driscoll* [EMAIL PROTECTED]
Date: Sat, Aug 2, 2008 at 12:15 PM
To: [EMAIL PROTECTED]


mercado mercado wrote:

 I am running wxPython 2.8.8.1 http://2.8.8.1 on Ubuntu 8.04.1 Hardy.


Hmmm...this works on Windows XP, '2.8.7.1 (msw-unicode)', Python 2.5.2.

Try changing the event binding to this instead:

self.Bind(wx.EVT_MENU, self.OnTestEvent, id=EVT_TEST_ID)

That's the way I was told to do it...by Robin, I think.

---
Mike Driscoll

Blog:   http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org

___
wxpython-users mailing list
[EMAIL PROTECTED]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

--
From: *mercado mercado* [EMAIL PROTECTED]
Date: Sat, Aug 2, 2008 at 4:02 PM
To: [EMAIL PROTECTED]



Thanks for the response Mike.  Unfortunately, the alternative syntax doesn't
work for me either.

???


--
From: *Mike Driscoll* [EMAIL PROTECTED]
Date: Mon, Aug 4, 2008 at 8:56 AM
To: [EMAIL PROTECTED]


mercado mercado wrote:

 On Sat, Aug 2, 2008 at 1:15 PM, Mike Driscoll [EMAIL PROTECTED]mailto:
 [EMAIL PROTECTED] wrote:

Hmmm...this works on Windows XP, '2.8.7.1 http://2.8.7.1
(msw-unicode)', Python 2.5.2. http://2.5.2.


I loaded Ubuntu Hardy in my VM and confirmed that it does not work with your
sample code. Weird. I did find a recipe in the wiki that might work for you:

http://wiki.wxpython.org/Using%20Multi-key%20Shortcuts

It's a little bit above my head, but it seems to be using an alternative
technique. Maybe it can be modified to work for you?

--
From: *Robin Dunn* [EMAIL PROTECTED]
Date: Mon, Aug 4, 2008 at 1:31 PM
To: [EMAIL PROTECTED]


Try adding a widget to the frame that can have the keyboard focus.  The
focus needs to be on some widget within the frame for accelerators attached
to the frame to be active.


-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!

--
From: *mercado mercado* [EMAIL PROTECTED]
Date: Mon, Aug 4, 2008 at 1:48 PM
To: [EMAIL PROTECTED]


I tried adding a button to the panel, and giving the button focus, and now
the accelerator table is working as expected.

Thanks Mike and Robin, for your prompt and helpful responses.


--
From: *mercado mercado* [EMAIL PROTECTED]
Date: Mon, Nov 24, 2008 at 6:58 PM
To: python dev [EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: 3.0rc3: 'os.extsep' gone ... ?

2008-11-24 Thread Terry Reedy

Martin v. Löwis wrote:


Perhaps this gives the rationale for the change - migration into the
platform modules is now complete.


Except that, as I posted earlier, extsep is the *only* os system info 
constant that has been removed from os.


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


segfault calling SSE enabled library from ctypes

2008-11-24 Thread Olivier Grisel
Hello,

It seems that I am able to reproduce the same problem as reported
earlier on this list by someone else:

  http://mail.python.org/pipermail/python-list/2008-October/511794.html

Similar setup: python 2.5.2 / gcc (Ubuntu 4.3.2-1ubuntu11) from
Intrepid on 32bit intel Core 2 Duo.  I can confirm this is not related
to any alignment problem from data passed from python, I took care of
that and I could even reproduce the problem with the following minimal
test case that does not use any external data (you can fetch the
following source here
http://www.bitbucket.org/ogrisel/ctypes_sse/get/tip.gz )

sample

=== dummysse.c ===

#include stdio.h
#include emmintrin.h

void dummy_sse(void)
{
// allocate an alligned vector of 128 bits
__m128 myvector;

printf([dummy_sse] before calling setzero\n);
fflush(stdout);

// initialize it to 4 32 bits float valued to zeros
myvector = _mm_setzero_ps();

printf([dummysse] after calling setzero\n);
fflush(stdout);

// display the content of the vector
float* part = (float*) myvector;
printf([dummysse] myvector = {%f, %f, %f, %f}\n,
part[0], part[1], part[2], part[3]);
}

int main()
{
dummy_sse();
return 0;
}

=== dummysse.py ===

from ctypes import cdll

lib = cdll.LoadLibrary('./dummysse.so')
lib.dummy_sse()


=== Makefile ===
CC = gcc
CFLAGS = -Wall -g -O0 -msse2

all: dummysse dummysse.so

dummysse:
$(CC) $(CFLAGS) $(LIBS) -o dummysse dummysse.c
#   ./dummysse

dummysse.so:
$(CC) $(CFLAGS) $(LIBS) -shared -o dummysse.so dummysse.c
#   python dummysse.py

clean:
rm -f dummysse dummysse.so

/sample

By running the main of the C program I get the expected behavior:

  gcc -Wall -g -O0 -msse2  -o dummysse dummysse.c
  ./dummysse
  [dummy_sse] before calling setzero
  [dummysse] after calling setzero
  [dummysse] myvector = {0.00, 0.00, 0.00, 0.00}

Running from python, the call to the _mm_setzero_ps() segfaults:

  gcc -Wall -g -O0 -msse2  -shared -o dummysse.so dummysse.c
  python dummysse.py
  [dummy_sse] before calling setzero
  Segmentation fault

Is this to be expected? The result to a call to valgrind python
dummysse.py is available here :

  http://www.bitbucket.org/ogrisel/ctypes_sse/src/tip/valgrind.log

I am not familiar with python internal at all so I cannot understand
what's wrong. You can notice that valgrind make the program run till
the end and display the correct results (4 zeros) on stdout while
logging a bunch of errors (most of those are not related to our
problem since they appear when launching python on an empty script).

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


Re: Start learning 2.6 or wait for 3.0?

2008-11-24 Thread Terry Reedy

Alan Biddle wrote:

I am planning on learning Python, primarily for my own interest,
rather than any immediate need.  I am wondering whether I would be
wasting my time to start with the latest 2.6 version which has a lot
of good instructional material, or wait a bit for version 3.0?


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


Re: Start learning 2.6 or wait for 3.0?

2008-11-24 Thread Terry Reedy

Alan Biddle wrote:

I am planning on learning Python, primarily for my own interest,
rather than any immediate need.  I am wondering whether I would be
wasting my time to start with the latest 2.6 version which has a lot
of good instructional material, or wait a bit for version 3.0?


If you want to use 3rd party modules, I would today consider 2.5.2 (soon 
to be 2.5.3) rather that 2.6.  In either case, also include object or 
other built-in class in the list of base classes for class statements, 
and always start with 'from __future__ import division'.


If you are not interested in 3rd party modules, I would consider 3.0 
(which will be little different from the current candidate).  The main 
change relevant to a beginner is the deletion of duplicate or obsolete 
features.


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


Re: Start learning 2.6 or wait for 3.0?

2008-11-24 Thread Aahz
In article [EMAIL PROTECTED],
Alan Biddle  [EMAIL PROTECTED] wrote:

I am planning on learning Python, primarily for my own interest,
rather than any immediate need.  I am wondering whether I would be
wasting my time to start with the latest 2.6 version which has a lot
of good instructional material, or wait a bit for version 3.0?

Few people will be using 3.x for production work for at least a year or
three.  Stick with 2.x.
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

It is easier to optimize correct code than to correct optimized code.
--Bill Harlan
--
http://mail.python.org/mailman/listinfo/python-list


Re: My first Python program -- a lexer

2008-11-24 Thread Arnaud Delobelle
Thomas Mlynarczyk [EMAIL PROTECTED] writes:

 John Machin schrieb:

 *IF* you need to access the regex associated with a token in O(1)
 time, a dict is indicated.

 O(1) - Does that mean `mydict[mykey]` takes the same amount of time,
 no matter if mydict has 10 or 10 entries? How does this magic
 work? O(log n) I would understand, but constant time?

As I understand it, in theory it's not O(1) - I guess it's O(n).  But
for any non-cunningly crafted data it's as if it was O(1).

Dictionaries are implemented as hashtables, not as trees.

 If you have *both* requirements simultaneously, then *both* list and
 dict are indicated.

 So I would have to duplicate my data and store it once in a list, once
 in a dict? Or should I decide for one way and accept that one type of
 access will not be optimal?

Depends what you want to do!

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


Re: 3.0rc3: 'os.extsep' gone ... ?

2008-11-24 Thread Martin v. Löwis
 Except that, as I posted earlier, extsep is the *only* os system info
 constant that has been removed from os.

Ah, this gives another clue:



r57097 | skip.montanaro | 2007-08-16 16:35:24 +0200 (Do, 16. Aug 2007) |
1 line

Remove RISCOS support


Still not sure though why extsep was removed in this change...

Not that I regret it's gone - it was a useless constant, anyway,
as the extension separator is '.' on all interesting systems.

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


Re: 3.0rc3: 'os.extsep' gone ... ?

2008-11-24 Thread skip

Martin 

Martin r57097 | skip.montanaro | 2007-08-16 16:35:24 +0200 (Do, 16. Aug 
2007) |
Martin 1 line

Martin Remove RISCOS support
Martin 


Yeah, that was me.

Martin Not that I regret it's gone - it was a useless constant, anyway,
Martin as the extension separator is '.' on all interesting systems.

Except if you diff r57096 and r57097 I suspect you'll find that it was
different in RISCOS.  Perhaps it was only ever added to Python to support
that platform.

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


Herald: Python surpasses Perl in popularity!

2008-11-24 Thread Xah Lee
herald: Python surpasses Perl in popularity!

According to
“TIOBE Programming Community Index for November 2008” at
http://www.tiobe.com/content/paperinfo/tpci/index.html

it seems that Python has surpassed Perl in popularity this month!

Good for Python!

From my own personal experience in the programing industry, i find it
hard to believe that Python actually surpassed Perl in terms of use in
companies. Python is used in, Google, as everybody knows, but where
else? Perl is used in, umm, about every company except Google (and
probably Google too! in fact).

A quick search in monster.com, i find that perl returns 2673 results,
and Python returns 879 results. Perlers, you still safe!

Looking at other lang popularity site,
http://www.langpop.com/
it indicates that it's pretty much a tie.

So, i think it's not all peaches and cream for Python yet.

However, am pretty sure it'll be so in the next couple of years.

(btw, for those perlers who wishes to learn Python, see a comparative
tutorial:

• Xah's Perl and Python Tutorial
  http://xahlee.org/perl-python/index.html
)

  Xah
∑ http://xahlee.org/

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


Re: Printing digits in one place

2008-11-24 Thread Tim Chase

Try repeatedly writing something like

\r  \rBytes Transferred So Far %d \
  % count


Rather than backing up twice with \r, I'd just suggest

  \rBytes Transferred So Far %d% count

or even

  \rBytes Transferred So Far %d%s % (count, ' '*20)

-tkc




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


Usage opinion wanted

2008-11-24 Thread Saurabh Agrawal
Hi group:

I hope that you good people here could help me with a decision I am finding
hard to make.

I am about to develop a MIS type application for a Non for profit
organization teaching young children in India.

I am trying to use this opportunity to make myself learn python, and if
required the whole web based development paradigm using django.

I have experience of c++ graphical algorithms development.

Now obviously this application would be database based and database
manipulation would be the major part. It would be mostly used across desktop
computers in the organization running Windows XP. The decision which I am
unable to make is that should I use django for this project? My issues are:

1. This application would be run on desktops, so GUI toolkits such as PyQT
might suffice.
2. Making good interfaces for web would require additional learning on my
part such as HTML, CSS and Javascript, an area  in which I have absolutely
no expertise, just a very basic idea.

So what do you guys suggest? If learning the above things would still give
me an edge( in terms of time required for development) over PyQt based
interfaces, in terms of automated databse manipulation tools such as the
admin interface, I would go for it and it might be a good experience for me.

Thanks for reading this slightly incoherent and maybe off-topic mail.

All suggestions are welcome and I would be grateful for them.

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


Python surpasses Perl in popularity?

2008-11-24 Thread david . lyon


Interesting topic !

I would venture so far to say that perl is todays 'C'..

Perl is todays language of technical complexity. It is obscure,  
complex, and is oriented towards the supremely intelligent (or equally  
- those seeking to get 'lost' in programming).


Python, whilst very powerful, doesn't have the sheer scale of  
contributors that Perl has. ie cpan. Many libraries, aren't as  
sophisticated - ie spreadsheet reading and writing.


Python is very clever.. but it goes in a 'purest' direction.

It is being used in stockbrocking and many other fields. It has a good  
following. It is being taught in schools here.. meaning it is  
extremely healthy.


More popular doesn't always mean better...

Quoting Xah Lee [EMAIL PROTECTED]:


herald: Python surpasses Perl in popularity!

According to
“TIOBE Programming Community Index for November 2008” at
http://www.tiobe.com/content/paperinfo/tpci/index.html

it seems that Python has surpassed Perl in popularity this month!

Good for Python!

From my own personal experience in the programing industry, i find it
hard to believe that Python actually surpassed Perl in terms of use in
companies. Python is used in, Google, as everybody knows, but where
else? Perl is used in, umm, about every company except Google (and
probably Google too! in fact).

A quick search in monster.com, i find that perl returns 2673 results,
and Python returns 879 results. Perlers, you still safe!

Looking at other lang popularity site,
http://www.langpop.com/
it indicates that it's pretty much a tie.

So, i think it's not all peaches and cream for Python yet.

However, am pretty sure it'll be so in the next couple of years.

(btw, for those perlers who wishes to learn Python, see a comparative
tutorial:

• Xah's Perl and Python Tutorial
  http://xahlee.org/perl-python/index.html
)

  Xah
∑ http://xahlee.org/

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





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


Quick question about None and comparisons

2008-11-24 Thread Giampaolo Rodola'
Sorry for the title but I didn't find anything more appropriate.
To have a less verbose code would it be ok doing:

if a  b:

...instead of:

if a is not None and a  b:

...?
Is there any hidden complication behind that?
Thanks in advance

--- Giampaolo
code.google.com/p/pyftpdlib/


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


Re: Start learning 2.6 or wait for 3.0?

2008-11-24 Thread Giampaolo Rodola'
Definitively 2.X.
Whether 2.5 or 2.6 doesn't really matter.

--- Giampaolo
http://code.google.com/p/pyftpdlib/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Quick question about None and comparisons

2008-11-24 Thread r
On Nov 24, 7:52 pm, Giampaolo Rodola' [EMAIL PROTECTED] wrote:
 Sorry for the title but I didn't find anything more appropriate.
 To have a less verbose code would it be ok doing:

 if a  b:

 ...instead of:

 if a is not None and a  b:

 ...?
 Is there any hidden complication behind that?
 Thanks in advance

 --- Giampaolo
 code.google.com/p/pyftpdlib/

you are doing 2 different things there
the first only ask IS a greater than b?
the second ask IF a IS NOT none and a IS greater than b
one is not shorthand for the other in all circumstances!

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


Re: Quick question about None and comparisons

2008-11-24 Thread Chris Rebert
On Mon, Nov 24, 2008 at 5:52 PM, Giampaolo Rodola' [EMAIL PROTECTED] wrote:
 Sorry for the title but I didn't find anything more appropriate.
 To have a less verbose code would it be ok doing:

 if a  b:

 ...instead of:

 if a is not None and a  b:

 ...?
 Is there any hidden complication behind that?

Yes. In Python 3.0, doing non-equality comparisons with None will
raise a TypeError because it's nonsensical to ask whether two objects
of unrelated types are less than or greater than each other (e.g Is
[1,2]  ab ?).
Assuming `a` will never take on a value considered boolean false, you
can do `if a and a  b:` instead.

Cheers,
Chris
-- 
Follow the path of the Iguana...
http://rebertia.com

 Thanks in advance

 --- Giampaolo
 code.google.com/p/pyftpdlib/


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

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


Re: 3.0rc3: 'os.extsep' gone ... ?

2008-11-24 Thread Martin v. Löwis
 Martin Not that I regret it's gone - it was a useless constant, anyway,
 Martin as the extension separator is '.' on all interesting systems.
 
 Except if you diff r57096 and r57097 I suspect you'll find that it was
 different in RISCOS. 

I did, and interestingly enough, you won't find that. It was different
indeed - but you need to look r57116 to find out what happened to
riscospath.py (as only then, you removed the specific path module).

In any case - if the intention was that extsep is now not supported
anymore, it should have been removed from the other *path modules
as well (along with removing it from the documentation).

Regards,
Martin

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


Re: Python surpasses Perl in popularity?

2008-11-24 Thread John Machin
On Nov 25, 12:25 pm, [EMAIL PROTECTED] wrote:

 Python, whilst very powerful, doesn't have the sheer scale of  
 contributors that Perl has. ie cpan. Many libraries, aren't as  
 sophisticated - ie spreadsheet reading and writing.

Care to elaborate on the relative unsophistication of Python
spreadsheet reading and writing libraries?

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


Re: 3.0rc3: 'os.extsep' gone ... ?

2008-11-24 Thread Martin v. Löwis
[EMAIL PROTECTED] wrote:
 Martin In any case - if the intention was that extsep is now not
 Martin supported anymore, it should have been removed from the other
 Martin *path modules as well (along with removing it from the
 Martin documentation).
 
 No, that wasn't my intent.  I was speculating that os.extsep turned up in
 Python when RISCOS support was added.  At the time I removed support I
 wasn't thinking in terms of getting rid of that attribute.

I don't quite understand. Yes, the variable was added when RISCOS
support was introduced. So when RISCOS support is removed, it seems
natural to remove the variable also. You chose not to - so why did you
then remove it from the os module?

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


online dating louisville

2008-11-24 Thread porphyrymoralesnh
online dating louisville
.
.
.
***CLICK HERE
http://dating365.co.cc/online-dating-louisville
*
.
.
.
.
.
.
.
.
.
.
.
.
online dating louisville
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python surpasses Perl in popularity?

2008-11-24 Thread david . lyon

Quoting John Machin [EMAIL PROTECTED]:


Care to elaborate on the relative unsophistication of Python
spreadsheet reading and writing libraries?

Cheers,
John


Not really.

But one only has to use both languages on a regular basis to realise  
that perl is well ahead on the libaray/module front.


Some things in python are still pretty primitive...

but I know a lot of work has gone into them... just not anywhere near  
like what you see in perl.


David

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


Re: Python surpasses Perl in popularity?

2008-11-24 Thread John Machin
On Nov 25, 2:59 pm, [EMAIL PROTECTED] wrote:
 Quoting John Machin [EMAIL PROTECTED]:

  Care to elaborate on the relative unsophistication of Python
  spreadsheet reading and writing libraries?

  Cheers,
  John

 Not really.

 But one only has to use both languages on a regular basis to realise  
 that perl is well ahead on the libaray/module front.

 Some things in python are still pretty primitive...

 but I know a lot of work has gone into them... just not anywhere near  
 like what you see in perl.

I'll try again: On what grounds do you assert that Many libraries,
aren't as sophisticated - ie spreadsheet reading and writing.? What
Python spreadsheet reading and writing libraries have you used? In
what way are they less sophisticated than their perl counterparts? Do
you have any particular enhancement requests?


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


Re: Python surpasses Perl in popularity?

2008-11-24 Thread alex23
On Nov 25, 11:25 am, [EMAIL PROTECTED] wrote:
 Perl is todays language of technical complexity. It is obscure,  
 complex, and is oriented towards the supremely intelligent [...]

I think you misspelled insular.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python surpasses Perl in popularity?

2008-11-24 Thread Richard Riley
alex23 [EMAIL PROTECTED] writes:

 On Nov 25, 11:25 am, [EMAIL PROTECTED] wrote:
 Perl is todays language of technical complexity. It is obscure,  
 complex, and is oriented towards the supremely intelligent [...]

 I think you misspelled insular.

Sounds like eLisp :-;
--
http://mail.python.org/mailman/listinfo/python-list


Accessing Modification Time of an Outlook Mail in Python

2008-11-24 Thread [EMAIL PROTECTED]
Hi all,
   I am writing a small application which reads the contents of an
Outlook Mail using python. I am able to read the contents, subject
along with senders and receivers of a mail using MAPI objects. But may
I know how can I get access to the modification time or the
receiving time of an outlook mail in Python. For the others I have
used message object of MAPI session. Here I am pasting a sample code
to get an idea of what am I doing.


session = Dispatch(MAPI.session)
session.Logon('outlook')  # MAPI profile name
inbox = session.Inbox

print Inbox name is:, inbox.Name
print Number of messages:, inbox.Messages.Count

for i in range(inbox.Messages.Count):
message = inbox.Messages.Item(i + 1)

objSender = message.Sender.Address
objRecip = message.Recipients.Item(j+1)


Now here I want to access the modification time of each mail. And if
possible if you can guide me to a place where I can get the elements
of that message object, that would be helpful.

 Please mail back for further information.
Thanks in advance,
Venu.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Multiple equates

2008-11-24 Thread Lawrence D'Oliveiro
Cameron Laird wrote:

 I've been trying to decide if there's any sober reason to advocate
 the one-liner
 
 map(lambda i: a.__setitem__(i, False), [x1, x2, x3, ..., x1024])

Are lambdas like the Dark Side of Python?

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


Re: Python surpasses Perl in popularity?

2008-11-24 Thread david . lyon

Quoting John Machin [EMAIL PROTECTED]:


I'll try again: On what grounds do you assert that Many libraries,
aren't as sophisticated - ie spreadsheet reading and writing.? What
Python spreadsheet reading and writing libraries have you used? In
what way are they less sophisticated than their perl counterparts? Do
you have any particular enhancement requests?


Hi John,

Since you asked a second time and appear genuinely interested - I will  
answer properly. :-)


pyExcelorator  - Setting column widths. Doesn't seem to work.

Nor setting attrributes in sheets. Things seem to be only half done  
when compared to what I have seen in Perl.


Perl was much easier to get the same functionality working.

Here is my particular complaint:

..
from pyExcelerator import *
..
..
# -- Adjust the column width
if dbf1.fieldDefinitions()[f].fieldInfo()[1] == 'C':
ws.col(f).width = 0x0d00 + (f * 600)

in perl

$sheet1-set_column(0, 0, 20);


perl works nicely... I couldn't find a way to so easily set a column width...

plus.. colours are all broken...

If you can shed any light on it for me, I would be thankful.

Regards

David




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


Re: Palette-mode PNG images

2008-11-24 Thread Lawrence D'Oliveiro
Lawrence D'Oliveiro wrote:

 Ideally I'd like to create a PNG file with just two bits per pixel, with
 four colour-table entries of my choice. I'm using PyCairo
 http://www.cairographics.org/pycairo/ to do the drawing, but that
 doesn't seem to support colour-table images as far as I can tell. So I'm
 trying to figure out how to use PIL
 http://www.pythonware.com/library/pil/handbook/index.htm to save the
 images to PNG files with a suitable format.

For those who are interested, I finally gave up on PIL and resorted to direct 
calls to libpng via ctypes. This successfully lets me write 1-bit-per-pixel PNG 
images with colour tables of my choice.

One issue I found is that the png_set_packing call doesn't seem to work on my 
Gentoo AMD64 system. And Cairo and libpng use a different order for sub-byte 
pixels on little-endian platforms. So I have to do rearrangement of bits within 
each byte. Which is a bit slow in Python.

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


initialized list: strange behavior

2008-11-24 Thread alexander . genkin
Hi Python experts! Please explain this behavior:

 nn=3*[[]]
 nn
[[], [], []]
 mm=[[],[],[]]
 mm
[[], [], []]

Up till now, 'mm' and 'nn' look the same, right? Nope!

 mm[1].append(17)
 mm
[[], [17], []]
 nn[1].append(17)
 nn
[[17], [17], [17]]

???

Python 2.5 Win XP

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


ROGER DUBUIS WATCHES

2008-11-24 Thread [EMAIL PROTECTED]
http://www.flyingzg.com/roger-dubuis-watches-c-113.html

Founded by Carlos Dias in 1995 as SOGEM SA (Socie`te` Genevoise des
Montres), the company did not lay claim to its current title of
Manufacture until 1999. In March 2001, he established the first
building of the Manufacture ROGER DUBUIS in the Meyrin industrial area
just outside the city of Geneva. This facility was to enable him to
undertake the process of verticalisation for the production of the
brand?s movements. Inaugurated in April 2002, this first building
features timeless architecture based on glass and metal expressing a
pure, modern design concept. Two years later, work began on a second
building to extend the production units of the Manufacture and which
naturally served to increase brand visibility. Since achieving
complete independence in 2003, the Manufacture ROGER DUBUIS conceives,
develops and produces not only its simple, complicated and extremely
complicated movements, but also the regulating organs with which they
are equipped. The balance-springs and balances, as indeed all other
movement parts, are produced in-house.With Roger Dubuis replica
watches you will be really successful! We`ll be pleased to submit you
the similar quality replica Roger Dubuis watches but cheaper than
original ones.
--
http://mail.python.org/mailman/listinfo/python-list


Re: initialized list: strange behavior

2008-11-24 Thread Gary Herron
[EMAIL PROTECTED] wrote:
 Hi Python experts! Please explain this behavior:
   

[] make an empty list.
[ [],[],[] ] makes a list of three different empty lists.
3*[[]]  makes a list of three references to the same list.

Realy, that should explain it all, but perhaps there are enough empty
lists here to obscure things.  Try this:

Here b is a list that contains three references to a.   Modify a, and
all three references to a show the modification:

 a = [1,2,3]
 b = [a,a,a]
 a.append(4)
 b
[[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]]

Gary Herron



   
 nn=3*[[]]
 nn
 
 [[], [], []]
   
 mm=[[],[],[]]
 mm
 
 [[], [], []]

 Up till now, 'mm' and 'nn' look the same, right? Nope!

   
 mm[1].append(17)
 mm
 
 [[], [17], []]
   
 nn[1].append(17)
 nn
 
 [[17], [17], [17]]

 ???

 Python 2.5 Win XP

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

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


  1   2   3   >