EPD 2.5.2001 for OS X released!

2008-08-08 Thread Dave Peterson

I'm pleased to announce that Enthought has released the Enthought Python
Distribution (EPD) 2.5.2001 for OS X!

EPD is a Distribution of the Python Programming Language (currently
version 2.5.2) that includes over 60 additional libraries, including ETS
2.7.1. Please visit the EPD website (http://www.enthought.com/epd) to
get the OS X release, or just to find out more information about EPD
2.5.2001


So what’s the big deal?

In addition to making everyones’ life easier with installation, EPD also
represents a common suite of functionality deployed across platforms
such as Windows XP, RedHat Linux, and now OS X 10.4 and above. The
cross-platform promise of Python is better realized because it’s trivial
for everyone to get substantially the same set of libraries installed on
their system with a single-click install.


What’s the catch?

You knew it was coming, huh? If you’d like to use EPD in a Commercial or
Governmental entity, we do ask you to pay for an annual subscription to
download and update EPD. For academics and non-profit, private-sector
organizations, EPD is and will remain free. Let’s be clear, though. EPD
is the bundle of software. People pay for the subscription to download
the bundle. The included libraries are, of course, freely available
separately under the terms of license for each individual package (this
should sound familiar). The terms for the bundle subscription are
available at http://www.enthought.com/products/epdlicense.php. BTW,
anyone can try it out for free for 30 days.

If you have questions, check out the FAQ at
http://www.enthought.com/products/epdfaq.php or drop us a line at
[EMAIL PROTECTED]

And just one more note:
Enthought is deeply grateful to all those who have contributed to these
libraries over the years. We’ve built a business around the things they
allow us to do and we appreciate such a nice set of tools and the
privilege of being part of the community that created them.


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

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


RE: very newbie question

2008-08-08 Thread Peter Anderson

Try this:

# The player tries to guess it and the computer lets
# the player know if the guess is too high, too low
# or right on the money

import random

print \tWelcome to 'Guess My Number'!
print \nI'm thinking of a number between 1 and 100.
print Try to guess it in as few attempts as possible.\n

# set the initial values
the_number = random.randrange(100) + 1
tries = 0

def ask_number():
guess = int(raw_input(Take a guess: ))
tries = 1

while (guess != the_number):
if (guess  the_number):
print Lower...
else:
print Higher...
tries += 1
guess = int(raw_input(Take a guess: ))
tries += 1

ask_number()

print You guessed it! The number was, the_number
print And it only took you, tries, tries!\n

raw_input(\n\nPress the enter key to exit.)

The variables the_number and tries were not available outside the 
ask_number() module.


Alternatively drop the def function and lump it all into a simple script.
--
*Peter Anderson*
There is nothing more difficult to take in hand, more perilous to 
conduct, or more uncertain in its success, than to take the lead in the 
introduction of a new order of things—Niccolo Machiavelli, /The Prince/, 
ch. 6

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


Re: how to find out if an object is a class?

2008-08-08 Thread Stefan Behnel
Ben Finney wrote:
 szczepiq writes:
 
 Pardon me for most likely a dummy question but how do I find out if
 an object is a class?
 
 Presumably you want to know whether it's a class in order to use it
 for instantiating it. It is usually more Pythonic to use the object as
 intended, and allow the object itself to tell you (via exceptions)
 when it's not behaving as you expect.

This also allows passing a factory function instead of a class, BTW.

I recently had the reverse case that a (stupidly implemented) extension module
required a callback function and I wanted to pass a function wrapped in a
wrapper object. That failed, because it specifically checked for the argument
being a function, not just a callable object. I had to pull quite a number of
tricks to reimplement the wrapper class as a function (thank god, it's Python!).

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


Threading and wx.....

2008-08-08 Thread SamG
Hi,

Im trying my hand at threading with wx applications. I have written
the following code...

import wx
from threading import Thread, Lock

class createWindow(Thread):
def __init__(self):
Thread.__init__(self)
self.lock = Lock()
self.app=None

def run(self):
#self.lock.acquire()
self.app = wx.PySimpleApp()
frame = wx.Frame(None, title=Hello wx)
frame.Show()
#self.lock.release()
self.app.MainLoop()


if __name__=='__main__':
c = createWindow()
c.start()
c.join()

Now when i run this program i get a window but the application just
does not respond. Is there something that im missing here. Pls let me
know. Thanks in advance.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Best practise implementation for equal by value objects

2008-08-08 Thread Slaunger
On 7 Aug., 21:25, Paul Rubin http://[EMAIL PROTECTED] wrote:
 Terry Reedy [EMAIL PROTECTED] writes:
  So when the initializers for instances are all 'nice' (as for range),
  go for it (as in 'Age(10)').  And test it as you are by eval'ing the
  rep. Just accept that the eval will only work in contexts with the
  class name bound to the class.  For built-in like range, it always is,
  by default -- unless masked by another assignment!

 Eval is extremely dangerous.  Think of data from untrusted sources,
 then ask yourself how well you really know where ALL your data came
 from.  It's preferable to avoid using it that way.  There have been a
 few safe eval recipes posted here and at ASPN.  It would be good if
 one of them made it into the standard library.  Note that pickle
 (which would otherwise be an obious choice for this) has the same
 problems, though not as severely as flat-out evalling something.

Thank you for pointing out the dangers of eval. I think you are right
to
caution about it. In my particular case it is a closed-loop system, so
no
danger there, but that certainly could have been an issue.

That caution should perhaps be mentioned in
http://docs.python.org/lib/built-in-funcs.html
--
http://mail.python.org/mailman/listinfo/python-list


Re: benchmark

2008-08-08 Thread alex23
On Aug 8, 2:49 pm, Dhananjay [EMAIL PROTECTED] wrote:
 Is it that a question of time and effort,
 or is there something that doesn't make it appropriate to python ?

I don't think I've ever seen anyone who has raised concerns about the
speed of python actually offer to contribute to resolving it, so I'm
guessing it's the former.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Books to begin learning Python

2008-08-08 Thread Mark Summerfield
On 7 Aug, 21:10, Mike Driscoll [EMAIL PROTECTED] wrote:
 On Aug 7, 1:12 pm, Beliavsky [EMAIL PROTECTED] wrote:



  On Aug 6, 4:08 pm, Mike Driscoll [EMAIL PROTECTED] wrote:

   On Aug 6, 2:56 pm, Edward Cormier [EMAIL PROTECTED] wrote:

Which computer books are the best to begin learning Python 2.5 with?
I've heard that Learning Python 3rd Edition is a good choice - can
anyone give any more advice on this?

Thanks.

   There's lots of good books to read, including a few online ones. A lot
   of people like Dive Into Python (http://diveintopython.org/). If you
   want LOTS of information and some good code examples, Lutz's
   Programming Python 3rd Ed is great.

  I have the 2nd edition. Has the 3rd edition been rewritten so that all
  of its code will be valid in Python 3? I'd prefer not to buy Python
  books that will become obsolete.

 As Wojtek already pointed out, Lutz's 3rd edition is written with 2.x
 in mind. I think it's 2.4 or 2.5, but I forget exactly which. Still,
 most programming books are obsolete almost from the day their
 printed. I'm not aware of any Python 3.0 books...

I'm writing a Python 3 book that will be published as soon as possible
after Python 3.0 final is released (so hopefully November). It assumes
programming experience in _some_ language (not necessarily Python 2).

Programming in Python 3: A Complete Introduction to the Python
Language ISBN 0137129297

The table of contents and a link to some (out of date) sample text is
here:
http://www.qtrac.eu/py3book.html
--
http://mail.python.org/mailman/listinfo/python-list


Re: .cpp to .pyd

2008-08-08 Thread Kay Schluehr
On 7 Aug., 21:43, Carl Banks [EMAIL PROTECTED] wrote:
 On Aug 7, 3:25 am, [EMAIL PROTECTED] wrote:



  Hello,

  I want to build my C++ (.cpp) script to (.pyd) like this:

 http://en.wikibooks.org/wiki/Python_Programming/Extending_with_C%2B%2B

  I have installed Microsoft Visual studio .NET 2003 and Boost
  Python and then after I run my setup script:

  python setup.py build

  I get this error:

  running build
  running build_ext
  building 'hello' extension
  D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /
  nologo /Ox
   /MD /W3 /GX /DNDEBUG -IC:\Panda3D-1.5.2\python\include -IC:
  \Panda3D-1.5.2\pytho
  n\PC /Tphellomodule.cpp /Fobuild\temp.win32-2.5\Release
  \hellomodule.obj
  hellomodule.cpp
  hellomodule.cpp(9) : fatal error C1083: Cannot open include file:
  'boost/python/
  module.hpp': No such file or directory
  error: command 'D:\Program Files\Microsoft Visual Studio .NET
  2003\Vc7\bin\cl.e
  xe' failed with exit status 2

  I think that my MS visual studio  cannot find boost python, if
  that's the problem then can you tell me how can I solve it.
  This is very begginer question,but I can't find answer nowhere, and I
  don't have any expirience with Microsoft products.

  Sorry for my bad english!
  Regards,
  Veki

 First, locate the boost header files.  Suppose you find the file
 module.hpp in this location:

 C:\boost-whatever-version\include\boost\python\module.hpp

 The part that comes before boost\python\module.hpp is the required
 include directory.  You can tell setup to use this directory by adding
 the following argument to the Extension call:

 include_dirs = ['C:\\boost-whatever-version\\include']

 Notice the doubling of backslashes.  Remember to add the directory
 where the boost header files lie on your system; don't add this line
 exactly.

 You should end up with a setup call that looks like this:

 setup(name=blah,
 ext_modules=[
 Extension(hello, [hellomodule.cpp],
 libraries = [boost_python],
 include_dirs = ['C:\\boost-whatever-version\\include'])
 ])

 Carl Banks

One can omit double backslashes when prefixing by 'r' or 'R':

r'C:\boost-whatever-version\include'

Python is just too kind.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Threading and wx.....

2008-08-08 Thread SamG
On Aug 8, 12:01 pm, SamG [EMAIL PROTECTED] wrote:
 Hi,

 Im trying my hand at threading with wx applications. I have written
 the following code...

 import wx
 from threading import Thread, Lock

 class createWindow(Thread):
 def __init__(self):
 Thread.__init__(self)
 self.lock = Lock()
 self.app=None

 def run(self):
 #self.lock.acquire()
 self.app = wx.PySimpleApp()
 frame = wx.Frame(None, title=Hello wx)
 frame.Show()
 #self.lock.release()
 self.app.MainLoop()

 if __name__=='__main__':
 c = createWindow()
 c.start()
 c.join()

 Now when i run this program i get a window but the application just
 does not respond. Is there something that im missing here. Pls let me
 know. Thanks in advance.

Oops! Murphy's law works again! And the above code is working fine.
--
http://mail.python.org/mailman/listinfo/python-list


Re: benchmark

2008-08-08 Thread cokofreedom
On Aug 8, 9:08 am, alex23 [EMAIL PROTECTED] wrote:
 On Aug 8, 2:49 pm, Dhananjay [EMAIL PROTECTED] wrote:

  Is it that a question of time and effort,
  or is there something that doesn't make it appropriate to python ?

 I don't think I've ever seen anyone who has raised concerns about the
 speed of python actually offer to contribute to resolving it, so I'm
 guessing it's the former.

Contribute to resolve it? Part of me just wants to say that to speed
up python would be such a huge undertaking, the outcome would alter
the language beyond what people liked. Another part thinks, why speed
it up, it is pretty fast presently, and I've rarely seen real-world
applications that need that 80/20 rule applied heavily.

Benchmarks for showing what languages are good at is fine, but in
general most conform to a standard range of speed. I cannot find the
article but there was a good piece about how it takes most programmers
the same time to program in any language. Reading through the code is
another matter, I think Python is faster than most in that respect.

I'd look to increase the worst-case scenario's of Python before trying
to speed up everything. Hell the tim_sort is pretty damn fast.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Best practise implementation for equal by value objects

2008-08-08 Thread Slaunger
On 7 Aug., 21:19, Terry Reedy [EMAIL PROTECTED] wrote:
 Slaunger wrote:
  On 6 Aug., 21:36, Terry Reedy [EMAIL PROTECTED] wrote:
  OK, the situation is more complicated than that then. In the case here
  though,
  the attributes would always be sinmple bulit-in types, where
  eval(repr(x))==x
  or, where the attribute is a user-defined equal-by-value class, that I
  have
  control over.

 I think most would agree that a more accurate and informative
 representation is better than a general representation like Pythons
 default.  For instance,
   a=range(2,10,2) # 3.0
   a
 range(2, 10, 2)

 is nicer than class 'range' object at ##.

 So when the initializers for instances are all 'nice' (as for range), go
 for it (as in 'Age(10)').  And test it as you are by eval'ing the rep.
 Just accept that the eval will only work in contexts with the class name
   bound to the class.  For built-in like range, it always is, by default
 -- unless masked by another assignment!

OK, i am encouraged to carry on my quest with the eval(repr)) for my
'nice' classes.
I just revisited the documentation for eval and noticed that there are
optional globals
and locals name space variables, that one could specify:

http://docs.python.org/lib/built-in-funcs.html

Quite frankly I do not understand how to make use of these parameters,
but it is my feeling
that if I enforce a convention of always specifying the globals/locals
parameter in a specific
manner:
assert eval(repr(x), globals, locals) == x
would work independent of how I have imported the module under test.

Now, I just need to figure out if this is right and how to specify the
globals and locals if that is not too cumbersome...
or maybe I am just over-engineering...


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


Re: Suggestions for creating a PDF table

2008-08-08 Thread Ken Starks

Kirk Strauser wrote:

Short question:

Is there a good library for generating HTML-style tables with the equivalent
of colspans, automatically sized columns, etc. that can render directly to
PDF?

Longer question:

I'm re-doing a big chunk of locally-written code.  I have a
report-generating function that takes a list of lists of lists as input and
returns either a PDF, an HTML table, or an Excel spreadsheet as requested. 
For example, input might look like:


makereport('html',
   headers=['Invoice number', 'Customer', 'Price'],
   data=[
 [['123', 'John Doe', '$50.00'],
  ['Ordered on 2008-01-01 via the website']],
 [['124', 'Peter Bilt', '$25.99'],
  ['Mail via African swallow']]
   ])


  snip


Now, I have a similar transformation to PDF via pdflatex.  This works fairly
well but requires a bunch of temp files and subprocesses, and I've never
been 100% happy with the LaTeX output (you have to calculate your own
column widths, for instance).  Since I plan to re-write this anyway, I'd
like to find a more widely used library if one was available.

snip 





Short answer: LaTeX should be good. Use XML source; XSLT to TeXML; TeXML 
to LaTeX ( uses a python program); compile to PDF.


Longer answer: Can you provide a minimal example of the kind of
LaTeX source you would ideally like ?

If not, your problem is with LaTeX itself, which has if anything 
__too_many__ ways of controlling tables rather than inadequate
ways. If so, we may be able to help with the rather arcane 
transformation into TeXML format.


As for all the temp files that LaTeX creates, they are easily dealt
with using a makefile or whatever.

Bye for now,
Ken
--
http://mail.python.org/mailman/listinfo/python-list


Re: kill thread

2008-08-08 Thread Mathieu Prevot
2008/8/8 Miki [EMAIL PROTECTED]:
 Hello,

 I have a threading.Thread class with a for i in range(1,50) loop
 within. When it runs and I do ^C, I have the error [1] as many as
 loops. I would like to catch this exception (and if possible do some
 cleanup like in C pthreads) so the program finishes cleanly. Where and
 how can I do this ? in __run__ ? __init__ ? a try/except stuff ?
 You can have a try/except KeyboardException around the thread code.

 HTH,
 --
 Miki

Of course, but I don't know where. I placed this inside loop, within
called functions from the loop, I still have the problem.

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


Re: random numbers according to user defined distribution ??

2008-08-08 Thread Robert Kern

sturlamolden wrote:

Alex wrote:


I wonder if it is possible in python to produce random numbers
according to a user defined distribution?
Unfortunately the random module does not contain the distribution I
need :-(


There exist some very general algorithms to generate random numbers
from arbitrary distributions.

The most notable of these are Markov Chain Monte Carlo, e.g. the
Metropolis-Hastings algorithm. It is very easy to implement in any
programming language. The nature MCMC algorithms makes it inefficient
when implemented in pure Python. But you can get tremendous speedup by
simulating multiple Markov chains in parallel, by means of vectorizing
with NumPy.

A relative of Metropolis-Hastings which may also be applicable to your
problem is pure rejection sampling. It is far less efficient, but
produces no autocorrelation in the samples.


I don't know. I think the certainty that rejection sampling actually gives you 
the desired distribution as opposed to MH's uncertainty is very much a 
worthwhile tradeoff for univariate distributions. Sure, you throw away fewer 
samples, but you know that MH isn't throwing away samples that it ought to. 
Personally, I view MH as a last resort when the dimensionality gets too large to 
do anything else. But then, that's just my opinion.


--
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco

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


Re: how to find out if an object is a class?

2008-08-08 Thread Miles
On Fri, Aug 8, 2008 at 2:31 AM, Stefan Behnel wrote:
 I recently had the reverse case that a (stupidly implemented) extension module
 required a callback function and I wanted to pass a function wrapped in a
 wrapper object. That failed, because it specifically checked for the argument
 being a function, not just a callable object. I had to pull quite a number of
 tricks to reimplement the wrapper class as a function (thank god, it's 
 Python!).

You really only needed one trick:

def functionize(callable):
return lambda *args, **kwargs: callable(*args, **kwargs)

:)

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


CAB files

2008-08-08 Thread Virgil Stokes

I would appreciate python code for creating *.cab files.

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


Re: Fastest way to store ints and floats on disk

2008-08-08 Thread Laszlo Nagy




Hmm... I wrote an browser based analysis tool and used the working 
name pyvot...

Is this for the public domain?


I found Numeric to provide the best balance of memory footprint and 
speed. I also segregated data prep into a separate process to avoid 
excessive memory use at run time. Turns out python
Do you mean numpy? (Numeric is not actively supported, numarray is 
deprecated.)


For the site I'm at, I've got 10 years sales history recapped from 
4327846 detail records into 458197 item by customer by month records 
and top shows a 240Mb memory footprint. I've got 21 cross indexed 
selection fields, and can display up to six data types (qty, price, 
sqft, cost, gp%, avg). At another site I've got approx 8.5M records 
recapped into 1M records with 15 indexes and 5 years monthly history 
living in a 540Mb memory footprint.


It's reasonably quick: a query like 'select san mateo, foster city and 
san carlos accounts, sort by customer and product category and display 
this year's sales by month' selects 260 records and renders in the 
browser in about 2 seconds. Or on the larger installation 'Show sales 
for the past five years for product group 12 sorted by city within 
route' selects 160 records and renders in about 3 seconds.

Incredible. :-)

My objective was to keep the info in memory for fast response times.
Permature optimalization is the root of all evil. (Who said that?) All 
right, first I'll try to keep it in memory and come back if that doesn't 
work out.
I played a lot of games getting this all to work well, including some 
c extensions, but Numeric's take, sum, tostring and fromstring ended 
up with 'pivotal' roles. :)

