pafo 0.1 released

2010-07-05 Thread Daneel Yaitskov

Hi All,

pafo is a help debug library. it allows programmer to observer  data
fields' state of a complex object or a bundle of objects. Even if some
objects in the bundle haven't __str__ or __repr__ methods. Such
situation is very usual. Nobody want to writer code only that to print
the state of an object two-three times.


It provides one function - printObject.

You can use it as follows:

 from pafo import *
 printObject( [ 1,2,3] )
[ 1 :: int, 2 :: int, 3 :: int ]
 class A:
...  field = 3
...
 printObject( [ 1,2,3, A()] )
[ 1 :: int, 2 :: int, 3 :: int,
 class A:
   field = 3 :: int
  ]
 class B:
...   field2 = A()
...   listField = [ 1,2,2,4,A()]
...
 printObject( [ 1,2,B(),3, A()] )
[ 1 :: int, 2 :: int,
 class B:
   field2 = class A:
  field = 3 :: int
   listField = [ 1 :: int, 2 :: int, 2 :: int, 4 :: int,
 class A:
   field = 3 :: int
  ]
 , 3 :: int,
 class A:
   field = 3 :: int
  ]



Module can be downloaded from:

http://daneel0yaitskov.000space.com/pafo-0.1.tar.gz
--
http://mail.python.org/mailman/listinfo/python-announce-list

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


Python Ireland's pre-PyCon drinks - Wed, 14th July @ Trinity Capital Hotel

2010-07-05 Thread Vicky Twomey-Lee
Hi All,

Join us for drinks and a chat (a warm-up session to PyCon Ireland ;-) ).

When: Wed 14th July, from 7pm
Where: Trinity Capital Hotel

More details at:
http://www.python.ie/meetup/2010/python_ireland_meetup_-_july_2010/

Cheers,

/// Vicky

~
~~ http://irishbornchinese.com ~~
~~   http://www.python.ie ~~
~
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Re: The real problem with Python 3 - no business case for conversion (was I strongly dislike Python 3)

2010-07-05 Thread Steven D'Aprano
On Sun, 04 Jul 2010 17:34:04 -0700, sturlamolden wrote:

 Using Python 2.x for new
 projects is not advisable (at least many will think so), and using 3.x
 is not possible. What to do? It's not a helpful situation for Python.

That's pure FUD.

Python 2.7 will be supported longer than the normal support period for 
versions 2.6, 2.5, 2.4, ... so if you have a new project that requires 
libraries that aren't available for 3.1, then go right ahead and use 2.7. 
By the time 2.7 is no longer supported (probably around the time 3.4 
comes out?), the library situation will be fixed.

Those 3.1 features that can be backported to 2.x have been, specifically 
to reduce the pain in porting 2.7-based applications to 3.x. Feature-
wise, 2.7 is designed to ease the transition from the 2.x series to the 
3.x series. Claiming that it's not advisable to use 2.7 is simply 
nonsense.



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


Re: Python as a scripting language. Alternative to bash script?

2010-07-05 Thread Lawrence D'Oliveiro
In message 7xpqzbj8st@ruckus.brouhaha.com, Paul Rubin wrote:

 ... and argc/argv were passed to the child process on its stack.

I’ve always felt that to be a misfeature. It means you can’t implement a 
self-contained argument-parsing library, it still needs the mainline to 
explicitly pass/put its arguments somewhere.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python as a scripting language. Alternative to bash script?

2010-07-05 Thread Lawrence D'Oliveiro
In message xns9da77f36b9f6emithrandirisawes...@80.93.112.4, Mithrandir wrote:

 I think that Python could be a alternative to bash and have some
 advantages, but it's a long way off from being fully implemented.

Would you prefer to do the following sort of thing in Python or Bash?

   AudioParms = -f s16le -ar 48000 -ac 2 # because I can't seem to pipe 
compressed audio
   ImportCmd = \
  (
ffmpeg -v 0 -i (%(src_video)s)
 %(audio_parms)s -i (%(src_audio)s)
 -vcodec copy -acodec %(audio_codec)s -y %(dstfile)s
%
{
src_video :
; .join
  (
[
ffmpeg -v 0 -i %(srcfile)s -f image2pipe 
-vcodec copy
 -y /dev/stdout
%
{srcfile : ShellEscape(SrcFile)}
for
SrcFile in SrcFiles
]
  ), # pipe through compressed video without 
recompression
src_audio :
; .join
  (
[
ffmpeg -v 0 -i %(srcfile)s %(audio_parms)s 
-y /dev/stdout
%
{
srcfile : ShellEscape(SrcFile),
audio_parms : AudioParms,
}
for
SrcFile in SrcFiles
]
  ),
dstfile : ShellEscape(DstFile),
audio_parms : AudioParms,
audio_codec : mp2, # assumption!
}
  )

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


Re: Python as a scripting language. Alternative to bash script?

2010-07-05 Thread Lawrence D'Oliveiro
In message op.ve06nlvia8n...@gnudebst, Rhodri James wrote:

 Classic Unix programming is a matter of stringing a bunch of tools
 together with pipes to get the output you want.  This isn't a great
 paradigm for GUIs (not without tweaking that hasn't really been done), but
 then again it was never meant to be.

I’ve never come across any system where you could string together multiple 
GUI apps, or even multiple GUI operations in the same app, in any sensible 
or effective way at all. GUIs just aren’t designed to work that way.

The command line (or scripting, the difference isn’t that important) remains 
the only workable way to string together complex combinations of simpler 
operations.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The real problem with Python 3 - no business case for conversion (was I strongly dislike Python 3)

2010-07-05 Thread John Nagle

On 7/4/2010 10:44 PM, Terry Reedy wrote:

On 7/4/2010 7:58 PM, John Nagle wrote:


The incompatible with all extension modules I need part
is the problem right now. A good first step would be to
identify the top 5 or 10 modules that are blocking a move to
Python 3 by major projects with many users.


Let me repeat. Last September, if not before, Guido identified numpy as
a top package blocking moves by other packages and projects. I am not
sure what he thought, but I consider it number 1. He encouraged the
numpy people to produce a 3.x version even though some did not see any
personal benefit. We supposedly will see numpy for 3.2. If we actually
do, other dominoes will fall into place.

I you have any other ideas about other top blockers, please share them.


   The Twisted team has a list of what they need:

http://stackoverflow.com/questions/172306/how-are-you-planning-on-handling-the-migration-to-python-3;

* Zope Interface
* PyCrypto
* PyOpenSSL
* PyGTK


John Nagle

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


Re: The real problem with Python 3 - no business case for conversion (was I strongly dislike Python 3)

2010-07-05 Thread Steven D'Aprano
On Sun, 04 Jul 2010 18:59:03 -0700, John Nagle wrote:

 Denying that there's a problem does not help.

Nobody is denying that there is a problem, but there are plenty of people 
denying that there are any solutions.

The folks doing development of CPython are genuinely interested in 
constructive criticism. Go spend some time on the python-dev mailing list 
to see that they're serious about resolving problems. But harping on and 
on with the same old negatives and same old FUD (Python is too slow, 
nothing works with Python 3, people will abandon Python, the transition 
is being mismanaged, blah blah blah blah) conspicuously lacking in 
*actual* details is not helping anyone.

Let's hear specifics. What is your project, what is the project timeline, 
why did you want to use 3.1 (instead of, say, waiting for 3.2) and what 
*specific* problem stopped you? I'm not interested in hand-waving and 
vague generalities. I want to hear names and versions, not bitching.

We are planning on building an app to do Foo, and choose to target 2.6 
instead of 3.1 because the 3rd party FooLib only supports 2.5 and 2.6...

I wrote an app using 3.1, and ran into these really painful problems 
with this library...

That's the sort of thing that is helpful.

By the same token, if you've successfully targeted 3.1, we'd love to hear 
your success stories too. 



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


Re: Python 3 put-downs: What's the point?

2010-07-05 Thread Antoine Pitrou
On Sun, 4 Jul 2010 18:20:38 -0700 (PDT)
CM cmpyt...@gmail.com wrote:
 
 Any online group is an opportunity to register dissent in a way that
 is public, open, immediate, interactive, and will (probably) be
 preserved for historians to check.  The fact is, some people have
 gripes with Python 3; they are letting it be known.  If no one did,
 there could be no later time at which people could look back and know
 what the reaction was to its introduction--it would just be a blank.
 Aren't opinions that dissent from the prevailing ones important to
 register, whether one thinks they are right or wrong?

Sure. As long as you don't record the same dissent from the same person
ten times in a row. Then it becomes trolling.



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


Re: SyntaxError not honoured in list comprehension?

2010-07-05 Thread Mark Dickinson
On Jul 4, 11:02 pm, John Machin sjmac...@lexicon.net wrote:
 On Jul 5, 1:08 am, Thomas Jollans tho...@jollans.com wrote:

  On 07/04/2010 03:49 PM, jmfauth wrote:
     File psi last command, line 1
       print9.0
              ^
   SyntaxError: invalid syntax

  somewhat strange, yes.

 There are two tokens, print9 (a name) and .0 (a float constant) --
 looks like SyntaxError to me.

Yep.  Looks that way to me, too.

Python 2.7.0+ (release27-maint:82569, Jul  5 2010, 08:35:08)
[GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type help, copyright, credits or license for more information.
 from cStringIO import StringIO
 import tokenize, token
 for tok in tokenize.generate_tokens(StringIO(print9.0).readline):
... print token.tok_name[tok[0]], tok[1]
...
NAME print9
NUMBER .0
ENDMARKER

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


Re: Python 3 put-downs: What's the point?

2010-07-05 Thread Gregor Horvath
Am Sun, 04 Jul 2010 18:51:54 -0500
schrieb Tim Chase python.l...@tim.thechases.com:

 I think it's the same venting of frustration that caused veteran 
 VB6 developers to start calling VB.Net Visual Fred -- the 
 language was too different and too non-backwards-compatible.
 

VB6 - VB.NET and Python 2 - 3 is not a valid comparison.

VB6 and VB.NET are totally different languages and technologies, with
some similarity in syntax. This is not true for Python 2-3. 
This is an healthy organic language growth, not an abandon of a
language.

--
Greg

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


Re: Python 2.7 released

2010-07-05 Thread Benjamin Kaplan
On Sun, Jul 4, 2010 at 7:58 PM, John Machin sjmac...@lexicon.net wrote:
 On Jul 5, 12:27 pm, Martineau ggrp2.20.martin...@dfgh.net wrote:
 On Jul 4, 8:34 am, Benjamin Peterson benja...@python.org wrote:



  On behalf of the Python development team, I'm jocund to announce the second
  release candidate of Python 2.7.

  Python 2.7 will be the last major version in the 2.x series. However, it 
  will
  also have an extended period of bugfix maintenance.

  2.7 includes many features that were first released in Python 3.1. The 
  faster io
  module, the new nested with statement syntax, improved float repr, set 
  literals,
  dictionary views, and the memoryview object have been backported from 3.1. 
  Other
  features include an ordered dictionary implementation, unittests 
  improvements, a
  new sysconfig module, auto-numbering of fields in the str/unicode format 
  method,
  and support for ttk Tile in Tkinter.  For a more extensive list of changes 
  in
  2.7, seehttp://doc.python.org/dev/whatsnew/2.7.htmlorMisc/NEWS in the 
  Python
  distribution.

  To download Python 2.7 visit:

       http://www.python.org/download/releases/2.7/

  2.7 documentation can be found at:

       http://docs.python.org/2.7/

  This is a production release and should be suitable for all libraries and
  applications.  Please report any bugs you find, so they can be fixed in 
  the next
  maintenance releases.  The bug tracker is at:

       http://bugs.python.org/

  Enjoy!

  --
  Benjamin Peterson
  Release Manager
  benjamin at python.org
  (on behalf of the entire python-dev team and 2.7's contributors)

 Benjamin (or anyone else), do you know where I can get the Compiled
 Windows Help file -- python27.chm -- for this release? In the past
 I've been able to download it from the Python web site, but have been
 unable to locate it anywhere for this new release. I can't build it
 myself because I don't have the Microsoft HTML help file compiler.

 Thanks in advance.

 If you have a Windows box, download the .msi installer for Python 2.7
 and install it. The chm file will be in C:\Python27\Doc (if you choose
 the default installation directory). Otherwise ask a friendly local
 Windows user for a copy.
 --

Or you can just use 7-zip or cabextract on the MSi. Saves you from
having to uninstall it later, and it works on non-Windows machines.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: delegation pattern via descriptor

2010-07-05 Thread Bruno Desthuilliers

kedra marbun a écrit :

i'm confused which part that doesn't make sense?
this is my 2nd attempt to py, the 1st was on april this year, it was
just a month, i'm afraid i haven't got the fundamentals right yet. so
i'm gonna lay out how i got to this conclusion, CMIIW

**explanation of feeling (0) on my 1st post**
to me, descriptor is a particular kind of delegation, it takes the job
of coding the delegation by having a contract with programmers that
the tree meta operations (get, set, del) on attr are delegated to the
obj that is bound to the attr
are we agree that descriptor is a kind of delegation?

the mechanism that makes descriptor works is in __getattribute__,
__setattr__, __delattr__ of 'object'  'type'

now, if i want a single descriptor obj to be delegated to multiple
tasks, i can't do it since __get__ doesn't get info that can be used
to determine which task to do
i must have diff descriptor obj for each task

class Helper:
def __init__(self, name):
self.name = name
def __get__(self, ins, cls):
if self.name == 'task0': ...
elif self.name == 'task1': ...
else: ...



Replacing such big switch code with polymorphic dispatch is one of the 
 goals (and feature) of OO. This should be:



class Task0(object):
def __get__(self, obj, cls):
# code here


class Task1(object):
def __get__(self, obj, cls):
# code here


class A(object):
task0 = Task0()
task1 = Task1()


If you have common code to share between TaskO and Task1 then factor it 
out into a base class.




if __get__ receives the name, then i could do

class Helper:
def __get__(self, ins, cls, name):
...

class a:
task0 = task1 = Helper()



Yuck.

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


What is the name of the name space I am in?

2010-07-05 Thread Anthra Norell
I try to use new.new.classobj (name, baseclass, dict) and have no clue 
what the dict of the current name space is. I can name dicts of  
imported modules, because their name exists in the current name space. 
If, for instance, I import a module service then that module's name 
space would be service.__dict__. But if I import * from service, then 
I incorporate that name space into the current one and I cannot name it, 
because the current module's name is not part of the module's own name 
space. dir (service) is equivalent to service.__dict__.keys () if 
service is importet. dir () is equivalent to ?.__dict__.keys () 
where ? is the name of the current module, itself not part of the 
current module's name space. So the question mark stands for an implicit 
name that can be neither named nor dropped. So my question is: how does 
one name the dictionary of the name space one is in?


Frederic

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


Re: What is the name of the name space I am in?

2010-07-05 Thread Thomas Jollans
On 07/05/2010 11:07 AM, Anthra Norell wrote:
 I try to use new.new.classobj (name, baseclass, dict) and have no clue
 what the dict of the current name space is. I can name dicts of 
 imported modules, because their name exists in the current name space.
 If, for instance, I import a module service then that module's name
 space would be service.__dict__. But if I import * from service, then
 I incorporate that name space into the current one and I cannot name it,
 because the current module's name is not part of the module's own name
 space. dir (service) is equivalent to service.__dict__.keys () if
 service is importet. dir () is equivalent to ?.__dict__.keys ()
 where ? is the name of the current module, itself not part of the
 current module's name space. So the question mark stands for an implicit
 name that can be neither named nor dropped. So my question is: how does
 one name the dictionary of the name space one is in?

either globals() or locals(), depending on what you mean.

 
 Frederic
 

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


Re: GAE + recursion limit

2010-07-05 Thread Soltys
On 2 Lip, 22:49, Paul McGuire pt...@austin.rr.com wrote:
  Does anyone have any clue what that might be?
  Why the problem is onGAE(even when run locally), when command line
  run works just fine (even withrecursionlimitdecreased)?

 Can't explain why you see different behavior onGAEvs. local, but it
 is unusual for a small translator to flirt withrecursionlimit.  I
 don't usually see parsers come close to this with fewer than 40 or 50
 sub-expressions.  You may have some left-recursiongoing on.  Can you
 post your translator somewhere, perhaps on pastebin, or on the
 pyparsing wiki Discussion page (pyparsing.wikispaces.com)?

 -- Paul

@David, thanks for the advice, I did ask on GAE list, id not get
answer till now though.

@Paul, I think I solved it. I did extensive test during weekend and
it
appears that my regular translator almost reaches 1000 recursion
limit.
Probably the last time I've tried to increase the recursion limit for
GAE
app I did it in the wrong place. (For future, if you'd like to do it,
the best
and working is to set that right before call to
run_wsgi_app(application)).
The only think that remains is, I need to review the grammar and how
processing
happens that I reach that limit with GAE.

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


Re: [ANN] eric 5.0.0 released

2010-07-05 Thread Jean-Michel Pichavant

Detlev Offenbach wrote:

Hi,

I just uploaded eric 5.0.0. This is the first official release. It 
is available via the eric web site.


http://eric-ide.python-projects.org/index.html

What is it?
---
eric5 is the Python3 variant of the well know eric4 Python IDE and is 
the first development environment, that runs natively with Python3. It 
comes with all batteries included. The features are too much to be 
listed in this announcement. Please see the eric web site for details.


Regards,
Detlev
  

Nice work, thanks for sharing.

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


Re: What is the name of the name space I am in?

2010-07-05 Thread Chris Rebert
On Mon, Jul 5, 2010 at 2:07 AM, Anthra Norell anthra.nor...@bluewin.ch wrote:
 I try to use new.new.classobj (name, baseclass, dict) and have no clue

Slight tangent:
Note that both the `new` module and old-style classes (which are what
`classobj` produces) are deprecated.
To produce new-style classes dynamically, use `type`.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The real problem with Python 3 - no business case for conversion (was I strongly dislike Python 3)

2010-07-05 Thread David Cournapeau
On Mon, Jul 5, 2010 at 12:44 PM, Terry Reedy tjre...@udel.edu wrote:
 On 7/4/2010 7:58 PM, John Nagle wrote:

 The incompatible with all extension modules I need part
 is the problem right now. A good first step would be to
 identify the top 5 or 10 modules that are blocking a move to
 Python 3 by major projects with many users.

 Let me repeat. Last September, if not before, Guido identified numpy as a
 top package blocking moves by other packages and projects. I am not sure
 what he thought, but I consider it number 1. He encouraged the numpy people
 to produce a 3.x version even though some did not see any personal benefit.
 We supposedly will see numpy for 3.2.

I think numpy will work for 3.1 as well (I don't know about 3.0, but
my understanding is that there is no point into even looking at that
release).

With the scipy conferences going on, it will certainly be a good
occasion to synchronize a bit faster - nothing beats face to face as a
communication medium after all :)

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


SMTPHandler and Unicode

2010-07-05 Thread norbert
Hello,

I want to send error messages with SMTPHandler logging. But
SMTPHandler does not seem to be unicode aware. Is there something
doable without playing with sys.setdefaultencoding ?

import logging,logging.handlers
smtpHandler =
logging.handlers.SMTPHandler(mailhost=(smtp.example.com,25),
fromaddr=t...@example.com, toaddrs=t...@example.com,
subject=uerror message)

LOG = logging.getLogger()
LOG.addHandler(smtpHandler)

LOG.error(usans accent)
LOG.error(uaccentu\u00E9)

gives : UnicodeEncodeError: 'ascii' codec can't encode character
u'\xe9' in position 117: ordinal not in range(128)

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


Re: Crash in PyThread_acquire_lock

2010-07-05 Thread moerchendiser2k3
Thanks Antoine! :) You were right. It was the wrong thread...uhmm...

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


Re: Confusion over etree.ElementTree.Element.getiterator

2010-07-05 Thread Ben Sizer
On Jul 4, 7:33 am, Stefan Behnel stefan...@behnel.de wrote:
 BenSizer, 04.07.2010 00:32:

  On Jul 3, 11:12 pm,BenSizerkylo...@gmail.com  wrote:

   for el in root.getiterator():

  ...        print el
  [much output snipped]
  Element {http://www.w3.org/1999/xhtml}a at d871e8
  Element {http://www.w3.org/1999/xhtml}a at d87288
  Element {http://www.w3.org/1999/xhtml}script at d87300
  Element {http://www.w3.org/1999/xhtml}script at d87378

  Hmm, I think I've worked it out. Apparently the XML namespace forms
  part of the tag name in this case. Is that what is intended?

 Sure.

  I didn't see any examples of this in the docs.

 Admittedly, it's three clicks away from the library docs on docs.python.org.

 http://effbot.org/zone/element.htm#xml-namespaces

Hopefully someone will see fit to roll this important documentation
into docs.python.org before the next release... oops, too late. ;)

It's one of those things that's easy to fix when you know what the
problem is. Unfortunately it makes the examples a bit awkward. The
example on http://docs.python.org/library/xml.etree.elementtree.html
opens up an xhtml file and reads a p tag within a body tag, but
the xhtml specification (http://www.w3.org/TR/xhtml1/#strict) states
that 'The root element of the document must contain an xmlns
declaration for the XHTML namespace'. Therefore I don't see how the
example Python code given could work on a proper xhtml file, given
that there should always be a namespace in effect but the code doesn't
allow for it.

That's my excuse anyway! :)

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


Re: Twisted 10.1.0 released

2010-07-05 Thread Daniel Fetchinson
 On behalf of Twisted Matrix Laboratories, I am honored to announce the
 release of Twisted 10.1.0.

 Highlights include:

  * Deferreds now support cancellation

  * A new endpoint interface which can abstractly describe stream
 transport endpoints such as TCP and SSL

  * inotify support for Linux, which allows monitoring of file system events.

  * AMP supports transferring timestamps

 Note also that this is the *last* supported release of Twisted for
 Python 2.4 on Windows.

 For more information, see the NEWS file.

 It's stable, backwards compatible, well tested and in every way an
 improvement. Download it now from:

  http://tmrc.mit.edu/mirror/twisted/Twisted/10.1/Twisted-10.1.0.tar.bz2
 http://tmrc.mit.edu/mirror/twisted/Twisted/10.1/Twisted-10.1.0.winxp32-py2.5.msi
 http://tmrc.mit.edu/mirror/twisted/Twisted/10.1/Twisted-10.1.0.winxp32-py2.6.msi

 Many thanks to Glyph Lefkowitz, who helped do the release preparation,
 and the PyCon 2010 sprinters, who did so much of the work for this
 release.


The twisted website at http://twistedmatrix.com/ seems to be having
issues (trac can not connect to its database?).

Cheers,
Daniel

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


Re: SMTPHandler and Unicode

2010-07-05 Thread Chris Withers

norbert wrote:

I want to send error messages with SMTPHandler logging. But
SMTPHandler does not seem to be unicode aware. Is there something
doable without playing with sys.setdefaultencoding ?


try MailingLogger:

http://www.simplistix.co.uk/software/python/mailinglogger

If you have unicode problems with that, I'd be interested in fixing them!

cheers,

Chris

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


Plot problem.. ?? No sign at all

2010-07-05 Thread Ritchy lelis
hello guys..

I'm new at python programming and i'm having some problems with a
script that i have been developing for my final project of my
graduation.

I have a script that is supposed to make a plot of a
Residuo (waveform) witch is an output of a ADC ( Analogic To Digital
Converter) for the first stage of the Flash pipiline ADC
structure.This script doesn't show any syntax errors but it doesn't
show no waveform at all at the plot window.

I'm worried about this situation so I came here looking for help since
I am new to the Python language.


---

from pylab import*

Vref = arange(1, 20, 0.02)
Vi = arange(1, 10,0.1)

for i in Vref:
 for n in Vi:
  if n  i/4:
V0 = 2*n-i
  elif (-i/4) = n and n = i/4:
V0 = 2*n
  elif Vi  -i/4:
V0 = 2*n+i
  else:
print Try Again
##print V0
plot (V0)boboz10



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


Re: What is the name of the name space I am in?

2010-07-05 Thread Anthra Norell

Thomas Jollans wrote:

On 07/05/2010 11:07 AM, Anthra Norell wrote:
  

I try to use new.new.classobj (name, baseclass, dict) and have no clue
what the dict of the current name space is. I can name dicts of 
imported modules, because their name exists in the current name space.

If, for instance, I import a module service then that module's name
space would be service.__dict__. But if I import * from service, then
I incorporate that name space into the current one and I cannot name it,
because the current module's name is not part of the module's own name
space. dir (service) is equivalent to service.__dict__.keys () if
service is importet. dir () is equivalent to ?.__dict__.keys ()
where ? is the name of the current module, itself not part of the
current module's name space. So the question mark stands for an implicit
name that can be neither named nor dropped. So my question is: how does
one name the dictionary of the name space one is in?



either globals() or locals(), depending on what you mean.

  

Frederic




Thomas,
Thanks a million. Just the tip I needed.
Frederic

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


Re: SMTPHandler and Unicode

2010-07-05 Thread Chris Withers

norbert wrote:

Your package has the same unicode problem :
import logging,logging.handlers
from mailinglogger.MailingLogger import MailingLogger
mailingLogger = MailingLogger(mailhost=('smtp.example.com',
25),fromaddr='t...@example.com',toaddrs=('t...@example.com',))
LOG = logging.getLogger()
LOG.addHandler(mailingLogger)
LOG.error(usans accent)
LOG.error(uaccentu\u00E9)

-- UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9'
in position 7: ordinal not in range(128)


Interesting, I don't know what the logging framework's position is on 
unicode...


What happens when you try the same logging with just a FileHandler 
registered? What encoding does the log file use?


cheers,

Chris

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


Re: SMTPHandler and Unicode

2010-07-05 Thread norbert
On 5 juil, 13:17, Chris Withers ch...@simplistix.co.uk wrote:
 try MailingLogger:

 If you have unicode problems with that, I'd be interested in fixing them!

Your package has the same unicode problem :
import logging,logging.handlers
from mailinglogger.MailingLogger import MailingLogger
mailingLogger = MailingLogger(mailhost=('smtp.example.com',
25),fromaddr='t...@example.com',toaddrs=('t...@example.com',))
LOG = logging.getLogger()
LOG.addHandler(mailingLogger)
LOG.error(usans accent)
LOG.error(uaccentu\u00E9)

-- UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9'
in position 7: ordinal not in range(128)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plot problem.. ?? No sign at all

2010-07-05 Thread MRAB

Ritchy lelis wrote:

hello guys..

I'm new at python programming and i'm having some problems with a
script that i have been developing for my final project of my
graduation.

I have a script that is supposed to make a plot of a
Residuo (waveform) witch is an output of a ADC ( Analogic To Digital
Converter) for the first stage of the Flash pipiline ADC
structure.This script doesn't show any syntax errors but it doesn't
show no waveform at all at the plot window.

I'm worried about this situation so I came here looking for help since
I am new to the Python language.


---

from pylab import*

Vref = arange(1, 20, 0.02)
Vi = arange(1, 10,0.1)

for i in Vref:
 for n in Vi:
  if n  i/4:
V0 = 2*n-i
  elif (-i/4) = n and n = i/4:
V0 = 2*n
  elif Vi  -i/4:
V0 = 2*n+i
  else:
print Try Again
##print V0
plot (V0)boboz10




Only the first 2 'if' conditions are ever true, so nothing is ever
plotted.

Also, I don't know what you're trying to do here:

elif Vi  -i/4:

because Vi is an array and i is a float. If Python ever tried to execute
it there would be a ValueError exception:

ValueError: The truth value of an array with more than one element is 
ambiguous.

 Use a.any() or a.all()
--
http://mail.python.org/mailman/listinfo/python-list


Re: SMTPHandler and Unicode

2010-07-05 Thread norbert
On 5 juil, 14:32, Chris Withers ch...@simplistix.co.uk wrote:
 norbert wrote:
  Your package has the same unicode problem :
  import logging,logging.handlers
  from mailinglogger.MailingLogger import MailingLogger
  mailingLogger = MailingLogger(mailhost=('smtp.example.com',
  25),fromaddr='t...@example.com',toaddrs=('t...@example.com',))
  LOG = logging.getLogger()
  LOG.addHandler(mailingLogger)
  LOG.error(usans accent)
  LOG.error(uaccentu\u00E9)

  -- UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9'
  in position 7: ordinal not in range(128)

 Interesting, I don't know what the logging framework's position is on
 unicode...

 What happens when you try the same logging with just a FileHandler
 registered? What encoding does the log file use?


a FileHandler works as expected, the log file being UTF-8 encoded. The
SMTPHandler is the only logger I know with this problem, maybe
connected to SMTPLib implementation ?

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


Re: What is the name of the name space I am in?

2010-07-05 Thread Anthra Norell

Chris Rebert wrote:

On Mon, Jul 5, 2010 at 2:07 AM, Anthra Norell anthra.nor...@bluewin.ch wrote:
  

I try to use new.new.classobj (name, baseclass, dict) and have no clue



Slight tangent:
Note that both the `new` module and old-style classes (which are what
`classobj` produces) are deprecated.
To produce new-style classes dynamically, use `type`.

Cheers,
Chris
--
http://blog.rebertia.com

  

Chris,
 I noticed the deprecation situation reading the doc, but opted for 
what I thought might be more backward-compatible. Your suggestion 
prompted me to take a closer look and it turns out that types is 
compatible as far back as I have to go (2.5). So I use types with 
thanks to you.

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


Re: SMTPHandler and Unicode

2010-07-05 Thread Antoine Pitrou
On Mon, 5 Jul 2010 06:17:38 -0700 (PDT)
norbert ncaude...@gmail.com wrote:
 
 a FileHandler works as expected, the log file being UTF-8 encoded.

Ouch. Implicit encoding sounds like a bad behaviour.

 The
 SMTPHandler is the only logger I know with this problem, maybe
 connected to SMTPLib implementation ?

I suggest you report an issue on http://bugs.python.org



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


Re: Python 3 put-downs: What's the point?

2010-07-05 Thread Roy Smith
In article mailman.247.1278309447.1673.python-l...@python.org,
 Dennis Lee Bieber wlfr...@ix.netcom.com wrote:

 On Sun, 04 Jul 2010 20:05:03 -0400, Roy Smith r...@panix.com declaimed
 the following in gmane.comp.python.general:
 
  In article mailman.238.1278287528.1673.python-l...@python.org,
   Tim Chase python.l...@tim.thechases.com wrote:
  
   I've often wondered if changing the name of the language (such as 
   Adder, Served, Dwarf or Fawlty for the Britcom fans in 
   the crowd) would have mitigated some of the more vituperative 
   slurs on what became Py3, designating a shared legacy without the 
   expectation of 100% backwards-compatibility.
  
  Maybe it should have been Python five, no, THREE!
 
   But Adder works on two levels... The BritCom, and the serpentine...

Not to mention that the same main characters show up in each version :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


black console window of executing os.chmod() and os.access()

2010-07-05 Thread 朱重八
Hi all,
I want to use os.chmod or os.access to check the permission of a folder
on remote Windows computer:
os.chmod(\\1.1.1.1\sharedfolder, stat.S_IWRITE)
or
os.access(\\1.1.1.1\sharedfolder, os.W_OK)

I saved this python file as a.pyw, run it with pythonw.exe a.pyw, then a
black console window display one second.
Only remote folder has this problem, local folder has no this problem.

Anybody know how to remove the black console window?

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


Re: black console window of executing os.chmod() and os.access()

2010-07-05 Thread Thomas Jollans
On 07/05/2010 04:19 PM, 朱重八 wrote:
 Hi all,
 I want to use os.chmod or os.access to check the permission of a
 folder on remote Windows computer:
 os.chmod(\\1.1.1.1\sharedfolder, stat.S_IWRITE)
 or
 os.access(\\1.1.1.1\sharedfolder, os.W_OK)

That won't work:

 print(\\1.1.1.1\sharedfolder)
\1.1.1.1\sharedfolder



 
 I saved this python file as a.pyw, run it with pythonw.exe a.pyw, then a
 black console window display one second.
 Only remote folder has this problem, local folder has no this problem.
 
 Anybody know how to remove the black console window?

Does the script actually work for remote folders? Does the same problem
occur for other file operations on remote systems?

Maybe someone else knows an answer, otherwise maybe my thoughts will be
of some help.

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


ImportError: DLL load failed: The specified module could not be found, SWIG, life, etc

2010-07-05 Thread Bill Davy
I am struggling :-(



I have used SWIG to build a module called SHIP.  So I have a directory 
containing SHIP.py and _SHIP.pyd, as follows:



H:\Viper\HostPC\V1\SHIP\Releasedir

 Volume in drive H has no label.

 Volume Serial Number is B83B-76F2



 Directory of H:\Viper\HostPC\V1\SHIP\Release



05/07/2010  14:43DIR  .

05/07/2010  14:43DIR  ..

03/07/2010  16:2841,079 SHIP.py

03/07/2010  14:36   495,616 _SHIP.pyd

   2 File(s)536,695 bytes

   2 Dir(s)  58,270,535,680 bytes free







I have a test Python program which imports sys and os and then attempts to 
import SHIP; it begins as follows:





## D for John's notebook

## E for Rod's notebook

## H for Bill's notebook

DRIVE = 'H:'



import sys

import os

if ( not os.path.exists(DRIVE) ):

print Drive \'%s\' does not exist on this machine; edit top of file % 
(DRIVE)

sys.exit(0)



# Prepend our path

sys.path[:0] = [DRIVE + r'\Viper\HostPC\V1\SHIP\Release']



import SHIP



SHIP.Initialise();





I then create a Command Prompt window and enter:





H:\Viper\HostPC\V1\SHIPC:\Python26\python -vv Test1.py tmp.txt 21



In tmp.txt, I see the following:



snipped out lots of importing

Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] 
on win32

Type help, copyright, credits or license for more information.

# trying H:\Viper\HostPC\V1\SHIP\Release\SHIP.pyd

# trying H:\Viper\HostPC\V1\SHIP\Release\SHIP.py

# H:\Viper\HostPC\V1\SHIP\Release\SHIP.pyc matches 
H:\Viper\HostPC\V1\SHIP\Release\SHIP.py

import SHIP # precompiled from H:\Viper\HostPC\V1\SHIP\Release\SHIP.pyc

# trying H:\Viper\HostPC\V1\SHIP\Release\_SHIP.pyd

#   clear[2] __name__

#   clear[2] __file__

Traceback (most recent call last):

  File Test1.py, line 15, in module

import SHIP

  File H:\Viper\HostPC\V1\SHIP\Release\SHIP.py, line 7, in module

import _SHIP

ImportError: DLL load failed: The specified module could not be found.

snip



It would seem the import SHIP is finding SHIP.py without any trouble.

SHIP.py begins by import _SHIP.

Python appears to find H:\Viper\HostPC\V1\SHIP\Release\_SHIP.pyd but for 
some reason, which I cannot fathom, says DLL load failed.



Can anyone offer me any suggestion where I am going wrong or how to tackle 
this problem?



Could it be that the Python 2.6 I am running did not use the same compiler 
(VC6) with which I buiult _SHIP.pyd and if so, is there a way round this 
without moving on from VC6?



TIA,

   Bill


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


Re: Plot problem.. ?? No sign at all

2010-07-05 Thread Alan G Isaac

On 7/5/2010 7:45 AM, Ritchy lelis wrote:

from pylab import*

Vref = arange(1, 20, 0.02)
Vi = arange(1, 10,0.1)

for i in Vref:
  for n in Vi:
   if n  i/4:
 V0 = 2*n-i
   elif (-i/4)= n and n= i/4:
 V0 = 2*n
   elif Vi  -i/4:
 V0 = 2*n+i
   else:
 print Try Again
 ##print V0
 plot (V0)



Your data manipulations don't make sense to me,
and plotting one point at a time is probably
not what you want to do.  As a rule, use arange
only with integer arguments. Finally, if you
want to see your plot, you need to show it
(or save it). So create an **array** V0 and
then do  something like the following:

import numpy as np
import matplotlib.pyplot as plt
Vref = np.linspace(1,20, 1000)
Vi = np.linspace(1,10,100)
#replace the next line
V0 = ... #create an array
plt.plot(V0)
plt.show()

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


Re: black console window of executing os.chmod() and os.access()

2010-07-05 Thread 朱重八
Sorry, I mean 1.1.1.1\\sharedfolder

Seems os.chmod(), os.access() and os.makedirs() all have this problem when
the path is a remote path.

2010/7/5 Thomas Jollans tho...@jollans.com

 On 07/05/2010 04:19 PM, 朱重八 wrote:
  Hi all,
  I want to use os.chmod or os.access to check the permission of a
  folder on remote Windows computer:
  os.chmod(\\1.1.1.1\sharedfolder, stat.S_IWRITE)
  or
  os.access(\\1.1.1.1\sharedfolder, os.W_OK)

 That won't work:

  print(\\1.1.1.1\sharedfolder)
 \1.1.1.1\sharedfolder
 


 
  I saved this python file as a.pyw, run it with pythonw.exe a.pyw, then a
  black console window display one second.
  Only remote folder has this problem, local folder has no this problem.
 
  Anybody know how to remove the black console window?

 Does the script actually work for remote folders? Does the same problem
 occur for other file operations on remote systems?

 Maybe someone else knows an answer, otherwise maybe my thoughts will be
 of some help.

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

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


Re: ImportError: DLL load failed: The specified module could not be found, SWIG, life, etc

2010-07-05 Thread Thomas Jollans
On 07/05/2010 04:35 PM, Bill Davy wrote:
 I am struggling :-(

smile!

 
 I have used SWIG to build a module called SHIP.  So I have a directory 
 containing SHIP.py and _SHIP.pyd, as follows:
 
 [ ...]
 
 Python appears to find H:\Viper\HostPC\V1\SHIP\Release\_SHIP.pyd but for 
 some reason, which I cannot fathom, says DLL load failed.
 

Maybe it doesn't mean _SHIP.pyd, but another DLL: maybe _SHIP.pyd
depends on some other DLL? Since you used SWIG, I'm guessing that you're
wrapping some other library. Maybe that's what it can't find.

 
 
 Can anyone offer me any suggestion where I am going wrong or how to tackle 
 this problem?
 
 
 
 Could it be that the Python 2.6 I am running did not use the same compiler 
 (VC6) with which I buiult _SHIP.pyd and if so, is there a way round this 
 without moving on from VC6?
 

Shouldn't be a problem, as long as the calling convention hasn't change,
which it hasn't. If you're on a 64-bit system there might be a problem
there with Python and some DLLs being built for different architectures?

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


Re: VICIOUS Enemy Insurgents kill 34 US soldiers after 9 hrs attack - Bellies ripped open and numerous injured - call for TRUE PATRIOTS . The deep undercover spies agents of influence mislead the pub

2010-07-05 Thread nanothermite911fbibustards
http://www.veteranstoday.com/2010/06/16/jim-w-dean-faked-israeli-flotilla-v=
ideos-provide-opening-to-expose-israeli-expionage-here/

JIM W. DEAN: FAKED ISRAELI FLOTILLA VIDEOS PROVIDE OPENING TO EXPOSE
ISRAELI EXPIONAGE HERE



June 16, 2010 posted by Gordon Duff =B7 20 Comments
Share
Faked Israeli Flotilla videos provide opening to expose Israeli
Espionage here
By Jim W. Dean for Veterans Today

Dear Friends, The Zionists shot themselves in both feet with this
rushed spin job to deflect attention on their slaughter of the Gaza
Flotilla activists. We can thank the retired Intel folks for the frame
analysis exposing the fraud on the Veterans Today link above.
Fortunately more and more retired Intel and security people are
getting into the life or death struggle defending the country from our
=91domestic enemies=92.

These Photo shopped videos were done so poorly as to be almost comical
if they were not done to cover up murders. You will have to watch the
video several times to really visually catch their mistakes. Don=92t
be
afraid to use the pause button to study the images.

The ending scenes on the fantail immediately struck me as a studio
shoot. The lighting was way to bright for a ship in that situation.
The actors=85well=85they did a really poor job. In the real videos you
see
more confusion=85the clothes are not right. If was a completely staged
event, even down to the tiny slingshot one guy raises up so it can be
noticed. Also, the camera is stationary (on a tripod)=85a huge
mistake.


YouTube - Veterans Today -

That the radical Zionists would lie, cheat or steal to gain some
benefit for themselves is not even a news event. Our own American
declassified intelligence lays this all out in spades. The best one
book read on it is Steven Green=92s Taking Sides, if you can find a
used
one online.

The real news here is how such an obvious fraud was pipelined into
American mass media. Any experienced news video editor would have
spotted the obvious fraud on these tapes. But they pushed it right out
onto unsuspecting Americans who wrongly think that mass media would
not pedal something they know to be totally bogus. And how wrong they
are.

But it gets worse. Our Intel and security agencies always do frame by
frame analysis of important video material like this. They also had to
have spotted this=85yet they did not warn the American people that
this
was a fraud. Why not?

The answer is that Israel espionage has penetrated American
government, media, politics, and even our security institutions to the
point that the Zios have no fear of those responsible for our national
security protecting us from the Israeli 5th column operating here.
They are protected by powerful interests.

The military, veteran and intelligence communities are really the only
American institutions who can take the lead on tearing the Israeli
espionage networks out by the roots. All the other institutions are
already compromised. And they will fight like hell as they know that
the 5th column could not have been as effective as they have been
without more than a few disloyal Americans helping them, many who are
well known names. They will do anything to protect themselves from
exposure=85anything=85and they have. The USS Liberty is just one
example,
where dead and wounded servicemen were literally abandoned on the
battlefield so as to not reveal to the American public that they were
murdered by the Israelis.

You might remember that the last whistleblower reform legislation was
slapped down a while back. The Congresscritters know what a threat
that is. So do the Israelis. We have loyal Intel people who know that
the Israelis have been given key Homeland Security contracts that
actually have the American taxpayer funding their espionage
operations. Oh yes, the Israelis make us pay for it=85smart folks
they.

Michael Chertoff flew to Israel a few years back to put on a =91fast
track=92 seminar for Israeli security companies (staffed by Mussed and
military Intel people) to make sure they can the key contracts that
they wanted, like airport security and communications plums. This is a
huge national scandal, and one that a Congressional investigation
would not put a dent into as those folks have sold us out to the
Israelis in return for political support. John McCain is one of the
worst examples, but he has lots of company.

I listened to General Russel Honore give a great Memorial Day speech
in Atlanta recently. It was short and sweet in his normal style.
=93We were born by accident, based on where our parents were. To live
free is a privilege. But to die free is an obligation that we leave to
each generation.=94

Folks, If we don=92t join hands and root out this the Israeli 5th
column
here we will be breaking the chain, and it is getting late in the day.
Their numbers are small, so they have put the fix it at the top,
political espionage. But we have the numbers to beat them. They have
just not been brought to bear due to their divide 

throwing exceptions from csv.DictReader or even csv.reader

2010-07-05 Thread Tim
Hullo
Csv is a very common format for publishing data as a form of primitive
integration. It's an annoyingly brittle approach, so I'd like to
ensure that I capture errors as soon as possible, so that I can get
the upstream processes fixed, or at worst put in some correction
mechanisms and avoid getting polluted data into my analyses.

A symptom of several types of errors is that the number of fields
being interpreted varies over a file (eg from wrongly embedded quote
strings or mishandled embedded newlines). My preferred approach would
be to get DictReader to throw an exception when encountering such
oddities, but at the moment it seems to try to patch over the error
and fill in the blanks for short lines, or ignore long lines. I know
that I can use the restval parameter and then check for what's been
parsed when I get my results back, but this seems brittle as whatever
I use for restval could legitimately be in the data.

Is there any way to get csv.DictReader to throw and exception on such
simple line errors, or am I going to have to use csv.reader and
explicitly check for the number of fields read in on each line?

cheers

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


Re: SMTPHandler and Unicode

2010-07-05 Thread Chris Withers

Antoine Pitrou wrote:

On Mon, 5 Jul 2010 06:17:38 -0700 (PDT)
norbert ncaude...@gmail.com wrote:

a FileHandler works as expected, the log file being UTF-8 encoded.


Ouch. Implicit encoding sounds like a bad behaviour.


Yes indeed, hence my question on python-dev...

Chris

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


Re: throwing exceptions from csv.DictReader or even csv.reader

2010-07-05 Thread Peter Otten
Tim wrote:

 Csv is a very common format for publishing data as a form of primitive
 integration. It's an annoyingly brittle approach, so I'd like to
 ensure that I capture errors as soon as possible, so that I can get
 the upstream processes fixed, or at worst put in some correction
 mechanisms and avoid getting polluted data into my analyses.
 
 A symptom of several types of errors is that the number of fields
 being interpreted varies over a file (eg from wrongly embedded quote
 strings or mishandled embedded newlines). My preferred approach would
 be to get DictReader to throw an exception when encountering such
 oddities, but at the moment it seems to try to patch over the error
 and fill in the blanks for short lines, or ignore long lines. I know
 that I can use the restval parameter and then check for what's been
 parsed when I get my results back, but this seems brittle as whatever
 I use for restval could legitimately be in the data.
 
 Is there any way to get csv.DictReader to throw and exception on such
 simple line errors, or am I going to have to use csv.reader and
 explicitly check for the number of fields read in on each line?

I think you have to use csv.reader. Untested:

def DictReader(f, fieldnames=None, *args, **kw):
reader = csv.reader(f, *args, **kw)
if fieldnames is None:
fieldnames = next(reader)
for row in reader:
if row:
if len(fieldnames) != len(row):
raise ValueError
yield dict(zip(fieldnames, row))

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


Re: ImportError: DLL load failed: The specified module could notbe found, SWIG, life, etc

2010-07-05 Thread Bill Davy
Thomas Jollans tho...@jollans.com wrote in message 
news:mailman.265.1278342154.1673.python-l...@python.org...
 On 07/05/2010 04:35 PM, Bill Davy wrote:
 I am struggling :-(

 smile!


 I have used SWIG to build a module called SHIP.  So I have a directory
 containing SHIP.py and _SHIP.pyd, as follows:

 [ ...]

 Python appears to find H:\Viper\HostPC\V1\SHIP\Release\_SHIP.pyd but for
 some reason, which I cannot fathom, says DLL load failed.


 Maybe it doesn't mean _SHIP.pyd, but another DLL: maybe _SHIP.pyd
 depends on some other DLL? Since you used SWIG, I'm guessing that you're
 wrapping some other library. Maybe that's what it can't find.


Well, there's no mention of another librarary, and import _SHIP is the 
first (non-comment) statement in SHIP.py
But when I run Dependency Walker against _SHIP.pyd it does say there's a 
missing DLL (WINUSB.DLL) so I suspect I've got to sort that out.



 Can anyone offer me any suggestion where I am going wrong or how to 
 tackle
 this problem?



 Could it be that the Python 2.6 I am running did not use the same 
 compiler
 (VC6) with which I buiult _SHIP.pyd and if so, is there a way round this
 without moving on from VC6?


 Shouldn't be a problem, as long as the calling convention hasn't change,
 which it hasn't. If you're on a 64-bit system there might be a problem
 there with Python and some DLLs being built for different architectures?

Yep, all for the same architetcure.  I suspect it's a dependency problem. 
Oh well.


 Cheers,
 Thomas



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


Re: OT Komodo Edit, line selection gutter is one pixel wide?

2010-07-05 Thread Eric Promislow
On Jul 1, 9:39 am, John Doe j...@usenetlove.invalid wrote:
 Is there a way to increase the line selection gutter width? It
 seems to be only one pixel wide. In other words... When I single
 click on the left side of the line, in order to automatically
 select the line, the pointer must be in a precise single pixel
 location immediately to the left of the line. Or am I doing
 something wrong?

 Thanks.

 By the way... I can see that clicking and dragging to select
 multiple lines can be done somewhere in the space of the first
 character on the lines, but I am talking about single clicking to
 select the single line.

You can easily do this with a Komodo macro.  First you get a reference
to the current buffer like so.  In JS:

var view = ko.views.manager.currentView;
var scimoz = view.scimoz;  // the editor

In Python code:

currentView = components.classes[@activestate.com/koViewService;1].\
 getService(Components.interfaces.koIViewService).currentView
view =
currentView.QueryInterface(Components.interfaces.koIScintillaView)
scimoz = view.scimoz

To get the current width of the line-selection margin:

oldValue = scimoz.getMarginWidth(2)  # Margin #2, width given in
pixels

To set a new value:

scimoz.setMarginWidth(2, newValue)  # 4 looks like a good value

There is no boundary between the breakpoint margin (1) and the line-
selection
margin.

If you want this behaviour in general, you can write a post-file-open
macro that
will set the margin after a file is opened.  You currently can't write
a post-file-open trigger in Python, (see bug 
http://bugs.activestate.com/show_bug.cgi?id=45265)

Hope this helps,

Eric Promislow
Komodo Team Member

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


Re: Python as a scripting language. Alternative to bash script?

2010-07-05 Thread Tim Harig
On 2010-07-05, Lawrence D'Oliveiro l...@geek-central.gen.new_zealand wrote:
 In message op.ve06nlvia8n...@gnudebst, Rhodri James wrote:
 Classic Unix programming is a matter of stringing a bunch of tools
 together with pipes to get the output you want.  This isn't a great
 paradigm for GUIs (not without tweaking that hasn't really been done), but
 then again it was never meant to be.

 I???ve never come across any system where you could string together multiple 
 GUI apps, or even multiple GUI operations in the same app, in any sensible 
 or effective way at all. GUIs just aren???t designed to work that way.

You can if they are designed to be used externally.  COM is an execellent
example of this as is script-fu and any number of other technologies
that allow external access to the subroutines or automation capability
of a GUI application.  The problem is not that it cannot be done; but,
that it must be explicilty designed to be used this way.

I have worked with complex business process automation centered around
Excel and I have automated some really ugly AJAX style web based
applications that would only work inside of IE6 by accessing IE through
its COM interface.

 The command line (or scripting, the difference isn???t that important) 
 remains 
 the only workable way to string together complex combinations of simpler 
 operations.

The difference is that it is almost always possible to automate using
text based applications, even when the author of the software never
designed the software to be scripted.  Text based IO streams are easy
to capture and manipulate.  Automating GUI applications requires interal
access to the program through some kind of interface and, ideally, decent
documention of the interface, something that is missing from many, if
not most, GUIs.  Anything else relies on ugly and, generally fragile,
mechanisms to intercept the programs output and send event triggers to
the application.  The recent thread to automate Minesweeper by processing
its screenshot is an example of this.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Confusion over etree.ElementTree.Element.getiterator

2010-07-05 Thread Terry Reedy

On 7/5/2010 6:40 AM, Ben Sizer wrote:


Admittedly, it's three clicks away from the library docs on docs.python.org.

http://effbot.org/zone/element.htm#xml-namespaces


Hopefully someone will see fit to roll this important documentation
into docs.python.org before the next release... oops, too late. ;)


Not too late for next release. Open a doc issue with as specific a 
suggestion as possible.


It's one of those things that's easy to fix when you know what the
problem is. Unfortunately it makes the examples a bit awkward. The
example on http://docs.python.org/library/xml.etree.elementtree.html
opens up an xhtml file and reads a p tag within a body tag, but
the xhtml specification (http://www.w3.org/TR/xhtml1/#strict) states
that 'The root element of the document must contain an xmlns
declaration for the XHTML namespace'. Therefore I don't see how the
example Python code given could work on a proper xhtml file, given
that there should always be a namespace in effect but the code doesn't
allow for it.

That's my excuse anyway! :)



--
Terry Jan Reedy

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


Re: SyntaxError not honoured in list comprehension?

2010-07-05 Thread jmfauth
Thank you all for the discussion and the explanations.

 Mark Dickinson

I toyed a littled bit this afternoon and I wrote a colouriser
(British spelling?) with the tokenize module. It is quite
simple and easy.

BTW, if I understand correctly the module tokenize import
the module token. So your example becomes:

 from cStringIO import StringIO
 import tokenize
 for tok in tokenize.generate_tokens(StringIO(print9.0).readline):
print tokenize.tok_name[tok[0]], tok[1]

NAME print9
NUMBER .0
ENDMARKER

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


Re: Python 3 put-downs: What's the point?

2010-07-05 Thread Terry Reedy

On 7/4/2010 9:20 PM, CM wrote:

On Jul 4, 7:14 pm, Terry Reedytjre...@udel.edu  wrote:




I think there's a good point to Python 3 put-downs (if I take put-down
to mean generally reasonable criticism, which is what I've read here
recently, and not trolling).  And that is simply to register
dissent.


But dissent from what?

Dissent from something obviously true?
(like 'Pythonx.y is useful to some people')

Dissent from something obvious false, that no one has said?
(like 'Everyone should switch to Pythonx.y')


Any online group is an opportunity to register dissent in a way that
is public, open, immediate, interactive, and will (probably) be
preserved for historians to check.  The fact is, some people have
gripes with Python 3; they are letting it be known.


I have several 'gripes' with 2.7 and it is currently useless to me. 
Should I let them be known? How many times?



 If no one did,
there could be no later time at which people could look back and know
what the reaction was to its introduction--it would just be a blank.
Aren't opinions that dissent from the prevailing ones important to
register, whether one thinks they are right or wrong?


Do you agree with me that the same criteria for gripe legitimacy should 
be applied equally to all Python versions (even if we should disagree on 
what those criteria should be)?


--
Terry Jan Reedy

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


Re: The real problem with Python 3 - no business case for conversion (was I strongly dislike Python 3)

2010-07-05 Thread Terry Reedy

On 7/5/2010 2:56 AM, John Nagle wrote:

On 7/4/2010 10:44 PM, Terry Reedy wrote:



I you have any other ideas about other top blockers, please share them.


The Twisted team has a list of what they need:

http://stackoverflow.com/questions/172306/how-are-you-planning-on-handling-the-migration-to-python-3;


* Zope Interface
* PyCrypto
* PyOpenSSL
* PyGTK


Good start. Now what is blocking those four?
Lack of developer interest/time/ability?
or something else that they need?

--
Terry Jan Reedy

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


Re: Python as a scripting language. Alternative to bash script?

2010-07-05 Thread Emile van Sebille

On 7/5/2010 11:02 AM Tim Harig said...

 Automating GUI applications requires interal
access to the program through some kind of interface and, ideally, decent
documention of the interface, something that is missing from many, if
not most, GUIs.  Anything else relies on ugly and, generally fragile,
mechanisms to intercept the programs output and send event triggers to
the application.


I've been doing the 'anything else...' stuff for years now without 
issue, so ugly, yes, but fragile, not really.


Unless you let users on the same machine...

Emile



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


Re: The real problem with Python 3 - no business case for conversion (was I strongly dislike Python 3)

2010-07-05 Thread Terry Reedy

On 7/5/2010 6:04 AM, David Cournapeau wrote:

On Mon, Jul 5, 2010 at 12:44 PM, Terry Reedytjre...@udel.edu  wrote:

[snip]


I think numpy will work for 3.1 as well


If numpy were released today for 3.1 (or even anytime before 3.2), that 
would be great. It would let those waiting for it that it is real and 
that they can go ahead on their ports.


Part of the reason for the 3.2 core-change moratorium was to let 
3rd-party packages target 3.2 by working with 3.1. If they finish and 
release sooner (as some have), even better. Unless they depend on 
something that changes in the stdlib, porting for one should pretty much 
be porting for both.



(I don't know about 3.0, but
my understanding is that there is no point into even looking at that
release).


Agreed.


--
Terry Jan Reedy

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


vidio*****

2010-07-05 Thread eslam
http://www.kavalec.com/thisisislam.swf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3 put-downs: What's the point?

2010-07-05 Thread Tim Chase

On 07/05/2010 02:50 AM, Gregor Horvath wrote:

Am Sun, 04 Jul 2010 18:51:54 -0500
schrieb Tim Chasepython.l...@tim.thechases.com:


I think it's the same venting of frustration that caused veteran
VB6 developers to start calling VB.Net Visual Fred -- the
language was too different and too non-backwards-compatible.



VB6 -  VB.NET and Python 2 -  3 is not a valid comparison.

VB6 and VB.NET are totally different languages and technologies, with
some similarity in syntax. This is not true for Python 2-3.
This is an healthy organic language growth, not an abandon of a
language.


The quintessential example is Py3's breaking of Hello World. 
It's a spectrum of language changes -- Visual Fred just happens 
to be MUCH further down the same spectrum having more dramatic 
changes.  Only a subset of $OLD_VER (whether Py2 or VB6) code 
will run unmodified under $NEW_VER (whether Py3 or VB.Net).  It 
just happens that the subset for Python is considerably larger 
than the subset for VB (and Python's conversion tools seem a 
little more useful than VB's, IMHO).  IIRC, neither raw VB6 nor 
Py2 byte-code will run raw in the new environment (old VB .exe 
files don't make use of .Net libraries/CLR, nor do Py2 .pyc files 
run under Py3) so a project-rebuild is a minimum (though in Py3, 
s/minimum/negligible/) requirement.


A little defensive coding in $OLD_VER also helps, and here I'd 
say Python developers had a MUCH longer lead-time to understand 
scope  magnitude of the coming changes; VB6 developers (former 
self included) had VB.Net foisted on them with much less 
heralding about the areas-of-breakage.


I'm very much +0 on Py3...it doesn't impact my life yet and it's 
not a regular part of my coding, but the changes I've seen are 
good for the language and the future of Python.  But 
breaking-changes freak some folks out, leading to the put-downs 
referenced by the OP.  As a former VB6 developer, the shift to 
VB.Net was enough to send me packing.  The shift from Py2 to Py3 
will be bumpy, but not enough to lose me as a developer.


-tkc






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


Re: The real problem with Python 3 - no business case for conversion (was I strongly dislike Python 3)

2010-07-05 Thread Kevin Walzer

On 7/5/10 2:56 AM, John Nagle wrote:


* PyCrypto
* PyOpenSSL


These, and Mark Pilgrim's feedparser, need to be 3.x compatible before I 
can think about Python 3.x.


--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: SyntaxError not honoured in list comprehension?

2010-07-05 Thread Mark Dickinson
On Jul 5, 7:12 pm, jmfauth wxjmfa...@gmail.com wrote:
 BTW, if I understand correctly the module tokenize import
 the module token. So your example becomes:

  from cStringIO import StringIO
  import tokenize
  for tok in tokenize.generate_tokens(StringIO(print9.0).readline):

         print tokenize.tok_name[tok[0]], tok[1]

Ah yes;  you're right.  Thanks!

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


Re: Python 2.7 released

2010-07-05 Thread Martineau
On Jul 5, 1:12 am, Benjamin Kaplan benjamin.kap...@case.edu wrote:
 On Sun, Jul 4, 2010 at 7:58 PM, John Machin sjmac...@lexicon.net wrote:
  On Jul 5, 12:27 pm, Martineau ggrp2.20.martin...@dfgh.net wrote:
  On Jul 4, 8:34 am, Benjamin Peterson benja...@python.org wrote:

   On behalf of the Python development team, I'm jocund to announce the 
   second
   release candidate of Python 2.7.

   Python 2.7 will be the last major version in the 2.x series. However, it 
   will
   also have an extended period of bugfix maintenance.

   2.7 includes many features that were first released in Python 3.1. The 
   faster io
   module, the new nested with statement syntax, improved float repr, set 
   literals,
   dictionary views, and the memoryview object have been backported from 
   3.1. Other
   features include an ordered dictionary implementation, unittests 
   improvements, a
   new sysconfig module, auto-numbering of fields in the str/unicode format 
   method,
   and support for ttk Tile in Tkinter.  For a more extensive list of 
   changes in
   2.7, seehttp://doc.python.org/dev/whatsnew/2.7.htmlorMisc/NEWSin the 
   Python
   distribution.

   To download Python 2.7 visit:

        http://www.python.org/download/releases/2.7/

   2.7 documentation can be found at:

        http://docs.python.org/2.7/

   This is a production release and should be suitable for all libraries and
   applications.  Please report any bugs you find, so they can be fixed in 
   the next
   maintenance releases.  The bug tracker is at:

        http://bugs.python.org/

   Enjoy!

   --
   Benjamin Peterson
   Release Manager
   benjamin at python.org
   (on behalf of the entire python-dev team and 2.7's contributors)

  Benjamin (or anyone else), do you know where I can get the Compiled
  Windows Help file -- python27.chm -- for this release? In the past
  I've been able to download it from the Python web site, but have been
  unable to locate it anywhere for this new release. I can't build it
  myself because I don't have the Microsoft HTML help file compiler.

  Thanks in advance.

  If you have a Windows box, download the .msi installer for Python 2.7
  and install it. The chm file will be in C:\Python27\Doc (if you choose
  the default installation directory). Otherwise ask a friendly local
  Windows user for a copy.
  --

 Or you can just use 7-zip or cabextract on the MSi. Saves you from
 having to uninstall it later, and it works on non-Windows machines.

Perhaps it's hidden somewhere, but I couldn't find the .chm help file
in the python-2.7.msi file using 7-zip, nor saw anything that looked
like a Doc folder embedded within it -- so I doubt installing it on a
Windows machine would work any better.

I'd like to view the contents of the help file without actually
installing the release which would wipe out any currently installed
version (I'm one of those rare people who actually reads manuals
*before* using or installing most things.)

So my original question stands -- where can one get the Windows Help
file for v2.7?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The real problem with Python 3 - no business case for conversion (was I strongly dislike Python 3)

2010-07-05 Thread D'Arcy J.M. Cain
On Mon, 05 Jul 2010 14:42:13 -0400
Terry Reedy tjre...@udel.edu wrote:
 Good start. Now what is blocking those four?
 Lack of developer interest/time/ability?
 or something else that they need?

How about a basic how-to document?  I maintain PyGreSQL and would like
to move it to 3.x right now but I don't even know what the issues are.
I can see on the site the 2.x documents and the 3.x documents for
extending with C modules and I can read both from end to end but that
hits the time issue above.  If there was a relatively simple document
that showed what needed to be changed in the C code we could get
started on the transition sooner.

Or is there no change at the C level?  That would make things easy.

-- 
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: Python 2.7 released

2010-07-05 Thread Alexander Kapps

Martineau wrote:


Perhaps it's hidden somewhere, but I couldn't find the .chm help file
in the python-2.7.msi file using 7-zip, nor saw anything that looked
like a Doc folder embedded within it -- so I doubt installing it on a
Windows machine would work any better.


I don't know much about the .msi format or how 7-Zip handles it, but 
on my XP box, 7-Zip lists a python sub-archive (a 7-Zip 
compound). Within is the python27.chm

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


Re: Python 3 put-downs: What's the point?

2010-07-05 Thread CM
On Jul 5, 2:33 pm, Terry Reedy tjre...@udel.edu wrote:
 On 7/4/2010 9:20 PM, CM wrote:

  On Jul 4, 7:14 pm, Terry Reedytjre...@udel.edu  wrote:

  I think there's a good point to Python 3 put-downs (if I take put-down
  to mean generally reasonable criticism, which is what I've read here
  recently, and not trolling).  And that is simply to register
  dissent.

 But dissent from what?

 Dissent from something obviously true?
 (like 'Pythonx.y is useful to some people')

 Dissent from something obvious false, that no one has said?
 (like 'Everyone should switch to Pythonx.y')

I was thinking more like dissent from something that is not obviously
true or false, but a matter of debate, like some of the decisions
behind Python 3 itself or how the transition is being managed.  I got
the sense that was about where the complaints lie.  Some of the
responses to those complaints were educational to me, so I didn't mind
reading the exchanges.

  Any online group is an opportunity to register dissent in a way that
  is public, open, immediate, interactive, and will (probably) be
  preserved for historians to check.  The fact is, some people have
  gripes with Python 3; they are letting it be known.

 I have several 'gripes' with 2.7 and it is currently useless to me.
 Should I let them be known? How many times?

Maybe you should; maybe it can be constructive criticism to developers
or can jog someone to tell you something that you didn't know.  How
many times?  Once, maybe twice.  I agree one can overdo it, and maybe
you've read more of the gripes than I have and it seems repetitive by
now.

   If no one did,
  there could be no later time at which people could look back and know
  what the reaction was to its introduction--it would just be a blank.
  Aren't opinions that dissent from the prevailing ones important to
  register, whether one thinks they are right or wrong?

 Do you agree with me that the same criteria for gripe legitimacy should
 be applied equally to all Python versions (even if we should disagree on
 what those criteria should be)?

I think so, sure.

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


Re: SMTPHandler and Unicode

2010-07-05 Thread norbert
  Ouch. Implicit encoding sounds like a bad behaviour.

Looking at the FileHandler source (
http://svn.python.org/view/python/trunk/Lib/logging/__init__.py?view=markup
) : the utf-8 encoding is a fallback. But *FileHandler family let you
specify the encoding you want, so that's OK I think.

But SMTPHandler does not have such a thing it sends its email with :
msg = From: %s\r\nTo: %s\r\nSubject: %s\r\nDate: %s\r\n\r\n%s % (
self.fromaddr,
,.join(self.toaddrs),
self.getSubject(record),
formatdate(), msg)
...
smtp.sendmail(from,to,msg)

And there is no encoding in all this.

It seems pretty dangerous to me (so my first post) because your
application will work without any problem with a FileHandler and the
day you'll decide to send email in case of serious problem, it will
crash with a UnicodeError. I can't see any workaround, except by
subclassing SMTPHandler's emit method to be unicode-aware or at least
URF-8 aware.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The real problem with Python 3 - no business case for conversion (was I strongly dislike Python 3)

2010-07-05 Thread Martin v. Loewis
Am 05.07.2010 22:30, schrieb D'Arcy J.M. Cain:
 On Mon, 05 Jul 2010 14:42:13 -0400
 Terry Reedy tjre...@udel.edu wrote:
 Good start. Now what is blocking those four?
 Lack of developer interest/time/ability?
 or something else that they need?
 
 How about a basic how-to document?  I maintain PyGreSQL and would like
 to move it to 3.x right now but I don't even know what the issues are.
 I can see on the site the 2.x documents and the 3.x documents for
 extending with C modules and I can read both from end to end but that
 hits the time issue above.  If there was a relatively simple document
 that showed what needed to be changed in the C code we could get
 started on the transition sooner.
 
 Or is there no change at the C level?  That would make things easy.

If somebody would move that into a narrative form, I'd be happy to
list the changes I know of, and the approaches I took to make C modules
work on both 2.x and 3.x (actually, I did the port of psycopg2, so I
expect PyGreSQL might be similar).

However, I'm not willing to maintain such a document - I have too many
projects already, and English is not my native language.

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


Re: Very odd output from subprocess

2010-07-05 Thread m
On Jul 1, 12:42 am, Nobody nob...@nowhere.com wrote:
 On Wed, 30 Jun 2010 21:12:12 -0700, m wrote:
  If I add the line:
       for l in line: print ord(l),'\t',l
  after the first readline, I get the following:

  27          
  91         [
  48         0
  48         0
  109        m
  27          
  91         [
  51         3
  55         7
  109        m

  before the codes begin for the string as it appears if I just print
  it.  So, what is this sequence?  They seem like some sort of escape
  codes, I've never seen this before at all.

 ESC[00m is the ANSI code to reset attributes to their default state.
 ESC[37m is the ANSI code to set the foreground color to white.

  Can anyone enlighten me as to what is going on?

  And, can I safely strip sets of 5 characters from the front as long as
  they start with Escape (27)?

 No, escape sequences can be of arbitrary length.


It turned out that make was aliased to colourmake, and the escape
codes were being
put in there for beautifying the console output.  Sorry to bother
everyone.
-- 
http://mail.python.org/mailman/listinfo/python-list


using the netflix api

2010-07-05 Thread member thudfoo
Has anyone had success using the netflix api with Netflix.py?
Especially getting access?
-- 
http://mail.python.org/mailman/listinfo/python-list


Getting pyparsing to backtrack

2010-07-05 Thread John Nagle

  I'm working on street address parsing again, and I'm trying to deal
with some of the harder cases.

  Here's a subparser, intended to take in things like N MAIN and 
SOUTH, and break out the directional from street name.


Directionals =  ['southeast', 'northeast', 'north', 'northwest',
 'west', 'east', 'south', 'southwest', 'SE', 'NE', 'N', 'NW',
 'W', 'E', 'S', 'SW']

direction = Combine(MatchFirst(map(CaselessKeyword, directionals)) + 
Optional(.).suppress())


streetNameParser = Optional(direction.setResultsName(predirectional)) 
+ Combine(OneOrMore(Word(alphanums)),

adjacent=False, joinString= ).setResultsName(streetname)



This parses something like N WEBB fine; N is the predirectional,
and WEBB is the street name.

SOUTH (which, when not followed by another word, is a streetname,
not a predirectional), raises a parsing exception:

 Street address line parse failed for SOUTH : Expected W:(abcd...)
  (at  char 5), (line:1, col:6)

The problem is that direction matched SOUTH, and even though
direction is within an Optional and followed by another word,
the parser didn't back up when it hit the end of the expression
without satisfying the OneOrMore clause.

Pyparsing does some backup, but I'm not clear on how much,
or how to force it to happen.  There's some discussion at
http://www.mail-archive.com/python-list@python.org/msg169559.html;.
Apparently the Or operator will force some backup, but it's not
clear how much lookahead and backtracking is supported.

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


Re: The real problem with Python 3 - no business case for conversion (was I strongly dislike Python 3)

2010-07-05 Thread John Nagle

On 7/5/2010 12:35 PM, Kevin Walzer wrote:

On 7/5/10 2:56 AM, John Nagle wrote:


* PyCrypto
* PyOpenSSL


These, and Mark Pilgrim's feedparser, need to be 3.x compatible before I
can think about Python 3.x.


There's been an attempt to port feedparser to 3.0, but
that needed a port of BeautifulSoup:

http://code.google.com/p/feedparser/issues/detail?id=215

They also had some problems with chardet.

John Nagle

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


Re: The real problem with Python 3 - no business case for conversion (was I strongly dislike Python 3)

2010-07-05 Thread Philip Semanchuk


On Jul 5, 2010, at 4:30 PM, D'Arcy J.M. Cain wrote:


On Mon, 05 Jul 2010 14:42:13 -0400
Terry Reedy tjre...@udel.edu wrote:

Good start. Now what is blocking those four?
Lack of developer interest/time/ability?
or something else that they need?


How about a basic how-to document?  I maintain PyGreSQL and would like
to move it to 3.x right now but I don't even know what the issues are.
I can see on the site the 2.x documents and the 3.x documents for
extending with C modules and I can read both from end to end but that
hits the time issue above.  If there was a relatively simple document
that showed what needed to be changed in the C code we could get
started on the transition sooner.

Or is there no change at the C level?  That would make things easy.


There are definitely changes at the C level.

I ported two pure C extensions from 2 to 3 and was even able to keep a  
single C codebase. I'd be willing to contribute my experiences to a  
document somewhere. (Is there a Wiki?) I would have found such a  
document very helpful before I started porting.


Cheers
Philip

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


Re: The real problem with Python 3 - no business case for conversion (was I strongly dislike Python 3)

2010-07-05 Thread Chris Rebert
On Mon, Jul 5, 2010 at 3:38 PM, Philip Semanchuk phi...@semanchuk.com wrote:
 On Jul 5, 2010, at 4:30 PM, D'Arcy J.M. Cain wrote:
 On Mon, 05 Jul 2010 14:42:13 -0400
 Terry Reedy tjre...@udel.edu wrote:
 Good start. Now what is blocking those four?
 Lack of developer interest/time/ability?
 or something else that they need?

 How about a basic how-to document?  I maintain PyGreSQL and would like
 to move it to 3.x right now but I don't even know what the issues are.
 I can see on the site the 2.x documents and the 3.x documents for
 extending with C modules and I can read both from end to end but that
 hits the time issue above.  If there was a relatively simple document
 that showed what needed to be changed in the C code we could get
 started on the transition sooner.

 Or is there no change at the C level?  That would make things easy.

 There are definitely changes at the C level.

 I ported two pure C extensions from 2 to 3 and was even able to keep a
 single C codebase. I'd be willing to contribute my experiences to a document
 somewhere. (Is there a Wiki?)

Indeed there is: http://wiki.python.org/moin/

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


Python Embedding Importing relative modules

2010-07-05 Thread moerchendiser2k3
Hi all,

I have a serious problem I haven't solved yet, hope one of you can
help me. The first thing is, I embedded Python into my app and I
execute several scripts in this environment.

The problem is, the scripts don't import modules from their relative
path. I guess this is related to the sys.path ['',...] and the current
working directory which is set to the directory of my host
application.

I could set that path manually, but all the scripts might be stored in
different locations. So now I try to find a way to handle that. Any
suggestions?

A solution would be, that each script, appends its own directory to
the system path, but this might lead to problems. Imagine all of them
have a module called 'foo.py' and its not the same. This might lead to
name conflicts, wouldnt it?

Btw, I found a source code line in the documentation, where I should
really get rid of the ['', ...] path in the system path due to
security reasons.

import sys; sys.path.pop(0)


Hope one of you can help me out here. Really thanks!!

Bye,

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


Re: What is the name of the name space I am in?

2010-07-05 Thread Gregory Ewing

On 07/05/2010 11:07 AM, Anthra Norell wrote:


I try to use new.new.classobj (name, baseclass, dict) and have no clue
what the dict of the current name space is.


Are you sure that's what you really want to know? The
'dict' argument to classobj() defines the attributes
that you want the new class to have. It's not meant
to be the namespace in which the code creating the
class is executing.

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


Another Regexp Question

2010-07-05 Thread andrew cooke

As ever, I guess it's most likely I've misunderstood something, but in
Python 2.6 lookback seems to actually be lookahead.  All the following
tests pass:

from re import compile

assert compile('(a)b(?=(?(2)x|c))(c)').match('abc')
assert not compile('(a)b(?=(?(2)b|x))(c)').match('abc')
assert compile('(a)b(?=(?(1)c|x))(c)').match('abc')

assert compile('(a)b(?=(?(2)x|c))(c)').match('abc')
assert not compile('(a)b(?=(?(2)b|x))(c)').match('abc')
assert compile('(a)b(?=(?(1)c|x))(c)').match('abc')

But it seems to me that the first block should fail, because they
check the match *before* the point in question.

Note that without group references these work as I would expected:

assert compile('(a)b(?=b)(c)').match('abc')
assert not compile('(a)b(?=c)(c)').match('abc')

assert not compile('(a)b(?=b)(c)').match('abc')
assert compile('(a)b(?=c)(c)').match('abc')

in which lookback does indeed lookback (note the asymmetry, while the
first examples were symmetrical).

What am I missing this time? :o(

Thanks,
Andrew

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


Re: Python 2.7 released

2010-07-05 Thread Steven D'Aprano
On Mon, 05 Jul 2010 12:59:00 -0700, Martineau wrote:

 I'd like to view the contents of the help file without actually
 installing the release which would wipe out any currently installed
 version (I'm one of those rare people who actually reads manuals
 *before* using or installing most things.)

When you say wipe out any currently installed version, do you mean an 
older version of 2.7, or an older version such as 2.6, 2.5, 2.4, ... ?

If the first, I don't know of any simple way to keep multiple 
installations with the same major and minor version number (e.g. 2.7.0a 
and 2.7.0.b). Sorry.

But if you mean the second, that you don't want to over-write 2.6, I'd be 
shocked if the Python installer does that. Doesn't it install Python to 
something like C:\Programs\Pythonversion ?

Performing a source install under Linux, by default existing versions 
remain in place, but there's a soft link python which points to the 
most recent version. Doing a regular install over-writes the soft link. 
But there's an altinstall option which leaves the link untouched, so 
(for example) I have python - python 2.5 while still having other 
versions installed and accessible directly with python2.6, python2.4 etc. 
I would be stunned if Windows didn't support an equivalent to altinstall.

Are there any Windows users out there who can confirm that the installer 
does or doesn't leave existing versions in place?


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


Re: Python 3 put-downs: What's the point?

2010-07-05 Thread Steven D'Aprano
On Mon, 05 Jul 2010 14:32:13 -0500, Tim Chase wrote:

 On 07/05/2010 02:50 AM, Gregor Horvath wrote:
 Am Sun, 04 Jul 2010 18:51:54 -0500
 schrieb Tim Chasepython.l...@tim.thechases.com:

 I think it's the same venting of frustration that caused veteran VB6
 developers to start calling VB.Net Visual Fred -- the language was
 too different and too non-backwards-compatible.


 VB6 -  VB.NET and Python 2 -  3 is not a valid comparison.

 VB6 and VB.NET are totally different languages and technologies, with
 some similarity in syntax. This is not true for Python 2-3. This is an
 healthy organic language growth, not an abandon of a language.
 
 The quintessential example is Py3's breaking of Hello World. It's a
 spectrum of language changes -- Visual Fred just happens to be MUCH
 further down the same spectrum having more dramatic changes.  Only a
 subset of $OLD_VER (whether Py2 or VB6) code will run unmodified under
 $NEW_VER (whether Py3 or VB.Net).

The same holds for older versions of Python to Python 2.5 or 2.6, it's 
just that you have to work harder to find the incompatibilities. Try 
running this under later versions:

[st...@sylar ~]$ python2.0
Python 2.0.1 (#1, Jan 14 2010, 15:43:17)
[GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2
Type copyright, credits or license for more information.
 None = Hello world
 print None
Hello world


 It just happens that the subset for
 Python is considerably larger than the subset for VB (and Python's
 conversion tools seem a little more useful than VB's, IMHO).  IIRC,
 neither raw VB6 nor Py2 byte-code will run raw in the new environment
 (old VB .exe files don't make use of .Net libraries/CLR, nor do Py2 .pyc
 files run under Py3) 

Python byte-code has never been compatible across minor version numbers, 
let alone major ones.



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


Re: Shared object access problems

2010-07-05 Thread Tim Johnson
John Nagle wrote:

 On 7/4/2010 6:36 PM, Philip Semanchuk wrote:
 hi Tim,
 This seems more likely to be a MySQLdb problem than a Python one. 
Have
 you considered asking in the MySQLdb forums?

 On Jul 4, 2010, at 7:46 PM, Tim Johnson wrote:

 Using python 2.6.4 on slackware 13.1
 I have MySQLdb 'by hand', that is: by
 1)downloading MySQL-python-1.2.3c1.tar.gz
 2)unzipping tarfile
 3)running python setup.py build
 4)running python setup.py install

 The build and install seemed to proceded without error,
 but upon invoking the interpreter and running
 import MySQLdb
 I get the following ImportError:
 ##
 Traceback (most recent call last):
 File stdin, line 1, in module
 File build/bdist.linux-i686/egg/MySQLdb/__init__.py,
 line 19, in module
 File build/bdist.linux-i686/egg/_mysql.py,
 line 7, in module
 File build/bdist.linux-i686/egg/_mysql.py,
 line 6, in __bootstrap__
 ImportError: libmysqlclient_r.so.15:
 cannot open shared object file: No such file or directory
 
 Did you install the development libraries for MySQL first?
 Those are needed to build MySQLdb yourself.
 
 John Nagle
By that I think you mean libmysqlclient_r.so* and so forth, if so, 
yes.
The question has become moot, as I recently did an upgrade from
slack 13.0 to 13.1, and I've decided to procede with a clean install.
So I'm dropping this inquiry and I'll keep my development on ubuntu
for the time being. 
thanks for the help

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


Re: Python 2.7 released

2010-07-05 Thread David Robinow
On Mon, Jul 5, 2010 at 8:15 PM, Steven D'Aprano
st...@remove-this-cybersource.com.au wrote:
 On Mon, 05 Jul 2010 12:59:00 -0700, Martineau wrote:

 I'd like to view the contents of the help file without actually
 installing the release which would wipe out any currently installed
 version (I'm one of those rare people who actually reads manuals
 *before* using or installing most things.)
...
 Are there any Windows users out there who can confirm that the installer
 does or doesn't leave existing versions in place?
 The installer does leave existing versions in place. I have no idea
what the OP is referring to.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Another Regexp Question

2010-07-05 Thread MRAB

andrew cooke wrote:

As ever, I guess it's most likely I've misunderstood something, but in
Python 2.6 lookback seems to actually be lookahead.  All the following
tests pass:

from re import compile

assert compile('(a)b(?=(?(2)x|c))(c)').match('abc')
assert not compile('(a)b(?=(?(2)b|x))(c)').match('abc')
assert compile('(a)b(?=(?(1)c|x))(c)').match('abc')

assert compile('(a)b(?=(?(2)x|c))(c)').match('abc')
assert not compile('(a)b(?=(?(2)b|x))(c)').match('abc')
assert compile('(a)b(?=(?(1)c|x))(c)').match('abc')

But it seems to me that the first block should fail, because they
check the match *before* the point in question.


Both the first and third should fail, but they pass.


Note that without group references these work as I would expected:

assert compile('(a)b(?=b)(c)').match('abc')
assert not compile('(a)b(?=c)(c)').match('abc')

assert not compile('(a)b(?=b)(c)').match('abc')
assert compile('(a)b(?=c)(c)').match('abc')

in which lookback does indeed lookback (note the asymmetry, while the
first examples were symmetrical).

What am I missing this time? :o(


Nothing. It's a bug. :-(
--
http://mail.python.org/mailman/listinfo/python-list


Re: The real problem with Python 3 - no business case for conversion (was I strongly dislike Python 3)

2010-07-05 Thread Philip Semanchuk


On Jul 5, 2010, at 6:41 PM, Chris Rebert wrote:

On Mon, Jul 5, 2010 at 3:38 PM, Philip Semanchuk  
phi...@semanchuk.com wrote:

On Jul 5, 2010, at 4:30 PM, D'Arcy J.M. Cain wrote:

On Mon, 05 Jul 2010 14:42:13 -0400
Terry Reedy tjre...@udel.edu wrote:

Good start. Now what is blocking those four?
Lack of developer interest/time/ability?
or something else that they need?


How about a basic how-to document?  I maintain PyGreSQL and would  
like
to move it to 3.x right now but I don't even know what the issues  
are.

I can see on the site the 2.x documents and the 3.x documents for
extending with C modules and I can read both from end to end but  
that
hits the time issue above.  If there was a relatively simple  
document

that showed what needed to be changed in the C code we could get
started on the transition sooner.

Or is there no change at the C level?  That would make things easy.


There are definitely changes at the C level.

I ported two pure C extensions from 2 to 3 and was even able to  
keep a
single C codebase. I'd be willing to contribute my experiences to a  
document

somewhere. (Is there a Wiki?)


Indeed there is: http://wiki.python.org/moin/


Thanks. I don't want to appear ungrateful, but I was hoping for  
something specific to the 2-to-3 conversion. I guess someone has to  
start somewhere...







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


Re: Another Regexp Question

2010-07-05 Thread andrew cooke
On Jul 5, 8:56 pm, MRAB pyt...@mrabarnett.plus.com wrote:
 andrew cooke wrote:
  What am I missing this time? :o(
 Nothing. It's a bug. :-(

Sweet :o)

Thanks - do you want me to raise an issue or will you?

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


Re: Another Regexp Question

2010-07-05 Thread MRAB

andrew cooke wrote:

On Jul 5, 8:56 pm, MRAB pyt...@mrabarnett.plus.com wrote:

andrew cooke wrote:

What am I missing this time? :o(

Nothing. It's a bug. :-(


Sweet :o)

Thanks - do you want me to raise an issue or will you?


You found it. You can have the pleasure.
--
http://mail.python.org/mailman/listinfo/python-list


Re: markmin 0.1

2010-07-05 Thread Chris Rebert
On Mon, Jul 5, 2010 at 4:56 PM, Massimo Di Pierro
mdipie...@cs.depaul.edu wrote:
 Markmin is a wiki markup language
 implemented in less than 100 lines of code (one file, no dependencies)
 easy to read
 secure
 support table, ul, ol, code
 support html5 video and audio elements
 can align images and resize them
 CSS friendly (can specify class for tables and code elements)
 can add anchors anywhere
 does not use _ for markup (since it creates odd behavior)
 automatically links urls
 fast
 with tests

Okay, but where can it be downloaded from? You didn't include a link.

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


Re: Python 2.7 released

2010-07-05 Thread Martineau
On Jul 5, 1:31 pm, Alexander Kapps alex.ka...@web.de wrote:
 Martineau wrote:
  Perhaps it's hidden somewhere, but I couldn't find the .chm help file
  in the python-2.7.msi file using 7-zip, nor saw anything that looked
  like a Doc folder embedded within it -- so I doubt installing it on a
  Windows machine would work any better.

 I don't know much about the .msi format or how 7-Zip handles it, but
 on my XP box, 7-Zip lists a python sub-archive (a 7-Zip
 compound). Within is the python27.chm

My mistake -- you're quite right the .chm *is* in the .msi where you
indicated. FWIW I actually did look in that sub-section before posting
yet somehow missed it. Sorry about that and thanks to all involved for
your help.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.7 released

2010-07-05 Thread Martineau
On Jul 5, 5:53 pm, David Robinow drobi...@gmail.com wrote:
 On Mon, Jul 5, 2010 at 8:15 PM, Steven 
 D'Apranost...@remove-this-cybersource.com.au wrote:
  On Mon, 05 Jul 2010 12:59:00 -0700, Martineau wrote:

  I'd like to view the contents of the help file without actually
  installing the release which would wipe out any currently installed
  version (I'm one of those rare people who actually reads manuals
  *before* using or installing most things.)
 ...
  Are there any Windows users out there who can confirm that the installer
  does or doesn't leave existing versions in place?

  The installer does leave existing versions in place. I have no idea
 what the OP is referring to.

Some clarification. I meant installed 2.7 on top of 2.6.x. Doing so
would have interfered with the currently installed version because I
always install Python in the same directory, one named just Python,
to minimize the number of changes I have to make to to other parts of
the system. Some trivial examples are desktop shortcuts I've set up
which point to the commandline version of the interpreter and another
for the help file. I also believe the Windows installer makes registry
changes that also involve paths to the currently installed version,
which again, is something I wanted to avoid until I'm  actually ready
to commit to upgrading.

If there are better ways on Windows to accomplish this, I'd like to
hear about them. I suppose I could use hardlinks or junctions but
they're not well supported on most versions of Windows.

BTW, my original problem -- getting a copy of the Windows format
compiled help file fro v2/7 without installing it has been taken care
by suggestions from other, so this discussion is starting to way off-
topic...

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


Re: Python 2.7 released

2010-07-05 Thread Martin v. Loewis
 Benjamin (or anyone else), do you know where I can get the Compiled
 Windows Help file -- python27.chm -- for this release?

I have now put that file separately on the release page.

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


Re: delegation pattern via descriptor

2010-07-05 Thread kedra marbun
On Jul 5, 3:42 pm, Bruno Desthuilliers bruno.
42.desthuilli...@websiteburo.invalid wrote:
 kedra marbun a écrit :



  i'm confused which part that doesn't make sense?
  this is my 2nd attempt to py, the 1st was on april this year, it was
  just a month, i'm afraid i haven't got the fundamentals right yet. so
  i'm gonna lay out how i got to this conclusion, CMIIW

  **explanation of feeling (0) on my 1st post**
  to me, descriptor is a particular kind of delegation, it takes the job
  of coding the delegation by having a contract with programmers that
  the tree meta operations (get, set, del) on attr are delegated to the
  obj that is bound to the attr
  are we agree that descriptor is a kind of delegation?

  the mechanism that makes descriptor works is in __getattribute__,
  __setattr__, __delattr__ of 'object'  'type'

  now, if i want a single descriptor obj to be delegated to multiple
  tasks, i can't do it since __get__ doesn't get info that can be used
  to determine which task to do
  i must have diff descriptor obj for each task

  class Helper:
     def __init__(self, name):
             self.name = name
     def __get__(self, ins, cls):
             if self.name == 'task0': ...
             elif self.name == 'task1': ...
             else: ...

 Replacing such big switch code with polymorphic dispatch is one of the
   goals (and feature) of OO. This should be:

 class Task0(object):
      def __get__(self, obj, cls):
          # code here

 class Task1(object):
      def __get__(self, obj, cls):
          # code here

 class A(object):
      task0 = Task0()
      task1 = Task1()

 If you have common code to share between TaskO and Task1 then factor it
 out into a base class.

  if __get__ receives the name, then i could do

  class Helper:
     def __get__(self, ins, cls, name):
             ...

  class a:
     task0 = task1 = Helper()

 Yuck.

what's so 'Yuck' about it? ;)
i guess i need a strong stmt: is descriptor a kind of delegation? or
is it not?
* if it is a kind of delegation, then the code that you labeled as
'Yuck' is just a result of applying delegation
what's wrong with delegating multiple tasks to a single obj?

that code is similar to this

class Helper:
def do_this(self, ins): ...
def do_that(self, ins): ...

class a:
delegate = Helper()
def task0(self): self.delegate.do_that(self)
def task1(self): self.delegate.do_this(self)

the diff is that this code manually code the delegation, that's why it
can branches to 2 funcs. while descriptor takes all to __get__,
because it works on more meta lv

* if it's not, then there's nothing to be argued, the name
'descriptor' is perfectly fit: descriptor obj describes attr of class,
with 'describe' translates to: . = del, in py vocabularies. then, to
think a single descriptor obj describing a single attr is acceptable,
it's a common sense
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: delegation pattern via descriptor

2010-07-05 Thread kedra marbun
On Jul 5, 7:49 am, Gregory Ewing greg.ew...@canterbury.ac.nz wrote:
 kedra marbun wrote:
  now, i'm asking another favor, what about the 2nd point in my 1st post?

 Your original post has dropped off my newsscope, so
 you'll have to remind me what the 2nd point was.

 --
 Greg

it's like 'name', it's about info that i think should be passed to
descriptor's __{get|set|delete}__. i wonder what are the reasons for
not passing the class on which the descriptor is attached to, what
pattern is encouraged by this?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting the name of the file that imported current module

2010-07-05 Thread kedra marbun
On Jul 5, 6:29 am, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
 On Sun, 04 Jul 2010 21:05:56 +, Tobiah wrote:
  foo.py:

  import bar
  bar.show_importer()

  output:

  'foo' or 'foo.py' or 'path/to/foo' etc.

  Possible?

 I don't think so. Your question isn't even well-defined. Given three
 modules:

 # a.py
 import b
 import d

 # b.py
 import d

 # c.py
 import a
 import d
 import b
 print d.show_importer()

 and you run c.py, what do you expect d.show_importer() to return?

 And what about from d import show_importer -- does that count as
 importing d?

 Why do you think that a module needs to know what other modules imported
 it? I can't imagine why this would be necessary, what are you intending
 to do with it?

 --
 Steven

i guess he just likes to play things around, entertains his
imagination, no need for practical reason for that
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting the name of the file that imported current module

2010-07-05 Thread kedra marbun
On Jul 5, 4:05 am, Tobiah t...@rcsreg.com wrote:
 foo.py:

 import bar
 bar.show_importer()

 output:

 'foo' or 'foo.py' or 'path/to/foo' etc.

 Possible?

 Thanks,

 Tobiah

if what you mean by 'importer' is the one that really cause py to load
the mod, then why not dynamically set it?

foo.py
--
import bar, sys
if '_importer' not in bar.__dict__: bar._importer =
sys.modules[__name__]

bar.py
--
def show_importer(): return _importer

or

you could borrow space from builtins. i don't know if it breaks any
rule ;)

foo.py
--
def set_importer(mod):
bdict = (__builtins__.__dict__ if __name__ == '__main__' else
__builtins__)
if '_importer' not in bdict:
bdict['_importer'] = {mod : sys.modules[__name__]}
else:
if mod not in bdict:
bdict['_importer'][mod] = sys.modules[__name__]

import bar
set_importer(bar)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting pyparsing to backtrack

2010-07-05 Thread John Nagle

On 7/5/2010 3:19 PM, John Nagle wrote:

  I'm working on street address parsing again, and I'm trying to deal
with some of the harder cases.


The approach below works for the cases given.  The Or operator (^) 
supports backtracking, but Optional() apparently does not.



direction = Combine(MatchFirst(map(CaselessKeyword, directionals)) +
Optional(.).suppress())

streetNameOnly = Combine(OneOrMore(Word(alphanums)), adjacent=False,
joinString= ).setResultsName(streetname)

streetNameParser =
((direction.setResultsName(predirectional) + streetNameOnly)
^ streetNameOnly)



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


Re: delegation pattern via descriptor

2010-07-05 Thread Steven D'Aprano
On Mon, 05 Jul 2010 21:12:47 -0700, kedra marbun wrote:

 On Jul 5, 7:49 am, Gregory Ewing greg.ew...@canterbury.ac.nz wrote:
 kedra marbun wrote:
  now, i'm asking another favor, what about the 2nd point in my 1st
  post?

 Your original post has dropped off my newsscope, so you'll have to
 remind me what the 2nd point was.

 --
 Greg
 
 it's like 'name', it's about info that i think should be passed to
 descriptor's __{get|set|delete}__. i wonder what are the reasons for not
 passing the class on which the descriptor is attached to, what pattern
 is encouraged by this?



Perhaps I'm missing the context, but since the descriptor is passed the 
instance, you can easily get the class with type(self) or self.__class__. 
There's no need to pass the class as a separate argument.



-- 
Steven

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


Re: delegation pattern via descriptor

2010-07-05 Thread Rami Chowdhury
On Monday 05 July 2010 21:10:51 kedra marbun wrote:
 On Jul 5, 3:42 pm, Bruno Desthuilliers bruno.
 
 42.desthuilli...@websiteburo.invalid wrote:
  kedra marbun a écrit :
   i'm confused which part that doesn't make sense?
   this is my 2nd attempt to py, the 1st was on april this year, it was
   just a month, i'm afraid i haven't got the fundamentals right yet. so
   i'm gonna lay out how i got to this conclusion, CMIIW
   
   **explanation of feeling (0) on my 1st post**
   to me, descriptor is a particular kind of delegation, it takes the job
   of coding the delegation by having a contract with programmers that
   the tree meta operations (get, set, del) on attr are delegated to the
   obj that is bound to the attr
   are we agree that descriptor is a kind of delegation?
   
   the mechanism that makes descriptor works is in __getattribute__,
   __setattr__, __delattr__ of 'object'  'type'
   
   now, if i want a single descriptor obj to be delegated to multiple
   tasks, i can't do it since __get__ doesn't get info that can be used
   to determine which task to do
   i must have diff descriptor obj for each task
   
   class Helper:
  def __init__(self, name):
  self.name = name
  def __get__(self, ins, cls):
  if self.name == 'task0': ...
  elif self.name == 'task1': ...
  else: ...
  
  Replacing such big switch code with polymorphic dispatch is one of the
goals (and feature) of OO. This should be:
  
  class Task0(object):
   def __get__(self, obj, cls):
   # code here
  
  class Task1(object):
   def __get__(self, obj, cls):
   # code here
  
  class A(object):
   task0 = Task0()
   task1 = Task1()
  
  If you have common code to share between TaskO and Task1 then factor it
  out into a base class.
  
   if __get__ receives the name, then i could do
   
   class Helper:
  def __get__(self, ins, cls, name):
  ...
   
   class a:
  task0 = task1 = Helper()
  
  Yuck.
 
 what's so 'Yuck' about it? ;)
 i guess i need a strong stmt: is descriptor a kind of delegation? or
 is it not?

Thanks for posting the code sample -- it makes your meaning a great deal 
clearer. No, descriptors are not delegation as in your sample**, although they 
are very flexible and could be used to implement that if you wanted.
 
 * if it's not, then there's nothing to be argued, the name
 'descriptor' is perfectly fit: descriptor obj describes attr of class,
 with 'describe' translates to: . = del, in py vocabularies. then, to
 think a single descriptor obj describing a single attr is acceptable,
 it's a common sense

** As I understand it, anyway -- someone please correct me if I'm wrong.



Rami Chowdhury
Never attribute to malice that which can be attributed to stupidity. --
Hanlon's Razor
+1-408-597-7068 / +44-7875-841-046 / +88-01819-245544
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The real problem with Python 3 - no business case for conversion (was I strongly dislike Python 3)

2010-07-05 Thread Terry Reedy

On 7/5/2010 9:00 PM, Philip Semanchuk wrote:


On Jul 5, 2010, at 6:41 PM, Chris Rebert wrote:


On Mon, Jul 5, 2010 at 3:38 PM, Philip Semanchuk



I ported two pure C extensions from 2 to 3 and was even able to keep a
single C codebase. I'd be willing to contribute my experiences to a
document
somewhere. (Is there a Wiki?)


Indeed there is: http://wiki.python.org/moin/


Thanks. I don't want to appear ungrateful, but I was hoping for
something specific to the 2-to-3 conversion. I guess someone has to
start somewhere...


There is an existing 2to3 and other pages for Python code conversion. I 
do not know of any for CAPI conversion. The need for such has been 
acknowledged among the devs but if there is nothing yet, we need someone 
with specialized experience and a bit of time to make a first draft. If 
you start one, give it an easy to remember name C2to3? 2to3Capi? You 
choose. And link to it from the 2to3 page


In his post on this thread, Martin Loewis volunteered to list what he 
knows from psycopg2 if someone else will edit.


--
Terry Jan Reedy

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


[issue3802] smtpd.py __getaddr insufficient handling

2010-07-05 Thread Mark Lawrence

Mark Lawrence breamore...@yahoo.co.uk added the comment:

Note there is a patch inline, not sure if a doc patch is needed for this.

--
keywords: +patch
nosy: +BreamoreBoy
stage:  - unit test needed
type:  - behavior

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



[issue3964] quiet the freeze makefile

2010-07-05 Thread Mark Lawrence

Mark Lawrence breamore...@yahoo.co.uk added the comment:

Assuming the patch works (I don't do makefiles) would anyone use this yes or no?

--
nosy: +BreamoreBoy

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



[issue9162] License for multiprocessing files

2010-07-05 Thread Michael Fladischer

New submission from Michael Fladischer mich...@fladi.at:

The files in Lib/multiprocessing (except __init__.py) are referring to their 
license by point to a nonexistent file called COPYING.txt.

This possibly needs clarification as if this file is missing or the license is 
to be found somewhere else.

--
components: Library (Lib)
messages: 109306
nosy: FladischerMichael
priority: normal
severity: normal
status: open
title: License for multiprocessing files

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



[issue9162] License for multiprocessing files

2010-07-05 Thread Ask Solem

Changes by Ask Solem a...@opera.com:


--
nosy: +asksol

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



[issue9160] Documentation link of 3.2 not working at docs.python.org

2010-07-05 Thread anatoly techtonik

anatoly techtonik techto...@gmail.com added the comment:

For me only http://www.python.org/doc/3.1.1/ gives 403.

Seems like all other links should be updated from 
http://www.python.org/doc/2.3.2/ to http://docs.python.org/release/2.3.2/ 
format to avoid additional redirect.

--
nosy: +techtonik

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



[issue9160] Documentation link of 3.2 not working at docs.python.org

2010-07-05 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

3.1.1 docs are fixed.  Development docs will be rebuilt soon automatically; 
after that everything should work again.

--
nosy: +georg.brandl
resolution:  - fixed
status: open - closed

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



[issue9136] RuntimeError when profiling Decimal

2010-07-05 Thread Mark Dickinson

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

 I don't quite understand the point of catching NameError here

So that the initialization of DefaultContext itself doesn't fail.

--

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



[issue9161] add_option in optparse no longer accepts unicode string

2010-07-05 Thread Craig McQueen

Craig McQueen pyt...@craig.mcqueen.id.au added the comment:

To further explain, I had code e.g.:

parser.add_option(u'-s', u'--seqfile', dest='seq_file_name', help=u'Write 
sequence file output to FILE', metavar=u'FILE')

I had to remove the unicode designator for the first parameter:
parser.add_option('-s', u'--seqfile', dest='seq_file_name', help=u'Write 
sequence file output to FILE', metavar=u'FILE')

On further investigation, it looks as though the optparse module has other 
problems with Unicode: e.g. if I try to set a non-ASCII parameter on the 
command line e.g.:
myprog.py -本
Then optparse can't handle that--it gets an encoding error on line 1396.

What _does_ work is that an option's parameters can be Unicode:
myprog.py -s 本.txt

So I guess there are broader problems than the specific 2.6 to 2.7 change that 
I originally reported.

--

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



[issue9163] test_gdb fails

2010-07-05 Thread Michael Blume

New submission from Michael Blume blume.m...@gmail.com:

After building Python 2.7 on two separate X68 Ubuntu boxes, test_gdb failed 
both times.

./configure
make
make test

output follows:


test_gdb
test test_gdb failed -- Traceback (most recent call last):
  File /home/mike/workspace/Python-2.7/Lib/test/test_gdb.py, line 637, in 
test_basic_command
''')
  File /home/mike/workspace/Python-2.7/Lib/test/test_gdb.py, line 163, in 
assertMultilineMatches
msg='%r did not match %r' % (actual, pattern))
AssertionError: 'Breakpoint 1 at 0x80957d6: file Objects/object.c, line 
329.\n[Thread debugging using libthread_db enabled]\n\nBreakpoint 1, 
PyObject_Print (op=42, fp=0x401cf4e0, flags=1) at 
Objects/object.c:329\n329\t{\n#3 Frame 0x81e322c, for file 
/home/mike/workspace/Python-2.7/Lib/test/gdb_sample.py, line 10, in baz 
(args=(1, 2, 3))\nprint(42)\n#7 (unable to read python frame 
information)\n#10 Frame 0x81d5544, for file 
/home/mike/workspace/Python-2.7/Lib/test/gdb_sample.py, line 7, in bar (a=1, 
b=2, c=3)\nbaz(a, b, c)\n#13 Frame 0x81d53dc, for file 
/home/mike/workspace/Python-2.7/Lib/test/gdb_sample.py, line 4, in foo (a=1, 
b=2, c=3)\nbar(a, b, c)\n' did not match '^.*\n#[0-9]+ Frame 0x[0-9a-f]+, 
for file .*gdb_sample.py, line 7, in bar \\(a=1, b=2, c=3\\)\nbaz\\(a, b, 
c\\)\n#[0-9]+ Frame 0x[0-9a-f]+, for file .*gdb_sample.py, line 4, in foo 
\\(a=1, b=2, c=3\\)\nbar\\(a, b, c\\)\n#[0-9]+ Frame 0x[0-9a-f]+, for file 
.*gdb_sample.py, line 12, in module
  \\(\\)\nfoo\\(1, 2, 3\\)\n'

machines have the following packages installed, with the following versions:
gdb 7.1-1ubuntu2
libgdb-dev 7.1-1ubuntu2

--
components: Tests
messages: 109311
nosy: Michael.Blume
priority: normal
severity: normal
status: open
title: test_gdb fails
versions: Python 2.7

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



  1   2   >