Python training in Florida, January 19-21

2009-12-17 Thread Python Training
Don't miss your chance to attend our upcoming Florida
Python training class next month.  This 3-day public
class is being held January 19-21, in Sarasota, Florida.
It is open to both individual and group enrollments.

For more details on the class, as well as registration
instructions, please visit the class web page:

http://home.earthlink.net/~python-training/2010-public-classes.html

If you are unable to attend in January, our next 
Sarasota class is already scheduled for April 6-8.

Thanks, and we hope to see you at a Python class in
sunny and warm Florida soon.

--Mark Lutz at Python Training Services

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

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


Bazaar 2.0.3 and 2.1.0b4 released!

2009-12-17 Thread John Arbash Meinel
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

The Bazaar team is happy to announce availability of a new releases of
the bzr adaptive version control system. Bazaar is part of the GNU
system http://gnu.org/.

The third release of Bazaar 2.0 (2.0.3) has a small handful of bugfixes.
As expected, this has no internal or external compatibility changes
versus 2.0.2 (or 2.0.0).

The fourth beta release in the 2.1 series brings with it a significant
number of bugfixes (~20). The test suite is once again (finally) green
on Windows, and should remain that way for future releases. There are a
few performance related updates (faster upgrade and log), and several UI
tweaks. There has also been a significant number of tweaks to the
runtime documentation. 2.1.0b4 include everything from the 2.0.3 release.

It is expected that the next release in the 2.1 series will be 2.1.0rc1,
which means it will then enter into its stable bugfix-only phase (and
2.2.0b1 will be opened for development.)

Thanks to everyone who contributed patches, suggestions, and feedback.

Both the source and platform specific binaries can be downloaded from
  https://launchpad.net/bzr/2.0/2.0.3
  https://launchpad.net/bzr/2.1/2.1.0b4

As always, all releases are available from
  https://launchpad.net/bzr/+download

John
=:-

The full changelog for 2.1.0b4 and 2.0.3 follows:

bzr 2.1.0b4
###

:Codename: san francisco airport
:2.1.0b4: 2009-12-14

The fourth beta release in the 2.1 series brings with it a significant
number of bugfixes (~20). The test suite is once again (finally)
green on Windows, and should remain that way for future releases.
There are a few performance related updates (faster upgrade and log),
and several UI tweaks. There has also been a significant number of
tweaks to the runtime documentation. 2.1.0b4 include everything from
the 2.0.3 release.


Compatibility Breaks