Thank you,

Laszlo

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


Re: Large production environments using ZODB/ZOE?

2008-08-08 Thread Bruno Desthuilliers

Phillip B Oldham a écrit :

I've been reading a lot recently on ZODB/ZOE, but I've not seen any
reference to its use in large-scale production envrironments.

Are there any real-world examples of ZODB/ZOE in use for a large
system? By large, I'm thinking in terms of both horizontally-scaled
systems and in terms of data storage size.


You'll probably get more (and possibly better) answers on the Zope 
mailing list. Now FWIW, using ZEO is almost mandatory for any 
non-trivial Zope instance (think of mammoths like Plone etc...).

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


Re: Fastest way to store ints and floats on disk

2008-08-08 Thread Paul Rudin
Laszlo Nagy [EMAIL PROTECTED] writes:


 Permature optimalization is the root of all evil. (Who said that?) 

Knuth I think. 

But note the premature bit - around here people sometimes give the
impression that it goes optimisation is the root of all evil.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Create 2D character matrix

2008-08-08 Thread arsyed
On Thu, Aug 7, 2008 at 1:36 PM, Simon Parker [EMAIL PROTECTED] wrote:
 Hello.

 I want to be able to create a 2D character matrix, ThisMatrix, like :


 a A
 b B
 c C
 d D

 and to be able to pick out elements, or rows or columns.

 I have become used to programming in R where I can easily refer to a row as
 :

 ThisMatrix [1,]

 and a column as

 ThisMatrix[,1].

 etc..

 Can this be done easily in Python ?



You can use numpy:

http://www.scipy.org/NumPy

for example:

In [139]: arr = numpy.char.array(['a', 'A', 'b', 'B', 'c', 'C'])

In [140]: arr = arr.reshape((3,2))

In [141]: arr
Out[141]:
chararray([['a', 'A'],
   ['b', 'B'],
   ['c', 'C']],
  dtype='|S1')

In [142]: arr[0,:]
Out[142]:
chararray(['a', 'A'],
  dtype='|S1')

In [143]: arr[:,0]
Out[143]:
chararray(['a', 'b', 'c'],
  dtype='|S1')

More documentation here:

http://mentat.za.net/numpy/refguide/

or take a look at these pages for some quick examples of what's possible:

http://pages.physics.cornell.edu/~myers/teaching/ComputationalMethods/python/arrays.html
http://www.scipy.org/Numpy_Example_List_With_Doc
--
http://mail.python.org/mailman/listinfo/python-list


Re: Best practise implementation for equal by value objects

2008-08-08 Thread Steven D'Aprano
On Fri, 08 Aug 2008 00:28:02 -0700, Slaunger wrote:

 OK, i am encouraged to carry on my quest with the eval(repr)) for my
 'nice' classes.
 I just revisited the documentation for eval and noticed that there are
 optional globals
 and locals name space variables, that one could specify:
 
 http://docs.python.org/lib/built-in-funcs.html
 
 Quite frankly I do not understand how to make use of these parameters,
 but it is my feeling
 that if I enforce a convention of always specifying the globals/locals
 parameter in a specific
 manner:
 assert eval(repr(x), globals, locals) == x would work independent of how
 I have imported the module under test.
 
 Now, I just need to figure out if this is right and how to specify the
 globals and locals if that is not too cumbersome... or maybe I am just
 over-engineering...


I think it is infeasible for the repr() of an object to know where it was 
imported from. Including the globals and locals in the call to eval() 
won't help you, because they can have changed between the time you 
created the instance and the time you call repr(). Consider:


 import datetime
 x = datetime.time(20, 21, 22)
 x
datetime.time(20, 21, 22)
 eval(repr(x)) == x
True

So far so good! But now watch this, starting in a fresh session:

 import datetime as timedate
 t = timedate.time
 timedate.tttime = timedate.time
 del timedate.time
 assert t is timedate.tttime
 
 x1 = t(20, 21, 22)
 x2 = timedate.tttime(20, 21, 22)
 assert x1 == x2

What should repr(x1) and repr(x2) be, for your invariant eval(repr(x))==x 
to hold?

It gets better (or worse):

 alist = [None, t, None]
 del t, timedate
 x3 = alist[1](20, 21, 22)
 assert x1 == x2 == x3

What should the repr() of x1, x2, x3 be now?


Bringing this back to the unittests... as I see it, there's an easy way 
to solve your problem. In the unittest, just do something like the 
following:

# repr(x) looks like module.class(arg), 
# but we actually import it as package.module.submodule.class
module = package.module.submodule
assert eval(repr(x)) == x

I think that is all you need to do.


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


Re: kill thread

2008-08-08 Thread bockman
On 8 Ago, 10:03, Mathieu Prevot [EMAIL PROTECTED] wrote:
 2008/8/8 Miki [EMAIL PROTECTED]:

  Hello,

  I have a threading.Thread class with a for i in range(1,50) loop
  within. When it runs and I do ^C, I have the error [1] as many as
  loops. I would like to catch this exception (and if possible do some
  cleanup like in C pthreads) so the program finishes cleanly. Where and
  how can I do this ? in __run__ ? __init__ ? a try/except stuff ?
  You can have a try/except KeyboardException around the thread code.

  HTH,
  --
  Miki

 Of course, but I don't know where. I placed this inside loop, within
 called functions from the loop, I still have the problem.

 Mathieu

Try this:

  loop_completed = True
  for i in range(1,50):
  try:
 # your code here
  except KeyboardException:
 loop_completed = False
 break # this breaks the loop
  # end loop
  if loop_completed:
 # code to be executed in case of normal completion
  else:
 # code to be executed in case of interruption
  # code to be executed in both cases
--
http://mail.python.org/mailman/listinfo/python-list


regular expressions.

2008-08-08 Thread Atul.
Hey All,

I have been playing around with REs and could not get the following
code to run.

import re
vowel = r'[aeiou]'
re.findall(vowel, rvowel)

anything wrong I have done?

Regards,
Atul.

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


Re: regular expressions.

2008-08-08 Thread Peter Otten
Atul. wrote:

 I have been playing around with REs and could not get the following
 code to run.
 
 import re
 vowel = r'[aeiou]'
 re.findall(vowel, rvowel)
 
 anything wrong I have done?

Yes. You didn't paste the traceback into your message.
 
 import re
 vowel = r'[aeiou]'
 re.findall(vowel, rvowel)
['o', 'e']

It works as expected here.

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


numpy and filtering (was: Fastest way to store ints and floats on disk)

2008-08-08 Thread Laszlo Nagy
Attached there is an example program that only requires numpy. At the 
end I have two numpy array:


rdims:

[[3 1 1]
[0 0 4]
[1 3 0]
[2 2 0]
[3 3 3]
[0 0 2]]


rmeas:

[[10.0 254.0]
[4.0 200.0]
[5.0 185.0]
[5000.0 160.0]
[15.0 260.0]
[2.0 180.0]]


I would like to use numpy to create statistic, for example the mean 
value of the prices:


 rmeas[:,0] # Prices of cars
array([10.0, 4.0, 5.0, 5000.0, 15.0, 2.0], 
dtype=float96)

 rmeas[:,0].mean() # Mean price
60833.3321

However, I only want to do this for 'color=yellow' or 'year=2003, 
make=Ford' etc. I wonder if there a built-in numpy method that can 
filter out rows using a set of values. E.g. create a view of the 
original array or a new array that contains only the filtered rows. I 
know how to do it from Python with iterators, but I wonder if there is a 
better way to do it in numpy. (I'm new to numpy please forgive me if 
this is a dumb question.)


Thanks,

  Laszlo




import numpy

columns = ['Color','Year','Make','Price','VMax']
dimension_columns = [0,1,2]
measure_columns = [3,4]
data = [
['Yellow', '2000', 'Ferrari', 10.,254.],
['Blue',   '2003', 'Volvo',4.,200.],
['Black',  '2005', 'Ford', 5.,185.],
['Red','1990', 'Ford',  5000.,160.],
['Yellow', '2005', 'Lamborgini',  15.,260.],
['Blue',   '2003', 'Suzuki',   2.,180.],
]
print Original data
print ---
for row in data:
print row

# Create dimension values list
dimensions = []
for colindex in dimension_columns:
dimensions.append({
'name':columns[colindex],
'colindex':colindex,
'values': list(set(  map( lambda row: row[colindex], data )   )),
})

print Dimensions
print ---
for d in dimensions:
print d

# Create a numpy array from dimensions
nrows = len(data)
ncols = len(dimension_columns)
rdims = numpy.empty( (nrows,ncols), dtype=numpy.uint32 )
for rindex,row in enumerate(data):
for dindex,cindex in enumerate(dimension_columns):
dimension = dimensions[dindex]
rdims[rindex,cindex] = dimension['values'].index(row[cindex])
print Dimension value indexes
print ---
print rdims

# Create numpy array from values
nrows = len(data)
ncols = len(measure_columns)
rmeas = numpy.empty( (nrows,ncols), dtype=numpy.float96 )
for rindex,row in enumerate(data):
for mindex,cindex in enumerate(measure_columns):
rmeas[rindex,mindex] = row[cindex]
print Measure values
print ---
print rmeas

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

Re: regular expressions.

2008-08-08 Thread Atul.

 Yes. You didn't paste the traceback into your message.

  import re
  vowel = r'[aeiou]'
  re.findall(vowel, rvowel)

 ['o', 'e']

 It works as expected here.

 Peter

When I key this input in IDLE it works but when I try to run the
module it wont work.
--
http://mail.python.org/mailman/listinfo/python-list


Re: regular expressions.

2008-08-08 Thread Alexei Zankevich
Use the print statement:

import re
vowel = r'[aeiou]'
print re.findall(vowel, rvowel)

Alexey

On Fri, Aug 8, 2008 at 2:17 PM, Atul. [EMAIL PROTECTED] wrote:


  Yes. You didn't paste the traceback into your message.
 
   import re
   vowel = r'[aeiou]'
   re.findall(vowel, rvowel)
 
  ['o', 'e']
 
  It works as expected here.
 
  Peter

 When I key this input in IDLE it works but when I try to run the
 module it wont work.
 --
 http://mail.python.org/mailman/listinfo/python-list

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

Re: regular expressions.

2008-08-08 Thread Peter Otten
Atul. wrote:

 
 Yes. You didn't paste the traceback into your message.

  import re
  vowel = r'[aeiou]'
  re.findall(vowel, rvowel)

 ['o', 'e']

 It works as expected here.

 Peter
 
 When I key this input in IDLE it works but when I try to run the
 module it wont work.

What's the name of your script? What happens when you run it? Does it print
a traceback? If so, what does it say? Please cut and paste, don't
paraphrase.

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


Re: regular expressions.

2008-08-08 Thread Atul.
On Aug 8, 4:22 pm, Peter Otten [EMAIL PROTECTED] wrote:
 Atul. wrote:

  Yes. You didn't paste the traceback into your message.

   import re
   vowel = r'[aeiou]'
   re.findall(vowel, rvowel)

  ['o', 'e']

  It works as expected here.

  Peter

  When I key this input in IDLE it works but when I try to run the
  module it wont work.

 What's the name of your script? What happens when you run it? Does it print
 a traceback? If so, what does it say? Please cut and paste, don't
 paraphrase.

 Peter

This is something get when I run it like below. it does not print any
output.

[EMAIL PROTECTED]:~/Work/work/programs$ python fourth.py
[EMAIL PROTECTED]:~/Work/work/programs$
--
http://mail.python.org/mailman/listinfo/python-list


Re: regular expressions.

2008-08-08 Thread Atul.
On Aug 8, 4:33 pm, Atul. [EMAIL PROTECTED] wrote:
 On Aug 8, 4:22 pm, Peter Otten [EMAIL PROTECTED] wrote:



  Atul. wrote:

   Yes. You didn't paste the traceback into your message.

import re
vowel = r'[aeiou]'
re.findall(vowel, rvowel)

   ['o', 'e']

   It works as expected here.

   Peter

   When I key this input in IDLE it works but when I try to run the
   module it wont work.

  What's the name of your script? What happens when you run it? Does it print
  a traceback? If so, what does it say? Please cut and paste, don't
  paraphrase.

  Peter

 This is something get when I run it like below. it does not print any
 output.

 [EMAIL PROTECTED]:~/Work/work/programs$ python fourth.py
 [EMAIL PROTECTED]:~/Work/work/programs$

ok I get it thats coz, I dont print it. right? when I print it does
she it.
--
http://mail.python.org/mailman/listinfo/python-list


Re: regular expressions.

2008-08-08 Thread Diez B. Roggisch

Atul. schrieb:

On Aug 8, 4:33 pm, Atul. [EMAIL PROTECTED] wrote:

On Aug 8, 4:22 pm, Peter Otten [EMAIL PROTECTED] wrote:




Atul. wrote:

Yes. You didn't paste the traceback into your message.

import re
vowel = r'[aeiou]'
re.findall(vowel, rvowel)

['o', 'e']
It works as expected here.
Peter

When I key this input in IDLE it works but when I try to run the
module it wont work.

What's the name of your script? What happens when you run it? Does it print
a traceback? If so, what does it say? Please cut and paste, don't
paraphrase.
Peter

This is something get when I run it like below. it does not print any
output.

[EMAIL PROTECTED]:~/Work/work/programs$ python fourth.py
[EMAIL PROTECTED]:~/Work/work/programs$


ok I get it thats coz, I dont print it. right? when I print it does
she it.


Yes.

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


Re: regular expressions.

2008-08-08 Thread Peter Otten
Atul. wrote:

 On Aug 8, 4:33 pm, Atul. [EMAIL PROTECTED] wrote:
 On Aug 8, 4:22 pm, Peter Otten [EMAIL PROTECTED] wrote:



  Atul. wrote:

   Yes. You didn't paste the traceback into your message.

import re
vowel = r'[aeiou]'
re.findall(vowel, rvowel)

   ['o', 'e']

   It works as expected here.

   Peter

   When I key this input in IDLE it works but when I try to run the
   module it wont work.

  What's the name of your script? What happens when you run it? Does it
  print a traceback? If so, what does it say? Please cut and paste, don't
  paraphrase.

  Peter

 This is something get when I run it like below. it does not print any
 output.

 [EMAIL PROTECTED]:~/Work/work/programs$ python fourth.py
 [EMAIL PROTECTED]:~/Work/work/programs$
 
 ok I get it thats coz, I dont print it. right? when I print it does
 she it.

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

Re: Books to begin learning Python

2008-08-08 Thread Jaime Irurzun
Hi Edward,

I like Dive into Python because it's been written for people who
know programming with other languages. This could be an advantage or a
disadvantage, if you feel really uncomfortable reading Python code (if
you can't imagine absolutly nothing about what it does), my advice is
to choose another book. Otherwise, Dive in to Python is a fantastic
choice.

I'll take this opportunity to introduce myself, because this is my
first post. Best regards to everybody from a spanish Python novice and
enthusiast :-)

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


Re: Limits of Metaprogramming

2008-08-08 Thread Iain King
On Aug 4, 5:13 pm, Tomasz Rola [EMAIL PROTECTED] wrote:
 On Mon, 4 Aug 2008, Wilson wrote:
   Every sufficiently large application has a poor/incomplete
  implementation ofLISPembedded within it .

 Yep, this is either exact or very close copy of what I have read.


It's Greenspun's Tenth Rule of Programming:

Any sufficiently complicated C or Fortran program contains an ad-hoc,
informally-specified bug-ridden slow implementation of half of Common
Lisp.

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


Re: python-mode is missing the class browser

2008-08-08 Thread Michele Simionato
On Aug 7, 5:55 pm, Alexander Schmolck [EMAIL PROTECTED] wrote:
 There are two different and independently developedpython-modes. The
 politically correct one that comes with emacs (IIRC python.el) that had pretty
 limited functionality last time I looked, and the original but not FSF blessed
 python-mode.el (http://sourceforge.net/projects/python-mode/), which should
 come with install instructions. If you use ipython you might additionally
 want to install ipython.el, which comes with the ipython tar ball.

I have solved by using ipython.el which was already installed. For the
sake of
future googlers using Ubuntu 8.04, emacs and ipython, it is enough if
you just add

(setq ipython-command /usr/bin/ipython)
(require 'ipython)

to your .emacs. It is nice since I get the occasion to try ipython.el
which I am
sure I will like ;)

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


Re: regular expressions.

2008-08-08 Thread Atul.
The same file when I use with the following does not work.

import re
vowel =
r'[u\u093eu\u093fu\u0940u\u0941u\u0942u\u0943u\u0944u\u0945u\u0946u\u0947u\u0948u\u0949u\u094au\u094bu\u094c]'
print re.findall(vowel, u\u092f\u093e\u0902\u091a\u094d\u092f\u093e,
re.UNICODE)



[EMAIL PROTECTED]:~/Work/work/programs$ python fourth.py
[]
[EMAIL PROTECTED]:~/Work/work/programs$


is this the way to use Unicode in REs?

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


Re: random numbers according to user defined distribution ??

2008-08-08 Thread Jeremy Sanders
Alex wrote:

 I wonder if it is possible in python to produce random numbers
 according to a user defined distribution?
 Unfortunately the random module does not contain the distribution I
 need :-(

Have you looked at the numpy random number module? It seems to have quite a
lot of distributions. See help(numpy.random).

Jeremy

-- 
Jeremy Sanders
http://www.jeremysanders.net/
--
http://mail.python.org/mailman/listinfo/python-list


Re: python-mode is missing the class browser

2008-08-08 Thread Adam Jenkins
On Fri, Aug 8, 2008 at 7:32 AM, Michele Simionato
[EMAIL PROTECTED] wrote:
 On Aug 7, 5:55 pm, Alexander Schmolck [EMAIL PROTECTED] wrote:
...

 I have solved by using ipython.el which was already installed. For the
 sake of
 future googlers using Ubuntu 8.04, emacs and ipython, it is enough if
 you just add

 (setq ipython-command /usr/bin/ipython)
 (require 'ipython)

 to your .emacs. It is nice since I get the occasion to try ipython.el
 which I am
 sure I will like ;)

So, I'm looking at the .el, but I'm not sure. What else does
ipython.el give you than just the ipython shell?


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

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


Re: regular expressions.

2008-08-08 Thread Peter Otten
Atul. wrote:

 The same file when I use with the following does not work.
 
 import re
 vowel =
 r'[u\u093eu\u093fu\u0940u\u0941u\u0942u\u0943u\u0944u\u0945u\u0946u\u0947u\u0948u\u0949u\u094au\u094bu\u094c]'
 print re.findall(vowel, u\u092f\u093e\u0902\u091a\u094d\u092f\u093e,
 re.UNICODE)
 
 
 
 [EMAIL PROTECTED]:~/Work/work/programs$ python fourth.py
 []
 [EMAIL PROTECTED]:~/Work/work/programs$
 
 
 is this the way to use Unicode in REs?

No, u... is part of the string, not the character. The regex becomes

# untested
vowel = 
u'[\u093e\u093f\u0940\u0941\u0942\u0943\u0944\u0945\u0946\u0947\u0948\u0949\u094a\u094b\u094c]'

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


Re: how to find out if an object is a class?

2008-08-08 Thread Christian Heimes

szczepiq wrote:

Pardon me for most likely a dummy question but how do I find out if an
object is a class?


For God's sake don't reinvent the wheel! The 'inspect' module (part of 
the Python standard library) has a functions isclass(). It does the 
proper tests for new style and old style classes.


import inspect
inspect.isclass(something)

Christian

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


Re: regular expressions.

2008-08-08 Thread Hrvoje Niksic
Atul. [EMAIL PROTECTED] writes:

 the following does not work.

 import re
 vowel =
 r'[u\u093eu\u093fu\u0940u\u0941u\u0942u\u0943u\u0944u\u0945u\u0946u\u0947u\u0948u\u0949u\u094au\u094bu\u094c]'

Unfortunately you cannot embed arbitrary Python string constants
(u...) in regular expressions.  What does work is something like:

 vowel = 
 u'[\u093e\u093f\u0940\u0941\u0942\u0943\u0944\u0945\u0946\u0947\u0948\u0949\u094a\u094b\u094c]'
 re.findall(vowel, u\u092f\u093e\u0902\u091a\u094d\u092f\u093e)
[u'\u093e', u'\u093e']
--
http://mail.python.org/mailman/listinfo/python-list


Re: Threading and wx.....

2008-08-08 Thread Mike Driscoll
On Aug 8, 2:19 am, SamG [EMAIL PROTECTED] wrote:
 On Aug 8, 12:01 pm, SamG [EMAIL PROTECTED] wrote:



  Hi,

  Im trying my hand at threading with wx applications. I have written
  the following code...

  import wx
  from threading import Thread, Lock

  class createWindow(Thread):
      def __init__(self):
          Thread.__init__(self)
          self.lock = Lock()
          self.app=None

      def run(self):
          #self.lock.acquire()
          self.app = wx.PySimpleApp()
          frame = wx.Frame(None, title=Hello wx)
          frame.Show()
          #self.lock.release()
          self.app.MainLoop()

  if __name__=='__main__':
      c = createWindow()
      c.start()
      c.join()

  Now when i run this program i get a window but the application just
  does not respond. Is there something that im missing here. Pls let me
  know. Thanks in advance.

 Oops! Murphy's law works again! And the above code is working fine.

You'll probably also find the following wiki article helpful:
http://wiki.wxpython.org/LongRunningTasks

And there's at least one demo in the wxPython Demo that's a good
example of threading.

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


Re: CAB files

2008-08-08 Thread Tim Golden

Virgil Stokes wrote:

I would appreciate python code for creating *.cab files.


I'm not aware of any existing modules for creating
CABs. I thought there were some MS API calls for
doing that kind of thing but a quick search hasn't
shown anything up.

You may have to roll your own:

http://support.microsoft.com/kb/310618

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


bbfreeze problem

2008-08-08 Thread Neal Becker
Any ideas on this?

bb-freeze test5-coded-pre.py
WARNING: found xml.sax in multiple directories. Assuming it's a namespace 
package. (found in /usr/lib64/python2.5/site-packages/_xmlplus/sax, 
/usr/lib64/python2.5/xml/sax)
*** applied function recipe_doctest at 0xc618c0
recipe_matplotlib: using the backend_qt4agg matplotlib backend
*** applied function recipe_matplotlib at 0xc61d70
*** applied function recipe_pydoc at 0xc619b0
*** applied function recipe_time at 0xc61c80
*** applied function recipe_urllib at 0xc61a28
SKIPPING: SharedLibrary('libgthread-2.0.so.0',)
SKIPPING: SharedLibrary('libglib-2.0.so.0',)
*** applied function recipe_gtk_and_friends at 0xc61e60
*** applied function recipe_tkinter at 0xc61de8
==
The following eggs are being used:
Numeric 24.2 (/usr/lib64/python2.5/site-packages/Numeric)
configobj 4.5.2 (/usr/lib/python2.5/site-packages/configobj-4.5.2-py2.5.egg)
matplotlib 0.91.2 (/usr/lib/python2.5/site-packages/matplotlib-0.91.2-py2.5-
linux-x86_64.egg)
setuptools 0.6c8 (/usr/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg)
==
/usr/lib64/python2.5/site-packages/Numeric looks like a development egg. need 
to run setup.py bdist_egg
Traceback (most recent call last):
  File /usr/bin/bb-freeze, line 8, in module
load_entry_point('bbfreeze==0.96.2', 'console_scripts', 'bb-freeze')()
  File /usr/lib/python2.5/site-packages/bbfreeze-0.96.2-py2.5-linux-
x86_64.egg/bbfreeze/__init__.py, line 18, in main
f()
  File /usr/lib/python2.5/site-packages/bbfreeze-0.96.2-py2.5-linux-
x86_64.egg/bbfreeze/freezer.py, line 516, in __call__
analyzer.copy(self.distdir)
  File /usr/lib/python2.5/site-packages/bbfreeze-0.96.2-py2.5-linux-
x86_64.egg/bbfreeze/freezer.py, line 138, in copy
eggutil.copyDistribution(x, destdir)
  File /usr/lib/python2.5/site-packages/bbfreeze-0.96.2-py2.5-linux-
x86_64.egg/bbfreeze/eggutil.py, line 132, in copyDistribution
raise RuntimeError(setup.py not found for development egg)
RuntimeError: setup.py not found for development egg

I don't think I'm using matplotlib, don't understand what dragged it in (python 
-v on my script does _not_ show any matplotlib)

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


Re: Limits of Metaprogramming

2008-08-08 Thread Wilson
On 8 Aug, 13:30, Iain King [EMAIL PROTECTED] wrote:
 On Aug 4, 5:13 pm, Tomasz Rola [EMAIL PROTECTED] wrote:

  On Mon, 4 Aug 2008, Wilson wrote:
Every sufficiently large application has a poor/incomplete
   implementation ofLISPembedded within it .

  Yep, this is either exact or very close copy of what I have read.

 It's Greenspun's Tenth Rule of Programming:

 Any sufficiently complicated C or Fortran program contains an ad-hoc,
 informally-specified bug-ridden slow implementation of half of Common
 Lisp.

 Iain

Thanks for that. Makes my attempt look pathetic! :)
--
http://mail.python.org/mailman/listinfo/python-list


Re: CAB files

2008-08-08 Thread Thomas Heller
Virgil Stokes schrieb:
 I would appreciate python code for creating *.cab files.
 
 --V. Stokes

Here is some code that I have still laying around.  It has never been
used in production and I do not know what you can do with the cab files
it creates, but I have been able to create a cab and open it with winzip.

Thomas

cab.py
from ctypes import *
import sys, os, tempfile, glob

BOOL = c_int
ULONG = c_ulong
UINT = c_uint
USHORT = c_ushort

class ERF(Structure):
_fields_ = [(erfOper, c_int),
(erfType, c_int),
(fError, BOOL)]

CB_MAX_CHUNK =   32768
CB_MAX_DISK =0x7ff
CB_MAX_FILENAME =   256
CB_MAX_CABINET_NAME =   256
CB_MAX_CAB_PATH =   256
CB_MAX_DISK_NAME =  256

class CCAB(Structure):
_fields_ = [
(cb, ULONG),  # size available for cabinet on this 
media
(cbFolderThresh, ULONG),  # Thresshold for forcing a new Folder
(cbReserveCFHeader, UINT),   # Space to reserve in CFHEADER
(cbReserveCFFolder, UINT),   # Space to reserve in CFFOLDER
(cbReserveCFData, UINT), # Space to reserve in CFDATA
(iCab, c_int),# sequential numbers for cabinets
(iDisk, c_int),   # Disk number
(fFailOnIncompressible, c_int), # TRUE = Fail if a block is 
incompressible
(setID, USHORT),   # Cabinet set ID
(szDisk, c_char * CB_MAX_DISK_NAME),# current disk name
(szCab, c_char * CB_MAX_CABINET_NAME),  # current cabinet name
(szCabPath, c_char * CB_MAX_CAB_PATH),  # path for creating cabinet
]

cab = cdll.cabinet

class HFCI(object):
_handle = 0
_as_parameter_ = property(lambda self: self._handle)

def __init__(self, fnm, verbose=1):
self.verbose = verbose
self.erf = ERF()
ccab = self.ccab = CCAB()
ccab.cb = 1
ccab.cbFolderThresh = 10
ccab.szCab = os.path.basename(fnm)
dirname = os.path.dirname(fnm)
if not dirname:
dirname = .
ccab.szCabPath = dirname + \\
self._init_callbacks()
self._handle = cab.FCICreate(byref(self.erf),
 self.pfn_filedest,
 cdll.msvcrt.malloc,
 cdll.msvcrt.free,
 cdll.msvcrt._open,
 cdll.msvcrt._read,
 cdll.msvcrt._write,
 cdll.msvcrt._close,
 cdll.msvcrt._lseek,
 cdll.msvcrt._unlink,
 self.pfn_gettempfnm,
 byref(ccab),
 None)

def _init_callbacks(self):
self.pfn_gettempfnm = CFUNCTYPE(c_int, c_void_p, c_int, 
c_void_p)(self._gettempfnm)
self.pfn_filedest = CFUNCTYPE(c_int)(self._filedest)
self.pfn_status = CFUNCTYPE(c_int, c_int, c_uint, c_uint, 
c_void_p)(self._status)
self.pfn_getnextcab = CFUNCTYPE(c_int)(self._getnextcab)
self.pfn_getopeninfo = CFUNCTYPE(c_int, c_char_p)(self._getopeninfo)

def _getopeninfo(self, fnm):
if self.verbose:
print File, fnm
return cdll.msvcrt._open(fnm, os.O_BINARY | os.O_RDONLY)

def _status(self, typeStatus, cb1, cb2, pv):
return 0

def _filedest(self):
return 0

def _getnextcab(self):
return 0

def _gettempfnm(self, pszTempName, cbTempName, pv):
# same as tempfile.mktemp(), but this is deprecated
fh, fnm = tempfile.mkstemp()
os.close(fh)
os.remove(fnm)
cdll.msvcrt.strcpy(pszTempName, fnm)
return 1

def AddFile(self, src, dst=None, compressed=0):
if dst is None:
dst = os.path.basename(src)
cab.FCIAddFile(self,
   src,
   dst,
   0, # fExecute
   self.pfn_getnextcab,
   self.pfn_status,
   self.pfn_getopeninfo,
   compressed)

def Close(self):
if self._handle != 0:
cab.FCIFlushCabinet(self,
0, # fGetNextCab
self.pfn_getnextcab,
self.pfn_status)
cab.FCIDestroy(self)
self._handle = 0

if __name__ == __main__:
import os, glob

hfci = HFCI(my-first.cab, verbose=1)

files = glob.glob(r.\cab\*.*)

for fnm in files:
hfci.AddFile(fnm)

hfci.Close()
eof
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to find out if an object is a class?

2008-08-08 Thread Stefan Behnel
Miles wrote:
 On Fri, Aug 8, 2008 at 2:31 AM, Stefan Behnel wrote:
 I recently had the reverse case that a (stupidly implemented) extension 
 module
 required a callback function and I wanted to pass a function wrapped in a
 wrapper object. That failed, because it specifically checked for the argument
 being a function, not just a callable object. I had to pull quite a number of
 tricks to reimplement the wrapper class as a function (thank god, it's 
 Python!).
 
 You really only needed one trick:
 
 def functionize(callable):
 return lambda *args, **kwargs: callable(*args, **kwargs)

Congratulations, you found the trivial case.

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


small issue with Idle

2008-08-08 Thread v4vijayakumar
When you press 'home' button cursor goes before  prompt. This is
little uncomfortable.

I am using Idle 1.2.2. (python 2.5.2.)
--
http://mail.python.org/mailman/listinfo/python-list


Re: python-mode is missing the class browser

2008-08-08 Thread Alexander Schmolck
Adam Jenkins [EMAIL PROTECTED] writes:

 On Fri, Aug 8, 2008 at 7:32 AM, Michele Simionato
 [EMAIL PROTECTED] wrote:
 On Aug 7, 5:55 pm, Alexander Schmolck [EMAIL PROTECTED] wrote:
 ...

 I have solved by using ipython.el which was already installed. For the
 sake of
 future googlers using Ubuntu 8.04, emacs and ipython, it is enough if
 you just add

 (setq ipython-command /usr/bin/ipython)
 (require 'ipython)

 to your .emacs. It is nice since I get the occasion to try ipython.el
 which I am
 sure I will like ;)

 So, I'm looking at the .el, but I'm not sure. What else does
 ipython.el give you than just the ipython shell?

What else could you possibly want? :)

Seriously, ipython.el is a simple kludge whose only function is to make
python-mode work with ipython (rather than python[*]). Despite this certain
primitiveness (c.f. slime), Emacs+ipython makes quite a powerful development
environment, significantly more so than ipython alone or emacs + python. Most
importantly thre is:

1. debug. Try it: write some code that will throw an unhandled exception, and
   just type ``debug``. Type ``u`` and ``d`` to go up and down the stack
   frame, and see the right file and line pop up in emacs. I really find that
   combined with the ability to do arbitrary things with the things I find on
   the stack incredibly useful for development. 

2. ? and ?? as well as ed. To get help on foo you just write ``foo?``. To get
   its source code as well type ``foo??``. Finally to edit the code that
   correspond's to foo's class or function definition (also works on class
   instances)) type ``ed foo`` (IIIRCk the default behavior is autoexecution,
   so you might want to re-alias).

3. Autocompletion with tab.

4. run (including -d and -p options). Try ``run?``

5. Matplotlib and gui stuff works interactively. (-pylab cmdline option)

6. Convenient Shell interaction (ls, !, int) and interpolation from and too
   python

7. Pretty printing.

But there's plenty more stuff. The most useful in terms of added functionality
via emacs is 1, but isearch and emacs editing power make the ipython shell
output also noticably more useful (and thus things like ?, ?? and pretty
printing).

cheers,

'as

[*] Inter alia the prompt parsing stuff needs to be different and the ansi
color formatting needs to be dealt with.
--
http://mail.python.org/mailman/listinfo/python-list


Re: .cpp to .pyd

2008-08-08 Thread vedrandekovic
On 7 kol, 21:43, Carl Banks [EMAIL PROTECTED] wrote:
 On Aug 7, 3:25 am, [EMAIL PROTECTED] wrote:



  Hello,

  I want to build my C++ (.cpp) script to (.pyd) like this:

 http://en.wikibooks.org/wiki/Python_Programming/Extending_with_C%2B%2B

  I have installed Microsoft Visual studio .NET 2003 and Boost
  Python and then after I run my setup script:

  python setup.py build

  I get this error:

  running build
  running build_ext
  building 'hello' extension
  D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /
  nologo /Ox
   /MD /W3 /GX /DNDEBUG -IC:\Panda3D-1.5.2\python\include -IC:
  \Panda3D-1.5.2\pytho
  n\PC /Tphellomodule.cpp /Fobuild\temp.win32-2.5\Release
  \hellomodule.obj
  hellomodule.cpp
  hellomodule.cpp(9) : fatal error C1083: Cannot open include file:
  'boost/python/
  module.hpp': No such file or directory
  error: command 'D:\Program Files\Microsoft Visual Studio .NET
  2003\Vc7\bin\cl.e
  xe' failed with exit status 2

  I think that my MS visual studio  cannot find boost python, if
  that's the problem then can you tell me how can I solve it.
  This is very begginer question,but I can't find answer nowhere, and I
  don't have any expirience with Microsoft products.

  Sorry for my bad english!
  Regards,
  Veki

 First, locate the boost header files.  Suppose you find the file
 module.hpp in this location:

 C:\boost-whatever-version\include\boost\python\module.hpp

 The part that comes before boost\python\module.hpp is the required
 include directory.  You can tell setup to use this directory by adding
 the following argument to the Extension call:

 include_dirs = ['C:\\boost-whatever-version\\include']

 Notice the doubling of backslashes.  Remember to add the directory
 where the boost header files lie on your system; don't add this line
 exactly.

 You should end up with a setup call that looks like this:

 setup(name=blah,
     ext_modules=[
         Extension(hello, [hellomodule.cpp],
             libraries = [boost_python],
             include_dirs = ['C:\\boost-whatever-version\\include'])
     ])

 Carl Banks

Hi,

Thanks for quick reply.Maybe I'm crazy but I did what you said and I
stll get the same error :(  :(  :( :(.I have boost version 1.34.1 and
I'm
running it on Windows XP SP2.

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


Re: Psycho question

2008-08-08 Thread David C. Ullrich
In article [EMAIL PROTECTED],
 Delaney, Timothy (Tim) [EMAIL PROTECTED] wrote:

 David C. Ullrich wrote:
 
  f: 0.0158488750458
  g: 0.000610113143921
  h: 0.00200295448303
  f: 0.0184948444366
  g: 0.000257015228271
  h: 0.00116610527039
 
 I suspect you're hitting the point of diminishing returns with g, and
 any further investigations into optimisation are purely for fun and
 learning ;)

No doubt. Hadn't meant to get into optimization, at least not
here, but various people made various comments - when someone
suggests this or that seems like I should try it.

Curiously smug grin g is exactly how I'd planned on doing it
before trying anything. The one thing that puzzles me about
all the results is why // is so much slower than / inside
that Psyco loop.

 Tim Delaney

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


Re: small issue with Idle

2008-08-08 Thread Lie
On Aug 8, 9:41 pm, v4vijayakumar [EMAIL PROTECTED]
wrote:
 When you press 'home' button cursor goes before  prompt. This is
 little uncomfortable.

 I am using Idle 1.2.2. (python 2.5.2.)

This is IDLE's behavior, not really python's. Anyway, I don't really
mind the minor annoyance as you don't seriously program serious
program in interactive mode (no pun intended). Anyway, if you feel
really disturbed by this, you should file a bug in: http://bugs.python.org/
--
http://mail.python.org/mailman/listinfo/python-list


relative imports improve program organization... suggestions?

2008-08-08 Thread DG
Alright, I have searched and searched and read many conversations on
the topic of relative and absolute imports and am still not getting
the whole thing through my skull.

Highlights of what I've read:
http://mail.python.org/pipermail/python-list/2007-January/422973.html
http://groups.google.com/group/comp.lang.python/browse_thread/thread/b1e8dc93471a7079/8751c82cfe1ca3f2?lnk=gstq=absolute+import#8751c82cfe1ca3f2
http://www.python.org/dev/peps/pep-0328/
http://docs.python.org/whatsnew/pep-328.html

So my problem and argument:
I want to create a package organized as the following:
pckg/
 __init__.py
 main.py
 moduleA/
  __init__.py
  A_base.py
  A1/
   __init__.py
   A_inherit1.py
   other_A1_files...
  A2/
   __init__.py
   A_inherit2.py
   other_A2_files...
 moduleB/
  ...
Explanation:
The main program is located in main.py and it implements the different
modules (A, B).  Within the modules the basic organization is; the
base class for all different types of A is directly within the moduleA
directory.  All of the different inherited classes of A are within
their own subdirectory with a mess of their own files.  This is done
so that a new subclass of A can be added/removed by just adding/
removing the subdirectory and each of these subclasses may have their
own maintainer, but they should all inherit from A_base.py

If I am developing the A1 directory, I want to be able to test
A_inherit1.py by using 'if __name__ == __main__' within the
A_inherit1.py file and by typing 'python A_inherit1.py' on the command
line.  I prefer this simply to keep all unit tests within the same
directory and same file as the inherited class.

My Problem:
A_inherit1.py has the line:
 'from ..A_base import A_Base_Class'
so that I can later declare the inherited class as such:
 'A1_Inherited_Class(A_Base_Class):'

*BUT* I get the 'attempted relative import in non-package' error even
when I try the
'from __future__ import absolute_import' command.
I would prefer to be able to test the file without adding anything to
the PYTHONPATH, like I said by using the name == main trick.

So could someone explain to me what the rationale behind not allowing
parent directory relative imports is?  And possibly what I can do to
get around it?  (I really don't like messing with the sys.path for
something like this)

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


Re: small issue with Idle

2008-08-08 Thread Mike Driscoll
On Aug 8, 9:41 am, v4vijayakumar [EMAIL PROTECTED]
wrote:
 When you press 'home' button cursor goes before  prompt. This is
 little uncomfortable.

 I am using Idle 1.2.2. (python 2.5.2.)

There's a free version of Wing IDE that has an IDLE-like interface
that doesn't have this issue...or you could just use the command line
version of IDLE.

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


Problem with global variables

2008-08-08 Thread Anthony Kuhlman
Pythoners,
I'm having trouble understanding the behavior of global variables in a
code I'm writing.  I have a file, test.py, with the following contents

foo = []

def goo():
global foo
foo = []
foo.append(2)

def moo():
print foo

In an ipython session, I see the following:

In [1]: from test import *

In [2]: foo
Out[2]: []

In [3]: goo()

In [4]: foo
Out[4]: []

In [5]: moo()
[2]

I don't understand this behavior.  I assumed that foo as defined in
test.py is a global object, but that doesn't seem to be the case.
Obviously, there's some sort of namespace thing going on here that I
don't get.  The ipython session seems to be dealing with one copy of foo
while goo() and moo() are using an entirely different copy.  

If I take out the line 'foo = []' in goo(), everything behaves exactly
as I expect, that is, in ipython, when I type goo() followed by foo I
get [2].

Can anyone shed some light on this behavior?

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


Re: HTTP basic authentication with form-based authentication

2008-08-08 Thread Max
On Aug 7, 3:54 pm, Wojtek Walczak
[EMAIL PROTECTED] wrote:
 Dnia Thu, 7 Aug 2008 11:14:05 -0700 (PDT), Max napisa³(a):

 Use ClientCookie or even better - 
 mechanize:http://pypi.python.org/pypi/mechanize/
 The docs aren't perfect, but you should easily
 find what you are searching for.

Thank you; mechanize is perfect. The example at 
http://wwwsearch.sourceforge.net/mechanize/
provided enough information for my problem.
--
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP basic authentication with form-based authentication

2008-08-08 Thread Max
On Aug 7, 3:54 pm, Wojtek Walczak
[EMAIL PROTECTED] wrote:
 Dnia Thu, 7 Aug 2008 11:14:05 -0700 (PDT), Max napisa³(a):

 Use ClientCookie or even better - 
 mechanize:http://pypi.python.org/pypi/mechanize/
 The docs aren't perfect, but you should easily
 find what you are searching for.

Thank you; mechanize is perfect. The example at 
http://wwwsearch.sourceforge.net/mechanize/
provided enough information for my problem.
--
http://mail.python.org/mailman/listinfo/python-list


Re: python-mode is missing the class browser

2008-08-08 Thread Neal Becker
Alexander Schmolck wrote:

 Adam Jenkins [EMAIL PROTECTED] writes:
 
 On Fri, Aug 8, 2008 at 7:32 AM, Michele Simionato
 [EMAIL PROTECTED] wrote:
 On Aug 7, 5:55 pm, Alexander Schmolck [EMAIL PROTECTED] wrote:
 ...

 I have solved by using ipython.el which was already installed. For the
 sake of
 future googlers using Ubuntu 8.04, emacs and ipython, it is enough if
 you just add

 (setq ipython-command /usr/bin/ipython)
 (require 'ipython)

 to your .emacs. It is nice since I get the occasion to try ipython.el
 which I am
 sure I will like ;)

 So, I'm looking at the .el, but I'm not sure. What else does
 ipython.el give you than just the ipython shell?
 
 What else could you possibly want? :)
 
 Seriously, ipython.el is a simple kludge whose only function is to make
 python-mode work with ipython (rather than python[*]). Despite this
 certain primitiveness (c.f. slime), Emacs+ipython makes quite a powerful
 development environment, significantly more so than ipython alone or emacs
 + python. Most importantly thre is:
 
 1. debug. Try it: write some code that will throw an unhandled exception,
 and
just type ``debug``. Type ``u`` and ``d`` to go up and down the stack
frame, and see the right file and line pop up in emacs. I really find
that combined with the ability to do arbitrary things with the things I
find on the stack incredibly useful for development.
 
 2. ? and ?? as well as ed. To get help on foo you just write ``foo?``. To
 get
its source code as well type ``foo??``. Finally to edit the code that
correspond's to foo's class or function definition (also works on class
instances)) type ``ed foo`` (IIIRCk the default behavior is
autoexecution, so you might want to re-alias).
 
 3. Autocompletion with tab.
 
 4. run (including -d and -p options). Try ``run?``
 
 5. Matplotlib and gui stuff works interactively. (-pylab cmdline option)
 
 6. Convenient Shell interaction (ls, !, int) and interpolation from and
 too
python
 
 7. Pretty printing.
 
 But there's plenty more stuff. The most useful in terms of added
 functionality via emacs is 1, but isearch and emacs editing power make the
 ipython shell output also noticably more useful (and thus things like ?,
 ?? and pretty printing).
 
 cheers,
 
 'as
 
 [*] Inter alia the prompt parsing stuff needs to be different and the ansi
 color formatting needs to be dealt with.
 --

Unfortunately, ipython.el seems to be incompatible with use on your own scripts 
if they process command line options (e.g., optparse).

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


Programmers needed: open governance project

2008-08-08 Thread Ed Pastore
The Metagovernment project is seeking Python programmers to help us 
build Metascore, an open source (Affero GPL) web application intended 
to act as the governing mechanism of any community of any size.
http://www.metagovernment.org/wiki/Metascore

Metascore could be used for something as simple as managing the 
administrative functions of a chess club to something as massive as 
being the legal government of a city (or larger).

The primary objective is to enable everyone in a community to 
participate in the governance of that community, without having to 
rely on any individual leader/representative.

In its simplest form, this system can simplify the administration of 
small communities, obviating the need for a cumbersome bureaucratic 
structure. In it's most sophisticated potential application, it can 
enable massively-participatory (web 2.0) global direct democracy 
without suffering from the traditional flaws of mob rule.  We are 
attempting to build a mechanism where consensus can be built 
organically through the promotion of synthesis between conflicting 
points of view.

We invite you to check us out and see if you could be of assistance.

We are pre-Alpha, and currently have two radically different branches. 
One of those is being developed in Python 2.4 and Django, and the lead 
developer would love to have some help. See this page for a general 
description and a link to a code repository:
http://www.metagovernment.org/wiki/PrototypeA
A running copy of the code is on the developer's laptop (but will be 
moved to metascore.org soon), so I won't give out that link, but he 
would be happy to talk to / share with you.

What's in it for you, other than some great programming experience? A 
chance to be an architect and builder of what just might be the new 
government of humanity. It is a long road we are following, but 
clearly the world is poised to mature beyond archaic, leader-follower 
forms of government. This is your chance to be one of the key players 
to make it happen.

Feel free to contact me, contact the lead developer of this branch (he 
hangs out on #metascore on irc.freenode.net) or to join our startup 
committee (i.e., mailing list) detailed at: 
http://www.metagovernment.org/wiki/Startup

Thank you for your consideration.

Ed Pastore
Metagovernment project
http://www.metagovernment.org/wiki/User:Ed_Pastore
--
http://mail.python.org/mailman/listinfo/python-list


Re: Psycho question

2008-08-08 Thread John Krukoff

On Fri, 2008-08-08 at 12:18 -0500, David C. Ullrich wrote:
 Curiously smug grin g is exactly how I'd planned on doing it
 before trying anything. The one thing that puzzles me about
 all the results is why // is so much slower than / inside
 that Psyco loop.
 
  Tim Delaney
 

One possibility for the performance difference, is that as I understand
it the psyco developer has moved on to working on pypy, and probably
isn't interested in keeping psyco updated and optimized for new python
syntax.

Somebody correct me if I'm wrong, but last I heard there's no
expectation of a python 3.0 compatible version of psyco, either.

-- 
John Krukoff [EMAIL PROTECTED]
Land Title Guarantee Company

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


I need a Python mentor

2008-08-08 Thread A. Joseph
How are you? You look good; I will like to meet you.

Visit my profile and drop some line for me.



Abah



Hello everybody, i`m new to this list. I was programming in PHP before, so
just of recent I started learning python. I need someone who I can be giving
me some assignment based on the chapter I read in the book, and tell person
will sometime review my code and tell me if it well structured.



Can you be my mentor?
--
http://mail.python.org/mailman/listinfo/python-list

I need a Python mentor

2008-08-08 Thread A. Joseph
*Please the first message i sent out contain error, i`m very very sorry.*


Hello everybody, i`m new to this list. I was programming in PHP before, so
just of recent I started learning python. I need someone who I can be giving
me some assignment based on the chapter I read in the book, and tell person
will sometime review my code and tell me if it well structured.



Can you be my mentor?

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

Re: Problem with global variables

2008-08-08 Thread Marc 'BlackJack' Rintsch
On Fri, 08 Aug 2008 13:10:48 -0400, Anthony Kuhlman wrote:

 I'm having trouble understanding the behavior of global variables in a
 code I'm writing.  I have a file, test.py, with the following contents
 
 foo = []
 
 def goo():
 global foo
 foo = []
 foo.append(2)
 
 def moo():
 print foo
 
 In an ipython session, I see the following:
 
 In [1]: from test import *
 
 In [2]: foo
 Out[2]: []
 
 In [3]: goo()
 
 In [4]: foo
 Out[4]: []
 
 In [5]: moo()
 [2]
 
 I don't understand this behavior.  I assumed that foo as defined in
 test.py is a global object, but that doesn't seem to be the case.

``global`` means module global.  There's no really global namespace in 
Python.

 The ipython session seems to be dealing with one copy of foo while
 goo() and moo() are using an entirely different copy.

The import binds the list from the module to the name `foo` in the 
IPython namespace.  When you call `goo()` it binds the name `foo` *within 
the module* to a new list.  This has of course no influence on the name 
in the IPython namespace which is still bound to the list object that was 
bound to `test.foo` before.

Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list


Re: Psycho question

2008-08-08 Thread bearophileHUGS
John Krukoff:
 One possibility for the performance difference, is that as I understand
 it the psyco developer has moved on to working on pypy, and probably
 isn't interested in keeping psyco updated and optimized for new python
 syntax.
 Somebody correct me if I'm wrong, but last I heard there's no
 expectation of a python 3.0 compatible version of psyco, either.

But for me on the short term Python 3 is probably more important than
pypy, and I'd like to keep using Psyco...

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


Re: numpy and filtering (was: Fastest way to store ints and floats on disk)

2008-08-08 Thread Robert Kern

Laszlo Nagy wrote:
Attached there is an example program that only requires numpy. At the 
end I have two numpy array:


rdims:

[[3 1 1]
[0 0 4]
[1 3 0]
[2 2 0]
[3 3 3]
[0 0 2]]


rmeas:

[[10.0 254.0]
[4.0 200.0]
[5.0 185.0]
[5000.0 160.0]
[15.0 260.0]
[2.0 180.0]]


I would like to use numpy to create statistic, for example the mean 
value of the prices:


  rmeas[:,0] # Prices of cars
array([10.0, 4.0, 5.0, 5000.0, 15.0, 2.0], 
dtype=float96)

  rmeas[:,0].mean() # Mean price
60833.3321

However, I only want to do this for 'color=yellow' or 'year=2003, 
make=Ford' etc. I wonder if there a built-in numpy method that can 
filter out rows using a set of values. E.g. create a view of the 
original array or a new array that contains only the filtered rows. I 
know how to do it from Python with iterators, but I wonder if there is a 
better way to do it in numpy. (I'm new to numpy please forgive me if 
this is a dumb question.)


It's not, but you will get more help on the numpy-discussion mailing list than 
here.

  http://www.scipy.org/Mailing_Lists

I would normally answer your question, too, but I'm on vacation and have to run 
off to a party right now.


--
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco

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


Re: benchmark

2008-08-08 Thread Terry Reedy



Dhananjay wrote:

On Aug 7, 11:58 pm, Terry Reedy [EMAIL PROTECTED] wrote:

[EMAIL PROTECTED] wrote:
  Are there any implications of using psyco ?

It compiles statements to machine code for each set of types used in the
statement or code block over the history of the run.  So code used
polymorphically with several combinations of types can end up with
several compiled versions (same as with C++ templates).  (But a few
extra megabytes in the running image is less of an issue than it was
even 5 or so years ago.)  And time spent compiling for a combination
used just once gains little.  So it works best with numeric code used
just for ints or floats.

Terry J. Reedy


But if site caching is indeed being adopted by so many dynamic language
runtime environments, I kind of wonder what makes python hold back from
bringing it in to its core. Is it that a question of time and effort,


Yes, and of priorities of the *current* volunteer developers, and of 
complexity and maintainability and their impact on being dependably correct.



or is there something that doesn't make it appropriate to python ?


How about less necessary.  Python was designed to be extended by native 
code.  The built-in functions and classes are built-in extensions.  The 
built-in extensions in the stdlib are importable extensions**.  *So are 
native-code 3rd party extensions*!


Numeric, Python's first killer app, and now numpy, which both wrap 
standard Fortran and C libraries, have been standard associated parts of 
'Python' (CPython) as used in the science, engineering, and technical 
community for over a decade.  There are features in Python that were 
introduced for their use.  Python 3.0 has (if plans get fulfilled) a new 
multi-dimensional buffer class/interface/C-API (not sure of the details 
;-) introduced by Travis Oliphant of NumPy for use by extension writers 
so extensions, built-in or 3rd-party, can work together (share C level 
date) without copying.  For instance, the C-level data for an image 
imported into a cooperating image program could be directly manipulated 
by NumPy and then directly blitted on the screen by a display manager.



About benchmarks: machine speed benchmarks miss the point that the real 
limiting factor in information processing is programmer availability and 
writing and debugging speed.  Python was optimized for *this*, not 
machine speed per se, knowing that most machine bottlenecks could be 
rewritten in C or another low-level language.  Why reinvent that wheel? 
 Measuring programmer productivity is hard, but it is real.


Number-crunching benchmarks which disallow NumPy because it is not 
distributed with the 'core' by PSF (although it *is* by other 
packagers), are simply braindead.  If a scientist/engineer/technologist 
saves half an hour setting up a 10-hour run by using Python instead of 
C, it is *completely irrelevant* that the C interface to the 
number-crunching libraries might run in a 1/10 second instead of, say, 
10 seconds.  That is why such people developed Numeric and then NumPy.



None of this is to say that continued development of Psyco or equivalent 
for new versions would not be great.  But that comes down to *someone* 
volunteering the resources.


Terry Jan Reedy



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


sending to an xterm

2008-08-08 Thread Kent Tenney
Howdy,

I want to open an xterm, send it a command and have it execute it.

I thought pexpect would do this, but I've been unsuccessful.

term = pexpect.spawn('xterm')

starts an xterm, but

term.sendline('ls') 

doesn't seem to do anything.

Suggestions?

Thanks,
Kent

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


Re: Best practise implementation for equal by value objects

2008-08-08 Thread Terry Reedy



Slaunger wrote:


OK, i am encouraged to carry on my quest with the eval(repr)) for my
'nice' classes.
I just revisited the documentation for eval and noticed that there are
optional globals
and locals name space variables, that one could specify:

http://docs.python.org/lib/built-in-funcs.html

Quite frankly I do not understand how to make use of these parameters,
but it is my feeling
that if I enforce a convention of always specifying the globals/locals
parameter in a specific
manner:
assert eval(repr(x), globals, locals) == x
would work independent of how I have imported the module under test.


I have no opinion as to whether you should or should not use eval beyond 
testing.  But I believe the following will work and teach a bit more 
too.  In one module, define 'mynice = {'Age':Age, ...}' for your nice 
classes (that module could import from other modules and use dotted 
names as needed).  Then eval(repr(x), mynice, mynice) should work 
anywhere (as long as mynice has been imported!).


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


Re: sending to an xterm

2008-08-08 Thread Emile van Sebille

Kent Tenney wrote:

Howdy,

I want to open an xterm, send it a command and have it execute it.

I thought pexpect would do this, but I've been unsuccessful.

term = pexpect.spawn('xterm')

starts an xterm, but

term.sendline('ls') 


doesn't seem to do anything.

Suggestions?

Thanks,
Kent

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



expect or http://www.noah.org/wiki/Pexpect


Emile

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


Re: sending to an xterm

2008-08-08 Thread Derek Martin
On Fri, Aug 08, 2008 at 08:25:19PM +, Kent Tenney wrote:
 Howdy,
 
 I want to open an xterm, send it a command and have it execute it.

You can't do that.  xterm doesn't execute shell commands passed on
stdin...  It can, however, execute one passed on the command line.

Instead of just running xterm, you can run xterm -e 'cmd foo bar'
where cmd is the program to run and foo and bar are its arguments.
The problem is that as soon as the program exits, xterm will exit
also.

-- 
Derek D. Martin
http://www.pizzashack.org/
GPG Key ID: 0x81CFE75D



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

Re: I need a Python mentor

2008-08-08 Thread Emile van Sebille

A. Joseph wrote:

*Please the first message i sent out contain error, i`m very very sorry.*


Hello everybody, i`m new to this list. I was programming in PHP before, 
so just of recent I started learning python. I need someone who I can be 
giving me some assignment based on the chapter I read in the book, and 
tell person will sometime review my code and tell me if it well structured.


 


Can you be my mentor?

Abah Josep




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



Try the tutor list...

http://mail.python.org/mailman/listinfo/tutor

Emile

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


Re: small issue with Idle

2008-08-08 Thread Terry Reedy



Lie wrote:

On Aug 8, 9:41 pm, v4vijayakumar [EMAIL PROTECTED]
wrote:

When you press 'home' button cursor goes before  prompt. This is
little uncomfortable.

I am using Idle 1.2.2. (python 2.5.2.)


This is IDLE's behavior, not really python's. Anyway, I don't really
mind the minor annoyance as you don't seriously program serious
program in interactive mode (no pun intended). Anyway, if you feel
really disturbed by this, you should file a bug in: http://bugs.python.org/


I verified that behavior is same in 3.0b2.  I added a note to
http://bugs.python.org/issue2704.
In the meanwhile, PageUp PageDn will go where you want if there is text 
above the window to jump to.


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


Re: small issue with Idle

2008-08-08 Thread Terry Reedy



Mike Driscoll wrote:


There's a free version of Wing IDE that has an IDLE-like interface
that doesn't have this issue...or you could just use the command line
version of IDLE.


What are you referring to?

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


Re: sending to an xterm

2008-08-08 Thread Kent Tenney
Derek Martin code at pizzashack.org writes:

 
 On Fri, Aug 08, 2008 at 08:25:19PM +, Kent Tenney wrote:
  Howdy,
  
  I want to open an xterm, send it a command and have it execute it.
 
 You can't do that.  xterm doesn't execute shell commands passed on
 stdin...  It can, however, execute one passed on the command line.
 
 Instead of just running xterm, you can run xterm -e 'cmd foo bar'
 where cmd is the program to run and foo and bar are its arguments.
 The problem is that as soon as the program exits, xterm will exit
 also.
 

OK, I see that. 

(getting off topic)

any chance of keeping the xterm open after running the command?

Thanks,
Kent



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


Re: sending to an xterm

2008-08-08 Thread Kent Tenney
Derek Martin code at pizzashack.org writes:

 
 On Fri, Aug 08, 2008 at 08:25:19PM +, Kent Tenney wrote:
  Howdy,
  
  I want to open an xterm, send it a command and have it execute it.
 
 You can't do that.  xterm doesn't execute shell commands passed on
 stdin...  It can, however, execute one passed on the command line.
 
 Instead of just running xterm, you can run xterm -e 'cmd foo bar'
 where cmd is the program to run and foo and bar are its arguments.
 The problem is that as soon as the program exits, xterm will exit
 also.
 

Sorry to reply before getting googly

This appears to be a solution;

xterm -e ls; bash

http://www.linuxforums.org/forum/misc/115239-getting-prompt-after-xterm-e-command.html


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


RE: I need a Python mentor

2008-08-08 Thread Support Desk
U...yea

 

 

  _  

From: A. Joseph [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 08, 2008 1:44 PM
To: python-list@python.org
Subject: I need a Python mentor

 

How are you? You look good; I will like to meet you. 

Visit my profile and drop some line for me.

 

Abah

 

Hello everybody, i`m new to this list. I was programming in PHP before, so
just of recent I started learning python. I need someone who I can be giving
me some assignment based on the chapter I read in the book, and tell person
will sometime review my code and tell me if it well structured.

 

Can you be my mentor? 

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

Re: Keg - A python web framework

2008-08-08 Thread eghansah
Hi,

Thank you for the comments so far.

To be honest with you I didn't know about pycoon until Bukzor mentioned it.
There appears to be some similarities between the two projects. However, I
think I'd have to take a closer look at it to be sure that I'm not
duplicating the efforts made in that project.

As to the question on how different this is from other frameworks, I think
there are certainly many similarities. As I admitted in the writeup, it
draws from other projects including django. However, there is one new idea I
haven't seen anywhere . . . not yet at least. In keg, I try to use URL
pattern matching to run one or more functions required to generate the page
the URL is pointing to. For instance, when you try to access a page like
http://www.python.org Keg will run all functions whose URL regex matches the
URL requested. Their output is then combined to generate the resulting page.
With this approach, we could have functions that generate menus, those that
generate page content and those that manage logins. These could all be
separately maintained. Keg ties their outputs all together to generate the
page. This means you could work on a menu system and not worry about how you
will generate ads for the page. The possibilities are endless . . . at least
in theory.

Also, each function receives the same input. This means that the execution
of one function does not really affect the execution of any others.
Hopefully this makes debugging much easier. Another good effect of this idea
is that all functions can be run in parallel since they are independent.
--
http://mail.python.org/mailman/listinfo/python-list

RE: sending to an xterm

2008-08-08 Thread Edwin . Madari
since I do not have access to xterm, here is the interactive session for 
spawning bash(another session if you will), sending ls command to it, and 
retrieving the results.
things to note are:
1. after spawning expect for the prompt, timeout, and eof #which ever happens 
first
2. return value is the action that matched
3. if prompt matched, the 'before' has the results
4. even the command 'ls' with '\r\n' will be in the results.
actual session--
[EMAIL PROTECTED]:/c/Edwin/Projects/expect
$ python
Python 2.5.1 (r251:54863, May 18 2007, 16:56:43) 
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type help, copyright, credits or license for more information.
 import pexpect
 c = pexpect.spawn('/bin/bash')
 c.expect([pexpect.TIMEOUT, pexpect.EOF, '\$ '])
2
 c.before
'[EMAIL PROTECTED]:/c/Edwin/Projects/expect\r\n'
 c.after
'$ '
 c.sendline('ls')
3
 c.expect([pexpect.TIMEOUT, pexpect.EOF, '\$ '])
2
 c.before
'[EMAIL PROTECTED]:/c/Edwin/Projects/expect\r\n'
 c.after
'$ '
 
 exit()
[EMAIL PROTECTED]:/c/Edwin/Projects/expect
$ 
---

good luck
Edwin
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
On Behalf Of Kent Tenney
Sent: Friday, August 08, 2008 4:25 PM
To: python-list@python.org
Subject: sending to an xterm


Howdy,

I want to open an xterm, send it a command and have it execute it.

I thought pexpect would do this, but I've been unsuccessful.

term = pexpect.spawn('xterm')

starts an xterm, but

term.sendline('ls') 

doesn't seem to do anything.

Suggestions?

Thanks,
Kent

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


The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure.  If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof.  Thank you.


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


maybe a stupid question

2008-08-08 Thread Strato

Hi,

I suppose this has already been asked in the list, but I ask anyway:

I want to determine from where my python app is executed, but I want to 
determine the path of the real script file, not the path of the command 
being executed (in case of symlink in a *bin dir in the system).


I explain:

I have an app installed in /usr/lib/python2.5/site-package/MyApp

I have a symlink in /usr/local/bin that points to 
/usr/lib/python2.5/site-package/MyApp/myscript.py


Then, when I launch my script from anywhere using the symlink, how to 
determine that the script is located in 
/usr/lib/python2.5/site-package/MyApp ?


Regards,
Strato


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


Re: Keg - A python web framework

2008-08-08 Thread Terry Reedy

eghansah wrote:

As to the question on how different this is from other frameworks, I 
think there are certainly many similarities. As I admitted in the 
writeup, it draws from other projects including django. However, there 
is one new idea I haven't seen anywhere . . . not yet at least. In keg, 
I try to use URL pattern matching to run one or more functions required 
to generate the page the URL is pointing to. For instance, when you try 
to access a page like http://www.python.org http://www.python.org/ Keg 
will run all functions whose URL regex matches the URL requested. Their 
output is then combined to generate the resulting page. With this 
approach, we could have functions that generate menus, those that 
generate page content and those that manage logins. These could all be 
separately maintained. Keg ties their outputs all together to generate 
the page. This means you could work on a menu system and not worry about 
how you will generate ads for the page. The possibilities are endless . 
. . at least in theory.
 
Also, each function receives the same input. This means that the 
execution of one function does not really affect the execution of any 
others. Hopefully this makes debugging much easier. Another good effect 
of this idea is that all functions can be run in parallel since they are 
independent.


So make your project an add-on to Django or other frameworks.  You tell 
Django to send all requests to key.py.  Keg.py runs the pattern matcher, 
call the functions, and re-assembles the result to pass back to Django 
for delivery.  The functions then have all other components of Django 
available.


In other words, don't reinvent the wheel, invent a new wheel cover*.

Terry Jan Reedy

This is possibly a new version of an old saying.  Other endings I found 
on Google (first 2000 hits) are '', 'improve it', 'improve on it', 'just 
add new tyres', 'just identify a colleague (who has done it)', 'Patch, 
extend or subclass an existing module', 're-invent its use!', 'write 
something new', and '(or worse, a flat tire)'.


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


Re: maybe a stupid question

2008-08-08 Thread Christian Heimes

Strato wrote:

I have an app installed in /usr/lib/python2.5/site-package/MyApp

I have a symlink in /usr/local/bin that points to 
/usr/lib/python2.5/site-package/MyApp/myscript.py


Then, when I launch my script from anywhere using the symlink, how to 
determine that the script is located in 
/usr/lib/python2.5/site-package/MyApp ?



Put this in myscript.py:

import os.path
HERE = os.path.dirname(os.path.abspath(__file__))

You may also need

HERE = os.path.realpath(HERE)

Explanation:

Almost every module has a global variable __file__. It points to the 
path from which the module was loaded. os.path.abspath() gives you the 
absolute path to the module. os.path.dirname() strips away the file part 
and gives you the path to the directory. os.path.realpath() migt be 
required to eliminate all symbolic links.


Christian

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


Re: variable expansion with sqlite

2008-08-08 Thread Kris Kennaway

marc wyburn wrote:

Hi and thanks,

I was hoping to avoid having to weld qmarks together but I guess
that's why people use things like SQL alchemy instead.  It's a good
lesson anyway.


The '?' substitution is there to safely handle untrusted input.  You 
*don't* want to pass in arbitrary user data into random parts of an SQL 
statement (or your database will get 0wned).  I think of it as a 
reminder that when you have to construct your own query template by 
using ... %s ... % (foo) to bypass this limitation, that you had 
better be darn sure the parameters you are passing in are safe.


Kris

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


Win32 trouble with threading, signals, and sleep()

2008-08-08 Thread Lowell Alleman
I'm trying to track down an issue with a multi-threaded program that
is responsible for handling real-time monitoring a business process.
Different threads track various aspects of the process and all of the
statistics filter back to the main thread for analysis.  The program
is run as a scheduled task, and various stats are shown in the console
window (dos box) as it runs.  Normally the main thread tells the
worker threads to stop (using an Event()) when the work is done.

I just recently added some signal handlers to the program to send out
an email if someone comes along and closes the console window. (BTW,
sometimes closing the app is legitimate, so I don't want to just
disable it or run the process in the background)

I'm running into this issue on Windows with the follow exception at
the time when the signal handler is called:

Traceback (most recent call last):
   ...
self.done.wait(30)
  File D:\Python24\lib\threading.py, line 348, in wait
self.__cond.wait(timeout)
  File D:\Python24\lib\threading.py, line 222, in wait
_sleep(delay)
IOError: [Errno 4] Interrupted function call

I do development work on both Linux and Windows, and Linux doesn't
seem to behave this way.  I'm careful to make sure that the signal
handler only directly interacts with the main thread to be safe, but
the must be something I'm missing.

I took a simple threading example and modified to demonstrate the
problem.  It fails the same way, every time I run it on Windows, and
it works find each time on Linux.

I temporarly stuck in a try/except block to just ignore IOErrors, but
that seems like a faulty approach.  I would have to add try/except
block everywhere I call anything that could potentially call sleep(),
which seems like a poor (and painful) solution.  I also thought about
replacing threading._sleep with a try/except wrapper function, but
that seems kind of evil.

Thanks in advance for any suggestions,

Lowell Alleman


-

import threading
import signal
import time, random

class Counter:
def __init__(self):
self.lock = threading.Lock()
self.value = 0
def increment(self):
self.lock.acquire()
self.value = value = self.value + 1
self.lock.release()
return value

class Worker(threading.Thread):
def __init__(self):
self.done = threading.Event()
threading.Thread.__init__(self)
def run(self):
while not self.done.isSet():
# pretend we're doing something that takes 10-100 ms
value = counter.increment() # increment global counter
time.sleep(random.randint(10, 100) / 1000.0)
print self.getName(), -- task, i, finished, value
def stop(self):
self.done.set()

def handler(sig, frame):
print Signal handler.  Sig=%r % sig
global workers
for w in workers:
w.stop()

counter = Counter()
workers = [ Worker() for i in range(10) ]
for w in workers:
w.start()

# Install my custom signal handler which tells worker threads to stop
try:   # Win32
signal.signal(signal.SIGBREAK, handler)
except:   # Linux
signal.signal(signal.SIGTERM, handler)
signal.signal(signal.SIGINT, handler)

print Please press Ctrl-C/Ctrl-Break or close the console window now...
# Main thread sleeps waiting for work to be done...
time.sleep(60)

# Wait for all workers to finish
print Stop All workers!
for w in workers:
w.stop()

print Joining all workers to main!
for w in workers:
w.join()

-

Traceback (most recent call last):
  File python_thread_signal_issue.py, line 45, in ?
time.sleep(60)
IOError: [Errno 4] Interrupted function call
--
http://mail.python.org/mailman/listinfo/python-list


Remove the first few(or any amount really) of letters in a string

2008-08-08 Thread Alexnb

Lets say I've got a stirng:

blah This is my string blah

I want to get rid of the blah's but keep the This is my string. I know you
can do this with a for loop, but that is messy and a pain. So does anyone
have any suggestions on how to do this?
-- 
View this message in context: 
http://www.nabble.com/Remove-the-first-few%28or-any-amount-really%29-of-letters-in-a-string-tp18901736p18901736.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Re: Remove the first few(or any amount really) of letters in a string

2008-08-08 Thread Terry Reedy



Alexnb wrote:

Lets say I've got a stirng:

blah This is my string blah

I want to get rid of the blah's but keep the This is my string. I know you
can do this with a for loop, but that is messy and a pain. So does anyone
have any suggestions on how to do this?


Strings are immutable.  Just slice out what you want.
IDLE 3.0b2
 blah This is what I want. blah blah[5:25]
'This is what I want.'

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


Re: CAB files

2008-08-08 Thread oyster
there is 2 files: text2pdf.py and cab.py
but I get a cab, in which there is a file text2pdf.py in it, but
cab.py is created as a directory!
[your cab.py starts]
blahblah

if __name__ == __main__:
   import os, glob

   hfci = HFCI(my-first.cab, verbose=1)

   files = glob.glob(r*.py)

   for fnm in files:
   hfci.AddFile(fnm)

   hfci.Close()
[/your cab.py ends]


 From: Thomas Heller [EMAIL PROTECTED]
 To: python-list@python.org
 Date: Fri, 08 Aug 2008 16:29:10 +0200
 Subject: Re: CAB files
 Virgil Stokes schrieb:
  I would appreciate python code for creating *.cab files.
 
  --V. Stokes

 Here is some code that I have still laying around.  It has never been
 used in production and I do not know what you can do with the cab files
 it creates, but I have been able to create a cab and open it with winzip.

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


Quality of Standard Modules

2008-08-08 Thread js
I read an interview with Guido at
http://www.techworld.com.au/article/255835/a-z_programming_languages_python
and
that's very interesting.

In that article, he said
there are also a lot of modules that aren't particularly well
thought-out, or serve only a very small specialized audience, or don't
work well with other modules.

I'm curious what modules he's refering and other Pythonistas feel it's
not pythonic.

Can you share some of your thought?
--
http://mail.python.org/mailman/listinfo/python-list


Re: sending to an xterm

2008-08-08 Thread Rich Healey
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Kent Tenney wrote:
 Derek Martin code at pizzashack.org writes:
 
 On Fri, Aug 08, 2008 at 08:25:19PM +, Kent Tenney wrote:
 Howdy,

 I want to open an xterm, send it a command and have it execute it.
 You can't do that.  xterm doesn't execute shell commands passed on
 stdin...  It can, however, execute one passed on the command line.

 Instead of just running xterm, you can run xterm -e 'cmd foo bar'
 where cmd is the program to run and foo and bar are its arguments.
 The problem is that as soon as the program exits, xterm will exit
 also.

 
 OK, I see that. 
 
 (getting off topic)
 
 any chance of keeping the xterm open after running the command?
 
 Thanks,
 Kent
 
xterm -hold -e whatever

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


- --
Rich Healey -  [EMAIL PROTECTED]
Developer / Systems Admin - OpenPGP: 0x8C8147807
MSN: [EMAIL PROTECTED] AIM: richohealey33
irc.psych0tik.net- #hbh #admins richohealey
irc.freenode.org - #hbh #debian PythonNinja
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkidKIAACgkQLeTfO4yBSAclUwCg3uuvxxWHgZ/vqenrmaNIV/iE
ceQAn3e8oC6t0rTLtVhpeisujnqq8jlh
=4s8n
-END PGP SIGNATURE-
--
http://mail.python.org/mailman/listinfo/python-list


[issue3519] Evaluation order example lacks suffix

2008-08-08 Thread Georg Brandl

Georg Brandl [EMAIL PROTECTED] added the comment:

Thanks, fixed in r65591.

--
resolution:  - fixed
status: open - closed

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3519
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3429] urllib.urlopen() return type

2008-08-08 Thread Georg Brandl

Georg Brandl [EMAIL PROTECTED] added the comment:

Agreed.

--
resolution:  - works for me
status: open - closed

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3429
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3522] zip() function example in tutorial

2008-08-08 Thread Georg Brandl

Georg Brandl [EMAIL PROTECTED] added the comment:

Thanks, applied in r65592.

--
resolution:  - fixed
status: open - closed

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3522
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3523] Reverse quotes in Python 3.0 tutorial

2008-08-08 Thread Georg Brandl

Georg Brandl [EMAIL PROTECTED] added the comment:

Thanks, applied in r65593.

--
resolution:  - fixed
status: open - closed

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3523
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3525] Changes to exceptions not reflected in tutorial examples.

2008-08-08 Thread Georg Brandl

Georg Brandl [EMAIL PROTECTED] added the comment:

Thanks, applied in r65594.

--
resolution:  - fixed
status: open - closed

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3525
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3524] IOError when attempting negative seek in file (Python 3.0 tutorial)

2008-08-08 Thread Georg Brandl

Georg Brandl [EMAIL PROTECTED] added the comment:

Since the file is a text file, such seeking is not possible.

I've now updated the whole section about files; in particular there was
also an outdated description of text vs. binary mode.

Committed r65595.

--
resolution:  - fixed
status: open - closed

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3524
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3429] urllib.urlopen() return type

2008-08-08 Thread ThomasH

ThomasH [EMAIL PROTECTED] added the comment:

On Fri, Aug 8, 2008 at 2:04 AM, Senthil [EMAIL PROTECTED] wrote:

 Senthil [EMAIL PROTECTED] added the comment:

 I agree with Benjamin on this issue, describing what is a File like Object 
 is
 so much un-needed in Python and especially at urlopen function. Users have 
 been
 able to understand and use it properly from a long time.

If only it were more file-like. But, oh, it adds info() and geturl()
methods which you have to string-search for to find the proper
description in the prose. And, ah, the size argument of the read()
method doesn't quite behave like on other file-like objects, but there
you go. And, uh, by the way, you really can't use it in places where
a true built-in file object is required (and I'm sure everybody knows
what that means). - So much for file-like.

I have no doubt that people can get along with the description as it
is, because that's what they always try. My main point was that it is
less approachable and breaks the usual format of a class
documentation. But I see there is much agreement in keeping the
status quo.

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3429
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3429] urllib.urlopen() return type

2008-08-08 Thread ThomasH

ThomasH [EMAIL PROTECTED] added the comment:

Georg,

you seem like a dedicated person. I'm sure you guys have thought about
documenting return types of methods and functions in a standardized
way, documenting classes so that you could fade in and out inherited
features, and such. Where do you guys discuss general documentation
issues? Is there a mailing list dedicated to Python documentation?!

On Fri, Aug 8, 2008 at 8:43 AM, Georg Brandl [EMAIL PROTECTED] wrote:

 Georg Brandl [EMAIL PROTECTED] added the comment:

 Agreed.

 --
 resolution:  - works for me
 status: open - closed

 ___
 Python tracker [EMAIL PROTECTED]
 http://bugs.python.org/issue3429
 ___


___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3429
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3270] test_multiprocessing: test_listener_client flakiness

2008-08-08 Thread Trent Nelson

Trent Nelson [EMAIL PROTECTED] added the comment:

Jesse, thanks for capturing my e-mail thread in this issue.  Can you 
comment on my last three paragraphs?  Essentially, I think we should 
lock down the API and assert that Listener.address will always be 
a 'connectable' end-point.  (i.e. not a wildcard host, 0.0.0.0, that 
can't be bound to by a socket, for example)

This would mean raising an exception in Listener.__init__ if this 
invariant is violated.

--
nosy: +Trent.Nelson

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3270
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1117601] os.path.exists returns false negatives in MAC environments.

2008-08-08 Thread Virgil Dupras

Virgil Dupras [EMAIL PROTECTED] added the comment:

hsoft-dev:~ hsoft$ mkdir foobar
hsoft-dev:~ hsoft$ echo baz  foobar/baz
hsoft-dev:~ hsoft$ chmod 000 foobar/baz
hsoft-dev:~ hsoft$ python
Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) 
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type help, copyright, credits or license for more information.
 import os.path
 os.path.exists('foobar/baz')
True
 
hsoft-dev:~ hsoft$ chmod 000 foobar
hsoft-dev:~ hsoft$ python
Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) 
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type help, copyright, credits or license for more information.
 import os.path
 os.path.exists('foobar/baz')
False
 os.path.exists('foobar')
True
 

This seems like the correct behavior to me.

--
nosy: +vdupras

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1117601
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3270] test_multiprocessing: test_listener_client flakiness

2008-08-08 Thread Antoine Pitrou

Antoine Pitrou [EMAIL PROTECTED] added the comment:

 This would mean raising an exception in Listener.__init__ if this 
 invariant is violated.

If I understand the suggestion correctly, it would forbid people to
listen on 0.0.0.0. I'm not sure it is the right correction for the
problem. Listening on 0.0.0.0 can be handy when you are not sure which
address to use; it would be better to address the problem elsewhere.

IMO, the FQDN removal patch as uploaded by Jesse is simple and
straight-forward enough, provided it does fix the bug.

--
nosy: +pitrou

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3270
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1117601] os.path.exists returns false negatives in MAC environments.

2008-08-08 Thread Antoine Pitrou

Antoine Pitrou [EMAIL PROTECTED] added the comment:

The only sane alternative to the current behaviour would be to raise an
Exception from os.path.exists rather than returning False. But it would
also break a lot of code, and complexify code using os.path.exists which
currently doesn't need to check for exceptions. Returning True sounds
completely incorrect on the other hand.

If there is no other straightforward method than stat() to know if a
path exists, I suggest closing this bug as wontfix.

--
nosy: +pitrou

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1117601
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >