Re: markov query

2006-03-14 Thread Erik Max Francis
kpp9c wrote:

> I have noticed a couple markov implementations in python, but none
> quite seem to do what i would like. Most seem to do an analysis of some
> text and create a new text based on that... I think, (sorry i just
> don't know terminology well) a markov table (or is it called a
> transition table) to describe how to get from one event to another.

Yes, a system which does this has to build a Markov chain from a data 
set and then traverse it.

> Does anyone know of any modules or packages that include markov tables
> for creating patterns like shown above.

Any program that actually uses Markov chains to generate new text based 
on existing input as you've described will necessarily create a Markov 
chain.  So if what you want is the Markov chain itself, then it's 
already in there somewhere.

> P.S. Does any one know first of all whether these are called markov
> tables, transition tables or probability tables? I am not sure i am
> referring to this correctly and what the differences would be if any

They're called Markov chains.

-- 
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   Nothing spoils a confession like repentence.
   -- Anatole France
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Memory visualization

2006-03-14 Thread Raymond Hettinger
[bearophile]
> During the execution of a Icon script there are ways to visualize the
> memory:
> http://www.cs.arizona.edu/icon/progvis/memmon/memmon.htm
 . . .
> I'd like to know if for Python there is a similar program to
> dynamically see the memory in a similar way.
> If such tool doesn't exist yet, I'd like to know if it may be diffifult
> to create it.

Yes, it would be difficult.

Python gets chunks of memory from the o/s -- those may not be
contiguous.  Python has some internal object reuse tricks such that a
chuck of memory may be tied-up in a free-list though no active object
is alive.  Extensions can call their own malloc and free so it would be
difficult to ensure that you catch those.  Some objects like lists and
dicts have chunks of partially used memory that allow room for growth.

That being said, there is likely some interesting things that could be
done in C by exploiting tp_traverse and by hacking Python's internal
object allocator.


Raymond

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


Re: PEP 8 example of 'Function and method arguments'

2006-03-14 Thread Duncan Booth
Terry Hancock wrote:

> So far, the only time I've ever encountered this is with the
> __new__ method, which, being a classmethod, needs "cls"
> (which gets loaded with the *class* not the *instance*).
> 

The __new__ method isn't actually a classmethod. In 
http://www.python.org/2.2.3/descrintro.html, GvR wrote:

> Factoid: __new__ is a static method, not a class method. I initially
> thought it would have to be a class method, and that's why I added the
> classmethod primitive. Unfortunately, with class methods, upcalls
> don't work right in this case, so I had to make it a static method
> with an explicit class as its first argument. Ironically, there are
> now no known uses for class methods in the Python distribution (other
> than in the test suite). However, class methods are still useful in
> other places, for example, to program inheritable alternate
> constructors. 

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


Re: sizeof(struct timeval)

2006-03-14 Thread Nick Kew
Tony Houghton wrote:
> I'm writing a python program which reads input device events so it needs
> to know sizeof(struct timeval). By using the struct module I should be
> able to work out sizeof(long) from python, but I can't think of a way to
> measure non-fundamental types without including a little bit of C,
> which I'd rather avoid.
> 
> How safe would I be assuming that 
> 
> sizeof(struct timeval) == 2 * sizeof(long)

I've no idea.

But regardless of whether it's 'safe' amongst current devices,
you're setting yourself up for a Y2K-family bug.  Except it'll
be a real one, not a storm-inna-teacup.

My python isn't up to sizeof issues either, so I can't help
you there.  Either figure it out, or do it in C.

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


wxPython Q? floating window

2006-03-14 Thread mitsura
Hi,

I have a question about wxPython.
On Windows systems, you can point your mouse over most items on your
desktop and a after a second or so, a small window will pop-up with
extra info about the thing your pointing at (try e.g. move your mouse
over the time in the right corner and a window will pop-up with the
date).
I was wondering this can be done with wxPython. I basically want to
create a wxTree object and when I point the mouse over the objects in
the tree I would like to have these kind of smal pop-up windows that
display more info about the object you are pointing at.

Any help much appreciated.

Kris

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


Re: trying to find repeated substrings with regular expression

2006-03-14 Thread Raymond Hettinger
[Robert Dodier]
> I'm trying to find substrings that look like 'FOO blah blah blah'
> in a string. For example give 'blah FOO blah1a blah1b FOO blah2
> FOO blah3a blah3b blah3b' I want to get three substrings,
> 'FOO blah1a blah1b', 'FOO blah2', and 'FOO blah3a blah3b blah3b'.

No need for regular expressions on this one:

>>> s = 'blah FOO blah1a blah1b FOO blah2 FOO blah3a blah3b blah3b'
>>> ['FOO' + tail for tail in s.split('FOO')[1:]]
['FOO blah1a blah1b ', 'FOO blah2 ', 'FOO blah3a blah3b blah3b']


>
> I've tried numerous variations on '.*(FOO((?!FOO).)*)+.*'
> and everything I've tried either matches too much or too little.

The regular expression way is to find the target phrase followed by any
text followed by the target phrase.  The first two are in a group and
the last is not included in the result group.  The any-text section is
non-greedy:

>>> import re
>>> re.findall('(FOO.*?)(?=FOO|$)', s)
['FOO blah1a blah1b ', 'FOO blah2 ', 'FOO blah3a blah3b blah3b']


Raymond

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


Re: list/classmethod problems

2006-03-14 Thread bruno at modulix
ahart wrote:
> Diez, Scott, and Bruno,
> 
> I thank you all for your help and suggestions. I wasn't aware that
> default values were considered class (static) values.

These are *not* 'default values'. Defining a name in the body of a class
statement bind that name to the *class*. To bind a name to the instance,
you have to do it inside an instance method - usually in the __init__()
method. Understand that there's not way to bind anything to an instance
before you actually *have* an instance !-)

> That seems a
> little odd to me,

Yes, it's very different from languages like Java or C++, but it makes
perfect sens once you understand Python's object model.

(snip)

> Again, I thank you all.
> 
You're welcome.

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Integer keys in shelve

2006-03-14 Thread josegomez
Hi!
I want to use shelve to store lists which are indexed by an integer
key. The keys are not concurrent or anything, they are just defined as
integer values. However, shelve complains that I cannot have integer
keys. Here's the error:
>>> d[1]
Traceback (most recent call last):
  File "", line 1, in ?
  File "E:\Python23\lib\shelve.py", line 118, in __getitem__
f = StringIO(self.dict[key])
  File "E:\Python23\lib\bsddb\__init__.py", line 116, in __getitem__
return self.db[key]
TypeError: Integer keys only allowed for Recno and Queue DB's

I understand that Recno is part of the bsddb3, but I don't know how to
instruct shelve to use the Recno back-end.

The other option is to str() the integer key, but I'd rather use an
integer key, and avoid all the extra clutter.

Did I miss something?

Ta
Jose

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


Re: Integer keys in shelve

2006-03-14 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> I want to use shelve to store lists which are indexed by an integer
> key. The keys are not concurrent or anything, they are just defined as
> integer values. However, shelve complains that I cannot have integer
> keys. Here's the error:
> >>> d[1]
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "E:\Python23\lib\shelve.py", line 118, in __getitem__
> f = StringIO(self.dict[key])
>   File "E:\Python23\lib\bsddb\__init__.py", line 116, in __getitem__
> return self.db[key]
> TypeError: Integer keys only allowed for Recno and Queue DB's
>
> I understand that Recno is part of the bsddb3, but I don't know how to
> instruct shelve to use the Recno back-end.
>
> The other option is to str() the integer key, but I'd rather use an
> integer key, and avoid all the extra clutter.
>
> Did I miss something?

the documentation ?

http://www.python.org/doc/current/lib/module-shelve.html

A "shelf" is a persistent, dictionary-like object. The difference
with "dbm" databases is that the values (not the keys!) in a
shelf can be essentially arbitrary Python objects -- anything
that the pickle module can handle. This includes most class
instances, recursive data types, and objects containing lots
of shared sub-objects. The keys are ordinary strings.





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


Re: Accessing overridden __builtin__s?

2006-03-14 Thread bruno at modulix
[EMAIL PROTECTED] wrote:
> I'm having a scoping problem.  I have a module called SpecialFile,

The convention is to use all_lowercase names for modules, and CamelCase
for classes.

> which defines:
> 
> def open(fname, mode):
>   return SpecialFile(fname, mode)

This shadows the builtin open() function.

> class SpecialFile:

Old-style classes are deprecated, please use new-style classes

>   def __init__(self, fname, mode):
> self.f = open(fname, mode)
> ...
> 
> 
> The problem, if it isn't obvioius, is that the open() call in __init__
> no longer refers to the builtin open(), but to the module open().  So,
> if I do:
> 
> f = SpecialFile.open(name, mode)
> 
> I get infinite recursion.
> 
> How do I tell my class that I want to refer to the __builtin__ open(),
> and not the one defined in the module?

You can use Steven's solution, or keep a reference to the builtin open()
function before defining your own open() function:

builtin_open = open
def open(fname, mode):
  return SpecialFile(fname, mode):

class SpecialFile(object):
  def __init__(self, fname, mode):
self.f = builtin_open(fname, mode)



-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SSL/TLS - am I doing it right?

2006-03-14 Thread Frank Millman

Sybren Stuvel wrote:
> Frank Millman enlightened us with:
> > If I understand correctly, a 'man-in-the-middle' attack would
> > involve someone setting up a 'pseudo server', which gives the
> > correct responses to the client's attempt to log in
>
> That's right. Usually it's done by proxying the data between the
> client and the real server.
>
> > and would also involve someone manipulating the client parameter so
> > that it points to the pseudo server instead of the real server.
>
> Yup. This can be done in various ways, like ARP poisoning of the
> network. Then the IP address will not change, but the network card
> that the traffic is sent to will. The fraudulent server, having the
> correct ARP table, can then forward the captured data to the real
> server.
>
> > What I have not understood is how to prevent this. How can the
> > client distinguish between a valid server and a fraudulent one?
>
> By checking the certificates. The CA mustn't sign server certificates
> except for the real server. The fraudulent server thus has no valid
> server certificate.
>

I don't know how to check the certificates. None of the documentation I
have read spells out in detail how to do this.

What about this idea? I am not looking for a state-of-the-art solution.
I am looking for something that is 'good enough' for a typical SME with
its own internal network.

Assume that the server is reasonably protected, i.e. can only be
accessed by administrators with valid permissions.

Assume that the client is reasonably protected - i.e. a fraudster
cannot access/change the file system. If this cannot be assumed, all
bets are off, as the fraudster can replace the pointer to the client
software with one to a modified version that bypasses the
authentication procedure, and we are back to square one.

Using openssl, generate a key for the server, generate a self-signed
certificate, and extract the sha1 fingerprint of the certificate. The
key must be kept secure but the fingerprint can be published.

When a client wishes to connect to the server, it must read a parameter
which includes the ip address, the port number, and the fingerprint.

After establishing an SSL connection, the client compares the session
fingerprint (TLSLite has a getFingerprint() function) with the
parameter. If different, client assumes it is talking to an imposter
and disconnects.

Are there any gaping holes in this approach?

Thanks

Frank

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


[ANN] NumPy 0.9.6 released

2006-03-14 Thread Travis Oliphant
This post is to announce the release of NumPy 0.9.6 which fixes some 
important bugs and has several speed improvments.


NumPy is a multi-dimensional array-package for Python that allows rapid 
high-level array computing with Python.  It is successor to both Numeric 
and Numarray.  More information at http://numeric.scipy.org


The release notes are attached:

Best regards,

NumPy Developers




NumPy 0.9.6 is a bug-fix and optimization release with a
few new features: 


  New features (and changes):

  - bigndarray removed and support for Python2.5 ssize_t added giving
 full support in Python2.5 to very-large arrays on 64-bit systems.

  - Strides can be set more arbitrarily from Python (and checking is done 
 to make sure memory won't be violated). 

  - __array_finalize__ is now called for every array sub-class creation.

  - kron and repmat functions added

  - .round() method added for arrays
  
  - rint, square, reciprocal, and ones_like ufuncs added.

  - keyword arguments now possible for methods taking a single 'axis'
 argument

  - Swig and Pyrex examples added in doc/swig and doc/pyrex

  - NumPy builds out of the box for cygwin

  - Different unit testing naming schemes are now supported.

  - memusage in numpy.distutils works for NT platforms

  - numpy.lib.math functions now take vectors

  - Most functions in oldnumeric now return intput class where possible


  Speed ups:
 
  - x**n for integer n signficantly improved

  - array() much faster

  - .fill() method is much faster


  Other fixes:

  - Output arrays to ufuncs works better. 

  - Several ma (Masked Array) fixes.

  - umath code generation improved

  - many fixes to optimized dot function (fixes bugs in 
matrix-sub-class multiply)

  - scalartype fixes

  - improvements to poly1d

  - f2py fixed to handle character arrays in common blocks

  - Scalar arithmetic improved to handle mixed-mode operation.

  - Make sure Python intYY types correspond exactly with C PyArray_INTYY


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

Re: SSL/TLS - am I doing it right?

2006-03-14 Thread Paul Rubin
"Frank Millman" <[EMAIL PROTECTED]> writes:
> I don't know how to check the certificates. None of the documentation I
> have read spells out in detail how to do this.

Lemme see if I can find you something--I'll put up another post if I do.

> What about this idea? I am not looking for a state-of-the-art solution.
> I am looking for something that is 'good enough' for a typical SME with
> its own internal network.

Didn't you say wireless?  That's not an internal network, it's a
network that extends off the premises and is accessible to anyone with
a laptop who can park a car in the neighborhood.

> Using openssl, generate a key for the server, generate a self-signed
> certificate, and extract the sha1 fingerprint of the certificate. The
> key must be kept secure but the fingerprint can be published.

Then install a copy of the certificate on the client, that the client
can authenticate against.  You also want to generate a client
certificate to install on the server.  If there are multiple clients
you should make a CA rather than trying to keep track of self-signed
certificates.  If you're paranoid, you can scrounge some $20 obsolete
laptop from ebay and dedicate it to use as a CA, never letting it
touch the internet (transfer files to and from it on floppy disc).

> After establishing an SSL connection, the client compares the session
> fingerprint (TLSLite has a getFingerprint() function) with the
> parameter. If different, client assumes it is talking to an imposter
> and disconnects.
> 
> Are there any gaping holes in this approach?

1. You have to authenticate both the server and the client; you can do
that with certificates at both ends (preferred for non-public-facing
applications) or you could do it with something like a client password
sent through the TLS session after the session is established.

2. I don't see the docs for getFingerprint at 
   http://trevp.com/tlslite/docs/index.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Very, Very Green Python User

2006-03-14 Thread jalanb

Scott David Daniels wrote:
> [EMAIL PROTECTED] wrote:
>  > The one you get with Perl stinks on ice. More than
> > anything else, I would like to have a powerful OO environment where I
> > do not have to worry about the debugger sucking 
> Do watch your language on this newsgroup.  Lots of people read this
> group and there is no good reason to offend them.  In turn, you will be
> cut some slack.
>

What exactly is your problem with the language used here ?

"Suck" rhymes too closely ?

Are "luck", "ruck", and "puck" offensive too?
And who gets to decide how easily offended "lots of people" are ?

Why do you think *anyone* else is as offended by hanumizzle's language
as others are by your sanctimoniousness ?

-- 
Alan
http://aivipi.blogspot.com

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


Re: Localized month names?

2006-03-14 Thread Sibylle Koczian
Benji York schrieb:
> Jarek Zgoda wrote:
> 
>> How do I get a list of localized month names for current locale? The
>> first thing that came to my mind was an ugly hack:
> 
> 
 import locale
 locale.nl_langinfo(locale.MON_1)
> 'January'
> 

What did you leave out? I get

Traceback (most recent call last):
  File "", line 1, in -toplevel-
locale.nl_langinfo(locale.MON_1)
AttributeError: 'module' object has no attribute 'nl_langinfo'

(Python 2.4, german Windows XP Pro)

Moreover, 'January' is probably not localized.

-- 
Dr. Sibylle Koczian
Universitaetsbibliothek, Abt. Naturwiss.
D-86135 Augsburg
e-mail : [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SSL/TLS - am I doing it right?

2006-03-14 Thread Sybren Stuvel
Paul Rubin enlightened us with:
> If you're paranoid, you can scrounge some $20 obsolete laptop from
> ebay and dedicate it to use as a CA, never letting it touch the
> internet (transfer files to and from it on floppy disc).

caCert use a special box for this too. It has no network connection,
and communicates through a serial cable. All it does with that serial
cable is accept certificate requests and spit out signed certificates
:)

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SSL/TLS - am I doing it right?

2006-03-14 Thread Sybren Stuvel
Frank Millman enlightened us with:
> I don't know how to check the certificates. None of the
> documentation I have read spells out in detail how to do this.

Read the readme that comes with TLS Lite. You can require certificate
checks, call certchain.validate(CAlist), and with my extension you can
also use the CRL module to check.

> Using openssl, generate a key for the server, generate a self-signed
> certificate, and extract the sha1 fingerprint of the certificate.
> The key must be kept secure but the fingerprint can be published.

The entire certificate can be published along with the fingerprint.

> When a client wishes to connect to the server, it must read a
> parameter which includes the ip address, the port number, and the
> fingerprint.
>
> After establishing an SSL connection, the client compares the
> session fingerprint (TLSLite has a getFingerprint() function) with
> the parameter. If different, client assumes it is talking to an
> imposter and disconnects.

It's a good idea if you want to keep the client lightweight. As a
matter of fact, it's what I use on the client side of my TLS
connection.

> Are there any gaping holes in this approach?

If anyone sees them, please let us know :)

There is one gaping hole, though, because you only talk about the
client checking the server. If you want to be really secure, you also
need to use client certificates and let the server check them for
validity. I do that too. Without a valid client certificate, no
connection.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this possible in Python?

2006-03-14 Thread jalanb
You might like the version here:
http://www.jorendorff.com/toys/out.html

Especially the "need to know" presentation, which is cute

-- 
Alan
http://aivipi.blogspot.com

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


Re: Why python doesn't use syntax like function(, , x) for default parameters?

2006-03-14 Thread Antoon Pardon
Op 2006-03-10, Terry Reedy schreef <[EMAIL PROTECTED]>:
>
> "Antoon Pardon" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>> but nobody seems to have
>> a problem with range(n) where n suddenly is the second parameter and
>> we use the default for the first.
>
> Actually, I consider the unique calling pattern for x/range to be something 
> of a wart.  Learning this inconsistency was at least a minor problem.  It 
> is a rather extreme example of typing laziness beats purity.

Well then we can at least agree on that.

> Given that enumerate() eliminate many uses of range(), it might be worth 
> considering requiring the start param.  range(0,n) only takes two more 
> keystrokes.  Better maybe to shorten range to rng to get them back ;-)

I can't use enumerate that much. I usually work with a Table which is
like a list, but the index can start at any integer value. Enumerate
doesn't work well with a table.

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


Re: Why python doesn't use syntax like function(, , x) for default parameters?

2006-03-14 Thread Antoon Pardon
Op 2006-03-10, Terry Reedy schreef <[EMAIL PROTECTED]>:
>
> "Antoon Pardon" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>> but nobody seems to have
>> a problem with range(n) where n suddenly is the second parameter and
>> we use the default for the first.
>
> Actually, I consider the unique calling pattern for x/range to be something 
> of a wart.  Learning this inconsistency was at least a minor problem.  It 
> is a rather extreme example of typing laziness beats purity.
>
> Given that enumerate() eliminate many uses of range(), it might be worth 
> considering requiring the start param.  range(0,n) only takes two more 
> keystrokes.  Better maybe to shorten range to rng to get them back ;-)

Take the split method of strings. Personnaly I would prefer to be able
to write:

  s.split(,3)

Instead of having to write

  s.split(None,3)


The reason is that None is IMO an implemenation detail here. Also
the alternative

  s,split(maxsplit=3)

doesn't work in this case.


What may be an option for the future is a Default Object. So that
if you have.

   def f(x=0,y=0):
  ...

then

   f(Default, 5)


would be equivallent to

   f(0,5)

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


Re: Why python doesn't use syntax like function(, , x) for default parameters?

2006-03-14 Thread Antoon Pardon
Op 2006-03-10, Diez B. Roggisch schreef <[EMAIL PROTECTED]>:
>> Those default values are not 0 and , you may have
>> only experience with situations where they behave as such but that
>> is not the same.
>
> Well, it might be - but the conceptual behavior is (usually) the same. 
>
>> If you need to know these values then you will need to know them
>> just as much when a keyword is used or when the default values
>> are used later. Calling
>> 
>>   f(3) or f(arg5=3)
>> 
>> Will give you no more a clue about the missing default values
>> than calling
>> 
>>   f(,3)
>> 
>> At least in the last call you are given a clue about missing
>> arguments.
>
> I didn't argue against that  - I don't like the proposal, but I'm pretty
> sure that it won't be accepted in any way whatsoever so I don't bother. 

You argued that f(,,3) would somehow be hard to figure out.

> I just wanted to point out that you proclaim false evidence for a similar
> situation already being part of python, and that thus the f(,,1) syntax was
> justified.

I didn't claim that the f(,,1) syntax was justified. I asked for an
explanation about why something like f(,,3) would be hard to figure
out.

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


Re: sizeof(struct timeval)

2006-03-14 Thread Giovanni Bajo
Tony Houghton wrote:

> I'm writing a python program which reads input device events so it
> needs to know sizeof(struct timeval). By using the struct module I
> should be able to work out sizeof(long) from python, but I can't
> think of a way to measure non-fundamental types without including a
> little bit of C, which I'd rather avoid.
>
> How safe would I be assuming that
>
> sizeof(struct timeval) == 2 * sizeof(long)
>
> is always true on Linux on different architectures? AFAIK the input
> device interface is Linux-specific so I don't need to worry about
> other OS's.


If I were you, I would write a Pyrex 4-liners which exposes this structure to
Python in the way you prefer. This would immediately fix all these
compatibility issues.
-- 
Giovanni Bajo


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


Re: Is this possible in Python?

2006-03-14 Thread Fredrik Lundh
"jalanb" wrote:

> You might like the version here:
> http://www.jorendorff.com/toys/out.html

which only works if 1) you're using a Python implementation that supports
those attributes, 2) the source code is available, 3) the expression is written
on a single line, and 4) you don't use confusing comments after the function
call (and probably some more things I cannot think of right now).

perfectly valid Python constructs like

out(
temp
)

or

out(temp) # XXX: should use gettemp() instead

breaks the function.

> Especially the "need to know" presentation, which is cute

indeed.

 



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


Re: Accessing overridden __builtin__s?

2006-03-14 Thread Steven D'Aprano
On Mon, 13 Mar 2006 21:28:06 -0800, garyjefferson123 wrote:

> I'm having a scoping problem.  I have a module called SpecialFile,
> which defines:
> 
> def open(fname, mode):
>   return SpecialFile(fname, mode)

This is called "shadowing a built-in", and generally speaking it causes
Bad Things To Happen. The secret to avoiding those Bad Things is to not
shadow built-ins. This isn't a hard and fast rule, but as a good general
principle, if you have to ask "How do I avoid this problem?", you
shouldn't be using shadowing.

(Think of it this way: if you have to ask "How do I avoid being horribly
injured when I crash my car into a wall at 90mph?", you shouldn't be
crashing your car into a wall at 90mph. Yes, I know that makes the
bootstrapping problem difficult for those budding stunt men and women who
want to learn, but they generally manage. And most of the time they manage
by not actually crashing their car into a wall at 90mph -- they find a
better way to get the same effect.)


> class SpecialFile:
> 
>   def __init__(self, fname, mode):
> self.f = open(fname, mode)
> ...
> 
> 
> The problem, if it isn't obvioius, is that the open() call in __init__
> no longer refers to the builtin open(), but to the module open().

In your code, open() is not a module, it is a function.

A better technique will be to turn open into a method of the class
SpecialFile, rather than a bare function. That way you keep open() the
built-in function separate from SpecialFile.open().

> So, if I do:
> 
> f = SpecialFile.open(name, mode)
> 
> I get infinite recursion.

I see you are already using an open method. So let me see if I have this
right: you have a function open, plus an open method? Why?

As near as I can tell, you have a function called "open" which returns a
SpecialFile instance. I don't understand why you would want to do that --
it seems like a poor API design to me. But maybe there's something I don't
understand. It looks like you are expecting to do this:

file = open('data.txt', 'r')
# file is now an automatically opened SpecialFile.

This is bad design because it isn't clear that you have done something
special. It *looks* like you have just opened an ordinary file, and unless
you study the entire module, you wouldn't have any clue that in fact you
have opened a SpecialFile instead.

I would handle it like this:

class SpecialFile(object):
def __init__(self, fname, mode='r'):
self.fname = fname
self.mode = mode
def open(self):
self.f = open(self.fname, self.mode)
def close(self):
self.f.close()
def read(self):
return self.f.read()
def write(self, data):
self.f.write(data)

You use it like so:

sf = SpecialFile("hello.txt")
sf.open()
data = sf.read()
sf.close()

(Actually, I wouldn't handle it like this at all, unless a SpecialFile did
things that an ordinary file didn't. But presumably you have something
special in mind.)

This, in my opinion, is a better solution. You don't have to jump through
hoops to get back at the built-in version of open, and the code is
self-documenting: to open a SpecialFile, you ask for a SpecialFile. 



-- 
Steven.

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


Re: Please, I Have A Question before I get started

2006-03-14 Thread Skipper
Well, thank you so much for taking the time to reply.  I guess that
about wraps up all my questions.


You fucking putz





On Mon, 13 Mar 2006 13:37:36 +0100, Sybren Stuvel
<[EMAIL PROTECTED]> wrote:

>Skipper enlightened us with:
>> I can not believe that there isn't a GUI programing tool that will
>> allow me to build GUI apps
>
>There are plenty of them.
>
>> just like I use Dreamweaver to build a web page
>
>Which produces horrible HTML.
>
>Sybren

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


Re: Please, I Have A Question before I get started

2006-03-14 Thread Skipper
Thanks to all (except one - of course) for your replys.  I think you
have more than answered my question and I appreciate your time.

I suppose this is going to be more difficult than I imagined... but
working at this is better then watching "Trading Spaces" with my wife
- -heh...

Thanks again

Mike





On Mon, 13 Mar 2006 08:53:51 -0800, Scott David Daniels
<[EMAIL PROTECTED]> wrote:

>Skipper wrote:
>> ... I am not asking for anyone to do this for me I simply want to 
>> know if I can do what I need to do with Python 
>> Can python do this?  I realize I am responsible for the menu sets,
>> pictures  attaching sounds etc  
>
>As you have been told by many other respondents above, the task is
>not as simple as it seems it should be.  If you decide to go ahead
>and attempt it in Python (after you have learned some easier stuff),
>you will definitely get lots of assistance here.  You just need to
>decide which mountains you want to climb, and which ones you pass up.
>
>--Scott David Daniels
>[EMAIL PROTECTED]

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


Re: Q's: pythonD and range(1,12)

2006-03-14 Thread Steven D'Aprano
On Mon, 13 Mar 2006 17:24:31 -0800, Raymond Hettinger wrote:

> John Savage wrote:
>> Could
>> someone please explain the rationale behind python designers' thinking
>> in deciding the function "range(1,12)" should return the sequence 1 to
>> 11 rather than the more intuitively-useful 1 to 12??
> 
> There are several ways to do this, closed intervals, half-open
> intervals, zero indexed, indexed from one, etc.   Each way has its own
> strengths and weaknesses.  Guido chose the one he liked best and
> applied the concept consistently throughout the language (slicing,
> etc).  His choice has some nice properties such as len(range(n))==n and
> range(0,i)+range(i,n)==range(n).
> 
> The downside of the half-open interval approach is that it can be
> confusing when counting backwards:  range(n-1, -1, -1).  Accordingly,
> the builtin reversed() function was introduced so you could write this
> in a more intuitive and readable manner:  list(reversed(range(n))).
> 
> Some of this is a matter of taste and a matter of what you're used to
> using, so the answer to what is the "more intuitively-useful" varies
> depending on who is answering the question.

It is true that *some* of this is just a matter of taste, but more
importantly, *much* of this is a matter of objective superiority.

See, for example:

http://lists.canonical.org/pipermail/kragen-tol/2004-March/000757.html
http://www.jaggersoft.com/pubs/HowToWriteALoop.htm#Half-Open%20Interval

This thread discusses why a closed interval is better:

http://mail.python.org/pipermail/edu-sig/2004-April/003747.html

As near as I can tell from reading it, the sole reason a closed interval
is better is that in common English phrases "x to y" usually (but not
always) means the closed interval including both x and y. 

A very common error in programming is the so-called fencepost error.
Half-open intervals help avoid them, while closed intervals tend to
result in this bug.

http://en.wikipedia.org/wiki/Fencepost_error

In other words, while the choice of half-open intervals is partly a matter
of taste, Guido is no dummy. Most of the time, his taste is influenced by
practical matters, and this is one of those times. Half-open intervals
will naturally help you avoid bugs. 


-- 
Steven.

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


Re: Localized month names?

2006-03-14 Thread Peter Otten
Sibylle Koczian wrote:

> Benji York schrieb:
>> Jarek Zgoda wrote:
>> 
>>> How do I get a list of localized month names for current locale? The
>>> first thing that came to my mind was an ugly hack:
>> 
>> 
> import locale
> locale.nl_langinfo(locale.MON_1)
>> 'January'
>> 
> 
> What did you leave out? 

Nothing, most likely.

> I get 
> 
> Traceback (most recent call last):
>   File "", line 1, in -toplevel-
> locale.nl_langinfo(locale.MON_1)
> AttributeError: 'module' object has no attribute 'nl_langinfo'
> 
> (Python 2.4, german Windows XP Pro)
> 
> Moreover, 'January' is probably not localized.

Python 2.4.2 (#4, Nov 19 2005, 13:25:59)
[GCC 3.3.3 (SuSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.nl_langinfo(locale.MON_1)
'January'
>>> locale.setlocale(locale.LC_ALL, "")
'de_DE.UTF-8'
>>> locale.nl_langinfo(locale.MON_1)
'Januar'


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


Re: Accessing overridden __builtin__s?

2006-03-14 Thread Fredrik Lundh
Steven D'Aprano wrote:

>> So, if I do:
>>
>> f = SpecialFile.open(name, mode)
>>
>> I get infinite recursion.
>
> I see you are already using an open method. So let me see if I have this
> right: you have a function open, plus an open method? Why?

SpecialFile is a module.  please read the posts you reply to, and please cut out
the "holier than thou" design advice.

overriding builtins is perfectly okay, if it makes sense for the target 
application.

just remember to use __builtin__ (a module) instead of __builtins__ (a cpython
implementation hack) if you need to access the original builtins.

 



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


Re: SSL/TLS - am I doing it right?

2006-03-14 Thread Frank Millman

Paul Rubin wrote:
> "Frank Millman" <[EMAIL PROTECTED]> writes:
> > I don't know how to check the certificates. None of the documentation I
> > have read spells out in detail how to do this.
>
> Lemme see if I can find you something--I'll put up another post if I do.
>

Thanks

> Didn't you say wireless?  That's not an internal network, it's a
> network that extends off the premises and is accessible to anyone with
> a laptop who can park a car in the neighborhood.
>

One of my goals is to use a diskless, wireless workstation that can be
positioned anywhere without a whole lot of cabling. This will be
particularly beneficial in a retail point-of-sale environment. It was
this that got me onto the idea of SSL, to prevent the proverbial car in
the neighborhood from eavesdropping on the network traffic.

> > Using openssl, generate a key for the server, generate a self-signed
> > certificate, and extract the sha1 fingerprint of the certificate. The
> > key must be kept secure but the fingerprint can be published.
>
> Then install a copy of the certificate on the client, that the client
> can authenticate against.

I wanted to keep the legwork required to set up a new client down to a
minimum. I was hoping that setting a pointer to the client software,
and a pointer to a connection parameter, would be sufficient. If the
fingerprint is an an adequate substitute for the full certificate, I
would prefer it, as it is much smaller, and can easily form part of the
connection parameter.

>  You also want to generate a client
> certificate to install on the server.  If there are multiple clients
> you should make a CA rather than trying to keep track of self-signed
> certificates.  If you're paranoid, you can scrounge some $20 obsolete
> laptop from ebay and dedicate it to use as a CA, never letting it
> touch the internet (transfer files to and from it on floppy disc).
>

Both you and Sybren are insistent that this is a necessary step, but I
confess I cannot see the need for it. The client is lightweight, and
authenticates itself to the server using a user id and password. What
is the worst that could go wrong?

>
> 2. I don't see the docs for getFingerprint at
>http://trevp.com/tlslite/docs/index.html

To quote from the docs, if the handshake completes without raising an
exception, authentication results will be stored in the connection's
session object. The following variables will be populated if
applicable, or else set to None:

...
connection.session.serverCertChain
...

session is an instance of the class Session.
serverCertChain is an instance of the class X509CertChain
getFingerprint() is a method of X509CertChain - it returns the
hex-encoded fingerprint of the end-entity certificate.

Paul, I would like to thank you and Sybren for your patience. I feel I
am being a bit obtuse. I am trying to understand enough of this so that
I can implement 'enough' security to protect users against obvious
attacks, without overburdening them with a load of maintenance which in
practice they will end up ignoring.

Many thanks

Frank

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


andmap and ormap

2006-03-14 Thread wkehowski
Hello,

Does python have andmap and ormap:

andmap((lambda t: boolean(t)),L)

gives True if boolean(t) is True for all t in L and False otherwise?
And

ormap((lambda t: boolean(t)),L)

gives True if boolean(t) is True for some t in L and False otherwise?
One can use a list comprehension like

[x for x in L if not(False in map((lambda t: boolean(t)),L))]

as an example of selection by andmap, and

[x for x in L if (True in map((lambda t: boolean(t)),L))]

as an example of selection by ormap.

How does one define andmap/ormap so its first argument is a boolean
procedure or lambda?

def andmap(b,L):
  if False in map(b,L): return False
  else: return True

def ormap(b,L):
  if True in map(b,L): return True
  else: return False

Is this good enough?

Walter Kehowski

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


Re: andmap and ormap

2006-03-14 Thread Felipe Almeida Lessa
Em Ter, 2006-03-14 às 04:23 -0800, [EMAIL PROTECTED] escreveu:
> def andmap(b,L):
>   if False in map(b,L): return False
>   else: return True
> 
> def ormap(b,L):
>   if True in map(b,L): return True
>   else: return False
> 
> Is this good enough?

The problem is that it will evaluate all possibilities needlessly. Try
(not tested and 2.4-only):

def andmap(func, objs):
for boolean in (func(obj) for obj in objs):
if not boolean:
return False
return True

def ormap(func, objs):
for boolean in (func(obj) for obj in objs):
if boolean:
return True
return False

-- 
"Quem excele em empregar a força militar subjulga os exércitos dos
outros povos sem travar batalha, toma cidades fortificadas dos outros
povos sem as atacar e destrói os estados dos outros povos sem lutas
prolongadas. Deve lutar sob o Céu com o propósito primordial da
'preservação'. Desse modo suas armas não se embotarão, e os ganhos
poderão ser preservados. Essa é a estratégia para planejar ofensivas."

  -- Sun Tzu, em "A arte da guerra"

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

Re: andmap and ormap

2006-03-14 Thread Dan Sommers
On 14 Mar 2006 04:23:55 -0800,
[EMAIL PROTECTED] wrote:

> Hello,
> Does python have andmap and ormap:

> andmap((lambda t: boolean(t)),L)

> gives True if boolean(t) is True for all t in L and False otherwise?
> And

> ormap((lambda t: boolean(t)),L)

> gives True if boolean(t) is True for some t in L and False otherwise?

import operator
reduce( L, operator.and_ ) # andmap
reduce( L, operator.or_ ) # ormap

> One can use a list comprehension like

[ ... ]

> Is this good enough?

If it works, and works correctly, then it's good enough.

Regards,
Dan

-- 
Dan Sommers

"I wish people would die in alphabetical order." -- My wife, the genealogist
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: andmap and ormap

2006-03-14 Thread Diez B. Roggisch
> Does python have andmap and ormap:
> 
> andmap((lambda t: boolean(t)),L)
> 
> gives True if boolean(t) is True for all t in L and False otherwise?
> And
> 
> ormap((lambda t: boolean(t)),L)
> 
> gives True if boolean(t) is True for some t in L and False otherwise?
> One can use a list comprehension like
> 
> [x for x in L if not(False in map((lambda t: boolean(t)),L))]
> 
> as an example of selection by andmap, and
> 
> [x for x in L if (True in map((lambda t: boolean(t)),L))]
> 
> as an example of selection by ormap.
> 
> How does one define andmap/ormap so its first argument is a boolean
> procedure or lambda?
> 
> def andmap(b,L):
>   if False in map(b,L): return False
>   else: return True
> 
> def ormap(b,L):
>   if True in map(b,L): return True
>   else: return False


import operator

reduce(operator.and_, [predcidate(o) for o in objects])

predicate can be a lambda, if it has to be.

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


Re: New python.org website

2006-03-14 Thread Roel Schroeven
robin schreef:
> "Michael Tobis" <[EMAIL PROTECTED]> wrote:
> 
>> While the new one is much better than the old website, the logo strikes
>> me as awful.
> As far as the layout goes, I still find it too busy. Specifically
> there are too many fonts on the one page. But I have already made that
> point, and did an entire version of the homepage, which the team have
> taken as input.

+1 on that. Last weekend I had a quick look at the stylesheet and 
removed most of the font-style and font-size declarations. It made the 
site look much better, IMO. If I can find a few spare minutes I might 
try to do put a bit more effort in it and send it in.

-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

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


Re: andmap and ormap

2006-03-14 Thread Fredrik Lundh
Felipe Almeida Lessa wrote:

> The problem is that it will evaluate all possibilities needlessly. Try
> (not tested and 2.4-only):

footnote: if you have a recent Python 2.5 build, you can make them even
shorter:

>>> help(any)
any(...)
any(iterable) -> bool
Return True if bool(x) is True for any x in the iterable.

>>> help(all)
all(...)
all(iterable) -> bool
Return True if bool(x) is True for all values x in the iterable.

 



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


Re: Is this possible in Python? SOLUTION FOUND

2006-03-14 Thread alainpoint

jalanb wrote:
> You might like the version here:
> http://www.jorendorff.com/toys/out.html
>
> Especially the "need to know" presentation, which is cute
>
> --
> Alan
> http://aivipi.blogspot.com

Thank you for the tip.
Meanwhile, I found a shorter solution to my problem:
def magic(arg):
import inspect
return inspect.stack()[1][4][0].split("magic")[-1][1:-1]

assert magic(3+4)=="3+4"

Alain

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


Re: anonymous memory mapping

2006-03-14 Thread Fabiano Sidler
2006/3/14, Peter Hansen <[EMAIL PROTECTED]>:
> (As for me, I have no idea what the question is about, so this is the
> most help I can give.)

Ok, sorry! I wanted to do this:

--- snip ---
from mmap import mmap, MAP_ANONYMOUS
mm = mmap(-1, 1024, MAP_ANONYMOUS)
--- snap ---

But I got an EnvironmentError, "[Errno 22] Invalid argument" (on
Linux2.6, btw.). The reason why I want to use anonymous mapping is
that it only allocates the memory it actually uses.

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


Re: andmap and ormap

2006-03-14 Thread Joel Hedlund
> footnote: if you have a recent Python 2.5 build,

Who would have that? Is it a good idea to use a pre-alpha python version? Or 
any unrealeased python version for that matter? I was under the impression that 
the recommended way to go for meager developers in python like myself is to 
stick with the latest stable production release (2.4.2 at the time of writing I 
believe). Or should I start grabbing the Subversion trunk on a nightly basis?

Cheers!
/Joel Hedlund
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: andmap and ormap

2006-03-14 Thread Peter Otten
[EMAIL PROTECTED] wrote:

> def ormap(b,L):
>   if True in map(b,L): return True
>   else: return False
> 
> Is this good enough?

No, because 

- (as Felipe observed) it doesn't shortcut, i. e. it always evaluates
b(item) for all items in L. 
- it creates a temporary list
- if truthvalue: return True
  else: return False
  is redundant and just plain ugly

Just write
  
return truthvalue

or, when truthvalue may consume a lot of memory,
  
return bool(truthvalue) # or: return not not truthvalue

Which gives:

def andmap(predicate, items):
return False not in (predicate(item) for item in items)

def ormap(predicate, items):
return True in (predicate(items) for item in items)


> andmap((lambda t: boolean(t)),L)

Superfluous lambda alert: make that

andmap(boolean, L)

Python 2.5 will feature similar functions any() and all() which seem to have
a fixed predicate == bool, though.

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


Re: andmap and ormap

2006-03-14 Thread Georg Brandl
Joel Hedlund wrote:
>> footnote: if you have a recent Python 2.5 build,
> 
> Who would have that? Is it a good idea to use a pre-alpha python version?
> Or any unrealeased python version for that matter? I was under the impression 
> that
> the recommended way to go for meager developers in python like myself is to 
> stick
> with the latest stable production release (2.4.2 at the time of writing I
believe).
> Or should I start grabbing the Subversion trunk on a nightly basis?

As most of the new features 2.5 is going to have are already implemented,
it's quite possible that people do checkout the SVN trunk and play with them.

Course, Fredrik could have said "In 2.5 you'll be able to write..."

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


Re: Which GUI toolkit is THE best?

2006-03-14 Thread Alan Franzoni
Paul Boddie on comp.lang.python said: 

> Now, since the commercial licence is "per developer", some cunning
> outfit could claim that only one developer wrote their product (rather
> than one hundred developers, say), but this would be a fairly big
> breach of trust (although nothing unusual in the world of commerce, I'm
> sure). Would a business making software for other such businesses care
> about such things? What kind of recourse would they have?

Just one thing I don't understand: if you're developing all your software
inside your company, how would they know if you already coded it or you
still have to?

Also, couldn't a big company buy a *single* commercial license from the
beginning, build a software employing hundreds of developers using the GPL
license, and then distribute the software pretending that the single
developer had done everything? This would hit Trolltech anyway.

I think the problem has to do with the QT license system. It's their
problem, not a developer's one. Also, I suppose one of their commercial
licenses provides with far lot more than a license - e.g. I think they'll
offer support, design tools, additional docs and libraries.

And what would then be their income if they refused to sell you a
commercial license because they *know* you've already coded your app using
the GPL license of Qt? You could simply throw away your app and never
distribute it, and they would'nt see a cent anyway.

Personally, I don't like Qt licensing, since I think there're good widget
sets around that don't have such limitations, but I don't think that people
at Trolltech are really trolls :-=

-- 
Alan Franzoni <[EMAIL PROTECTED]>
-
Togli .xyz dalla mia email per contattarmi.
Rremove .xyz from my address in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SSL/TLS - am I doing it right?

2006-03-14 Thread Michael Ekstrand
Disclaimer: I am not an expert. Take this with a grain of salt... but
I'll throw it out for what it's worth.

On 14 Mar 2006 04:12:38 -0800
"Frank Millman" <[EMAIL PROTECTED]> wrote:
> > > Using openssl, generate a key for the server, generate a
> > > self-signed certificate, and extract the sha1 fingerprint of the
> > > certificate. The key must be kept secure but the fingerprint can
> > > be published.
> >
> > Then install a copy of the certificate on the client, that the
> > client can authenticate against.
> 
> I wanted to keep the legwork required to set up a new client down to a
> minimum. I was hoping that setting a pointer to the client software,
> and a pointer to a connection parameter, would be sufficient. If the
> fingerprint is an an adequate substitute for the full certificate, I
> would prefer it, as it is much smaller, and can easily form part of
> the connection parameter.

Your client probably installs data files, right? Then just install the
server's public key (or a fingerprint thereof) as one of your data
files, put a checksum system in place to make sure it isn't tampered
with. Or just embed the checksum in your program or a DLL - the server
won't be changing its certificate very often.

If the user wants to go change the fingerprint to let the program
connect to a fradulent server, well, you've got a lot worse problems
than SSL will ever help you fix. I suppose a virus could change it, but
that'd be a weird (and highly targeted) virus.

> >  You also want to generate a client
> > certificate to install on the server.  If there are multiple clients
> > you should make a CA rather than trying to keep track of self-signed
> > certificates.  If you're paranoid, you can scrounge some $20
> > obsolete laptop from ebay and dedicate it to use as a CA, never
> > letting it touch the internet (transfer files to and from it on
> > floppy disc).
> >
> 
> Both you and Sybren are insistent that this is a necessary step, but I
> confess I cannot see the need for it. The client is lightweight, and
> authenticates itself to the server using a user id and password. What
> is the worst that could go wrong?

For what it's worth, the Web does not authenticate clients (for the
most part anyway). The server is authenticated - its certificate is
checked against the root CA list. But clients aren't expected to have
their own certificates. I think that the only time you really need the
clients to have certificates is when the certificate *is* your
authentication (e.g., in OpenVPN). Likewise, SSH does not verify client
certificates (unless you're using PKA, but that's different).

Since the password is your authentication, I don't see any reason why
the client verifying the server's certificate against its "known good"
fingerprint, and then providing username/password as its credentials,
is any less secure than SSH with password/keyboard-interactive. Sure,
maybe not quite as secure as SSH w/ public key auth, but it's good
enough for a lot of stuff.

- Michael

-- 
mouse, n: a device for pointing at the xterm in which you want to type.
-- Fortune
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython Q? floating window

2006-03-14 Thread Steve Holden
[EMAIL PROTECTED] wrote:
> Hi,
> 
> I have a question about wxPython.
> On Windows systems, you can point your mouse over most items on your
> desktop and a after a second or so, a small window will pop-up with
> extra info about the thing your pointing at (try e.g. move your mouse
> over the time in the right corner and a window will pop-up with the
> date).
> I was wondering this can be done with wxPython. I basically want to
> create a wxTree object and when I point the mouse over the objects in
> the tree I would like to have these kind of smal pop-up windows that
> display more info about the object you are pointing at.
> 
> Any help much appreciated.
> 
See wxToolTip - you can set a tooltip with the SetToolTip method on most 
objects.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd www.holdenweb.com
Love me, love my blog holdenweb.blogspot.com

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


Re: andmap and ormap

2006-03-14 Thread Georg Brandl
Peter Otten wrote:

> Python 2.5 will feature similar functions any() and all() which seem to have
> a fixed predicate == bool, though.

You cannot write

all(predicate, list)

but

all(predicate(x) for x in list)

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


Re: andmap and ormap

2006-03-14 Thread Peter Otten
Peter Otten wrote:

> def ormap(predicate, items):
> return True in (predicate(items) for item in items)

should be

def ormap(predicate, items):
return True in (predicate(item) for item in items)

Hmmpf.

Peter

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


Re: Localized month names?

2006-03-14 Thread Kent Johnson
Peter Otten wrote:
> Sibylle Koczian wrote:
>>What did you leave out? 
> 
> 
> Nothing, most likely.
> 
> 
>>I get 
>>
>>Traceback (most recent call last):
>>  File "", line 1, in -toplevel-
>>locale.nl_langinfo(locale.MON_1)
>>AttributeError: 'module' object has no attribute 'nl_langinfo'
>>
>>(Python 2.4, german Windows XP Pro)
>>
>>Moreover, 'January' is probably not localized.
> 
> 
> Python 2.4.2 (#4, Nov 19 2005, 13:25:59)
> [GCC 3.3.3 (SuSE Linux)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> 
import locale
locale.nl_langinfo(locale.MON_1)

 From the docs:
nl_langinfo(option)

 Return some locale-specific information as a string. This function 
is not available on all systems, and the set of possible options might 
also vary across platforms.

It doesn't seem to be available on Windows:
Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.

In [1]: import locale

In [2]: locale.nl_langinfo(locale.MON_1)

Traceback (most recent call last):
   File "", line 1, in ?
AttributeError: 'module' object has no attribute 'nl_langinfo'

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


Re: Which GUI toolkit is THE best?

2006-03-14 Thread Antoon Pardon
Op 2006-03-13, Paul Boddie schreef <[EMAIL PROTECTED]>:
> Paul Rubin wrote:
>> "Paul Boddie" <[EMAIL PROTECTED]> writes:
>> > What people don't usually understand (or rather complain about loudly)
>> > is that Trolltech can refuse to license Qt to you under the commercial
>> > licence, as is their right as the owner of the copyrighted work.
>>
>> What is the deal here?  Why would they refuse, to someone willing to
>> pay the commercial license fee?  They are a business, and as such,
>
> Well, I can't answer for them in any sense (and I should ask you to
> substitute any company with a similar business model for Trolltech in
> the text, along with accompanying product names, in order to emphasize
> the mere speculative nature of my explanation), but all I was trying to
> do was to explain the pattern of behaviour that goes something like
> this:
>
>  1. Developer downloads Qt GPL edition.
>  2. Developer develops product based on Qt.
>  3. Some time later, with finished product, developer now wants
> to release a closed source version of the product.
>  4. Developer approaches Trolltech and asks for a commercial
> licence in order to ship a closed source product.
>
> Now, since the commercial licence is "per developer", some cunning
> outfit could claim that only one developer wrote their product (rather
> than one hundred developers, say), but this would be a fairly big
> breach of trust (although nothing unusual in the world of commerce, I'm
> sure). Would a business making software for other such businesses care
> about such things? What kind of recourse would they have?

I wonder what this "per developer" means. Suppose ten people are working
on a product. But only one person is working on the GUI and comes into
contact with the Qt widget. Is that one or ten developers that are
counted for the license?

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


Re: Accessing overridden __builtin__s?

2006-03-14 Thread bruno at modulix
Steven D'Aprano wrote:
> On Mon, 13 Mar 2006 21:28:06 -0800, garyjefferson123 wrote:
> 
> 
>>I'm having a scoping problem.  I have a module called SpecialFile,
>>which defines:
>>
(snip code)

>>The problem, if it isn't obvioius, is that the open() call in __init__
>>no longer refers to the builtin open(), but to the module open().
> 
> 
> In your code, open() is not a module, it is a function.

Steven, it seems clear that the OP knows that already. Try reading the
previous sentence as:
"""
The problem, if it isn't obvioius, is that the open() call in __init__
no longer refers to the builtin's open(), but to the module's open().
"""

Does it make more sens ?-)

> A better technique will be to turn open into a method of the class
> SpecialFile, rather than a bare function. That way you keep open() the
> built-in function separate from SpecialFile.open().
> 
> 
>>So, if I do:
>>
>>f = SpecialFile.open(name, mode)
>>
>>I get infinite recursion.
> 
> 
> I see you are already using an open method. 

There again, you may want to read more carefully: SpecialFile is *also*
the module's name - which, I agree, is not pythonic.

(snip)

> 
> I would handle it like this:
> 
> class SpecialFile(object):
> def __init__(self, fname, mode='r'):
> self.fname = fname
> self.mode = mode
> def open(self):
> self.f = open(self.fname, self.mode)
> def close(self):
> self.f.close()
> def read(self):
> return self.f.read()
> def write(self, data):
> self.f.write(data)
> 
> You use it like so:
> 
> sf = SpecialFile("hello.txt")
> sf.open()
> data = sf.read()
> sf.close()

Small variant, more builtins-open-like, and taking full advantage of
Python's delegation mechanism:

class SpecialFile(object):
def __init__(self, fname, mode='r'):
self.fname = fname
self.mode = mode
self._file = open(self.fname, self.mode)

def __getattr__(self, name):
return getattr(self._file)

which allows:

sf = SpecialFile("hello.txt")
# then use it just like any other file object

My 2 cents
-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Accessing overridden __builtin__s?

2006-03-14 Thread Fredrik Lundh
"bruno at modulix" wrote:

> There again, you may want to read more carefully: SpecialFile is *also*
> the module's name - which, I agree, is not pythonic.

this approach was recommended by the official style until very recently.

http://www.python.org/doc/essays/styleguide.html

Modules that export a single class (or a number of closely related
classes, plus some additional support) are often named in Mixed-
Case, with the module name being the same as the class name
(e.g. the standard StringIO module).

 



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


Trace dynamically compiled code?

2006-03-14 Thread Ed Leafe
Hi,

Thanks to the help of many on this list, I've been able to take code  
that is created by the user in my app and add it to an object as an  
instance method. The technique used is roughly:

nm = "myMethod"
code = """def myMethod(self):
print "Line 1"
print "My Value is %s" % self.Value
return
"""
compCode = compile(code, "", "exec")
exec compCode
exec "self.%s = %s.__get__(self)" % (nm, nm)

This is working great, but now I'm wondering if there is a way to  
enable pdb tracing of the code as it executes? When tracing "normal"  
code, pdb will show you the name of the script being executed, the  
line number and the source code for the line about to be executed.  
But when stepping through code compiled dynamically as above, the  
current line's source code is not available to pdb, and thus does not  
display.

Does anyone know a way to compile the dynamic code so that pdb can  
'see' the source? I suppose I could write it all out to a bunch of  
temp files, but that would be terribly messy. Are there any neater  
solutions?

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com



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


Re: andmap and ormap

2006-03-14 Thread wkehowski
The following works perfectly:

import operator

def andmap(b,L):
return reduce(operator.and_, [b(x) for x in L])

def ormap(b,L):
return reduce(operator.or_, [b(x) for x in L]) 

Thanks!

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


Re: Very, Very Green Python User

2006-03-14 Thread bruno at modulix
Scott David Daniels wrote:
> [EMAIL PROTECTED] wrote:
> 
>> ... Is the Python debugger fairly stable?
> 
> Yes, but it is not massively featured.  The "Pythonic" way is to
> rarely use a debugger (test first and straightforward code should
> lead to "shallow" bugs).  Often for most of us judiciously placed
> print statements suffice.

Well, the fact is that I haven't used pdb on more than two or three
occasions, and I'm using Python since the 1.5.x.


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which GUI toolkit is THE best?

2006-03-14 Thread Paul Boddie
Alan Franzoni wrote:
>
> Just one thing I don't understand: if you're developing all your software
> inside your company, how would they know if you already coded it or you
> still have to?

I have no idea. But as I said elsewhere, I'm not in any sense a party
to the process that would attempt to define such enforcement matters.

> Also, couldn't a big company buy a *single* commercial license from the
> beginning, build a software employing hundreds of developers using the GPL
> license, and then distribute the software pretending that the single
> developer had done everything? This would hit Trolltech anyway.

True, but then have you ever used proprietary software with those
irritating floating licences or with licence keys? Sure, a company
doing stuff on the cheap could buy fewer licences than they need - I've
been in a situation where an employer has bought n licences of some
flashy-but-not-exactly-necessary solution that everyone (n + x people)
has been forced to use, and you end up with all sorts of management
workarounds ("if you're not using product X, can you log off and log
back in later?") - and I'd imagine that where technical measures aren't
the means of limiting the number of users, you get all sorts of
management workarounds to give the impression that only one developer
is using the software in other enforcement regimes: having one person
that collates and forwards support requests, for example. That
businesses would rather waste their employees' time at a much higher
cost than just forking out for more software isn't a surprise to me
whatsoever.

> I think the problem has to do with the QT license system. It's their
> problem, not a developer's one. Also, I suppose one of their commercial
> licenses provides with far lot more than a license - e.g. I think they'll
> offer support, design tools, additional docs and libraries.

I believe so, yes. However, the problem with any licensing system is
generally the developer's: if you want to sell a solution based on
Microsoft Office, is it Microsoft's problem that they chose an
ultra-proprietary licence? As a developer you do get to choose other
solutions, however. (Perhaps I've misinterpreted what you meant,
though.)

> And what would then be their income if they refused to sell you a
> commercial license because they *know* you've already coded your app using
> the GPL license of Qt? You could simply throw away your app and never
> distribute it, and they would'nt see a cent anyway.

I have no idea. It's best to ask them that question rather than random
newsgroup contributors, I think. ;-)

Paul

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


Re: Trace dynamically compiled code?

2006-03-14 Thread Thomas Heller
Ed Leafe wrote:
> Hi,
> 
>   Thanks to the help of many on this list, I've been able to take code  
> that is created by the user in my app and add it to an object as an  
> instance method. The technique used is roughly:
> 
> nm = "myMethod"
> code = """def myMethod(self):
> print "Line 1"
> print "My Value is %s" % self.Value
> return
> """
> compCode = compile(code, "", "exec")
> exec compCode
> exec "self.%s = %s.__get__(self)" % (nm, nm)
> 
>   This is working great, but now I'm wondering if there is a way to  
> enable pdb tracing of the code as it executes? When tracing "normal"  
> code, pdb will show you the name of the script being executed, the  
> line number and the source code for the line about to be executed.  
> But when stepping through code compiled dynamically as above, the  
> current line's source code is not available to pdb, and thus does not  
> display.
> 
>   Does anyone know a way to compile the dynamic code so that pdb can  
> 'see' the source? I suppose I could write it all out to a bunch of  
> temp files, but that would be terribly messy. Are there any neater  
> solutions?

You coud monkey-patch the getline function in the linecache module, so
that it is able to find your dynamically generated code.  IMO that is
what pdb uses.c

Thomas

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


Re: Which GUI toolkit is THE best?

2006-03-14 Thread Chris Mellon
On 14 Mar 2006 06:10:19 -0800, Paul Boddie <[EMAIL PROTECTED]> wrote:
> Alan Franzoni wrote:
> >
> > Just one thing I don't understand: if you're developing all your software
> > inside your company, how would they know if you already coded it or you
> > still have to?
>
> I have no idea. But as I said elsewhere, I'm not in any sense a party
> to the process that would attempt to define such enforcement matters.
>
> > Also, couldn't a big company buy a *single* commercial license from the
> > beginning, build a software employing hundreds of developers using the GPL
> > license, and then distribute the software pretending that the single
> > developer had done everything? This would hit Trolltech anyway.
>
> True, but then have you ever used proprietary software with those
> irritating floating licences or with licence keys? Sure, a company
> doing stuff on the cheap could buy fewer licences than they need - I've
> been in a situation where an employer has bought n licences of some
> flashy-but-not-exactly-necessary solution that everyone (n + x people)
> has been forced to use, and you end up with all sorts of management
> workarounds ("if you're not using product X, can you log off and log
> back in later?") - and I'd imagine that where technical measures aren't
> the means of limiting the number of users, you get all sorts of
> management workarounds to give the impression that only one developer
> is using the software in other enforcement regimes: having one person
> that collates and forwards support requests, for example. That
> businesses would rather waste their employees' time at a much higher
> cost than just forking out for more software isn't a surprise to me
> whatsoever.
>
> > I think the problem has to do with the QT license system. It's their
> > problem, not a developer's one. Also, I suppose one of their commercial
> > licenses provides with far lot more than a license - e.g. I think they'll
> > offer support, design tools, additional docs and libraries.
>
> I believe so, yes. However, the problem with any licensing system is
> generally the developer's: if you want to sell a solution based on
> Microsoft Office, is it Microsoft's problem that they chose an
> ultra-proprietary licence? As a developer you do get to choose other
> solutions, however. (Perhaps I've misinterpreted what you meant,
> though.)
>
> > And what would then be their income if they refused to sell you a
> > commercial license because they *know* you've already coded your app using
> > the GPL license of Qt? You could simply throw away your app and never
> > distribute it, and they would'nt see a cent anyway.
>
> I have no idea. It's best to ask them that question rather than random
> newsgroup contributors, I think. ;-)
>

It's pretty obvious, though. The whole point of people doing this is
that they only want to pay for 1 license once rather than X licenses
for the whole dev cycle. By not selling you a license they lose $1000,
but they keep enforcing a licensing system that makes them a lot more
money. Their leverage comes from the fact that you've invested however
much time and effort into the app development and while you can toss
it you're out a great deal more than they are.

I suspect that if enough money changed hands (like, you paid for your
X developers backdated to when you started development) you could
convince TT to sell you a license, too.
> Paul
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Customizing character set conversions with an error handler

2006-03-14 Thread Jukka Aho
Serge Orlov wrote:

>> # So the question becomes: how can I make this work
>> # in a graceful manner?

> change the return statement with this code:
>
> return (substitution.encode(error.encoding,"practical").decode(
>error.encoding), error.start+1)

Thanks, that was a quite neat recursive solution. :) I wouldn't have 
thought of that.

I ended up doing it without the recursion, by testing the individual 
problematic code points with .encode() within the handler, and catching 
the possible exceptions:

--- 8< ---

# This is our original problematic code point:
c = error.object[error.start]

while 1:

# Search for a substitute code point in
# our table:

c = table.get(c)

# If a substitute wasn't found, convert the original code
# point into a hexadecimal string representation of itself
# and exit the loop.

if c == None:
c = u"[U+%04x]" % ord(error.object[error.start])
break

# A substitute was found, but we're not sure if it is OK
# for for our target encoding. Let's check:

try:
c.encode(error.encoding,'strict')
# No exception; everything was OK, we
# can break off from the loop now
break

except UnicodeEncodeError:
# The mapping that was found in the table was not
# OK for the target encoding. Let's loop and try
# again; there might be a better (more generic)
# substitution in the chain waiting for us.
pass

--- 8< ---

-- 
znark

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


Writing 'C' structures out in cPickle format?

2006-03-14 Thread Chance Ginger
I have a problem that I am trying to solve. I have two different
systems - one written in C and another in Python. I would like the
two to exchange some information. 

On the Python side I decided to use cPickle. On the C side I would
write a library that can read the cPickle and generate the correct
C structure (the data is, more or less, self-describing) and visa
versa. 

I was wondering if anyone has done something like this before
and if so can they point me to information on how to easily do it?
The structures I am using on the C side are pretty simple (very
flat and using only integers and strings).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cheese Shop: some history for the new-comers

2006-03-14 Thread A.M. Kuchling
On Sun, 12 Mar 2006 10:25:19 +0100, 
Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> and while you're at it, change "python-dev" to "developers" and
> "psf" to "foundation" (or use a title on that link).

I've changed the PSF link, but am not sure what to do about the
python-dev link.  As others have noted, "Developers" is ambiguous
about whether it's for people who develop in Python or who develop
Python itself."Core Development"?  (Used on both perl.org and tcl.tk, so
maybe this is the best option.) "Development Team"?  

--amk

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


Re: Writing 'C' structures out in cPickle format?

2006-03-14 Thread Diez B. Roggisch
> On the Python side I decided to use cPickle. On the C side I would
> write a library that can read the cPickle and generate the correct
> C structure (the data is, more or less, self-describing) and visa
> versa.
> 
> I was wondering if anyone has done something like this before
> and if so can they point me to information on how to easily do it?
> The structures I am using on the C side are pretty simple (very
> flat and using only integers and strings).

I guess it might be the more sensible choice to use module struct and
transform your python-data to C-structs. The reason is simply that to teach
the old dog C new tricks (namely react flexible on cPickle) is a hard task,
whereas customizing python objects serialization is comparably easy.

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


Re: recycling internationalized garbage

2006-03-14 Thread aaronwmail-usenet
Regarding cleaning of mixed string encodings in
the discography search engine

http://www.xfeedme.com/discs/discography.html

Following 's suggestion I came up with this:

utf8enc = codecs.getencoder("utf8")
utf8dec = codecs.getdecoder("utf8")
iso88591dec = codecs.getdecoder("iso-8859-1")

def checkEncoding(s):
try:
(uni, dummy) = utf8dec(s)
except:
(uni, dummy) = iso88591dec(s, 'ignore')
(out, dummy) = utf8enc(uni)
return out

This works nicely for Nordic stuff like
"björgvin halldórsson - gunnar Þórðarson",
but russian seems to turn into garbage
and I have no idea about chinese.

Unless someone has any other ideas I'm
giving up now.
   -- Aaron Watters

===

In theory, theory is the same as practice.
In practice it's more complicated than that.
  -- folklore

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


EVT_ICONIZE lost focus

2006-03-14 Thread lux
Hi,
I have a wxFrame with some TextCtrl,
if I minimize the Frame when normalize it
lost the Focus and I must click to give the focus to textCtrl again

How can resolve?

Thank's,
Luca

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


Re: Please, I Have A Question before I get started

2006-03-14 Thread Terry Hancock
On Mon, 13 Mar 2006 02:19:39 GMT
Skipper <[EMAIL PROTECTED]> wrote:
> Basically the program will blank the screen and call up
> (for example) 6 pictures.  A flashing border with travel
> from picture to picture. When the computer senses a mouse
> click it will clear the screen and present a second set of
> choices ... one level deeper than the first ... based on
> the chosen picture.

So the key difference from, say, a web page in a browser,
is that you want the choice to be determined by timing,
not by where the mouse is pointed?

This is actually quite non-standard, so there won't be
a lot of support for it in GUI-building tools.

However, it is the sort of thing that a game toolkit is
well-organized for. IMHO, PyGame is probably very close
to the fastest way to achieve this.  But you will have
to learn how to create a data model for your menus,
etc.

The main module can be dead simple, though. You just
need to paste in a little PyGame boilerplate at the
top (examples are included in the PyGame distribution),
then you'll have a loop that handles displaying a menu,
rotating through the choices, and listening for keyboard
input.  Something like this (I'm writing from memory --
you'll have to check the pygame documentation (which is
excellent, BTW) to find details):

import pygame
from pygame.locals import *
pygame.init()

screen = pygame.display.set_mode((800,600))
# There are smarter ways to do this, but for
# a one-off project, just use your known screen size

# HERE YOU NEED TO BUILD YOUR MENU TREE
# I'm assuming a tree structure of some
# kind with some obvious methods attached
# to each node

current_menu = root_menu
while 1:
current_menu.display()
try:
for choice in current_menu.choices:
root_menu.highlight(choice)
t0= pygame.time.get_ticks()
t = t0
while thttp://www.AnansiSpaceworks.com

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


Re: Cheese Shop: some history for the new-comers

2006-03-14 Thread Robert Boyd
On 3/14/06, A.M. Kuchling <[EMAIL PROTECTED]> wrote:
> On Sun, 12 Mar 2006 10:25:19 +0100,
> Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> > and while you're at it, change "python-dev" to "developers" and
> > "psf" to "foundation" (or use a title on that link).
>
> I've changed the PSF link, but am not sure what to do about the
> python-dev link.  As others have noted, "Developers" is ambiguous
> about whether it's for people who develop in Python or who develop
> Python itself."Core Development"?  (Used on both perl.org and tcl.tk, so
> maybe this is the best option.) "Development Team"?
>
> --amk
>

"Core Development" is good IMO,  or "Language Development". I think
the latter is explicit and distinguishes itself from "using the
language to write programs" aka "Developing in (or with) Python".

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


calling another python file within python

2006-03-14 Thread Kevin
i have a python file called pyq which outputs stock quotes, currently i 
also have a html file that takes stock ticker inputs, i would like to 
bridge the two by building another program that takes the html inputs 
and uses them to call the pyq stock ticker program and then output them 
into a text file...

any idea how to do this? my tentative code is:



#!/usr/bin/python

import os
import urllib
os.system("python pyq.py ibm > text1.txt")




note: currently the text1.txt outputted is just blank, however if i run 
the command normally as 'python pyq.py ibm' in the command line, it 
works correctly and gives me the price of ibm.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Numpy-discussion] [ANN] NumPy 0.9.6 released

2006-03-14 Thread Colin J. Williams
Travis Oliphant wrote:

> This post is to announce the release of NumPy 0.9.6 which fixes some 
> important bugs and has several speed improvments.
>
> NumPy is a multi-dimensional array-package for Python that allows 
> rapid high-level array computing with Python.  It is successor to both 
> Numeric and Numarray.  More information at http://numeric.scipy.org
>
> The release notes are attached:
>
> Best regards,
>
> NumPy Developers
>
>  - __array_finalize__ is now called for every array sub-class creation.
>  
>
Thanks.  What are the parameters for this method and what does it do?

How does it differ from the common Python usage of __new__ followed by 
__init__?

[Dbg]>>>
Help on built-in function __array_finalize__:

__array_finalize__(...)


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


Tree and Graph structures in Python.

2006-03-14 Thread Ant
Hi all,

Are there any tree or graph modules available for python?

Cheers,

-- 
Ant...

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


Re: Tree and Graph structures in Python.

2006-03-14 Thread Lonnie Princehouse
Google for "boost graph python"

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


Re: calling another python file within python

2006-03-14 Thread Rene Pijlman
Kevin:
>#!/usr/bin/python
>
>import os
>import urllib
>os.system("python pyq.py ibm > text1.txt")

Check the return value of os.system.

>note: currently the text1.txt outputted is just blank, however if i run 
>the command normally as 'python pyq.py ibm' in the command line, it 
>works correctly and gives me the price of ibm.

Same PATH, PYTHONPATH, current working directory, user,... ?

-- 
René Pijlman
-- 
http://mail.python.org/mailman/listinfo/python-list


Tried Ruby (or, "what Python *really* needs" or "perldoc!")

2006-03-14 Thread john_sips_tea
Just tried Ruby over the past two days. I won't bore you
with the reasons I didn't like it, however one thing really
struck me about it that I think we (the Python community)
can learn from.

Ruby has ... an issue with docs. That is to say, there are
almost none. Well, actually, there are some. For example,
the "PickAxe" book (google it), and "Why's" Poignant Guide.
But there's a disturbing lack of *built-in* docs for Ruby.
Now, the situation is getting better. In fact, it's getting
better very quickly. Let me explain.

IMO, Perl has docs nailed. I learned Perl before coming
to Python, and I can tell you that their docs kick butt.
I believe the reason why is (besides Larry's excellent
and entertaining writing) because of perldoc. Here's how
it works: they write special doc directives into their .pl
files that the interpreter ignores, but that the perldoc
command processes into a manpage for you. This is a *bit*
like what pydoc does, only pydoc just regurgitates docstrings,
while perldoc formats special directives into headings, code
listings, bulleted lists, etc.

Now, the *real* magic of perldoc is that it makes writing
small self-contained little manpage style docs easy as pie.
What this means is that really good doc writers can sit down
and quickly produce something that can be readily incorporated
into the perl-doc distribution. *That's* the magic. That's
why I think they've organically grown such an amazing crop
of great docs. Anyone can quickly and easily write docs that
the community can then filter to find the best ones.

Back to Ruby's docs. Their situation is getting better. This
is because they're picking up on Perl's doc success and doing
the same sort of thing. Only, I think their solution may be
clunkier because it requires a separate program (rdoc) to
process the doc directives, and then you actually read the
docs with a program called ri (not sure). Regardless of the
minute details, it looks like their docs are starting to get
better, rapidly.

Here's what I think is currently happening with Python
(please correct me if I'm wrong): There's the docutils project
http://docutils.sourceforge.net/ which, AFAICT, is working on a
number of complicated things, one of which is to have a way to
allow you to put reStructuredText markup (aka "reST")
( http://docutils.sourceforge.net/rst.html ) into your docstrings
(and presumably have the pydoc command understand it). There's
more info in PEP 287 http://www.python.org/doc/peps/pep-0287/ .

I certainly don't understand all that Docutils is trying to
do. All I'm convinced of is, the real magic is in being able to
quickly write a .py file containing marked up docstrings and
have the pydoc command be able to render it as something that
looks like a man page in my terminal window. If it can later
also produce html, that's great too. But *that's* the essense,
IMO, of what will foster community involvement in making the
docs great, as well as allowing folks to more easily document
their own modules and contribute integrated docs to all the
great modules already available.

It looks like we have the tools do this *right now*. We've got
the markup (reST), we've got the tools to churn that into a
manpage or html (part of docutils?), and we've got the pydoc
command. I think the current hangup is that the docutils guys
(being smart and ambitious folks) want to get some sort of
inter-doc linking thing working so you can refer from one doc
page to another (?). I don't think perldoc has (or needs) that
feature... maybe we could put that on the "would be nice to
have down the road" list, and get a quick common-sense
docstring-reST pydoc setup working for us much sooner? I
don't know for sure, but my guess is "yes".

Eventually, maybe the tutorial, language reference, library ref,
etc., could even all make it into this format, with the html
versions generated from the .py/docstring/reST sources. That might
make it easier for the community to contribute to them (if their
respective maintainers are interested in that).

Please note, I certainly don't want to step on the doc-sig folks'
toes here -- but rather to generate more interest in what they're
doing, and to help make Python be even better in an area that I
see it struggling.

What do you folks think?

Yes, I'm trying to make time to look at the docutils code and the
pydoc command to see what's involved. Unfortunately, my spare
time is vanishingly close to zero right now.

Related link:
Doc-SIG http://www.python.org/community/sigs/current/doc-sig/

Thanks,
---John

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


Re: Please, I Have A Question before I get started

2006-03-14 Thread Steve Holden
Skipper wrote:
> Well, thank you so much for taking the time to reply.  I guess that
> about wraps up all my questions.
> 
> 
> You fucking putz
> 

I'd appreciate it if you;d keep that sort of response to yourself. While 
I don't mind you *thinking* it, it isn't the kind of behaviour we want 
to encourage in these parts, no matter how fatuous you may have found 
the response that triggered your profanity.

Thanks
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd www.holdenweb.com
Love me, love my blog holdenweb.blogspot.com

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


Re: Tried Ruby (or, "what Python *really* needs" or "perldoc!")

2006-03-14 Thread Diez B. Roggisch
> Please note, I certainly don't want to step on the doc-sig folks'
> toes here -- but rather to generate more interest in what they're
> doing, and to help make Python be even better in an area that I
> see it struggling.
> 
> What do you folks think?
> 
> Yes, I'm trying to make time to look at the docutils code and the
> pydoc command to see what's involved. Unfortunately, my spare
> time is vanishingly close to zero right now.


You heard of epydoc? http://epydoc.sourceforge.net/

It pretty much does what you say I think - and for my personal projects I
use it. Maybe we an adopt it as standard-tool.

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


How to create a Visual SourceSafe plugin in Python

2006-03-14 Thread looping
Hi,
I try to create a COM object with win32com to track events in Visual
SourceSafe.
I tried to modify ExcelAddin.py demo but with no luck.
I've now a Delphi DLL that make that job so I know it's possible.

If someone have an exemple, please help me.

Best regards.
Kadeko

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


Re: Tried Ruby (or, "what Python *really* needs" or "perldoc!")

2006-03-14 Thread john_sips_tea
Thanks Diez! Epydoc looks great.

Can we use epytext to generate output suitable for a manpage?

Do you prefer epytext or reST?

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


Re: Tried Ruby (or, "what Python *really* needs" or "perldoc!")

2006-03-14 Thread Diez B. Roggisch
> Thanks Diez! Epydoc looks great.
> 
> Can we use epytext to generate output suitable for a manpage?

Don't know, never tried that.
 
> Do you prefer epytext or reST?

So far epytext suited my needs.

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


Python Debugger / IDE ??

2006-03-14 Thread krypto . wizard
Is there any editor or IDE in Python (either Windows or Linux) which
has very good debugging facilites like MS VisualStudio has or something
like that.

I like SPE but couldn't easily use winPDP. I need tips to debug my code
easily.

Every help is greatly appreciated.

Thanks

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


Re: Tried Ruby (or, "what Python *really* needs" or "perldoc!")

2006-03-14 Thread john_sips_tea
> So far epytext suited my needs.

I like it too.

Ok, now I'm starting to get excited. :)

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


Re: Python Debugger / IDE ??

2006-03-14 Thread olsongt

[EMAIL PROTECTED] wrote:
> Is there any editor or IDE in Python (either Windows or Linux) which
> has very good debugging facilites like MS VisualStudio has or something
> like that.
>
> I like SPE but couldn't easily use winPDP. I need tips to debug my code
> easily.
>
> Every help is greatly appreciated.
>
> Thanks

I've always been happy with the debugger in PythonWin.  You can even
use:

from pywin.debugger import set_trace;set_trace()

to bring up the debugger directly from a script that wasn't originally
run in the ide.

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


Re: recycling internationalized garbage

2006-03-14 Thread Ross Ridge
[EMAIL PROTECTED] wrote:
> try:
> (uni, dummy) = utf8dec(s)
> except:
> (uni, dummy) = iso88591dec(s, 'ignore')

Is there really any point in even trying to decode with UTF-8?  You
might as well just assume ISO 8859-1.

   Ross Ridge

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


Re: Python Debugger / IDE ??

2006-03-14 Thread Rene Pijlman
[EMAIL PROTECTED]:
>Is there any editor or IDE in Python (either Windows or Linux) which
>has very good debugging facilites like MS VisualStudio has or something
>like that.

Here's a recent thread about IDEs:
http://groups.google.nl/group/comp.lang.python/browse_frm/thread/fd9604e225252ad4

-- 
René Pijlman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Debugger / IDE ??

2006-03-14 Thread [EMAIL PROTECTED]
>Is there any editor or IDE in Python (either Windows or Linux) which
>has very good debugging facilites like MS VisualStudio has or something
>like that.

I've been using Eclipse with PyDev and am very happy with it.

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


Re: Trace dynamically compiled code?

2006-03-14 Thread Ziga Seilnacht
Ed Leafe wrote:
> Hi,
>
>   Thanks to the help of many on this list, I've been able to take code
> that is created by the user in my app and add it to an object as an
> instance method. The technique used is roughly:

Just some notes about your code:

> nm = "myMethod"
> code = """def myMethod(self):
> print "Line 1"
> print "My Value is %s" % self.Value
> return
> """
> compCode = compile(code, "", "exec")
> exec compCode

Try not using bare exec statements, since they pollute the local scope.
In your example you could use:

compCode = compile(code, "", "exec")
d = {}
exec compCode in d
func = d[nm]

See http://docs.python.org/ref/exec.html for details.

> exec "self.%s = %s.__get__(self)" % (nm, nm)

You don't need dynamic execution here; you can simply use
setattr and the new module:

import new
method = new.instancemethod(func, self)
setattr(self, nm, method)

and yes, I remember that I was the one who suggested you
the __get__ hack.

>   This is working great, but now I'm wondering if there is a way to
> enable pdb tracing of the code as it executes? When tracing "normal"
> code, pdb will show you the name of the script being executed, the
> line number and the source code for the line about to be executed.
> But when stepping through code compiled dynamically as above, the
> current line's source code is not available to pdb, and thus does not
> display.
>
>   Does anyone know a way to compile the dynamic code so that pdb can
> 'see' the source? I suppose I could write it all out to a bunch of
> temp files, but that would be terribly messy. Are there any neater
> solutions?

You should check py lib: http://codespeak.net/py/current/doc/ ,
specifically the py.code "module". Then you can modify the
function from above:

import inspect
f = inspect.currentframe()
lineno = f.f_lineno - 5 # or some other constant
filename = f.f_code.co_filename

import py
co = py.code.Code(func)
new_code = co.new(co_lineno=lineno, co_filename=filename)
new_func = new.function(new_code, func.func_globals, nm,
func.func_defaults, func.func_closure)


> -- Ed Leafe
> -- http://leafe.com
> -- http://dabodev.com

Ziga Seilnacht

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


Re: Tried Ruby (or, "what Python *really* needs" or "perldoc!")

2006-03-14 Thread Colin J. Williams
Diez B. Roggisch wrote:
>>Thanks Diez! Epydoc looks great.
>>
>>Can we use epytext to generate output suitable for a manpage?
> 
> 
> Don't know, never tried that.
>  
The answer appear to be No, but there is a man.py file which indicates 
that some work was done on it.

Below is the epydoc commandline guide.

Colin W.

epydoc [OPTIONS] MODULES...

 MODULES...The Python modules to document.
 --htmlGenerate HTML output (default).
 --latex   Generate LaTeX output.
 --pdf Generate pdf output, via LaTeX.
 --check   Run documentation completeness checks.
 -o DIR, --output DIR  The output directory.
 -n NAME, --name NAME  The documented project's name.
 -u URL, --url URL The documented project's url.
 -t PAGE, --top PAGE   The top page for the HTML documentation.
 -c SHEET, --css SHEET CSS stylesheet for HTML files.
 --private-css SHEET   CSS stylesheet for private objects.
 --inheritance STYLE   The format for showing inherited objects.
 -V, --version Print the version of epydoc.
 -h, -?, --help, --usage   Display this usage message.
 -h TOPIC, --help TOPICDisplay information about TOPIC (docformat,
   css, inheritance, usage, or version).
> 
>>Do you prefer epytext or reST?
> 
> 
> So far epytext suited my needs.
> 
> Diez
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this possible in Python? SOLUTION FOUND

2006-03-14 Thread Kay Schluehr

[EMAIL PROTECTED] wrote:
> jalanb wrote:
> > You might like the version here:
> > http://www.jorendorff.com/toys/out.html
> >
> > Especially the "need to know" presentation, which is cute
> >
> > --
> > Alan
> > http://aivipi.blogspot.com
>
> Thank you for the tip.
> Meanwhile, I found a shorter solution to my problem:
> def magic(arg):
>   import inspect
>   return inspect.stack()[1][4][0].split("magic")[-1][1:-1]
>
> assert magic(3+4)=="3+4"
>
> Alain

Does it? Using your function I keep an assertion error. Storing the
return value of magic()in a variable s I receive the following result:

def magic(arg):
import inspect
return inspect.stack()[1][4][0].split("magic")[-1][1:-1]

s = magic(3+4) # magic line

>>> s
'lin'


BTW grepping the stack will likely cause context sensitive results.

Kay

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


Re: Tried Ruby (or, "what Python *really* needs" or "perldoc!")

2006-03-14 Thread john_sips_tea
Ok. I'm going to try and make something happen. Give me a day or so.

:)
---John

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


Re: Tried Ruby (or, "what Python *really* needs" or "perldoc!")

2006-03-14 Thread Nick Craig-Wood
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>  IMO, Perl has docs nailed. I learned Perl before coming
>  to Python, and I can tell you that their docs kick butt.
>  I believe the reason why is (besides Larry's excellent
>  and entertaining writing) because of perldoc. Here's how
>  it works: they write special doc directives into their .pl
>  files that the interpreter ignores, but that the perldoc
>  command processes into a manpage for you. This is a *bit*
>  like what pydoc does, only pydoc just regurgitates docstrings,
>  while perldoc formats special directives into headings, code
>  listings, bulleted lists, etc.

As another perl refugee I agree with you 100% here.

"perldoc perltoc" then "perldoc " will find you anything in perl.

Its frustrating that pydoc is only half (or less) of the docs.

However having bedded into python for a few years, I now just reach
for my web browser for the global module index instead of pydoc.  Its
not as good as perldoc as it doesn't cover all the modules I've got
installed, but its very good documentation.  Some modules have good
pydoc-umentation but not all of them.  Code examples tend to be
missing.

I think a major problem with our way of thinking about
perldoc/pydoc/man pages is that it is a) unix centric, and b) possibly
a bit old fashioned!  a) and b) apply to perl certainly, but I don't
think they apply to python in the same way.

I'd love to have a unified documentation system where *all* the
documentation for *all* installed modules was available to pydoc *and*
the web browser and *all* this documentation was in .py files.

(Putting the code together with the documentation is essential in my
opinion and experience - if you seperate the two then the documention
will lag the code.)

PS I've used reST and perldoc.  reST is easier to use for the easy
things, but gets complicated for the hard things.

-- 
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Debugger / IDE ??

2006-03-14 Thread Scott David Daniels
[EMAIL PROTECTED] wrote:
> Is there any editor or IDE in Python (either Windows or Linux) which
> has very good debugging facilites like MS VisualStudio has or something
> like that.
> 
> I like SPE but couldn't easily use winPDP. I need tips to debug my code
> easily.
> 
> Every help is greatly appreciated.
> 
> Thanks
> 
If you don't mind spending (not so much) money, ActiveState's Komodo
is a nice debugger.   With it you can even debug a Python program on
a remote machine over a network connection (ideal for GUI problems).

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


Re: convert hex to decimal

2006-03-14 Thread challman

Oh, that should have been whole number; not while.

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


Re: Tree and Graph structures in Python.

2006-03-14 Thread Istvan Albert
See this:

https://networkx.lanl.gov/

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


Re: Tree and Graph structures in Python.

2006-03-14 Thread bearophileHUGS
http://www.osl.iu.edu/~dgregor/bgl-python/
http://sourceforge.net/projects/pygraphlib/
http://sourceforge.net/projects/pynetwork/
https://networkx.lanl.gov/
http://starship.python.net/crew/aaron_watters/kjbuckets/
http://www.python.org/doc/essays/graphs.html
http://yapgvb.sourceforge.net/
http://dkbza.org/pydot.html
http://www.geocities.com/foetsch/mfgraph/index.htm

(Some of them are just explanations, or interfaces with a well known
graph plotting package).
With Google you can probably find 2-4 other libraries...
I think there are so many of them because some people need them, but
there isn't a standard one yet in the built-in library.

Bye,
bearophile

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


Re: Tried Ruby (or, "what Python *really* needs" or "perldoc!")

2006-03-14 Thread Terry Hancock
On 14 Mar 2006 09:25:07 -0800
[EMAIL PROTECTED] wrote:
> Do you prefer epytext or reST?

I personally prefer epytext primarily because it has support
for greek letters and math symbols. That could be very
useful in documenting certain kinds of software. OTOH, I
haven't had much occasion to use that feature (once upon a
time almost all the software I wrote was scientific, but it
seems I've pretty much given it up -- not that I
particularly planned to, but it's turned out that way).

I was under the impression that pydoc already interpreted
restructured text notation, but maybe I was wrong. I don't
like pydoc because it doesn't make useable static
documentation sets -- that's where epydoc (which I suppose
stands for "extended pydoc") shines.

Although it's great to have "manpage" type help, I
personally find HTML documentation much easier to read and
browse.  Pydoc can do this if you are willing to use it as a
server, but it doesn't do so well at making an in-package
website, which is what I usually want to do.

There's also happydoc, which was better than either at
discovering documentation, but stagnated somewhere between
2.x and 3.x with bugs that make it fairly unusable.  What
would be cool is if some of happydoc's unique features were
ported to epydoc (such as getting information from comments
as well as docstrings).

-- 
Terry Hancock ([EMAIL PROTECTED])
Anansi Spaceworks http://www.AnansiSpaceworks.com

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


Little Help with Exceptions and ConfigParser

2006-03-14 Thread mwt
Hi -
I'm having a little trouble using exceptions properly. I currently have
an initialization function on a little app that looks like this:

def __init__(self, config_file):
self.fahdata = fahdata.FAHData()
self.INI = ConfigParser.ConfigParser()
if os.path.exists(config_file):
try:
self.INI.read(config_file)
except ConfigParser.ParsingError:
print "Cannot parse configuration file!"

This is just a hack I came up with to load the configuration file and
try to test for serious problems with it. Trouble is, it doesn't really
do that, and furthermore, if there are small problems with the file
(such as a NoSectionError) the whole program bombs. Instead, I would
like to test for the relevant Errors and Exceptions, and have the
program deal with them gracefully.

Would one of you gurus be so kind as to point me in the right direction
here? I know that there are many possibilities, but what would be a
sane and reasonable set of exceptions to throw?

Meanwhile, I will be reading pages 337-339 in my copy of Python in a
Nutshell to try to get clearer about exceptions and how to use them.

Thanks.
mwt

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


Re: Please, I Have A Question before I get started

2006-03-14 Thread paron
Well, Nicholas Chase just posted an OpenLaszlo tutorial/app that shows
how OpenLaszlo handles sounds. Try
http://www-128.ibm.com/developerworks/edu/os-dw-os-php-openlaszlo1-i.html
You have to register, but it's free, and they don't bug you. It's PHP
driven, but that part's easily ported to Python.

Anyway, there's the basis of an all open-source or freeware application
that animates with sounds.

Ron

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


Re: Tried Ruby (or, "what Python *really* needs" or "perldoc!")

2006-03-14 Thread aaronwmail-usenet
I agree that more progress is needed on the Python documentation
front.  For example if you look at the "codecs" module documentation
there is no hint of what a codec is anywhere that I can see. Also
the distinction between an "encoder" and a "decoder" is not explained.
Even though I've used it many times and understand it, I still find
myself using the interactive interpreter to make sure I'm sending the
bytes in the right direction...

Perhaps some faqwiz/wiki-like tool to allow the broader community to
propose documentation enhancements would be useful?

  -- Aaron Watters

===

"I know what it's like to put food on my family."  G.W.Bush

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


Re: calling another python file within python

2006-03-14 Thread Ben C
On 2006-03-14, Kevin <[EMAIL PROTECTED]> wrote:
> i have a python file called pyq which outputs stock quotes, currently i 
> also have a html file that takes stock ticker inputs, i would like to 
> bridge the two by building another program that takes the html inputs 
> and uses them to call the pyq stock ticker program and then output them 
> into a text file...
>
> any idea how to do this? my tentative code is:
>
>
>
> #!/usr/bin/python
>
> import os
> import urllib
> os.system("python pyq.py ibm > text1.txt")

Rather than invoke the shell (which is what system does), you can just
do it all from Python. Something like:

import pyq
pyq.run("ibm")

Then in pyq.py, you could have something like this:

def run(filename):
# do whatever...

def main():
# check args etc..
run(sys.argv[1])

if __name__ == "__main__":
main()

This way pyq would work from the shell if you wanted to run it that way,
and also as a module.

Not quite sure of the details of the input. If the other program is
creating this file ibm which you're immediately reading as soon as it
appears you'd probably be better off with a pipe.

See Python docs for the "socket" module. Or less portably and if you're
on a UNIX system you could use a named pipe (created with mkfifo).

> note: currently the text1.txt outputted is just blank, however if i
> run the command normally as 'python pyq.py ibm' in the command line,
> it works correctly and gives me the price of ibm.

If you launch pyq.py like this it has to be in the current working
directory of the other program. If you just go os.system("pyq.py ibm")
and pyq.py has the #! business at the start of it, then pyq.py has to be
in your PATH. Otherwise it should work. So long as you're sure the file
ibm has been created by this point.

One of the benefits of doing it with import instead (the thing I
described above) is you don't have to worry about the shell and its
environment, or what PATH is, but only the Python environment
(PYTHONPATH, sys.path, that kind of thing). It's more portable.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: andmap and ormap

2006-03-14 Thread Terry Reedy

"Joel Hedlund" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>> footnote: if you have a recent Python 2.5 build,
>
> Who would have that? Is it a good idea to use a pre-alpha python version?

The pre-public release version compiles as 'alpha0'.  I have the impression 
the current alpha0 is being kept closer to releaseable more of the time 
than used to be the case.  For instance, the developers recently set up a 
buildbot system to compile and run all unit tests on several systems with a 
variety of hardware and OSes up to several times a day.  The results are 
available at
http://www.python.org/dev/buildbot/

At of minutes ago, 5 systems are green (ok), 1 orange (warn) , and 1 red 
(fail).

> ... Or should I start grabbing the Subversion trunk on a nightly basis?

'Should' if you want to experiment with new features or test existing code 
now rather than later.  I would only grab it when the tests pass on the 
system closest to yours, and only repeat when there is a reason to.

Terry Jan Reedy



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


Re: Tried Ruby (or, "what Python *really* needs" or "perldoc!")

2006-03-14 Thread john_sips_tea
Well, we've already got a wiki, of course: http://wiki.python.org/moin/

Regarding the docs for the module you're asking about, the way it's
supposed to work is (I think), you're supposed to checkout the Python
source, add your docs to the docstrings of that module, then either
commit your changes back in (if you have access privileges) or else
send a patch to the right list (python-dev?) so your patch can be
integrated.

It seems to me that it's best to write your docstring as epytext. That
way, for now, it just looks like regular plain text (though neatly
formatted) when viewed with the pydoc tool...

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


Re: Python Debugger / IDE ??

2006-03-14 Thread bruno at modulix
[EMAIL PROTECTED] wrote:
> Is there any editor or IDE in Python (either Windows or Linux) which
> has very good debugging facilites like MS VisualStudio has or something
> like that.
> 
> I like SPE but couldn't easily use winPDP. I need tips to debug my code
> easily.

pythonic "debugging" in three steps:

1/ unit tests
2/ a bunch of print statements
3/ the interactive python shell

All this relying on well-decoupled, modular code.

FWIW, I've almost never used a debugger with Python.

HTH
-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Debugger / IDE ??

2006-03-14 Thread krypto . wizard
My code has got big and it is an iterative program. I use print
statements but I thought I could get something handy it would be useful
to me.

thanks

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


Re: Cheese Shop: some history for the new-comers

2006-03-14 Thread Steven Bethard
A.M. Kuchling wrote:
> On Sun, 12 Mar 2006 10:25:19 +0100, 
>   Fredrik Lundh <[EMAIL PROTECTED]> wrote:
>> and while you're at it, change "python-dev" to "developers" and
>> "psf" to "foundation" (or use a title on that link).
> 
> I've changed the PSF link, but am not sure what to do about the
> python-dev link.  As others have noted, "Developers" is ambiguous
> about whether it's for people who develop in Python or who develop
> Python itself."Core Development"?  (Used on both perl.org and tcl.tk, so
> maybe this is the best option.) "Development Team"?  

+1 on Core Development.  It's still ambiguous, but less so.  And I can't 
think of anything better. ;)

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


  1   2   >