* The BZR_SSH environmental variable may now be set to the path of a
  secure shell client. If currently set to the value ``ssh`` it will
  now guess the vendor of the program with that name, to restore the
  old behaviour that indicated the SSH Corporation client use
  ``sshcorp`` instead as the magic string.
  (Martin gzl...@googlemail.com, #176292)

New Features


* ``bzr commit`` now has a ``--commit-time`` option.
  (Alexander Sack, #459276)

* ``-Dhpss`` now increases logging done when run on the bzr server,
  similarly to how it works on the client. (John Arbash Meinel)

* New option ``bzr unshelve --keep`` applies the changes and leaves
  them on the shelf.  (Martin Pool, Oscar Fuentes, #492091)

* The ``BZR_COLUMNS`` envrionment variable can be set to force bzr to
  respect a given terminal width. This can be useful when output is
  redirected or in obscure cases where the default value is not
  appropriate. Pagers can use it to get a better control of the line
  lengths.  (Vincent Ladeuil)

Bug Fixes
*

* After renaming a file, the dirstate could accidentally reference
  ``source\\path`` rather than ``source/path`` on Windows. This might
  be a source of some dirstate-related failures. (John Arbash Meinel)

* ``bzr commit`` now detects commit messages that looks like file
  names and issues a warning.  (Gioele Barabucci, #73073)

* ``bzr ignore /`` no longer causes an IndexError.
  (Gorder Tyler, #456036)

* ``bzr log -n0 -rN`` should not return revisions beyond its merged
  revisions.  (#325618, #484109, Marius Kruger)

* ``bzr merge --weave`` and ``--lca`` will now create ``.BASE`` files
  for files with conflicts (similar to ``--merge3``). The contents of the
  file is a synthesis of all bases used for the merge.
  (John Arbash Meinel, #40412)

* ``bzr mv --quiet`` really is quiet now.  (Gordon Tyler, #271790)

* ``bzr serve`` is more clear about the risk of supplying
  --allow-writes.  (Robert Collins, #84659)

* ``bzr serve --quiet`` really is quiet now.  (Gordon Tyler, #252834)

* Fix bug with redirected URLs over authenticated HTTP.
  (Glen Mailer, Neil Martinsen-Burrell, Vincent Ladeuil, #395714)

* Interactive merge doesn't leave branch locks behind.
  (Aaron Bentley)

* Lots of bugfixes for the test suite on Windows. We should once again
  have a test suite with no failures on Windows. (John Arbash Meinel)

* ``osutils.terminal_width()`` obeys the BZR_COLUMNS environment
  variable but returns None if the terminal is not a tty (when output
  is redirected for example). Also fixes its usage under OSes that
  doesn't provide termios.TIOCGWINSZ. Make sure the corresponding
  tests runs on windows too.
  (Joke de Buhr, Vincent Ladeuil, #353370, #62539)
  (John Arbash Meinel, Vincent Ladeuil, #492561)

* Terminate ssh subprocesses when no references to them remain, fixing
  subprocess and file descriptor leaks.  (Andrew Bennetts, #426662)

* The ``--hardlink`` option of ``bzr branch`` and ``bzr checkout`` now
  works for 2a format trees.  Only files unaffected by content filters
  will be hardlinked.  

Multiple python installations on opensuse?

2009-12-17 Thread Johan Ekh
Hi all,
I use the finite element package ABAQUS that is partly built around python
2.4.3.
ABAQUS ships with its own version of python 2.4.3 but it comes without third
party
libraries, e.g. numpy and scipy. In order to load these modules into ABAQUS
python
I must install python 2.4.3. on my opensuse laptop. How can I do this
without interference
with my python 2.6 installation that I use for all my non-ABAQUS python
work?

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


Re: pyZui - anyone know about this?

2009-12-17 Thread David Roberts
 /home/fetchinson/pyzui/pyzui/tilestore.py:22: DeprecationWarning: the
 sha module is deprecated; use the hashlib module instead
   import sha
Yeah, I'd noticed that. It's fixed in the repository now.

On Dec 16, 10:55 pm, Daniel Fetchinson fetchin...@googlemail.com
wrote:
  PyZUI 0.1 has been released:

 http://da.vidr.cc/projects/pyzui/

 Cool, thanks very much!

 I'm using python 2.6 these days and noticed that you use the sha
 module which makes py2.6 spit out a deprecation warning:

 /home/fetchinson/pyzui/pyzui/tilestore.py:22: DeprecationWarning: the
 sha module is deprecated; use the hashlib module instead
   import sha

 It's no big deal but if you want to be future proof maybe you can
 switch to hashlib for py2.6 and stay with sha for py2.5 and before (a
 try/except block would suffice).

 Cheers,
 Daniel

 --
 Psss, psss, put it down! -http://www.cafepress.com/putitdown

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


Re: pyZui - anyone know about this?

2009-12-17 Thread David Roberts
 Personally I see a merging of normal app windows and a zui: some kind of new
 window manager.
Have you seen Eagle Mode[1]?

[1] http://eaglemode.sourceforge.net/

On Dec 17, 5:14 pm, Donn donn.in...@gmail.com wrote:
 On Wednesday 16 December 2009 07:03:19 David Roberts wrote: It involves 
 scaling an image to various resolutions, and partitioning
  them into fixed-size tiles. It's roughly the same technique used by
  Google Maps/Earth.

 Thanks. That gives me something to go on. Wikipedia didn't like my search
 terms.

   ZUIs are useful for particular types of data - images  mapping
   especially - but I'd hate to have to navigate my desktop using its
   approach.

 Ever since Corel Draw in the 90's zoomed into my life I have been in love with
 the idea of an endless canvas that makes me feel like a satellite on a bungee
 cord. I think it would fit the desktop very well.

 Personally I see a merging of normal app windows and a zui: some kind of new
 window manager.
 If I planned it out it would look something like this:
 Your apps all run as they do now*, but they live on this endless plain.
 Perhaps it can be divided up into 'zones' or 'galaxies' or something. I would
 have a 'hyperspace' or 'hyperlink' or 'jump' facility (like alt-tab, I guess)
 to make transits from one custom-defined area to another quick.

 I would have a home position for the view -- like Inkscape does in terms of
 show all, zoom to selected, zoom to last, etc.

 I would have rules about traversing. Things like file-managers need some kind
 of static display - like the bread crumbs and up, back, home etc.

 Each app would only be active when 'locked-in', beyond that it's a bitmap of
 the last paint. You could drag apps around when you zoom out, and you can
 resize them at any time too.
 (Just imagine OOCalc in a zui! Super/Capslock and mouse wheel for scroll/pan)

 The other cool idea I had was to (handwavium here) graphically convey the
 notion of pipes and import/export between apps. Also between any nodes across
 the Universe of the zui. Perhaps a special 'node view' that overlays and shows
 all the conduits between them -- sharp where your mouse is, faded away from
 that so the whole thing is not too complex.
 Imagine the flow from Inkscape to Gimp and back. Instead of File - Export and
 then File - Import, you connect pipes along the side of each app.
 Inkscape, [save selected as png (properties preset)] goes to Gimp [import to
 layers by names (a script perhaps)] Now as you work in Inkscape and hit a
 hotkey, all your selected vectors are sent to Gimp which reacts as if you were
 there and places the new pngs into layers.
 This can work both ways and between multiple programs. Mix-in Blender and
 Scribus and Lyx and some grep and a loop or two and some imagemagick...

 Ah, I better stop. I can ramble on sometimes :)

 *I have many issues with the endless variety of re-invented wheels afa gui
 toolkits go. This is another whole can of shai-Hulud...

 I wrote some stuff about this a while back, if anyone wants to be put to 
 sleep:http://otherwise.relics.co.za/wiki/Particles/DreamDesignApp/
 :)

 \d

 --
 \/\/ave: donn.in...@googlewave.com
 home:http://otherwise.relics.co.za/
 2D vector animation :https://savannah.nongnu.org/projects/things/
 Font manager :https://savannah.nongnu.org/projects/fontypython/

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


Re: pyZui - anyone know about this?

2009-12-17 Thread Donn
On Thursday 17 December 2009 10:54:59 David Roberts wrote:
 Have you seen Eagle Mode[1]?
 
Yes. It's a strange beast. Good start I think; but addicted to zooming, to the 
detriment of the managing aspects I think. Still, here I sit writing no code 
and pontificating!

\d
-- 
\/\/ave: donn.in...@googlewave.com
home: http://otherwise.relics.co.za/
2D vector animation : https://savannah.nongnu.org/projects/things/
Font manager : https://savannah.nongnu.org/projects/fontypython/
-- 
http://mail.python.org/mailman/listinfo/python-list


ftplib timeout in Python 2.4

2009-12-17 Thread Nico Grubert

Hi there,

The ftplib has a timeout parameter in Python 2.6 and above.
Is there a way to set a timeout in Python 2.4?

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


Re: webscrapping ringcentral.com using mechanize

2009-12-17 Thread S.Selvam
On Thu, Dec 17, 2009 at 3:34 AM, shrini tshriniva...@gmail.com wrote:

 Hi,

 I am trying to scrap the website 'http://service.ringcentral.com'

 It has a form with three input boxes.

 When trying to get the form with mechanize, it is throwing the
 following error.

 mechanize._mechanize.FormNotFoundError: no form matching name 'login'

 but, the page has the form with name login.

 This form is submitted by javascript.



  Though i am not sure,i think posting values via urllib  could help .

   Also you may find it useful,


http://stackoverflow.com/questions/1806238/mechanize-python-click-a-button



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


Re: Object Relational Mappers are evil (a meditation)

2009-12-17 Thread Neil Cerutti
On 2009-12-16, J Kenneth King ja...@agentultra.com wrote:
 The language doesn't encourage anything.  It's just a medium
 like oil paints and canvas.  A painting can be good or bad
 despite the medium it is constructed on.  The skill of the
 painter is what matters.

Technically, oil paints do encourage a certain kind of painting.
They can be layered on top of old paint easily, and they dry
slowly, allowing you to slowly build up a painting in layers,
and create effects with texture. If you try doing thse things
with watercolors, and you'll probably be discouraged.

I think a programming language does encourage a certain kind of
code. Good code in one language can be poor in another.

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


Re: csv reader

2009-12-17 Thread Emmanuel
As csv.reader does not suport utf-8 encoded files, I'm using:

fp = codecs.open(arquivoCSV, r, utf-8)
self.tab=[]
for l in fp:
l=l.replace('\','').strip()
self.tab.append(l.split(','))

It works much better except that when I do self.sel.type(q, ustring)
where ustring is a unicode string obtained from the file using the
code showed above.

Remaining problem is that I obtain sp insted of a regular space...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: parallelpython 1.5.7 crash

2009-12-17 Thread makobu
Thanks Zeph.
-- 
http://mail.python.org/mailman/listinfo/python-list


accessing gmail

2009-12-17 Thread Tony
I'm having trouble getting to gmail messages.  I can access my googlemail 
account through imap with no problems, that's an old one.  The problem is 
trying to get to my current gmail account, which is actually 
t...@tonyburrows.com.  The page shows up as 
mail.google.com/a/tonyburrows.com and I can't see how to get at it.

mail = imaplib.IMAP4_SSL('imap.gmail.com, 993)
mail.login(username, password)

logs me in to my googlemail account and lets me collect mail in that one, 
but how do I get to the gmail one?

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


Re: accessing gmail

2009-12-17 Thread Tony
Intchanter / Daniel Fackrell wrote:

 http://mail.google.com/support/bin/answer.py?hl=enanswer=77654

Thanks!

Actually I had a sudden inspiration last night as I went to bed.  I'd set 
up Thunderbird, all I needed to do was use the same full h...@domain as the 
username.  Stupid, stupid - I'd wasted so much time and it was so simple.  
I will remember it though.

Now to figure out the rest of it.

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


Python Goldmine has been updated: http://preciseinfo.org/Convert/index_Convert_Python.html

2009-12-17 Thread tanix
Python Goldmine has been updated as of dec 15 2009.

http://preciseinfo.org/Convert/index_Convert_Python.html

Mirrors:

http://pythongoldmine.vndv.com.

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


Re: More stuff added to ch 2 of my programming intro

2009-12-17 Thread Ned Deily
In article 
183af5d2-e157-4cd6-bec6-8997809e1...@d21g2000yqn.googlegroups.com,
 Mensanator mensana...@aol.com wrote:
 Oh, I don't know, maybe because I'm thinking about
 buying one and seeing 2.3, 2.4 and 2.5 directories
 on the model in the store made me wary.

That's odd since, AFAIK, Apple has never released an OS X with Python 
2.4.

Current Apple systems ship with OS X 10.6, aka Snow Leopard.   10.6 
includes a Python 2.6.1 (64-bit/32-bit) and a Python 2.5.4 (32-bit 
only).  The previous release, 10.5, shipped with 2.5 and 2.3.  But, not 
to worry, if you need other versions, you can download OS X installers 
from python.org.

  http://www.python.org/download/releases/3.1.1/http://www.python.org/ftp/pyth
  on/3.1.1/python-3.1.1.dmg
 
 This tells me nothing.

That's the disk image for the OS X Python 3.1.1 installer.  Official 
binary installers for OS X are provided on python.org for every final 
Python release.

  or (for MacPorts fans):
 
  $ sudo port install python31
 
 
 And since I haven't got one, this also tells me nothing.

http://www.macports.org/

The MacPorts Project is an open-source community initiative to design 
an easy-to-use system for compiling, installing, and upgrading either 
command-line, X11 or Aqua based open-source software on the Mac OS X 
operating system.

-- 
 Ned Deily,
 n...@acm.org

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


Re: Multiple python installations on opensuse?

2009-12-17 Thread Ishwor Gurung
2009/12/17 Johan Ekh ekh.jo...@gmail.com:
 Hi all,
 I use the finite element package ABAQUS that is partly built around python
 2.4.3.
 ABAQUS ships with its own version of python 2.4.3 but it comes without third
 party
 libraries, e.g. numpy and scipy. In order to load these modules into ABAQUS
 python
 I must install python 2.4.3. on my opensuse laptop. How can I do this
 without interference
 with my python 2.6 installation that I use for all my non-ABAQUS python
 work?

Go to python.org, and download appropriate source (shjould be one for
2.4 final release).

$ mkdir $HOME/my2.4build/
$ ./configure --prefix=$HOME/my2.4build  make  make install;


To run-
$ cd $HOME/my2.4build/bin
$ ./python

I am assuming you've got the C/C++ libraries installed.
-- 
Regards,
Ishwor Gurung
-- 
http://mail.python.org/mailman/listinfo/python-list


Fwd: Multiple python installations on opensuse?

2009-12-17 Thread Ishwor Gurung
Scipy needs various libraries. On Ubuntu (which I use) -

Depends: python ( 2.7), python (= 2.5), python-central (= 0.6.11),
 python-numpy (= 1:1.2.0), libblas3gf | libblas.so.3gf |
 libatlas3gf-base, libc6 (= 2.4), libgcc1 (= 1:4.1.1), libgfortran3
 (= 4.3), liblapack3gf | liblapack.so.3gf | libatlas3gf-base,
 libstdc++6 (= 4.1.1), libsuitesparse-3.2.0 (= 1:3.2.0)

So, doing a source/binary install similarly and then install Scipy again.

-- Forwarded message --
From: Johan Ekh ekh.jo...@gmail.com
Date: 2009/12/17
Subject: Re: Multiple python installations on opensuse?
To: Ishwor Gurung ishwor.gur...@gmail.com


Thanks guys,
I installed it as root without the --prefix option using make
altinstall instead of make install.
It worked and I can now execute python2.4.6 with python2.4 while
python2.6 is still executed
with python.

I also managed to install numpy with python2.4 setup.py install.
However, installing scipy
in the same way failed with the error below. Most of my libraries
appears to be in /usr/lib64/
or /usr/local/lib64 and the install script can't find them because it
searched /usr/lib/ and /usr/local/lib/.

How can I fix this?

Sorry for newbiesh questions...

//Johan

== Output from python2.4 setup.py install

Warning: No configuration returned, assuming unavailable.
blas_opt_info:
blas_mkl_info:
  libraries mkl,vml,guide not found in /usr/local/lib
  libraries mkl,vml,guide not found in /usr/lib
  NOT AVAILABLE

atlas_blas_threads_info:
Setting PTATLAS=ATLAS
  libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
  libraries ptf77blas,ptcblas,atlas not found in /usr/lib
  NOT AVAILABLE

atlas_blas_info:
  libraries f77blas,cblas,atlas not found in /usr/local/lib
  libraries f77blas,cblas,atlas not found in /usr/lib
  NOT AVAILABLE

/usr/local/lib/python2.4/site-packages/numpy/distutils/system_info.py:1340:
UserWarning:
    Atlas (http://math-atlas.sourceforge.net/) libraries not found.
    Directories to search for the libraries can be specified in the
    numpy/distutils/site.cfg file (section [atlas]) or by setting
    the ATLAS environment variable.
  warnings.warn(AtlasNotFoundError.__doc__)
blas_info:
  libraries blas not found in /usr/local/lib
  libraries blas not found in /usr/lib
  NOT AVAILABLE

/usr/local/lib/python2.4/site-packages/numpy/distutils/system_info.py:1349:
UserWarning:
    Blas (http://www.netlib.org/blas/) libraries not found.
    Directories to search for the libraries can be specified in the
    numpy/distutils/site.cfg file (section [blas]) or by setting
    the BLAS environment variable.
  warnings.warn(BlasNotFoundError.__doc__)
blas_src_info:
  NOT AVAILABLE

/usr/local/lib/python2.4/site-packages/numpy/distutils/system_info.py:1352:
UserWarning:
    Blas (http://www.netlib.org/blas/) sources not found.
    Directories to search for the sources can be specified in the
    numpy/distutils/site.cfg file (section [blas_src]) or by setting
    the BLAS_SRC environment variable.
  warnings.warn(BlasSrcNotFoundError.__doc__)
Traceback (most recent call last):
  File setup.py, line 92, in ?
    setup_package()
  File setup.py, line 84, in setup_package
    configuration=configuration )
  File /usr/local/lib/python2.4/site-packages/numpy/distutils/core.py,
line 150, in setup
    config = configuration()
  File setup.py, line 54, in configuration
    config.add_subpackage('scipy')
  File /usr/local/lib/python2.4/site-packages/numpy/distutils/misc_util.py,
line 851, in add_subpackage
    caller_level = 2)
  File /usr/local/lib/python2.4/site-packages/numpy/distutils/misc_util.py,
line 834, in get_subpackage
    caller_level = caller_level + 1)
  File /usr/local/lib/python2.4/site-packages/numpy/distutils/misc_util.py,
line 781, in _get_configuration_from_setup_py
    config = setup_module.configuration(*args)
  File scipy/setup.py, line 8, in configuration
    config.add_subpackage('integrate')
  File /usr/local/lib/python2.4/site-packages/numpy/distutils/misc_util.py,
line 851, in add_subpackage
    caller_level = 2)
  File /usr/local/lib/python2.4/site-packages/numpy/distutils/misc_util.py,
line 834, in get_subpackage
    caller_level = caller_level + 1)
  File /usr/local/lib/python2.4/site-packages/numpy/distutils/misc_util.py,
line 781, in _get_configuration_from_setup_py
    config = setup_module.configuration(*args)
  File scipy/integrate/setup.py, line 10, in configuration
    blas_opt = get_info('blas_opt',notfound_action=2)
  File /usr/local/lib/python2.4/site-packages/numpy/distutils/system_info.py,
line 267, in get_info
    return cl().get_info(notfound_action)
  File /usr/local/lib/python2.4/site-packages/numpy/distutils/system_info.py,
line 416, in get_info
    raise self.notfounderror,self.notfounderror.__doc__
numpy.distutils.system_info.BlasNotFoundError:
    Blas (http://www.netlib.org/blas/) libraries not found.
    Directories to search for the libraries can be specified in the
    

Re: (OT) Where Are Cookies Stored?

2009-12-17 Thread Lie Ryan

On 12/17/2009 2:33 AM, Dave Angel wrote:



Victor Subervi wrote:

On Tue, Dec 15, 2009 at 6:57 PM, r0g aioe@technicalbloke.com wrote:

snip

Cookies in FF for Windows are stored in an sqlite database in here...

~\Application Data\Mozilla\Firefox\Profiles\%XYZ%\firefox_profile\



Man, I searched C drive (the only drive) on this computer where I'm
working
(Internet cafe) for Application Data and nuttin.
V


How are you searching? Microsoft is so sure we don't want to see the
gory details that they hide all sorts of things, by default. And
especially on a public computer, you shouldn't even look with Explorer.
As for searching with Explorer, there are not only design problems, but
bugs as well. Get a command line, and do something like:


snip

Or, you can just open Internet Explorer, type at the address bar 
www.google.com; then wait for a few seconds. After the page loads, 
type windows {VERSION} application data where you substitute {VERSION} 
with the windows version you're using. Press I'm feeling lucky and 
skim the page for something that looks like pathnames.

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


Re: Help with parsing a list

2009-12-17 Thread Sallu
On Dec 17, 4:23 am, thunderf...@gmail.com thunderf...@gmail.com
wrote:
 not as slick as Emile's (didn't think about using strip() ), but
 seemingly functional:

 data = ['key1: data1','key2: data2','key3: data3',' key4: ','
 \tdata4.1',' \tdata4.2',' \tdata4.3','key5: data5']
 result = {}

 for item in data:
     if item.endswith(': '):
         currkey = item[:-2]
         result[currkey] = []
     elif item.startswith(' \t'):
         result[currkey].append(item[2:])
     else:
         key, val = item.split(': ')
         result[key] = val

 print 'data = %s' % data
 print 'result = %s' % result



 data = ['key1: data1', 'key2: data2', 'key3: data3', ' key4: ', '
 \tdata4.1', ' \tdata4.2', ' \tdata4.3', 'key5: data5']
 result = {'key3': 'data3', 'key2': 'data2', 'key1': 'data1', 'key5':
 'data5', ' key4': ['data4.1', 'data4.2', 'data4.3']}





Hi i tried with thunderfoot code

error:

Traceback (most recent call last):
  File stdin, line 8, in ?
ValueError: need more than 1 value to unpack
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PIL: problem to convert an image array to PIL format

2009-12-17 Thread Robert Franke
Hi,

On Thu, Dec 17, 2009 at 1:14 PM, Sverre sverreodeg...@gmail.com wrote:

 After converting a PIL image in memory to an array with numpy.asarray
 (), I make a adthreshold() with pymorph() with the result, that all
 pixels in the array are either false or true (boolean). But my try to
 convert this back into PIL format is failing

 img = Image.fromarray(rawimg, '1')

 because a true will be interpreted as integer 1 ), so that 7 pixels
 are black and one white. Has someone a solution, so that a  picture
 inly with true values doesn't look like this?

 http://img707.imageshack.us/img707/6051/p012.jpg


I am not 100% sure this is what you want, but this is how I apply a simple
threshold to a picture:


threshold = 145
img = Image.open(gray.jpg)
arr = numpy.asarray(img)
filtered = arr * (arr  threshold)
new_img = Image.fromarray(filtered,L)


Cheers,

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


file.close() does not really close under Windows?

2009-12-17 Thread Dani
Is it correct that low-level file handles are not being closed after
doing

  fd = open(filepath)
  fd.close()

If so, what is the rationale?

This seems to result in system errors when trying to (re-)move or
reopen closed files, as well as when opening (and closing) too many
files under Windows.

A workaround seems to be

  os_fd = os.open(filepath)
  fd = os.fdopen(os_fd)
  os.close(os_fd)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ftplib timeout in Python 2.4

2009-12-17 Thread r0g
Nico Grubert wrote:
 Hi there,
 
 The ftplib has a timeout parameter in Python 2.6 and above.
 Is there a way to set a timeout in Python 2.4?
 
 Regards
 Nico


I don't know of one so you may need a workaround. What platforms do you
need to support?

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


When to use mechanize and Windmill library during WebScraping ?

2009-12-17 Thread Raji Seetharaman

 -- Forwarded message --
 From: Javier Collado javier.coll...@gmail.com
 To: Raji Seetharaman sraji...@gmail.com
 Date: Sat, 12 Dec 2009 12:52:27 +0100
 Subject: Re: When to use mechanize and Windmill library during WebScraping
 ?
 Hello,

 If a script that uses mechanize fails to find an html node that has
 been identified with Firebug, this is probably because that node has
 been autogenerated (provided that the expression to get the node is
 correct).

 As an alternative to verify this, you can try to download the html
 page and open it in your favourite editor. If some of the nodes that
 you can see in your browser are missing or empty, then one of the
 JavaScript scripts in the page should have created/populated it.

 If you're in doubt, you can try to use mechanize and, if you have
 problems such as the described above, then you can move to windmill or
 some other tool that executes JavaScript code before trying to get the
 desired data.

 Best regards,
Javier


Thanks for your help

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


When to use mechanize and Windmill library during WebScraping ?

2009-12-17 Thread Raji Seetharaman
 Be sure to look at Scrapy too: http://scrapy.org


 Thank U

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


Re: pyZui - anyone know about this?

2009-12-17 Thread Daniel Fetchinson
 /home/fetchinson/pyzui/pyzui/tilestore.py:22: DeprecationWarning: the
 sha module is deprecated; use the hashlib module instead
   import sha
 Yeah, I'd noticed that. It's fixed in the repository now.

Great, thanks, pulled it and all looks good.

Cheers,
Daniel


  PyZUI 0.1 has been released:

 http://da.vidr.cc/projects/pyzui/

 Cool, thanks very much!

 I'm using python 2.6 these days and noticed that you use the sha
 module which makes py2.6 spit out a deprecation warning:

 /home/fetchinson/pyzui/pyzui/tilestore.py:22: DeprecationWarning: the
 sha module is deprecated; use the hashlib module instead
   import sha

 It's no big deal but if you want to be future proof maybe you can
 switch to hashlib for py2.6 and stay with sha for py2.5 and before (a
 try/except block would suffice).

 Cheers,
 Daniel

 --
 Psss, psss, put it down! -http://www.cafepress.com/putitdown

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



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


Re: Multiple python installations on opensuse?

2009-12-17 Thread Ishwor Gurung
2009/12/17 Johan Ekh ekh.jo...@gmail.com:
 But I have them installed already! I have scipy installed under python 2.6
 and everything runs perfect.

ok

 It is only under python 2.4 that the install script can not find the
 libraries. I need to tell the script to
 lookin /usr/lib64 instead /usr/lib, how can I do this?

As root, tell linker to look for libraries in /usr/lib64:
$ echo /usr/lib64  /etc/ld.so.conf
$ ldconfig
$ ./configure

Please send email to the mailing list. I am subscribed to it :

[...]
-- 
Regards,
Ishwor Gurung
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: file.close() does not really close under Windows?

2009-12-17 Thread Tim Chase

Dani wrote:

Is it correct that low-level file handles are not being closed after
doing

  fd = open(filepath)
  fd.close()


no, you are not correct.

Demonstration:

Cmd window #1:

c:\temp echo hello world  x.txt

Cmd window #2

c:\temp python
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit 
(Intel)] on win32
Type help, copyright, credits or license for more 
information.

 f = file('x.txt')
 f.close()
 # remaining in an open python session


back to Cmd window #1
C:\temp del x.txt
C:\temp rem note...no error here.
C:\temp exit

back to Cmd window #2
 # quit python
 ^Z
C:\temp exit



If so, what is the rationale?


it's not because there is no good rationale for wanting that 
behavior :)  The above was performed on XP (SP2  SP3) with no 
issues.  I can't guarantee that MS hasn't borked something in 
Vista or Win7, but if they did, that's *their* issue, not Python's.



This seems to result in system errors when trying to (re-)move or
reopen closed files, as well as when opening (and closing) too many
files under Windows.


As always, check your own code/environment before assuming the 
problem is with Python.  In all likelihood, you had the file open 
in another window/process and didn't remember.  Perhaps some 
background indexing process happened to hold the file open for a 
brief spell?


-tkc



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


Re: ftplib timeout in Python 2.4

2009-12-17 Thread Nico Grubert

I don't know of one so you may need a workaround. What platforms do you

 need to support?

Suse Linux Enterprise 10, 64 Bit with Python 2.4.4.
I need the Python 2.4.4 for a running application Server (Zope).
--
http://mail.python.org/mailman/listinfo/python-list


Re: PIL: problem to convert an image array to PIL format

2009-12-17 Thread Peter Otten
Sverre wrote:

 After converting a PIL image in memory to an array with numpy.asarray
 (), I make a adthreshold() with pymorph() with the result, that all
 pixels in the array are either false or true (boolean). But my try to
 convert this back into PIL format is failing
 
 img = Image.fromarray(rawimg, '1')
 
 because a true will be interpreted as integer 1 ), so that 7 pixels
 are black and one white. Has someone a solution, so that a  picture
 inly with true values doesn't look like this?
 
 http://img707.imageshack.us/img707/6051/p012.jpg

This has come up before, see

http://mail.python.org/pipermail/python-list/2009-October/1221578.html

Image.fromarray() expects one bit per pixel but actually gets one byte. One 
possible workaround: introduce an intermediate array with a format 
understood by fromarray():

 import numpy
 from PIL import Image
 rawimg = numpy.zeros((20, 20), bool)
 rawimg[:10, :10] = rawimg[10:, 10:] = True
 b = numpy.array(rawimg, numpy.uint8)
 b *= 255
 Image.fromarray(b).save(tmp.jpg)

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


Re: file.close() does not really close under Windows?

2009-12-17 Thread Dani

 No, it is incorrect. I tested that exact snippet here and it correctly
 closes the file. I can move the file around just after that.

Yes, indeed. Sorry for not getting my facts straight and thank you for
testing. Part of the code *was* holding a low-level file handle.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Raw string substitution problem

2009-12-17 Thread Alan G Isaac

En Wed, 16 Dec 2009 11:09:32 -0300, Ed Keith e_...@yahoo.com escribió:


I am having a problem when substituting a raw string. When I do the
following:

re.sub('abc', r'a\nb\nc', '123abcdefg')

I get


123a
b
cdefg


what I want is

r'123a\nb\ncdefg'


 
On 12/16/2009 9:35 AM, Gabriel Genellina wrote:

 From http://docs.python.org/library/re.html#re.sub

re.sub(pattern, repl, string[, count])

...repl can be a string or a function; if
it is a string, any backslash escapes in
it are processed. That is, \n is converted
to a single newline character, \r is
converted to a linefeed, and so forth.

So you'll have to double your backslashes:




I'm not persuaded that the docs are clear.  Consider:

 'ab\\ncd' == r'ab\ncd'
True

Naturally enough.  So I think the right answer is:

1. this is a documentation bug (i.e., the documentation
   fails to specify unexpected behavior for raw strings), or
2. this is a bug (i.e., raw strings are not handled correctly
   when used as replacements)

I vote for 2.

Peter's use of a function highlights just how odd this is:
getting the raw string via a function produces a different
result than providing it directly.  If this is really the
way things ought to be, I'd appreciate a clear explanation
of why.

Alan Isaac

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


Which version of MSVC?90.DLL's to distribute with Python 2.6 based Py2exe executables?

2009-12-17 Thread python
Does anyone have any recommendations on which version of the
MSVC?90.DLL's need to be distributed with a Python 2.6.4 PY2EXE (0.6.9)
based executable? (I assume I need just a matching pair of MSVCR90.DLL
and MSVCP90.DLL?)

My understanding is that I need to match the version of the DLL's that
my version of Python 2.6.4 was compiled against?

On my Windows 7 Professional (64-bit) workstation, I have the following
sets of MSVC?9.DLL files to choose from. 

Directory of C:\Program Files\Sony\VAIO Care
07/14/2009  01:18 PM   245,248 msvcm90.dll
07/14/2009  01:18 PM   851,456 msvcp90.dll
07/14/2009  01:18 PM   627,200 msvcr90.dll
   3 File(s)  1,723,904 bytes

Directory of C:\Program Files\Sony\VAIO
Care\plugins\Microsoft.VC90.CRT
07/14/2009  01:18 PM   245,248 msvcm90.dll
07/14/2009  01:18 PM   851,456 msvcp90.dll
07/14/2009  01:18 PM   627,200 msvcr90.dll
   3 File(s)  1,723,904 bytes

Directory of C:\Program Files (x86)\Sony\VAIOData Restore Tool
11/26/2008  10:26 AM   568,832 msvcp90.dll
11/26/2008  08:57 AM   655,872 msvcr90.dll
   2 File(s)  1,224,704 bytes

Directory of C:\Program Files (x86)\Sony\VAIO Recovery\plugins
07/15/2009  05:21 PM   224,768 msvcm90.dll
07/15/2009  05:21 PM   568,832 msvcp90.dll
07/15/2009  05:21 PM   655,872 msvcr90.dll
   3 File(s)  1,449,472 bytes

Directory of C:\Program Files (x86)\Sony\VAIO
Recovery\plugins\x64
07/15/2009  05:21 PM   627,200 msvcr90.dll
   1 File(s)627,200 bytes
Directory of C:\Program Files (x86)\Sony\VAIO VP Utilities
04/02/2009  07:12 PM   568,832 msvcp90.dll
04/02/2009  07:12 PM   655,872 msvcr90.dll
   2 File(s)  1,224,704 bytes

Directory of
C:\Windows\winsxs\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.2
1022.8_none_750b37ff97f4f68b
09/04/2009  04:35 AM   245,248 msvcm90.dll
09/04/2009  04:35 AM   851,456 msvcp90.dll
09/04/2009  04:35 AM   627,200 msvcr90.dll
   3 File(s)  1,723,904 bytes

Directory of
C:\Windows\winsxs\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.3
0729.4926_none_08e1a05ba83fe554
06/10/2009  03:31 PM   245,760 msvcm90.dll
06/10/2009  03:31 PM   853,328 msvcp90.dll
06/10/2009  03:31 PM   623,440 msvcr90.dll
   3 File(s)  1,722,528 bytes

Directory of
C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.210
22.8_none_bcb86ed6ac711f91
09/04/2009  04:35 AM   224,768 msvcm90.dll
09/04/2009  04:35 AM   568,832 msvcp90.dll
09/04/2009  04:35 AM   655,872 msvcr90.dll
   3 File(s)  1,449,472 bytes

Directory of
C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.307
29.1_none_e163563597edeada
09/04/2009  04:19 AM   225,280 msvcm90.dll
09/04/2009  04:19 AM   572,928 msvcp90.dll
09/04/2009  04:19 AM   655,872 msvcr90.dll
   3 File(s)  1,454,080 bytes

Directory of
C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.307
29.4926_none_508ed732bcbc0e5a
06/10/2009  04:14 PM   225,280 msvcm90.dll
06/10/2009  04:14 PM   569,664 msvcp90.dll
06/10/2009  04:14 PM   652,608 msvcr90.dll
   3 File(s)  1,447,552 bytes

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


Re: Where is PyMethod_GET_CLASS in Python 3?

2009-12-17 Thread Antoine Pitrou
Le Tue, 15 Dec 2009 08:08:01 -0800, Infinity77 a écrit :
 
 When building C extensions In Python 2.X, there was a magical
 PyMethod_GET_CLASS implemented like this:
 
 #define PyMethod_GET_CLASS(meth) \
   (((PyMethodObject *)meth) - im_class)
 
 It looks like Python 3 has wiped out the im_class attribute. Which is
 the alternative was to handle this case in Python 3?

First, is it a bound method? Unbound methods are just function objects in 
py3k. Check that PyMethod_Check() returns true.
Second, have you tried Py_TYPE(PyMethod_GET_SELF(meth))?

 BTW, it's very, very,
 *very* hard to find any possible reference to help migrating existing C
 extensions from Python 2.X to Python 3.

There's http://docs.python.org/3.1/howto/cporting.html
You are encouraged to post any suggestions or corrections on the bug 
tracker: http://bugs.python.org

Finally, there's also a dedicated mailing-list for porting to py3k:
http://mail.python.org/mailman/listinfo/python-porting
While it hasn't seen a lot of activity lately, I'm sure there are people 
there willing to answer any questions you have!

Regards

Antoine.


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


Re: More stuff added to ch 2 of my programming intro

2009-12-17 Thread Benjamin Kaplan
On Thu, Dec 17, 2009 at 5:33 AM, Ned Deily n...@acm.org wrote:

  or (for MacPorts fans):
 
  $ sudo port install python31


 And since I haven't got one, this also tells me nothing.

 http://www.macports.org/

 The MacPorts Project is an open-source community initiative to design
 an easy-to-use system for compiling, installing, and upgrading either
 command-line, X11 or Aqua based open-source software on the Mac OS X
 operating system.

Description sans marketing fluff: It's a Mac package manager. It's
basically the same as Gentoo's portage if you've ever used that. It
downloads source tarballs and patches and then compiles them locally.
There are built-in lists of variants, basically sets of configure
args, to compile each package.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Raw string substitution problem

2009-12-17 Thread Richard Brodie

Alan G Isaac alan.is...@gmail.com wrote in message 
news:qemdnrut0jvj1lfwnz2dnuvz_vqdn...@rcn.net...

 Naturally enough.  So I think the right answer is:

 1. this is a documentation bug (i.e., the documentation
fails to specify unexpected behavior for raw strings), or
 2. this is a bug (i.e., raw strings are not handled correctly
when used as replacements)

neo There is no raw string. /neo

A raw string is not a distinct type from an ordinary string
in the same way byte strings and Unicode strings are. It
is a merely a notation for constants, like writing integers
in hexadecimal.

 (r'\n', u'a', 0x16)
('\\n', u'a', 22)





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


Re: frames in toplevel Tkinter

2009-12-17 Thread J Wolfe
On Dec 16, 11:09 pm, J Wolfe vorticitywo...@gmail.com wrote:
 Probably a stupid question, but can you have a frames in a toplevel
 widget? Anything I try to put in a frame goes back to the main or root
 widget and not the toplevel or pop-up widget.

 Thanks for the help!
 Jonathan

Thank you John,

from Tkinter import *
root = Tk()
Label(root, text='This is the root window').pack()
top = Toplevel(root)
fr = Frame(top)   # frame child of Toplevel called top
fr.pack()
Label(fr, text='This is in a frame in the Toplevel window').pack()
root.mainloop()

I swear I tried that about 20 times yesterday...and it kept putting it
in my main window.  Perhaps I had a naming issue.

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


Re: Using Python to Execute a C or FORTRAN Program (Windows)

2009-12-17 Thread W. eWatson

sturlamolden wrote:

On 17 Des, 03:41, W. eWatson wolftra...@invalid.com wrote:


His program was originally written in Python, but a new
hardware device (capture card) had no good interface with Python, so he
wrote it in C++, which does. From my knowledge of the Python program
before the entry of c++, it seems he could have farmed out the hardware
interface in much the same way he had done it before with a capture card
well know to him.


This sounds a bit incompetent.

Why didn't he just write an extension module in C++?

Also, if you don't know how to spawn a subprocess, I'd question your
competence as well.



I can't read his mind.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Either IDLE Can't Start a subprocess or a firewall software firewall is blocking the connection (Win)--Battlin McAfee

2009-12-17 Thread W. eWatson

Alf P. Steinbach wrote:

* W. eWatson:
See Subject msg from Python 2.5 Win XP. It is preceded by a Socket 
Error. It happened while I had a simple program displayed, and I 
wanted to see the shell. The msg occurred when I pressed Shell on Run 
from the menu. I played around for awhile, but got nowhere. Same msg. 
I did remove my McAfee firewall protection, and it worked once, but 
reverted to not working.


I rebooted and the first time I could use Shell, it succeeded. After 
that it failed. Comments? Geeze! Mcaffe turned on the firewall again 
after the reboot.


All seems well now. Nope. McAfee turned the firewall back on. It 
decided to warn me it was off, but now has allowed me to ignore the 
fact it is no longer protecting me. I'll just let Win firewall do 
that, thank you.


Nope it's back. I'll just stop here and let anyone who wants to just 
chime in. If I get it to stop, I'll be back.


I recall vaguely some similar problem caused by a program attempting to 
connect to localhost, and the solution then was to edit the hosts file 
(don't ask me for details, but perhaps that'll help you search: that 
problem had entirely to do with Windows' very over-zealous security 
measures).



Cheers  hth.,

- Alf

As it turns out, I can sneak around it, so I'm putting it aside.
--
http://mail.python.org/mailman/listinfo/python-list


Re: PIL: problem to convert an image array to PIL format

2009-12-17 Thread Sverre
On 17 Des, 15:45, Peter Otten __pete...@web.de wrote:

 This has come up before, see

 http://mail.python.org/pipermail/python-list/2009-October/1221578.html


 Peter

Thank you!

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


Re: iterators and views of lists

2009-12-17 Thread Anh Hai Trinh
 I have a couple of thoughts:
 1. Since [:] by convention already creates a copy, it might violate
 people's expectations if that syntax were used.

Indeed, listagent returns self on __getitem__[:]. What I meant was
this:

  x = [0, 1, 2, 3, 4, 5, 6, 7]
  a = listagent(x)[::2]
  a[:] = listagent(x)[::-2]

And we get x = [7, 1, 5, 3, 3, 5, 1, 7], the copying happens in-place,
of course.


 2. I'd give the listagent the mutable sequence interface

Done!  I put the code in a repository here for those who might be
interested:
http://github.com/aht/listagent.py.

In retrospect, the Python gurus here was right though. Copy, modify
then replace is good enough, if not better since items are just
pointers instead of values. For reversing, you need to translate all
the indices (which cost exactly one addition and one multiplication
per index). Is that cheaper than copying all the pointers to a new
list?  For sorting, you definitely need to construct a lookup table
since the sort algorithm needs to look over the indices multiple
times, which means you are using two pointer indirections per index.
Is that cheaper than just copying all the pointers to a new list? Even
if there is any benefit at all, you'll need to implement listagent in
C to squeeze it out.

However, using listagents is faster if you just want a few items out
of the slice. And it's cute.

Peace,
aht
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Raw string substitution problem

2009-12-17 Thread Alan G Isaac

On 12/17/2009 11:24 AM, Richard Brodie wrote:

A raw string is not a distinct type from an ordinary string
in the same way byte strings and Unicode strings are. It
is a merely a notation for constants, like writing integers
in hexadecimal.


(r'\n', u'a', 0x16)

('\\n', u'a', 22)




Yes, that was a mistake.  But the problem remains::

 re.sub('abc', r'a\nb\n.c\a','123abcdefg') == re.sub('abc', 
'a\\nb\\n.c\\a',' 123abcdefg') == re.sub('abc', 'a\nb\n.c\a','123abcdefg')
True
 r'a\nb\n.c\a' == 'a\\nb\\n.c\\a' == 'a\nb\n.c\a'
False

Why are the first two strings being treated as if they are the last one?
That is, why isn't '\\' being processed in the obvious way?
This still seems wrong.  Why isn't it?

More simply, consider::

 re.sub('abc', '\\', '123abcdefg')
Traceback (most recent call last):
  File stdin, line 1, in module
  File C:\Python26\lib\re.py, line 151, in sub
return _compile(pattern, 0).sub(repl, string, count)
  File C:\Python26\lib\re.py, line 273, in _subx
template = _compile_repl(template, pattern)
  File C:\Python26\lib\re.py, line 260, in _compile_repl
raise error, v # invalid expression
sre_constants.error: bogus escape (end of line)

Why is this the proper handling of what one might think would be an
obvious substitution?

Thanks,
Alan Isaac
 
--

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


Re: Help with parsing a list

2009-12-17 Thread thunderf...@gmail.com
On Dec 17, 6:05 am, Sallu praveen.sunsetpo...@gmail.com wrote:
 Hi i tried with thunderfoot code

 error:

 Traceback (most recent call last):
   File stdin, line 8, in ?
 ValueError: need more than 1 value to unpack- Hide quoted text -


hence, my 'seemingly' functional qualification. :)

that's most likely to due to a datum starting with '\t' instead of '
\t'. yet another reason that emile's code is superior to my one off.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Raw string substitution problem

2009-12-17 Thread D'Arcy J.M. Cain
On Thu, 17 Dec 2009 11:51:26 -0500
Alan G Isaac alan.is...@gmail.com wrote:
   re.sub('abc', r'a\nb\n.c\a','123abcdefg') == re.sub('abc', 
 'a\\nb\\n.c\\a',' 123abcdefg') == re.sub('abc', 'a\nb\n.c\a','123abcdefg')
  True

Was this a straight cut and paste or did you make a manual change?  Is
that leading space in the middle one a copying error?  I get False for
what you actually have there for obvious reasons.

   r'a\nb\n.c\a' == 'a\\nb\\n.c\\a' == 'a\nb\n.c\a'
  False
 
 Why are the first two strings being treated as if they are the last one?

They aren't.  The last string is different.

 for x in (r'a\nb\n.c\a', 'a\\nb\\n.c\\a', 'a\nb\n.c\a'): print repr(x)
...
'a\\nb\\n.c\\a'
'a\\nb\\n.c\\a'
'a\nb\n.c\x07'

 That is, why isn't '\\' being processed in the obvious way?
 This still seems wrong.  Why isn't it?

What do you think is wrong?  What would the obvious way of handling
'//' be?
 
 More simply, consider::
 
   re.sub('abc', '\\', '123abcdefg')
  Traceback (most recent call last):
File stdin, line 1, in module
File C:\Python26\lib\re.py, line 151, in sub
  return _compile(pattern, 0).sub(repl, string, count)
File C:\Python26\lib\re.py, line 273, in _subx
  template = _compile_repl(template, pattern)
File C:\Python26\lib\re.py, line 260, in _compile_repl
  raise error, v # invalid expression
  sre_constants.error: bogus escape (end of line)
 
 Why is this the proper handling of what one might think would be an
 obvious substitution?

Is this what you want?  What you have is a re expression consisting of
a single backslash that doesn't escape anything (EOL) so it barfs.

 re.sub('abc', r'\\', '123abcdefg')
'123\\defg'

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


Re: Raw string substitution problem

2009-12-17 Thread MRAB

Alan G Isaac wrote:

On 12/17/2009 11:24 AM, Richard Brodie wrote:

A raw string is not a distinct type from an ordinary string
in the same way byte strings and Unicode strings are. It
is a merely a notation for constants, like writing integers
in hexadecimal.


(r'\n', u'a', 0x16)

('\\n', u'a', 22)




Yes, that was a mistake.  But the problem remains::

 re.sub('abc', r'a\nb\n.c\a','123abcdefg') == re.sub('abc', 
'a\\nb\\n.c\\a',' 123abcdefg') == re.sub('abc', 'a\nb\n.c\a','123abcdefg')

True
 r'a\nb\n.c\a' == 'a\\nb\\n.c\\a' == 'a\nb\n.c\a'
False

Why are the first two strings being treated as if they are the last one?
That is, why isn't '\\' being processed in the obvious way?
This still seems wrong.  Why isn't it?

More simply, consider::

 re.sub('abc', '\\', '123abcdefg')
Traceback (most recent call last):
  File stdin, line 1, in module
  File C:\Python26\lib\re.py, line 151, in sub
return _compile(pattern, 0).sub(repl, string, count)
  File C:\Python26\lib\re.py, line 273, in _subx
template = _compile_repl(template, pattern)
  File C:\Python26\lib\re.py, line 260, in _compile_repl
raise error, v # invalid expression
sre_constants.error: bogus escape (end of line)

Why is this the proper handling of what one might think would be an
obvious substitution?


Regular expressions and replacement strings have their own escaping
mechanism, which also uses backslashes.

Some of these regex escape sequences are the same as those of string
literals, eg \n represents a newline; others are different, eg \b in a
regex represents a word boundary and not a backspace as in a string
literal.

You can match a newline in a regex by either using an actual newline
character ('\n' in a string literal) or an escape sequence ('\\n' or
r'\n' in a string literal). If you want a regex to match an actual
backslash followed by a letter 'n' then you need to escape the backslash
in the regex and then either use a raw string literal or escape it again
in a non-raw string literal.

Match characters: newline
Regex: \n
Raw string literal: r'\n'
Non-raw string literal: '\\n'

Match characters: \n
Regex: \\n
Raw string literal: r'\\n'
Non-raw string literal: 'n'

Replace with characters: newline
Replacement: \n
Raw string literal: r'\n'
Non-raw string literal: '\\n'

Replace with characters: \n
Replacement: \\n
Raw string literal: r'\\n'
Non-raw string literal: 'n'
--
http://mail.python.org/mailman/listinfo/python-list


shouldn't list comprehension be faster than for loops?

2009-12-17 Thread Carlos Grohmann
Hello all

I am testing my code with list comprehensions against for loops.

the loop:

dipList=[float(val[1]) for val in datalist]
dip1=[]
for dp in dipList:
if dp == 90:
dip1.append(dp - 0.01)
else:
dip1.append(dp)

listcomp:

dipList=[float(val[1]) for val in datalist]
dip1=[(dp, dp-0.01)[dp==90.0] for dp in dipList]


Tenting the time spent by each approach (using time.clock()), with a
file with about 100,000 entries, I get 0.03s for the loop and 0.05s
for the listcomp.

thoughts?

TIA
Carlos

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


Re: Which version of MSVC?90.DLL's to distribute with Python 2.6 based Py2exe executables?

2009-12-17 Thread Ross Ridge
pyt...@bdurham.com wrote:
Does anyone have any recommendations on which version of the
MSVC?90.DLL's need to be distributed with a Python 2.6.4 PY2EXE (0.6.9)
based executable? (I assume I need just a matching pair of MSVCR90.DLL
and MSVCP90.DLL?)

Either the one the came with your copy Microsoft Visual C++ or Python
2.6.4.  Otherwise, you don't have the legal right to redistribute
Microsoft's code.

Ross Ridge

-- 
 l/  //   Ross Ridge -- The Great HTMU
[oo][oo]  rri...@csclub.uwaterloo.ca
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyZui - anyone know about this?

2009-12-17 Thread Terry Reedy

On 12/17/2009 2:14 AM, Donn wrote:

On Wednesday 16 December 2009 07:03:19 David Roberts wrote:

It involves scaling an image to various resolutions, and partitioning
them into fixed-size tiles. It's roughly the same technique used by
Google Maps/Earth.

Thanks. That gives me something to go on. Wikipedia didn't like my search
terms.


ZUIs are useful for particular types of data - images  mapping
especially - but I'd hate to have to navigate my desktop using its
approach.

Ever since Corel Draw in the 90's zoomed into my life I have been in love with
the idea of an endless canvas that makes me feel like a satellite on a bungee
cord. I think it would fit the desktop very well.

Personally I see a merging of normal app windows and a zui: some kind of new
window manager.


The original idea, perhaps, was from Jef Raskin in The Human Interface. 
Wikipedia has articles on both. His idea was for a document rather than 
app centric plain. Not clear how one would pipe data from app to app in 
his model, though.


tjr

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


Re: shouldn't list comprehension be faster than for loops?

2009-12-17 Thread Alf P. Steinbach

* Carlos Grohmann:

Hello all

I am testing my code with list comprehensions against for loops.

the loop:

dipList=[float(val[1]) for val in datalist]
dip1=[]
for dp in dipList:
if dp == 90:
dip1.append(dp - 0.01)
else:
dip1.append(dp)

listcomp:

dipList=[float(val[1]) for val in datalist]
dip1=[(dp, dp-0.01)[dp==90.0] for dp in dipList]


Tenting the time spent by each approach (using time.clock()), with a
file with about 100,000 entries, I get 0.03s for the loop and 0.05s
for the listcomp.

thoughts?


In the list comprehension you're constructing n tuples that you're not 
constructing in the loop.


Have you tried this with

  dip1 = [dp - 0.01 if dp == 90 else dp for dp in dipList]

?


Cheers  hth.,

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


Re: Raw string substitution problem

2009-12-17 Thread Alan G Isaac

Alan G Isaacalan.is...@gmail.com  wrote:

re.sub('abc', r'a\nb\n.c\a','123abcdefg') == re.sub('abc', 
'a\\nb\\n.c\\a','123abcdefg') == re.sub('abc', 'a\nb\n.c\a','123abcdefg')
  True
Why are the first two strings being treated as if they are the last one?
 


On 12/17/2009 12:19 PM, D'Arcy J.M. Cain wrote:

They aren't.  The last string is different.


Of course it is different.
That is the basis of my question.
Why is it being treated as if it is the same?
(See the end of this post.)



Alan G Isaacalan.is...@gmail.com  wrote:

More simply, consider::

re.sub('abc', '\\', '123abcdefg')
  Traceback (most recent call last):
File stdin, line 1, inmodule
File C:\Python26\lib\re.py, line 151, in sub
  return _compile(pattern, 0).sub(repl, string, count)
File C:\Python26\lib\re.py, line 273, in _subx
  template = _compile_repl(template, pattern)
File C:\Python26\lib\re.py, line 260, in _compile_repl
  raise error, v # invalid expression
  sre_constants.error: bogus escape (end of line)

Why is this the proper handling of what one might think would be an
obvious substitution?



On 12/17/2009 12:19 PM, D'Arcy J.M. Cain wrote:

Is this what you want?  What you have is a re expression consisting of
a single backslash that doesn't escape anything (EOL) so it barfs.

 re.sub('abc', r'\\', '123abcdefg')
 '123\\defg'


Turning again to the documentation:
if it is a string, any backslash escapes in it are processed.
That is, \n is converted to a single newline character, \r is
converted to a linefeed, and so forth.
So why is '\n' converted to a newline but '\\' does not become a literal
backslash?  OK, I don't do much string processing, so perhaps this is where
I am missing the point: how is the replacement being converted?
(As Peter's example shows, if you supply the replacement via
a function, this does not happen.) You suggest it is just a matter of
it being an re, but::

 re.sub('abc', 'a\\nc','1abcd') == re.sub('abc', 'a\nc','1abcd')
True
 re.compile('a\\nc') == re.compile('a\nc')
False

So I have two string that are not the same, nor do they compile
equivalently, yet apparently they are converted to something
equivalent for the substitution. Why? Is my question clearer?

If the answer looks too obvious to state, assume I'm missing it anyway
and please state it.  As I said, I seldom use the re module.

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


Re: More stuff added to ch 2 of my programming intro

2009-12-17 Thread Mensanator
On Dec 17, 4:33 am, Ned Deily n...@acm.org wrote:
 In article
 183af5d2-e157-4cd6-bec6-8997809e1...@d21g2000yqn.googlegroups.com,

  Mensanator mensana...@aol.com wrote:
  Oh, I don't know, maybe because I'm thinking about
  buying one and seeing 2.3, 2.4 and 2.5 directories
  on the model in the store made me wary.

 That's odd since, AFAIK, Apple has never released an OS X with Python
 2.4.

Hmm...I was poking around in the finder on a display of new
iMacs at Best Buy last saturday. I searched for python and
it took me to a directory listing with three items:
Python 2.3
Python 2.4
Python 2.5

It's possible that Python 2.6 is located somewhere else. I assume
that Snow Leopard was installed, but I didn't actually check that.


 Current Apple systems ship with OS X 10.6, aka Snow Leopard.   10.6
 includes a Python 2.6.1 (64-bit/32-bit) and a Python 2.5.4 (32-bit
 only).  The previous release, 10.5, shipped with 2.5 and 2.3.  But, not
 to worry, if you need other versions, you can download OS X installers
 from python.org.

  http://www.python.org/download/releases/3.1.1/http://www.python.org/f...
   on/3.1.1/python-3.1.1.dmg

  This tells me nothing.

 That's the disk image for the OS X Python 3.1.1 installer.  

But it doesn't say whether that disk image is compatible with
Snow Leopard and I don't take such things for granted.

 Official
 binary installers for OS X are provided on python.org for every final
 Python release.

   or (for MacPorts fans):

   $ sudo port install python31

  And since I haven't got one, this also tells me nothing.

 http://www.macports.org/

 The MacPorts Project is an open-source community initiative to design
 an easy-to-use system for compiling, installing, and upgrading either
 command-line, X11 or Aqua based open-source software on the Mac OS X
 operating system.

Ok, now I know. Thanks for the information.


 --
  Ned Deily,
  n...@acm.org

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


Re: More stuff added to ch 2 of my programming intro

2009-12-17 Thread Mensanator
On Dec 17, 10:12 am, Benjamin Kaplan benjamin.kap...@case.edu wrote:
 On Thu, Dec 17, 2009 at 5:33 AM, Ned Deily n...@acm.org wrote:

   or (for MacPorts fans):

   $ sudo port install python31

  And since I haven't got one, this also tells me nothing.

 http://www.macports.org/

  The MacPorts Project is an open-source community initiative to design
  an easy-to-use system for compiling, installing, and upgrading either
  command-line, X11 or Aqua based open-source software on the Mac OS X
  operating system.

 Description sans marketing fluff: It's a Mac package manager. It's
 basically the same as Gentoo's portage if you've ever used that. It
 downloads source tarballs and patches and then compiles them locally.
 There are built-in lists of variants, basically sets of configure
 args, to compile each package.

That's the kind of thing I want to hear.

Looks like I can go ahead and get a Mac and not worry about getting
3.1.1 installed.

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


Re: More stuff added to ch 2 of my programming intro

2009-12-17 Thread Mensanator
On Dec 17, 1:40 am, geremy condra debat...@gmail.com wrote:
 On Thu, Dec 17, 2009 at 2:25 AM, Mensanator mensana...@aol.com wrote:
  On Dec 16, 8:45 pm, Ned Deily n...@acm.org wrote:
  In article
  88bab2c0-d27c-4081-a703-26b353b9e...@9g2000yqa.googlegroups.com,

  Mensanator mensana...@aol.com wrote:
   Oh, and about Chapter 1.

   If you're going to use version 3.1.1 as your standard, shouldn't
   you also point out that 3.1.1 is NOT bundled with Mac OS X?

   How about devoting a section on downloading the source files
   and compiling it on a Mac?

  Why would you do that?

  Oh, I don't know, maybe because I'm thinking about
  buying one and seeing 2.3, 2.4 and 2.5 directories
  on the model in the store made me wary.

 http://www.python.org/download/releases/3.1.1/http://www.python.org/f...

  This tells me nothing.

  or (for MacPorts fans):

  $ sudo port install python31

  And since I haven't got one, this also tells me nothing.

 He just told you what it meant, as if it weren't already obvious.

Why would it be obvious? I use a PC, for which
$ sudo port install python31
is meaningless. Is MacPorts bundled with Snow Leopard?

Or do I have to do this first:

MacPorts version 1.8.1 is available in various formats for download
and installation (note, if you are upgrading your Mac OS X to a new
major release, see the migration info page):

“dmg” disk images for Snow Leopard, Leopard and Tiger as a legacy
platform, containing pkg installers for use with the Mac OS X
Installer. By far the simplest installation procedure that most users
should follow after meeting the requirements listed below.

In source form as either a tar.bz2 package or a tar.gz one for manual
compilation, if you intend to customize your installation in any way.

SVN checkout of the unpackaged sources, if you wish to follow MacPorts
development.

The selfupdate target of the port(1) command, for users who already
have MacPorts installed and wish to upgrade to a newer release.

Checksums for our packaged downloads are contained in the
corresponding checksums file.

Please note that in order to install and run MacPorts on Mac OS X,
your system must have installations of the following components:

Apple's Xcode Developer Tools (version 3.2.1 or later for Snow
Leopard, 3.1.4 or later for Leopard, or 2.5 for Tiger), found at the
Apple Developer Connection site or on your Mac OS X installation CDs/
DVD.

Ensure that the optional components for command line development are
installed (Unix Development in the Xcode 3.x installer).

The X11 windowing environment (A.K.A. “X11 User”) for ports that
depend on the functionality it provides to run.

The “X11 User” package is an optional installation on your system CDs/
DVD for Tiger, enabled through the “Customize” button of the
installer, whereas it is included by default on Leopard and Snow
Leopard.

You can use the xorg-server port instead of Apple's X11.app if you
wish.




 Geremy Condra

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


Re: pyZui - anyone know about this?

2009-12-17 Thread Donn
On Thursday 17 December 2009 19:46:41 Terry Reedy wrote:
 His idea was for a document rather than 
 app centric plain. 
These days I find the notion of monolithic apps to be a pita. 
The concept of many small black boxes (but open source) that each do a single 
job and pipe in/out is so much more powerful. I don't see why everything in a 
gui and down can't be such a box. Then we get to wire them together as needed. 
We'd still have 'big apps' but they would be constructed more loosely and we 
could adapt them to fit real life needs.

I dunno. I think big apps are dinosaurs. As much as I love Inkscape and 
Blender and others, they are all islands with vast gulfs between them.

And let's have Python glue them all together!

 Not clear how one would pipe data from app to app in 
 his model, though.
The picture I have of it is illustrated by Blender's material node system. 
have a look at this pic:
http://upload.wikimedia.org/wikipedia/commons/2/26/Working_with_Nodes_Blender.PNG
Just a mental jump-off point. Think bash meets zui with a Python driving. :D

\d

-- 
\/\/ave: donn.in...@googlewave.com
home: http://otherwise.relics.co.za/
2D vector animation : https://savannah.nongnu.org/projects/things/
Font manager : https://savannah.nongnu.org/projects/fontypython/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyArg_ParseTupleAndKeywords in Python3.1

2009-12-17 Thread Joachim Dahl
In the Ubuntu 9.10 version of Python 3.1 (using your patch), there's a
related bug:

 foo(b='b')

will set the value of a in the extension module to zero, thus clearing
whatever
default value it may have had.  In other words, the optional character
arguments
that are skipped seem to be nulled by PyArg_ParseTupleAndKeywords().
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which version of MSVC?90.DLL's to distribute with Python 2.6 based Py2exe executables?

2009-12-17 Thread Jonathan Hartley
On Dec 17, 5:36 pm, Ross Ridge rri...@csclub.uwaterloo.ca wrote:
 pyt...@bdurham.com wrote:
 Does anyone have any recommendations on which version of the
 MSVC?90.DLL's need to be distributed with a Python 2.6.4 PY2EXE (0.6.9)
 based executable? (I assume I need just a matching pair of MSVCR90.DLL
 and MSVCP90.DLL?)

 Either the one the came with your copy Microsoft Visual C++ or Python
 2.6.4.  Otherwise, you don't have the legal right to redistribute
 Microsoft's code.

                                         Ross Ridge

 --
  l/  //   Ross Ridge -- The Great HTMU
 [oo][oo]  rri...@csclub.uwaterloo.ca
 -()-/()/  http://www.csclub.uwaterloo.ca/~rridge/
  db  //  

Hi. I clearly haven't yet quite understood this very well.

Only this week I sent a py2exe-derived executable to someone else (a
non-developer) and it would not run on their WinXP machine ('The
system cannot execute the specified program') - my current favourite
hypothesis is that my omission of this dll or something similar was to
blame.

To diagnose what's wrong, I can't get access to the machine that gives
the above error. To try and reproduce, I'm right now in the process of
creating a bare-bones WindowsXP installed on a VM.

My questions are, sadly, legion:


1) I don't understand why the OP's question doesn't deserve a literal
answer - isn't one of those DLLs in the WinSxS directory derived from
his MSVC install? In which case does he have the rights to
redistribute it?


Ross said:
 Either the one the came with your copy Microsoft Visual C++ or Python 2.6.4.

2) The required dlls come with Python? Whatwhatwhat? Is this if I
download Python source to compile myself?

2b) Presumably these runtimes must come with Visual Studio express
edition (the free one.) I assume I can just prise the required DLL off
my filesystem after MSVS express edition has installed, rather than
insisting that my users run the MSVC runtime installer at

3) The wxpython site describes that I have to use a manifest file as
well as the DLLs, although I find no mention of the word 'manifest' on
www.py2exe.org, excepting a vaguely worded news item. Other sites (eg.
StackOverflow) report conflicting ideas of whether and when this
manifest file is needed. Is there a simple answer to whether this is
required?


4) The py2exe wiki says, of the msvc runtime dll version 7.1 (for
versions of Python prior to 2.6) that:

Since most Windows installations nowadays include this DLL by
default, it may be unnecessary.

To what extent is this true? Does the same not also apply to the msvc
runtime 9.0 dll? (for Python 2.6.4)


Malcome said:
 (I assume I need just a matching pair of MSVCR90.DLL and MSVCP90.DLL?)

5) Whatwhatwhat again? More than one DLL is required? Are there ever
any more than these two?


Sorry to be dense. Terse links to useful sources of information
appreciated. I've read the whole py2exe wiki and been googling the
last hour.

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


Re: Raw string substitution problem

2009-12-17 Thread MRAB

Alan G Isaac wrote:

Alan G Isaacalan.is...@gmail.com  wrote:
re.sub('abc', r'a\nb\n.c\a','123abcdefg') == 
re.sub('abc', 'a\\nb\\n.c\\a','123abcdefg') == re.sub('abc', 
'a\nb\n.c\a','123abcdefg')

  True
Why are the first two strings being treated as if they are the last one?
 


On 12/17/2009 12:19 PM, D'Arcy J.M. Cain wrote:

They aren't.  The last string is different.


Of course it is different.
That is the basis of my question.
Why is it being treated as if it is the same?
(See the end of this post.)



Alan G Isaacalan.is...@gmail.com  wrote:

More simply, consider::

re.sub('abc', '\\', '123abcdefg')
  Traceback (most recent call last):
File stdin, line 1, inmodule
File C:\Python26\lib\re.py, line 151, in sub
  return _compile(pattern, 0).sub(repl, string, count)
File C:\Python26\lib\re.py, line 273, in _subx
  template = _compile_repl(template, pattern)
File C:\Python26\lib\re.py, line 260, in _compile_repl
  raise error, v # invalid expression
  sre_constants.error: bogus escape (end of line)

Why is this the proper handling of what one might think would be an
obvious substitution?



On 12/17/2009 12:19 PM, D'Arcy J.M. Cain wrote:

Is this what you want?  What you have is a re expression consisting of
a single backslash that doesn't escape anything (EOL) so it barfs.

 re.sub('abc', r'\\', '123abcdefg')
 '123\\defg'


Turning again to the documentation:
if it is a string, any backslash escapes in it are processed.
That is, \n is converted to a single newline character, \r is
converted to a linefeed, and so forth.
So why is '\n' converted to a newline but '\\' does not become a literal
backslash?  OK, I don't do much string processing, so perhaps this is where
I am missing the point: how is the replacement being converted?
(As Peter's example shows, if you supply the replacement via
a function, this does not happen.) You suggest it is just a matter of
it being an re, but::

 re.sub('abc', 'a\\nc','1abcd') == re.sub('abc', 'a\nc','1abcd')
True
 re.compile('a\\nc') == re.compile('a\nc')
False

So I have two string that are not the same, nor do they compile
equivalently, yet apparently they are converted to something
equivalent for the substitution. Why? Is my question clearer?


re.compile('a\\nc') _does_ compile to the same as regex as
re.compile('a\nc').

However, regex objects never compare equal to each other, so, strictly
speaking, re.compile('a\nc') != re.compile('a\nc').

However, having said that, the re module contains a cache (keyed on the
string and options supplied), so the first re.compile('a\nc') will put
the regex object in the cache and the second re.compile('a\nc') will
return that same regex object from the cache. If you clear the cache in
between the two calls (do re._cache.clear()) you'll get two different
regex objects which won't compare equal even though they are to all
intents identical.


If the answer looks too obvious to state, assume I'm missing it anyway
and please state it.  As I said, I seldom use the re module.


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


Re: iterators and views of lists

2009-12-17 Thread Brendan Miller
On Thu, Dec 17, 2009 at 8:41 AM, Anh Hai Trinh anh.hai.tr...@gmail.com wrote:
 I have a couple of thoughts:
 1. Since [:] by convention already creates a copy, it might violate
 people's expectations if that syntax were used.

 Indeed, listagent returns self on __getitem__[:]. What I meant was
 this:

  x = [0, 1, 2, 3, 4, 5, 6, 7]
  a = listagent(x)[::2]
  a[:] = listagent(x)[::-2]

 And we get x = [7, 1, 5, 3, 3, 5, 1, 7], the copying happens in-place,
 of course.


 2. I'd give the listagent the mutable sequence interface

 Done!  I put the code in a repository here for those who might be
 interested:
 http://github.com/aht/listagent.py.

 In retrospect, the Python gurus here was right though. Copy, modify
 then replace is good enough, if not better since items are just
 pointers instead of values. For reversing, you need to translate all
 the indices (which cost exactly one addition and one multiplication
 per index). Is that cheaper than copying all the pointers to a new
 list?  For sorting, you definitely need to construct a lookup table
 since the sort algorithm needs to look over the indices multiple
 times, which means you are using two pointer indirections per index.
 Is that cheaper than just copying all the pointers to a new list? Even
 if there is any benefit at all, you'll need to implement listagent in
 C to squeeze it out.

 However, using listagents is faster if you just want a few items out
 of the slice. And it's cute.

Well, it doesn't really need to be any slower than a normal list. You
only need to use index and do extra additions because it's in python.
However, if listagent were written in C, you would just have a pointer
into the contents of the original list, and the length, which is all
that list itself has.

I don't actually expect you to write that, I'm just pointing it out.

As for copying pointers not taking much time... that depends on how
long the list is. if you are working with small sets of data, you can
do almost anything and it will be efficient. However, if you have
megabytes or gigabytes of data (say you are working with images or
video), than the difference between an O(1) or an O(n) operation is a
big deal.

I agree though, it doesn't matter to everyone and anyone. The reason I
was interested was because i was trying to solve some specific
problems in an elegant way. I was thinking it would be cool to make
python more usable in programming competitions by giving it its own
port of the STL's algorithm library, which needs something along the
lines of C++'s more powerful iterators.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Raw string substitution problem

2009-12-17 Thread Alan G Isaac

On 12/17/2009 2:45 PM, MRAB wrote:

re.compile('a\\nc') _does_ compile to the same as regex as
re.compile('a\nc').

However, regex objects never compare equal to each other, so, strictly
speaking, re.compile('a\nc') != re.compile('a\nc').

However, having said that, the re module contains a cache (keyed on the
string and options supplied), so the first re.compile('a\nc') will put
the regex object in the cache and the second re.compile('a\nc') will
return that same regex object from the cache. If you clear the cache in
between the two calls (do re._cache.clear()) you'll get two different
regex objects which won't compare equal even though they are to all
intents identical.



OK, this is helpful.
(I did check equality but did not understand
I got True only because re used caching.)
So is the bottom line the following?
A string replacement is not just converted
as described in the documentation, essentially
it is compiled?

But that cannot quite be right.  E.g., \b will be a back
space not a word boundary.  So then the question arises
again, why isn't '\\' a backslash? Just because?
Why does it not get the obvious conversion?

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


Re: I have a cross platform os.startfile but I need to asociate files with xdg-open in linux how do I do that??

2009-12-17 Thread eric_dex...@msn.com
On Dec 16, 3:02 pm, eric_dex...@msn.com eric_dex...@msn.com wrote:
 On Dec 16, 10:36 am, Paul Boddie p...@boddie.org.uk wrote:



  On 16 Des, 17:03, eric_dex...@msn.com eric_dex...@msn.com wrote:

   #this should be a cross platform example of os.startfile ( startfile )
   #for windows and linux.  this is the first version and
   #linux, mac, other os's commands for exceptions to the
   #rule would be appreciated.  at some point this will be
   #in the dex tracker project.

  You could look at the desktop package for something similar:

 http://pypi.python.org/pypi/desktop

  The desktop.open function supports a few extra workarounds, mostly
  because it pre-dates xdg-open.

  Paul

 Since desktop environments like KDE and GNOME provide mechanisms for
 running
 browsers and editors according to the identified type of a file or
 resource,
 just as Windows runs files or resources, it is appropriate to have a
 module
 which accesses these mechanisms. It is this kind of functionality that
 the
 desktop package aims to support. Note that this approach is arguably
 better

 I am concerned this means I cant do something like associate python
 files with python in artistx (ubuntu).  It just associates text files
 with editors??  It does look like a cool package and I will look into
 that further.

I suppose I could test the extension..  if '.py' in filename and then
default to xdg-open if it isn't seems realy messy though.

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


Re: How to create a self-destructing Tkinter dialog box?

2009-12-17 Thread John Posner
On Thu, 17 Dec 2009 02:09:03 -0500, Martin P. Hellwig  
martin.hell...@dcuktec.org wrote:



mrstevegross wrote:

Ok, I would like to put together a Python/Tkinter dialog box that
displays a simple message and self-destructs after N seconds. Is there
a simple way to do this?
 Thanks,
 --Steve


Just, thinking aloud, I probably would do something like registering the  
[place|grid|pack]_forget() function by using the alarm callback  
'after()' function of that frame.




Yup, after() is your friend:

#---
from Tkinter import *
from functools import partial

def RemoveWindow(win):
win.destroy()

# root window
root = Tk()
Label(root, text=this is the main window).pack()

# another top-level window, to be removed in 2 seconds
top = Toplevel()
Label(top, text=this is the window to be removed).pack()
root.after(2000, partial(RemoveWindow, top))

# go
root.mainloop()
#---

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


Re: Which version of MSVC?90.DLL's to distribute with Python 2.6 based Py2exe executables?

2009-12-17 Thread Christian Heimes
Jonathan Hartley wrote:
 Only this week I sent a py2exe-derived executable to someone else (a
 non-developer) and it would not run on their WinXP machine ('The
 system cannot execute the specified program') - my current favourite
 hypothesis is that my omission of this dll or something similar was to
 blame.
 
 To diagnose what's wrong, I can't get access to the machine that gives
 the above error. To try and reproduce, I'm right now in the process of
 creating a bare-bones WindowsXP installed on a VM.

MSVCR90 is a side-by-side assembly (SxS). You can't just copy a SxS
assembly to another computer. You must at least ship the manifest file,
too. The easiest way to get your program running is the installation of
the MSVCR redistributable installer.

Christian

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


Re: Raw string substitution problem

2009-12-17 Thread MRAB

Alan G Isaac wrote:

On 12/17/2009 2:45 PM, MRAB wrote:

re.compile('a\\nc') _does_ compile to the same as regex as
re.compile('a\nc').

However, regex objects never compare equal to each other, so, strictly
speaking, re.compile('a\nc') != re.compile('a\nc').

However, having said that, the re module contains a cache (keyed on the
string and options supplied), so the first re.compile('a\nc') will put
the regex object in the cache and the second re.compile('a\nc') will
return that same regex object from the cache. If you clear the cache in
between the two calls (do re._cache.clear()) you'll get two different
regex objects which won't compare equal even though they are to all
intents identical.



OK, this is helpful.
(I did check equality but did not understand
I got True only because re used caching.)
So is the bottom line the following?
A string replacement is not just converted
as described in the documentation, essentially
it is compiled?

But that cannot quite be right.  E.g., \b will be a back
space not a word boundary.  So then the question arises
again, why isn't '\\' a backslash? Just because?
Why does it not get the obvious conversion?


If you give the re module a string containing \b, eg. '\\b' or r'\b',
then it will compile it to a word boundary if it's in a regex string or
a backspace if it's in a replacement string. This is different from
giving the re module a string which actually contains a backspace, eg,
'\b'.

Because the re module uses backslashes for escaping, you'll need to
escape a literal backslash with a backslash in the string you give it.
But string literals also use backslashes for escaping, so you'll need to
escape each of those backslashes with a backslash.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Which version of MSVC?90.DLL's to distribute with Python 2.6 based Py2exe executables?

2009-12-17 Thread Ross Ridge
Jonathan Hartley  tart...@tartley.com wrote:
1) I don't understand why the OP's question doesn't deserve a literal
answer ...

I gave what I thought was a simple, direct and literal answer.

.. isn't one of those DLLs in the WinSxS directory derived from
his MSVC install?

I have no idea.  He might not even have Microsoft Visual C++ installed
on his machine. 

2) The required dlls come with Python? Whatwhatwhat? 

The DLLs are required for Python to work, so yes the DLLs are included in
the official binary Python distribution for Windows. 

 Is this if I download Python source to compile myself?

No, the DLLs aren't included in the source distribution.  However, if
you compile the Python source yourself with a suitably licenced copy of
Microsoft Visual C++ then you'd be allowed to redistribute the Microsoft
Runtime DLLs as a part of your own binary Python distribution.

2b) Presumably these runtimes must come with Visual Studio express
edition (the free one.)

I'd assume so, but you should check the the terms of the EULA for that
particular product to make sure it also allows you to redistribute the
runtime DLLs.

 I assume I can just prise the required DLL off my filesystem after
MSVS express edition has installed, rather than insisting that my users
run the MSVC runtime installer at

It would problably simpler to use the DLL included in the redist
subdirectory of Microsoft Visual C++ installation.  That is, assumming
there is one, again you'll need to check the EULA.  Sometimes Microsoft
makes specific requirements on how its redistributables are packaged and
installed, and that definately seems to be the case with Visual C++ 2008.

4) The py2exe wiki says, of the msvc runtime dll version 7.1 (for
versions of Python prior to 2.6) that:

Since most Windows installations nowadays include this DLL by
default, it may be unnecessary.

To what extent is this true?

It's less true for newer versions of Windows.  I know there are a fair
number of people running Windows Vista and Windows 7 who've run into
problems with my own py2exe wrapped program because their machines don't
already have MSVCR71.DLL installed in their system directories.

Does the same not also apply to the msvc
runtime 9.0 dll? (for Python 2.6.4)

I'd assume the problem would be even worse.  I don't think Microsoft
allows the 9.0 runtime to be installed in system directory, so the
specific version of the runtime would need to be already installed the
WinSxS directory.

Malcome said:
 (I assume I need just a matching pair of MSVCR90.DLL and MSVCP90.DLL?)

5) Whatwhatwhat again? More than one DLL is required? Are there ever
any more than these two?

The P DLL is for C++ and so the original poster may not actually need
it.  I'm pretty sure Python itself doesn't need it, and py2exe shouldn't
either, but wxPython, or more precisely wxWidgets, almost certainly does.
So in your case you'll probably need to redistribute both DLLs.

Ross Ridge

-- 
 l/  //   Ross Ridge -- The Great HTMU
[oo][oo]  rri...@csclub.uwaterloo.ca
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //   
-- 
http://mail.python.org/mailman/listinfo/python-list


read from bin file

2009-12-17 Thread luca72
I have a bin file that i read as:
in_file = open('primo.ske', 'rb')
leggo = luca.readlines()

i get a list like :
['\x00\x80p\x8b\x00\x00\x01\x19\x9b\x11\xa1\xa1\x1f\xc9\x12\xaf\x81!
\x84\x01\x00\x01\x01\x02\xff\xff\x80\x01\x03\xb0\x01\x01\x10m\x7f\n',
etc...]

but if i try to print  luca[0]
i get not the the string in the list but i get some like  ఉ{
how i can get a string like the string in the list?
Thanks Luca
-- 
http://mail.python.org/mailman/listinfo/python-list


subprocess.Popen and ordering writes to stdout and stderr

2009-12-17 Thread Chris Withers

Hi All,

I have this simple function:

def execute(command):
process = Popen(command.split(),stderr=STDOUT,stdout=PIPE)
return process.communicate()[0]

..but my unit test for it fails:

from testfixtures import tempdir,compare
from unittest import TestCase

class TestExecute(TestCase):

@tempdir()
def test_out_and_err(self,d):
path = d.write('test.py','\n'.join((
import sys,
sys.stdout.write('stdout\\n'),
sys.stderr.write('stderr\\n'),
sys.stdout.write('stdout2\\n'),
)),path=True)
compare('stdout\nstderr\nstdout2\n',
execute(sys.executable+' '+path))

...because:

AssertionError:
@@ -1,4 +1,4 @@
-stdout
-stderr
-stdout2
+stdout
+stdout2
+stderr

...the order of the writes isn't preserved.
How can I get this to be the case?

Chris

--
Simplistix - Content Management, Batch Processing  Python Consulting
   - http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list


Re: ftplib timeout in Python 2.4

2009-12-17 Thread r0g
Nico Grubert wrote:
 I don't know of one so you may need a workaround. What platforms do you
 need to support?
 
 Suse Linux Enterprise 10, 64 Bit with Python 2.4.4.
 I need the Python 2.4.4 for a running application Server (Zope).



OK, then one approach would be to use signals.alarm(timeout) to raise
SIGALRM and break out of your FTP function. Have a look at the example
at the very bottom of...

http://docs.python.org/library/signal.html

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


Re: subprocess.Popen and ordering writes to stdout and stderr

2009-12-17 Thread exarkun

On 09:15 pm, ch...@simplistix.co.uk wrote:

Hi All,

I have this simple function:

def execute(command):
process = Popen(command.split(),stderr=STDOUT,stdout=PIPE)
return process.communicate()[0]

..but my unit test for it fails:

from testfixtures import tempdir,compare
from unittest import TestCase

class TestExecute(TestCase):

@tempdir()
def test_out_and_err(self,d):
path = d.write('test.py','\n'.join((
import sys,
sys.stdout.write('stdout\\n'),
sys.stderr.write('stderr\\n'),
sys.stdout.write('stdout2\\n'),
)),path=True)
compare('stdout\nstderr\nstdout2\n',
execute(sys.executable+' '+path))

...because:

AssertionError:
@@ -1,4 +1,4 @@
-stdout
-stderr
-stdout2
+stdout
+stdout2
+stderr

...the order of the writes isn't preserved.
How can I get this to be the case?


You probably just need to flush stdout and stderr after each write.  You 
set them up to go to the same underlying file descriptor, but they still 
each have independent buffering on top of that.


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


Re: subprocess.Popen and ordering writes to stdout and stderr

2009-12-17 Thread Chris Withers

exar...@twistedmatrix.com wrote:

How can I get this to be the case?


You probably just need to flush stdout and stderr after each write.  You 
set them up to go to the same underlying file descriptor, but they still 
each have independent buffering on top of that.


Okay, but if I do:

os.system(sys.executable+' '+path)

...with test.py as-is, I get things in the correct order.

How come?

Chris

--
Simplistix - Content Management, Batch Processing  Python Consulting
   - http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list


Re: subprocess.Popen and ordering writes to stdout and stderr

2009-12-17 Thread exarkun

On 09:56 pm, ch...@simplistix.co.uk wrote:

exar...@twistedmatrix.com wrote:

How can I get this to be the case?


You probably just need to flush stdout and stderr after each write. 
You set them up to go to the same underlying file descriptor, but they 
still each have independent buffering on top of that.


Okay, but if I do:

os.system(sys.executable+' '+path)

...with test.py as-is, I get things in the correct order.


libc is probably giving you line buffering when you use os.system 
(because the child process inherits the parent's stdio, and the parent's 
stdio is probably a pty, and that's the policy libc implements).


When you use subprocess.Popen, the child process gets a pipe (ie, not a 
pty) for its stdout/err, and libc gives you block buffering instead.


This makes the difference, since your test writes all end with \n - 
flushing the libc buffer when it's in line buffered mode, but not 
otherwise.


Try the os.system version with the parent process's stdio not attached 
to a pty (say, 'cat | program | cat') or try giving the subprocess.Popen 
version a pty of its own (I'm not sure how you do this with 
subprocess.Popen, though).  You should be able to observe the behavior 
change based on this.


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


Re: subprocess.Popen and ordering writes to stdout and stderr

2009-12-17 Thread Chris Withers

exar...@twistedmatrix.com wrote:
libc is probably giving you line buffering when you use os.system 
(because the child process inherits the parent's stdio, and the parent's 
stdio is probably a pty, and that's the policy libc implements).


snip

Interesting, but do these assertions still hold true when I tell you 
that I'm doing all this on Windows? ;-)


Chris

--
Simplistix - Content Management, Batch Processing  Python Consulting
   - http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list


Re: read from bin file

2009-12-17 Thread Dave Angel



Jerry Hill wrote:

On Thu, Dec 17, 2009 at 3:59 PM, luca72 lucabe...@libero.it wrote:
  

I have a bin file that i read as:
in_file =pen('primo.ske', 'rb')
leggo =uca.readlines()

i get a list like :
['\x00\x80p\x8b\x00\x00\x01\x19\x9b\x11\xa1\xa1\x1f\xc9\x12\xaf\x81!
\x84\x01\x00\x01\x01\x02\xff\xff\x80\x01\x03\xb0\x01\x01\x10m\x7f\n',
etc...]

but if i try to print  luca[0]
i get not the the string in the list but i get some like  ఉ{
how i can get a string like the string in the list?



print repr(luca[0])

  
You have several questions there. First, readlines() doesn't make sense 
if the file is binary. Unless you know that \n happens to be a delimiter 
in that particular formatted file, it makes more sense to just use 
read(), rather than readlines(). And in that case, you get a single 
string. You can specify how many bytes you want to read() each time.


Now when you print a list, print calls repr() on each item in the list. 
So Jerry is right that repr() is the direct answer to your question.


However, you may want a prettier output, such as that produced by 
binascii.hexlify(). A traditional dump file has hex bytes on one side, 
and printable characters on the other, with suitable spacing and such.


DaveA

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


Re: Which version of MSVC?90.DLL's to distribute with Python 2.6 based Py2exe executables?

2009-12-17 Thread Mark Hammond

On 18/12/2009 7:44 AM, Ross Ridge wrote:

The P DLL is for C++ and so the original poster may not actually need
it.  I'm pretty sure Python itself doesn't need it, and py2exe shouldn't
either, but wxPython, or more precisely wxWidgets, almost certainly does.
So in your case you'll probably need to redistribute both DLLs.


FYI, my experience is that an entire manifest must be distributed.  As 
the manifest in question actually lists 3 DLLs, IIUC, you must ship all 
4 files - the 3 DLLs and the manifest, even if only one of the DLLs is 
actually used.


This is from memory some time back though, so apologies in advance if 
I'm mis-remembering.


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


Re: subprocess.Popen and ordering writes to stdout and stderr

2009-12-17 Thread Mark Hammond

On 18/12/2009 9:33 AM, Chris Withers wrote:

exar...@twistedmatrix.com wrote:

libc is probably giving you line buffering when you use os.system
(because the child process inherits the parent's stdio, and the
parent's stdio is probably a pty, and that's the policy libc implements).


snip

Interesting, but do these assertions still hold true when I tell you
that I'm doing all this on Windows? ;-)


Yep.  You can see similar behaviour from just the cmd-prompt and the 
following script:


--
import sys
for i in range(10):
  print stdout
  print  sys.stderr, stderr
--

If you execute it normally from a command-prompt, you will see things 
written in the correct order.  If you execute it like 'python foo.py  
out 21', the order will be mixed up.  If you execute it like 'python 
-u foo.py  out 21' the order is restored.


HTH,

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


Re: subprocess.Popen and ordering writes to stdout and stderr

2009-12-17 Thread Terry Reedy

On 12/17/2009 5:33 PM, Chris Withers wrote:

exar...@twistedmatrix.com wrote:

libc is probably giving you line buffering when you use os.system
(because the child process inherits the parent's stdio, and the
parent's stdio is probably a pty, and that's the policy libc implements).


snip

Interesting, but do these assertions still hold true when I tell you
that I'm doing all this on Windows? ;-)


Which version /-)?

You can *fix* the test by sorting before comparing. If the app really 
requires synchronization of streams, I would just flush when needed and 
see if that were enough.


tjr



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


Re: Raw string substitution problem

2009-12-17 Thread Rhodri James
On Thu, 17 Dec 2009 20:18:12 -, Alan G Isaac alan.is...@gmail.com  
wrote:



So is the bottom line the following?
A string replacement is not just converted
as described in the documentation, essentially
it is compiled?


That depends entirely on what you mean.


But that cannot quite be right.  E.g., \b will be a back
space not a word boundary.  So then the question arises
again, why isn't '\\' a backslash? Just because?
Why does it not get the obvious conversion?


'\\' *is* a backslash.  That string containing a single backslash is then  
processed by the re module which sees a backslash, tries to interpret it  
as an escape, fails and barfs.


re.compile('a\\nc') passes a sequence of four characters to re.compile:  
'a', '\', 'n' and 'c'.  re.compile() then does it's own interpretation:  
'a' passes through as is, '\' flags an escape which combined with 'n'  
produces the newline character (0x0a), and 'c' passes through as is.


re.compile('a\nc') by contrast passes a sequence of three character to  
re.compile: 'a', 0x0a and 'c'.  re.compile() does it's own interpretation,  
which happens not to change any of the characters, resulting in the same  
regular expression as before.


Your problem is that you are conflating the compile-time processing of  
string literals with the run-time processing of strings specific to re.


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


Re: Seek support for new slice syntax PEP.

2009-12-17 Thread Nobody
On Mon, 14 Dec 2009 14:18:49 -0500, Terry Reedy wrote:

 Many more people uses range objects (xrange in 2.x). A range object has 
 the same info as a slice object *plus* it is iterable.

This isn't quite true, as a range cannot have a stop value of None, i.e.
you can't represent [n:] or [:] etc as a range. Similarly for using
negative stop values for indices relative to the end of the sequence being
sliced.

Also, aside from the semantics of slice objects themselves, slice notation
isn't limited to a single slice object; it can also return a tuple of
slices and values, e.g.:

 numpy.s_[1::2,...,3,4:5:6]
(slice(1, None, 2), Ellipsis, 3, slice(4, 5, 6))

For a single slice, enumerating over a slice with an unspecified stop
value would be equivalent to itertools.count(). Negative stop values won't
work.

For a multi-dimensional slice, with everything specified, you would
probably want to iterate over the cartesian product (i.e. N nested loops
for an N-dimensional slice). But this won't work if anything other than
the outermost loop has an unspecified stop value, or if you use an
ellipsis within a slice.

Oh, and being able to slice a slice could be quite useful, i.e.:

[10:90:10][2::2] == [30:90:20]

cf:
 numpy.arange(100)[10:90:10][2::2]
array([30, 50, 70])
 numpy.arange(100)[30:90:20]
array([30, 50, 70])

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


Parsing file format to ensure file meets criteria

2009-12-17 Thread seafoid

Hi folks,

I am new to python and am having some trouble parsing a file.

I wish to parse a file and ensure that the format meets certain
restrictions.

The file format is as below (abbreviated):

c this is a comment
p wcnf 1468 817439 186181
286 32 0
186191 -198 -1098 0
186191 98 -1098 1123 0

Lines beginning c are comment lines and must precede all other lines.

Lines beginning p are header lines with the numbers being 'nvar', 'nclauses'
and 'hard' respectively.

All other lines are clause lines. These must contain at least two integers
followed by zero. There is no limit on the number of clause lines.

Header lines must precede clause lines.

In the above example:
nvar = 1468
nclauses = 817439
hard = 186191

Now for the interesting part...

The first number in a clause line = weight.
All else are literals.
Therefore, clause = weight + literals

weight = hard
|literal|  0
|literal| = nvar
number of clause lines = nclauses

My attempts thus far have been a dismal failure, computing is so viciously
logical :confused:

My main problem is that below:

fname = raw_input('Please enter the name of the file: ')

z = open(fname, 'r')

z_list = [i.strip().split() for i in z]

#here each line is converted to a list, all nested within a list - all
elements of the list are strings, even integers are converted to strings

Question - how are nested lists indexed?

I then attempted to extract the comment, headers and clauses from the nested
list and assign them to a variable.

I tried:

for inner in z_list:
for lists in inner:
if lists[0] == 'c':
comment = lists[:]
elif lists[0] == 'p':
header = lists[:]
else:
clause = lists[:]
print comment, header, clause   

This does not work for some reasons which I understand. I have messed up the
indexing and my assignment of variables is wrong.

The aim was to extract the headers and comments and then be left with a
nested list of clauses.

Then I intended to converted the strings within the clauses nested list back
to integers and via indexing, check that all conditions are met. This would
have involved also converting the numerical strings within the header to
integers but the actual strings are proving a difficult problem to ignore.

Any suggestions?

If my mistakes are irritatingly stupid, please feel free to advise that I
r.t.f.m (read the f**king manual). However, thus far the manual has helped
me little.

Thanking you,
Seafoid.


-- 
View this message in context: 
http://old.nabble.com/Parsing-file-format-to-ensure-file-meets-criteria-tp26837682p26837682.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Re: Parsing file format to ensure file meets criteria

2009-12-17 Thread MRAB

seafoid wrote:

Hi folks,

I am new to python and am having some trouble parsing a file.

I wish to parse a file and ensure that the format meets certain
restrictions.

The file format is as below (abbreviated):

c this is a comment
p wcnf 1468 817439 186181
286 32 0
186191 -198 -1098 0
186191 98 -1098 1123 0

Lines beginning c are comment lines and must precede all other lines.

Lines beginning p are header lines with the numbers being 'nvar', 'nclauses'
and 'hard' respectively.

All other lines are clause lines. These must contain at least two integers
followed by zero. There is no limit on the number of clause lines.

Header lines must precede clause lines.

In the above example:
nvar = 1468
nclauses = 817439
hard = 186191

Now for the interesting part...

The first number in a clause line = weight.
All else are literals.
Therefore, clause = weight + literals

weight = hard
|literal|  0
|literal| = nvar
number of clause lines = nclauses

My attempts thus far have been a dismal failure, computing is so viciously
logical :confused:

My main problem is that below:

fname = raw_input('Please enter the name of the file: ')

z = open(fname, 'r')

z_list = [i.strip().split() for i in z]

#here each line is converted to a list, all nested within a list - all
elements of the list are strings, even integers are converted to strings

Question - how are nested lists indexed?


A list is indexed by integers:

 my_list = ['a', 'b', 'c']
 my_list[0]
'a'

A list of lists requires 2 subscripts, one for the list and the other
for the list in that list:

 my_list = [['a', 'b'], ['c', 'd']]
 my_list[0]
['a', 'b']
 my_list[0][1]
'b'


I then attempted to extract the comment, headers and clauses from the nested
list and assign them to a variable.

I tried:


z_list is a list of lines, where each line is a list of words.

For example, is the file contains:

c this is a comment
p wcnf 1468 817439 186181

then z_list contains:

[['c', 'this', 'is', 'a', 'comment'], ['p', 'wcnf', '1468',
'817439', '186181']]


for inner in z_list:
for lists in inner:
if lists[0] == 'c':
comment = lists[:]
elif lists[0] == 'p':
header = lists[:]
else:
clause = lists[:]
print comment, header, clause   


This does not work for some reasons which I understand. I have messed up the
indexing and my assignment of variables is wrong.

The aim was to extract the headers and comments and then be left with a
nested list of clauses.

Then I intended to converted the strings within the clauses nested list back
to integers and via indexing, check that all conditions are met. This would
have involved also converting the numerical strings within the header to
integers but the actual strings are proving a difficult problem to ignore.

Any suggestions?

If my mistakes are irritatingly stupid, please feel free to advise that I
r.t.f.m (read the f**king manual). However, thus far the manual has helped
me little.


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


Re: Parsing file format to ensure file meets criteria

2009-12-17 Thread John Bokma
seafoid fitzp...@tcd.ie writes:

 Hi folks,

 I am new to python and am having some trouble parsing a file.

It really sounds like you need something that generates a parser for you
based on a grammar instead of trying to code your own parser.

See: http://wiki.python.org/moin/LanguageParsing
for an overview of modules.

-- 
John Bokma

Read my blog: http://johnbokma.com/
Hire me (Perl/Python): http://castleamber.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Parsing file format to ensure file meets criteria

2009-12-17 Thread seafoid

MRAB-2

Thank you for that!

Funny how something so simple clarifies a whole lot!

I will crack on now!

Once again,
Cheers and Thanks!

-- 
View this message in context: 
http://old.nabble.com/Parsing-file-format-to-ensure-file-meets-criteria-tp26837682p26838085.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Re: Parsing file format to ensure file meets criteria

2009-12-17 Thread seafoid

Hi John,

I considered that, but in an attempt to really figure out this supposedly
simple language, I figure that I should try and solve this.

I will check out the modules for future reference.

Thanks,
Seafoid :-)

-- 
View this message in context: 
http://old.nabble.com/Parsing-file-format-to-ensure-file-meets-criteria-tp26837682p26838132.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Re: More stuff added to ch 2 of my programming intro

2009-12-17 Thread Ned Deily
In article 
b0b60848-9a66-4f84-ab89-d84ea3904...@a21g2000yqc.googlegroups.com,
 Mensanator mensana...@aol.com wrote:
  That's the disk image for the OS X Python 3.1.1 installer.  
 
 But it doesn't say whether that disk image is compatible with
 Snow Leopard and I don't take such things for granted.

That's a good point.  There should be stated there somewhere about which 
operating systems are supported.  For the record, 3.1.1 has been tested 
on 10.4, 10.5, and 10.6 and should work on 10.3.9.

-- 
 Ned Deily,
 n...@acm.org

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


Re: iterators and views of lists

2009-12-17 Thread Steven D'Aprano
On Thu, 17 Dec 2009 12:07:59 -0800, Brendan Miller wrote:

 I was thinking it would be cool to make python more usable in
 programming competitions by giving it its own port of the STL's
 algorithm library, which needs something along the lines of C++'s more
 powerful iterators.

For the benefit of those of us who aren't C++ programmers, what do its 
iterators do that Python's don't?


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


ANN: Zeus for Windows IDE Version 3.97a

2009-12-17 Thread JussiJ
The latest 3.97a release of the Zeus for Windows IDE is
now available:

  http://www.zeusedit.com/whatsnew.html

Zeus is fully configurable, language neutral IDE.

It comes pre-configured with Python syntax highlighting
and code folding.

It is also possible to write Zeus scripts using Python.

Jussi Jumppanen
Author: Zeus for Windows
-- 
http://mail.python.org/mailman/listinfo/python-list


imports in __init__.py

2009-12-17 Thread Phil
I use distutils / setup.py to install 'packagename', where...
/packagename
__init__.py
modulename.py

modulename.py has a class named 'classname'.

From an arbitrary python module, I 'import packagename'.
In said module, I want to use the 'classname' class from
'packagename.modulename', by doing 'packagename.classname(params)'.

I have seen this done by having either 'import modulename' and/or
'from modulename import *' in 'packagename's __init__.py. I don't
really know which one or combination of them would work, but I can't
get it to work either way. Unless I am missing something, webpy does
this with, among other things, its application class that is in
application.py. From a new web app, you would just use web.application
(params).

I am using Python 3.1.1, although I don't think that should matter.

Any help is appreciated. Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: imports in __init__.py

2009-12-17 Thread Ben Finney
Phil phil...@gmail.com writes:

 I use distutils / setup.py to install 'packagename', where...
 /packagename
 __init__.py
 modulename.py

 modulename.py has a class named 'classname'.

As per PEP 8, it's best if user-defined classes are named with
TitleCase, so ‘ClassName’.

 From an arbitrary python module, I 'import packagename'.

At that point, you have all the names that were defined within
‘packagename’, available inside the namespace ‘packagename’. Since
‘modulename’ is a module in that package, the module's namespace is
available to you via ‘packagename.modulename’.

 In said module, I want to use the 'classname' class from
 'packagename.modulename', by doing 'packagename.classname(params)'.

The name ‘ClassName’ is not in the namespace ‘packagename’. It is in the
namespace ‘packagename.modulename’, so you'll need to access it there::

import packagename.modulename
packagename.modulename.ClassName(params)

You can import the class from that namespace explicitly::

from packagename.modulename import ClassName
ClassName(params)

or you can import the module from the package namespace::

from packagename import modulename
modulename.ClassName(params)

 I have seen this done by having either 'import modulename' and/or
 'from modulename import *' in 'packagename's __init__.py.

Importing the module in the package would mean you would not have to
import the module yourself when using the package; it would not change
the qualification necessary of the namespace.

Importing using the ‘from foo import *’ form is usually a bad idea,
since it clobbers namespaces and makes it impossible to tell by looking
at the import code where the name ‘ClassName’ appeared from. Best to
import only explicit names, as above.

If you want to abbreviate, you can use the ability to rename while
importing::

import packagename.modulename as foo
foo.ClassName(params)

which keeps the names explicit and traceable.

-- 
 \   “Give a man a fish, and you'll feed him for a day; give him a |
  `\religion, and he'll starve to death while praying for a fish.” |
_o__)   —Anonymous |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: imports in __init__.py

2009-12-17 Thread Phil
I understand all of the above, including the reasons as to why this is
bad. For purposes of experimenting, I would still like to do it.

I guess I'm (still) wondering how it is done in webpy. I recall seeing
it done elsewhere too.

All I noticed was that in webpy's package 'web', it defines the
'application' class in 'application.py'.
And in web's __init__.py it has...
from application import *
And in whatever app you are creating, it has...
import web
app = web.application(params)

That being said, I can't get similar functionality with my own
package. Is there more to this? Within my package's __init__.py, I am
unable to import a module from the package without an import error.

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


ANN: withrestart 0.2.1

2009-12-17 Thread Ryan Kelly

Hi All,


  Apologies if you receive multiple copies of this, my python-announce
posts don't seem to be making it through.

  I've just released a new python module called withrestart.  It's an
attempted Pythonisation of the restart-based condition system of Common
Lisp.  Details are on PyPI:

http://pypi.python.org/pypi/withrestart/0.2.1


  For an introduction to conditions and restarts, see Beyond Exception
Handling by Peter Seibel:

   
http://www.gigamonkeys.com/book/beyond-exception-handling-conditions-and-restarts.html


  For a quick demo of the module in action, keep reading...

  Cheers,

  Ryan



About withrestart:
--

Version:  0.2.1
Licence:  MIT
Source:   http://github.com/rfk/withrestart


withrestart is a Pythonisation (Lispers might rightly say bastardisation) of
the restart-based condition system of Common Lisp.  It's designed to make error
recovery simpler and easier by removing the assumption that unhandled errors
must be fatal.

A restart represents a named strategy for resuming execution of a function
after the occurrence of an error.  At any point during its execution a
function can push a Restart object onto its call stack.  If an exception
occurs within the scope of that Restart, code higher-up in the call chain can
invoke it to recover from the error and let the function continue execution.
By providing several restarts, functions can offer several different strategies
for recovering from errors.

A handler represents a higher-level strategy for dealing with the occurrence
of an error.  It is conceptually similar to an except clause, in that one
establishes a suite of Handler objects to be invoked if an error occurs during
the execution of some code.  There is, however, a crucial difference: handlers
are executed without unwinding the call stack.  They thus have the opportunity
to take corrective action and then resume execution of whatever function
raised the error.

As an example, here's a function that doesn't like the number seven:

def anything_but_seven(v):
if v == 7:
raise ValueError(Argh!  A Seven!)
return v
 
And here's a function that can recover from the occurrence of a seven
using the pre-defined restarts skip and use_value:

def sum_items(items):
total = 0
for i in items:
with restarts(skip,use_value) as invoke:
total += invoke(anything_but_seven,i)
return total

Naively calling this will raise a ValueError:

 sum_items(range(8))
Traceback (most recent call last):
...
ValueError: Argh! A Seven!


But if we handle ValueErrors by invoking the skip restart, we can
still get the sum of the remaining items:

 with Handler(ValueError,skip):
... sum_items(range(8))
... 
21
 

Alternately, we can invoke the use_value restart to replace the sevens
with another value:

 with Handler(ValueError,use_value,12):
... sum_items(range(8))
... 
33
 

By splitting the responsibility for error recovery between Handlers and
Restarts, we can cleanly separate the low-level mechanics of recovering
from an error from the high-level decisions about what sort of recovery
to perform.



-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
r...@rfk.id.au|  http://www.rfk.id.au/ramblings/gpg/ for details





signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: iterators and views of lists

2009-12-17 Thread Brendan Miller
On Thu, Dec 17, 2009 at 6:44 PM, Steven D'Aprano
st...@remove-this-cybersource.com.au wrote:
 On Thu, 17 Dec 2009 12:07:59 -0800, Brendan Miller wrote:

 I was thinking it would be cool to make python more usable in
 programming competitions by giving it its own port of the STL's
 algorithm library, which needs something along the lines of C++'s more
 powerful iterators.

 For the benefit of those of us who aren't C++ programmers, what do its
 iterators do that Python's don't?

Python iterators basically only have one operation:

next(), which returns the next element or throws StopIteration.

In C++ terminology this is a Input iterator. It is good for writing
for each loops or map reduce operations.

An input iterator can't mutate the data it points to.

C++ also has progressively stronger iterators:
http://www.sgi.com/tech/stl/Iterators.html

InputIterator - read only, one direction, single pass
ForwardIterator - read/write, one direction, multi pass
BidirectionalIterator - read/write, can move in either direction
RandomAccessIterator - read/write, can move in either direction by an
arbitrary amount in constant time (as powerful as a pointer)

Each only adds extra operations over the one before. So a
RandomAccessIterator can be used anywhere a InputIterator can, but not
vice versa.

Also, this is a duck typing relationship, not a formal class
inheritance. Anything that quacks like a RandomAccessIterator is a
RandomAccessIterator, but there is no actual RandomAccessIterator
class.

So, for instance stl sort function takes pair of random access
iterator delimiting a range, and can sort any datastructure that can
provide that powerful of an iterator (arrays, vectors, deques).

http://www.sgi.com/tech/stl/sort.html

MyCollection stuff;
// put some stuff in stuff

sort(stuff.begin(), stuff.end());

Where begin() and end() by convention return iterators pointing to the
beginning and end of the sequence.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: regex help

2009-12-17 Thread S.Selvam
On Wed, Dec 16, 2009 at 10:46 PM, Gabriel Rossetti 
gabriel.rosse...@arimaz.com wrote:

 Hello everyone,

 I'm going nuts with some regex, could someone please show me what I'm doing
 wrong?

 I have an XMPP msg :

 message xmlns='jabber:client' to='n...@host.com'
   mynode xmlns='myprotocol:core' version='1.0' type='mytype'
   parameters
   param1123/param1
   param2456/param2
   /parameters
   payload type='plain'.../payload
   /mynode
   x xmlns='jabber:x:expire' seconds='15'/
 /message

 the parameter node may be absent or empty (parameter/), the x node
 may be absent. I'd like to grab everything exept the payload nod and
 create something new using regex, with the XMPP message example above I'd
 get this :

 message xmlns='jabber:client' to='n...@host.com'
   mynode xmlns='myprotocol:core' version='1.0' type='mytype'
   parameters
   param1123/param1
   param2456/param2
   /parameters
   /mynode
   x xmlns='jabber:x:expire' seconds='15'/
 /message

 for some reason my regex doesn't work correctly :

 r(message .*?).*?(mynode
 .*?).*?(?:(parameters.*?/parameters)|parameters/)?.*?(x .*/)?


If all you need is to remove payload node ,this could be useful,

s1=message xmlns='jabber:client' to='n...@host.com'mynode
xmlns='myprotocol:core' version='1.0'
type='mytype'parametersparam1123/param1param2456/param2/parameterspayload
type='plain'.../payload/mynodex xmlns='jabber:x:expire'
seconds='15'//message

pat=re.compile(rpayload.*\/payload)
s1=pat.sub(,s1)


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


Re: Raw string substitution problem

2009-12-17 Thread Gregory Ewing

MRAB wrote:


Regular expressions and replacement strings have their own escaping
mechanism, which also uses backslashes.


This seems like a misfeature to me. It makes sense for
a regular expression to give special meanings to backslash
sequences, because it's a sublanguage with its own syntax.
But I can't see any earthly reason to do that with the
*replacement* string, which is just data.

It looks like a feature that's been blindly copied over
from Perl without thinking about whether it makes sense
in Python.

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


share dictionary between processes

2009-12-17 Thread blumenkraft
Hi,

I want to share dictionary between two distinct processes.


Something like this:

first.py
import magic_share_module

def create_dictionary():
return {a: 1}

magic_share_module.share(shared_dictionary,
creator.create_dictionary)
while True:
 pass


second.py
import magic_share_module
d = magic_share_module.get_shared(shared_dictionary)
print d[a]

And then run in command line:
python first.py 
sleep 1
python second.py

I have looked at POSH, but it requires master process that will fork
childs. I want read-only sharing between completely unrelated
processes.
Is it possible?
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue7528] Provide PyLong_AsLongAndOverflow compatibility to Python 2.x

2009-12-17 Thread Case Van Horsen

New submission from Case Van Horsen cas...@gmail.com:

When I ported gmpy to Python 3.x, I began to use
PyLong_AsLongAndOverflow frequently. I found the code to slightly faster
and cleaner than using PyLong_AsLong and checking for overflow. I had
several code fragments that looked like:

#if PY_MAJOR_VERSION == 2
if(PyInt_Check(b)) {
temp = PyInt_AS_LONG(b));
Do stuff with temp.
}
#endif
if(PyLong_Check(b)) {
#if PY_MAJOR_VERSION == 3
temp = PyLong_AsLongAndOverflow(b, overflow);
if(overflow) {
#else
temp = PyLong_AsLong(b);
if(PyErr_Occurred()) {
PyErr_Clear();
#endif
Convert b to an mpz.
} else {
Do stuff with temp.
}
}

I wanted to use the PyLong_AsLongAndOverflow method with Python 2.x so I
extracted the code for PyLong_AsLongAndOverflow, tweeked it to accept
either PyInt or PyLong, and called it PyIntOrLong_AsLongAndOverflow. I
also defined PyIntOrLong_Check.

The same code fragment now looks like:

if(PyIntOrLong_Check(b)) {
temp = PyIntOrLong_AsLongAndOverflow(b, overflow);
if(overflow) {
Convert b to an mpz.
} else {
Do stuff with temp.
}
}

Is it possible to include a py3intcompat.c file with Python 2.7 that
provides this function (and possibly others) for extension authors to
include with their extension? A previous example is pymemcompat.h which
was made available in the Misc directory.

I'm specifically not in favor of adding it to the Python 2.7 API but
just in providing a file for extension authors to use. I've attached a
initial version that compiles successfully with Python 2.4+.

I'm willing to add additional functions, documentation, etc.

--
components: Extension Modules
messages: 96505
nosy: casevh
severity: normal
status: open
title: Provide PyLong_AsLongAndOverflow compatibility to Python 2.x
type: feature request
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7528
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7528] Provide PyLong_AsLongAndOverflow compatibility to Python 2.x

2009-12-17 Thread Case Van Horsen

Case Van Horsen cas...@gmail.com added the comment:

Attached py3intcompat.c

--
Added file: http://bugs.python.org/file15579/py3intcompat.c

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7528
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7518] Some functions in pymath.c should be moved elsewhere.

2009-12-17 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

So the configure test for tanh(-0.0) is purely informational:  it doesn't 
affect the behaviour of the built Python in any way.  I agree that the 
test is imperfect, in that if atan2 is also non-conformant on the given 
platform then the sign issue with tanh may go undetected, but all that 
happens in that case is that we get a bogus 'preserves sign of -0 ... yes' 
message in the configure output.

The wrapper for atan2 in Modules/mathmodules.c is a separate issue; it 
should ensure that we get the right behaviour for atan2 on all platforms,
including msvc 7.0.  I can't immediately see any reason why it wouldn't be 
working as intended.

 I don't think that python cmath tests will pass with MSVC before
8.0.

Which test(s) do you think will fail?

 May be is good to add depends=['_math.h'], for modules in setup.py.

Good point---thanks!  Done in r76865 (trunk), r76867 (py3k).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7518
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7529] StreamHandler does not live in logging.Handlers

2009-12-17 Thread Chris Withers

New submission from Chris Withers ch...@simplistix.co.uk:

http://docs.python.org/library/logging.html#module-logging.handlers

...explains that StreamHandler lives in logging but then the class docs
say logging.handlers.

Georg, if this isn't trivial for you to fix, re-assign it to me and I'll
make the changes when I get a chance :-)

cheers,

Chris

--
assignee: georg.brandl
components: Documentation
messages: 96508
nosy: cjw296, georg.brandl
severity: normal
status: open
title: StreamHandler does not live in logging.Handlers
versions: Python 2.6, Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7529
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7497] configure test for posix_semaphore capability leaves semaphore behind, causing test to fail for other users

2009-12-17 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

The configure test for enabled POSIX semaphores is now failing for me on 
OS X 10.6:  the test produces

sem_open: Permission denied

--
assignee:  - mark.dickinson
status: closed - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7497
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3588] sysconfig variable LINKFORSHARED has wrong value for MacOS X framework build

2009-12-17 Thread Tarek Ziadé

Tarek Ziadé ziade.ta...@gmail.com added the comment:

I agree with Ronald: making sure all variables in Makefile provide
values that can work in any environment just because distutils offers an
API to read them would be a major pain.

What is planned is to remove sysconfig from distutils, and have it in
the stdlib, with a private module built when ./configure is called, that
would contain these variables. 

And maybe we could filter out some variables in this process to keep
only the ones that can be used by code in all environments.

IOW, if python-config provides what you need, LINKFORSHARED could be
filtered out so the API cannot return it.

--
assignee:  - tarek

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3588
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7381] subprocess.check_output: docstring has inconsistent leading whitespace

2009-12-17 Thread flox

flox la...@yahoo.fr added the comment:

Patch updated to backport r51536 in trunk.
It makes python -3 happier (do not compare None = 0).

--
Added file: http://bugs.python.org/file15580/issue7381_v2.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7381
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7381] subprocess.check_output: docstring has inconsistent leading whitespace

2009-12-17 Thread flox

Changes by flox la...@yahoo.fr:


Added file: http://bugs.python.org/file15581/issue7381_py3k_v2.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7381
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >