Re: Parsing numeric ranges

2011-02-25 Thread Simon Brunning
On 25 February 2011 09:27, Seldon  wrote:
> Hi all,
> I have to convert integer ranges expressed in a popular "compact" notation
> (e.g. 2, 5-7, 20-22, 41) to a the actual set of numbers (i.e.
> 2,5,7,20,21,22,41).
>
> Is there any library for doing such kind of things or I have to write it
> from scratch ?

I dredged this out:



def _revision_list_with_ranges_to_list_without_ranges(revision_list):
'''Convert a revision list with ranges (e.g. '1,3,5-7') to a
simple list without ranges (1,3,5,6,7)'''
for revision in revision_list:
if '-' in revision:
from_revision, _, to_revision = revision.partition('-')
for revision_in_range in range(int(from_revision),
int(to_revision)+1):
yield revision_in_range
else:
yield int(revision)

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


Re: Will python never intend to support private, protected and public?

2005-09-28 Thread Simon Brunning
On 9/28/05, could ildg <[EMAIL PROTECTED]> wrote:
> Python is wonderful except that it has no real private and protected
> properties and methods.
> Every py object has dict so that you can easily find what fields and methods
> an obj has,
> this is very convenient, but because of this, py is very hard to support
> real private and
> protected?

My convention, attributes with names prefixed with a single underscore
are private. There's nothing to stop anyone using these, but, well, if
you take the back off the radio, the warranty is void.

> If private and protected is supported, python will be perfect.

If *real* private and protected are *enforced*, Python will be the
poorer for it. See
.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-28 Thread Simon Brunning
On 9/28/05, Simon Brunning <[EMAIL PROTECTED]> wrote:
> My convention, attributes with names prefixed with a single underscore
> are private. There's nothing to stop anyone using these, but, well, if
> you take the back off the radio, the warranty is void.

*By* convention, not *my* convention!

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-28 Thread Simon Brunning
On 9/28/05, Tony Meyer <[EMAIL PROTECTED]> wrote:
> I'm not sure why I haven't seen this mentioned yet, but a leading
> double-underscore does really make a member private:

I thought about it, but I didn't mention it in the end because this
feature ("name mangling") isn't intended as a mechanism for making
things private - it's intended to prevent namespace clashes when doing
multiple inheritance. It can be used to make things private, true, but
that's abusing the feature, just as using __slots__ as a way of
"declaring variables" is an abuse - (__slots__ is a memory
optimisation feature).

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-28 Thread Simon Brunning
On 28 Sep 2005 05:06:50 -0700, Paul Rubin
<"http://phr.cx"@nospam.invalid> wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> writes:
> > Do you know any language that has real private and protected attributes?
>
> Java?

Oh, there are ways around private and protected, even in Java. CGLIB
spings to mind. But you'd be wise to follow the rules, especially if
you work in a team.

When writing Java, I write Java. When writing Python, I write Python.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-28 Thread Simon Brunning
On 9/28/05, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> > If *real* private and protected are *enforced*, Python will be the
> > poorer for it. See
> > .
>
> That's a wonderful, if long, essay.

That's the Martellibot for you. Never use a word where a paragraph
with explanatory footnotes will do.

Sigh. I miss him on c.l.py.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-28 Thread Simon Brunning
On 28 Sep 2005 05:35:25 -0700, Paul Rubin
<"http://phr.cx"@nospam.invalid> wrote:
> I don't see anything on the CGLIB web page (in about 1 minute of
> looking) that says it can get around private and protected.  It looks
> like something that disassembles class files and reassembles them into
> new classes from them with additional interfaces.  That's a lot
> different than being able to reach into an already-existing class
> instance and get at its private variables.

I've never directly used CGLIB myself, but I do use JMock and
Hibernate, and AFAIK both use CGLIB to modify private and protected
members. I could certainly be wrong, though. Anyway, this is getting a
bit OT...

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-28 Thread Simon Brunning
On 9/28/05, Tony Meyer <[EMAIL PROTECTED]> wrote:
> That's not what the documentation says:

So, either the docs are wrong, or I am. You be the judge. 

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-29 Thread Simon Brunning
On 9/29/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> What if the access to that variable was forbidden for reasons you never
> foresaw? What if the class author decide to remove the variable in the next
> version of the class, because it's not an interface, but only a part of the
> class implementation?

Then your code breaks. You can't say you weren't warned.

But if too much is made private, chances are you could never get your
code working in the first place. This has happened to me several times
when using 3rd party Java components. Serves us right for using closed
source libraries, I suppose, but that wasn't my decision.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A rather unpythonic way of doing things

2005-09-29 Thread Simon Brunning
On 9/29/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> "fraca7" wrote:
>
> > print ''.join(map(lambda x: chrord(x) - ord('a')) + 13) % 26) + 
> > ord('a')), 'yvfc'))
>
> that's spelled
>
> print "yvfc".decode("rot-13")
>
> or, if you prefer,
>
> print "yvfc".encode("rot-13")
>
> , in contemporary python.

I'm not sure that being more comprehensible is considered a virtue in
this thread, /F. ;-)

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-29 Thread Simon Brunning
On 9/29/05, could ildg <[EMAIL PROTECTED]> wrote:
> **Encapsulation** is one of the 3 basic characteristics of OOP.

Pyhton has encapsulation. On objetcts members are encapsulated in a
namespace all of its own. You can't change these by accident.

> Every programmer is  just a human being, but not God. Our life is limited,
> our time is limited, so we need to use convenient tools to save time.
> Private variables guarantee that we will never make stupid mistakes

Private variables prevent the developer of the *client* of a class
from making a small subset of all possible stupid mistakes. But if the
developer of the classitself is mistaken in marking a variable as
private, and if the language enforces this, then there is nothing at
all that the client can do to fix it. Why should the developer of the
class be more likely to be god-like than the user of the class? This
has happened to me more than once.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python <=> Excel question

2005-09-30 Thread Simon Brunning
On 9/30/05, Gerry Blais <[EMAIL PROTECTED]> wrote:
> Finally, how can I, in Python, make a .txt version of a Word document?

http://www.brunningonline.net/simon/blog/archives/001299.html

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: updating local()

2005-10-06 Thread Simon Brunning
On 6 Oct 2005 05:55:14 -0700, Flavio <[EMAIL PROTECTED]> wrote:
> Now what would you do if you wanted to pass a lot of variables (like a
> thousand) to a function and did not wanted the declare them in the
> function header?

I'd think twice. If on reflection I decided I really wanted to do it,
I'd pass them all in a dictionary.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: updating local()

2005-10-06 Thread Simon Brunning
On 6 Oct 2005 07:04:08 -0700, Flavio <[EMAIL PROTECTED]> wrote:
> I know I could pass these variables around as:
>
> def some_function(**variables):
> ...
>
> some_function(**variables)
>
> but its a pain in the neck to have to refer to them as
> variables['whatever']...
>
> dont you think?

Err, no, not really. ;-)

If you'd prfefer to access them like this:

variables.whatever

Check out the Bunch class here -
.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Info] PEP 308 accepted - new conditional expressions

2005-10-07 Thread Simon Brunning
On 07/10/05, Eric Nieuwland <[EMAIL PROTECTED]> wrote:
> Ever cared to check what committees can do to a language ;-)

+1 QOTW.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to(can we ?) pass argument to .py script ?

2005-10-11 Thread Simon Brunning
On 11 Oct 2005 07:07:44 -0700, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> i wrote a .py file and it works fine, my goal is to pass argument to
> that py file when it get executed, and accept that argument within py
> file, eg. i prefer a command like below:
>
> python test.py -t
>
> and then, i may get "-t" within test.py for later use.
>
> i have no ideas how to do and i'm really stuck, can anyone help ?

Short answer:

import sys
print sys.argv

You might also want to take to butchers at the optparse module.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: slots? SLOTS?

2005-10-12 Thread Simon Brunning
On 12/10/05, tin gherdanarra <[EMAIL PROTECTED]> wrote:
> what is a "slot" in python?



--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Yes, this is a python question, and a serious one at that (moving to Win XP)

2005-10-19 Thread Simon Brunning
On 19/10/05, James Stroud <[EMAIL PROTECTED]> wrote:
> The OP is obviously a troll.

Hey - let's not throw the T word around quite so freely. The OP did
say that he was switching to Windows "for unfortunate reasons", and
that OSX was "not as bad" as Windows.

Besides, it is possible to prefer Windows. Odd, but possible. Having
moved from Windows to Mac recently myself, I know *I* won't be
switching back, but reasonable men can differ.

--
Though-clearly-not-differ-with-me-ly y'rs,
Simon B.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python variables are bound to types when used?

2005-10-19 Thread Simon Brunning
On 19 Oct 2005 12:51:02 -0700, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> So I want to define a method that takes a "boolean" in a module, eg.
>
> def getDBName(l2):
> ...
>
> Now, in Python variables are bound to types when used, right?

Python doesn't really have variables as such. It has objects, which
are typed, and names, which are not.

> Eg.
> x = 10 # makes it an INT

The name 'x' is now bound to an int.

> whereas
> x = "hello" # makes it a string

Now it's bound to a string.

> I take it, the parameters to a function (in the above example "l2") are
> bound in the definition, rather than as invoked.
>
> So, if I use "l2" thus:
>
> if (l2): # only then does it make it a boolean?
>
> and if I did,
>
> if (l2 = "hello"): # would it become string?
>
> and what if I never used it in the definition body?

Now you've lost me. Probably my problem - serves me right for posting
from the pub.

> Elucidate please.

I'll allow a true Python Zen master to do that -
.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Accessing a dll from Python

2005-10-21 Thread Simon Brunning
On 21/10/05, Grant Edwards <[EMAIL PROTECTED]> wrote:
> Sorry, I've no clue about anything VB-related unless it's
> Victoria Bitter.

+1 QOTW.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-27 Thread Simon Brunning
On 27/10/05, Gregory Piñero <[EMAIL PROTECTED]> wrote:
> So much for writing my whole program on one line :-(

http://www.unixuser.org/~euske/pyone/

But you didn't hear it from me, OK? ;-)

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python and DevTrack?

2005-11-02 Thread Simon Brunning
On 1 Nov 2005 10:57:29 -0800, warpcat <[EMAIL PROTECTED]> wrote:
> I'm a python nubie, so be gental.  I've been setting up functionality
> by managing my Perforce clientspec with python (since it seems all of
> P4's commands are avaliable at the prompt), and I'd love to get access
> to DevTrack in the same way, but it's looking like it's off limits, UI
> only.  Does anyone have any experience with this?  Much appreciated.  I
> have searched the posts, came up with nothing.

For driving Windows GUIs, check out WATSUP. But be warned, it's a
non-trivial exercise.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's website does a great disservice to the language

2005-11-02 Thread Simon Brunning
On 02/11/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> a version of Paint that works on a Mac, an obstreperous mentality,
> and a sense of humour.  what else do you need?

Biscuits. You need biscuits.

Treating-this-thread-as-seriously-as-it-deserves-ly y'rs,
Simon B.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonwin - Word automation - Removing watermark not working

2005-11-05 Thread Simon Brunning
On 04/11/05, Gregory Piñero <[EMAIL PROTECTED]> wrote:
> Is there a different group/mailing list I should try?  Does anyone know if
> there is a pythonwin group/list for example?

There is: .

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Addressing the last element of a list

2005-11-08 Thread Simon Brunning
On 8 Nov 2005 01:43:43 -0800, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> But if lst[42]["pos"] happens to hold an integer value, then
>
> a = lst[42]["pos"]
>
> will _copy_ that integer value into 'a', right?

Nope. It will bind the name 'a' to the integer object.

> Changing 'a' will not
> change the value at lst[42]["pos"]

Integers are immutable - they can't be modified. So, "Changing 'a'"
means binding the name 'a' to a different object. This will have no
effect on other references to the original object.

Reset your brain - .

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: what the %?....

2005-11-08 Thread Simon Brunning
On 07/11/05, john boy <[EMAIL PROTECTED]> wrote:
> Hey can somebody tell me what the "%" function does...I am not math
> illiterate...its just a new symbol for meis it a divisor? remainder
> something another??

For numeric values, it's the modulo operator - see
 and
.

Over strings, '%' performs string formatting. See
.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pywin32: How to import data into Excel?

2005-11-08 Thread Simon Brunning
On 08/11/05, Dmytro Lesnyak <[EMAIL PROTECTED]> wrote:
> I need to import some big data into Excel from my Python script. I have TXT
> file (~7,5 Mb).

Have you considered converting your text data to CSV format? Excel
opens CSV files happily enough, and you could always automate
save-as-workbook and any formatting you need afterwards.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: any python module to calculate sin, cos, arctan?

2005-11-08 Thread Simon Brunning
On 08/11/05, Shi Mu <[EMAIL PROTECTED]> wrote:
> any python module to calculate sin, cos, arctan?



I seem to be posting loads of links to the docs today...

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sorting Documentation

2005-11-08 Thread Simon Brunning
On 8 Nov 2005 02:27:29 -0800, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> I want to read a little bit about sorting in Python (sorted() and
> method sort()). But I can't seem to find anything in the documentation
> at the homepage?

Sorted() is documented here -
.

(All found from  here, BTW - .)

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sorting Documentation

2005-11-08 Thread Simon Brunning
On 8 Nov 2005 02:32:44 -0800, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> For example, where can I find the official documentation on the
> list.sort() method?



--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: output question 1

2005-11-10 Thread Simon Brunning
On 10/11/05, leewang kim <[EMAIL PROTECTED]> wrote:
> I wrote the following code and got the output:
> a 13 0
> None
> b 81 3

(snip)

> where are those 'none' from? and how can I remove them?
>
> class Point:
> def __init__(self,x,y,name):
> self.x = x
> self.y = y
> self.name = name
> def summary(self):
> print self.name,self.x,self.y

Here you print your self.name value etc.

> if __name__ == '__main__':
> from string import letters
> m = 13,81,8,9,1
> n = 0,3,2,2,1
> q=len(x)
> points = [ Point(m[i],n[i],letters[i]) for i in range(q) ]
>  i=0
> while i print points[i].summary()

Here you print whatever is returned from the summary() method. Since
that method doesn't return anything explicitly, None is returned by
default, and you are printing that.

> i=i+1

One simple fix - change the summary method to returnt the values
rather than print them - replace 'print' with 'return' in that method.
Another would be not to print the returned values - remove 'print'
from your while loop.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a built-in method for transforming (1, None, "Hello!") to 1, None, "Hello!"?

2005-11-11 Thread Simon Brunning
On 11 Nov 2005 07:21:46 -0800, Daniel Crespo <[EMAIL PROTECTED]> wrote:
> Is there a built-in method for transforming (1,None,"Hello!") to
> 1,None,"Hello!"?

There's no conversion to do:

>>> (1,None,"Hello!")
(1, None, 'Hello!')
>>> 1,None,"Hello!"
(1, None, 'Hello!')

They are both tuples contining identicle elements. What is it that you
want to do?

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Countdown

2005-11-11 Thread Simon Brunning
On 11/11/05, john boy <[EMAIL PROTECTED]> wrote:
> I am running the following program from the example in "how to think like a
> computer scientist"
>
> def countdown(n):
>   if n ==0:
>print "Blastoff!"
>   else:
>   print n
>   countdown (n-1)
>
> countdown (1000)
>
> When I set "n"= 1000 the program runs in interpreter and stops counting down
> at 14 instead of running all the way to "Blastoff".  If I set n = 985 it
> completes the program. If I set n=1200 it runs to 214 and stops.  Why is
> this program only counting to 986Anybody have an answer??
> I am using Python 2.4.2

Look at this:

import sys
sys.getrecursionlimit()

It's set to 1000 by default. (Are you using IDLE or something? That
would explain where your other 14 levels of stack went.) You can
change it if you want to:

sys.setrecursionlevel(2000)

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Countdown

2005-11-11 Thread Simon Brunning
On 11/11/05, john boy <[EMAIL PROTECTED]> wrote:
> I have adjusted the program to:
>
> import sys.
> sys. getrecursionlimit()
> sys.setrecursionlimit(2000)
> def countdown (n):
>if n ==0:
>print "blastoff"
>   else:
>   print n
>   countdown (n-1)
> countdown (1200)
>
> this acutally works now

Good!

> is there any way to permanently set the recursion
> level or do I have to type a setrecursionlimit everytime the program will
> likely exceed 1000

Well, you could always always set it in site.py, I suppose, but in
general, I prefer iteration over recursion in Python.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: string help

2005-11-15 Thread Simon Brunning
On 14/11/05, john boy <[EMAIL PROTECTED]> wrote:
> using the following program:
>
> prefixes = "JKLMNOPQ"
> suffix = "ack"
> for letter in prefixes:
> print letter + suffix
> if prefixes == "O" or "Q"

Here you need:

if prefixes == "O" or prefixes ==  "Q"

>print letter + "u" + suffix
>
> For this program I am trying to combine the individual letters with the
> suffix to form names...but for O and Q I need to add in a "u" so the
> spelling is correct...I am having a hard time pulling just the O and Q out
> of the list of letters for manipulation...instead it is adding "u" to all
> the letters when combining with the suffix...apparently its due the fact
> that O and Q are present in the entire "string"..anybody have some
> suggestions for this??...

It's not because "O and Q are present in the entire string" - it's
because your expression

prefixes == "O" or "Q"

evaluates as

(prefixes == "O") or ("Q")

Since a string containing a value always evaluates as true, your
expression was always true, too.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python worth it??

2005-11-15 Thread Simon Brunning
On 14/11/05, john boy <[EMAIL PROTECTED]> wrote:
> I have started out trying to learn Python for my first programming language.
>  I am starting off with the book "how to think like a computer scientist."
> I spend about 4-5 hrs a day trying to learn this stuff.  It is certainly no
> easy task.  I've been at it for about 1-2 weeks now and have a very
> elementary picture of how Python works.  I am teaching myself from home and
> only recieve help from this forum.  Can anybody give me a timeframe as to
> how long it usually takes to pick something like this up, so I can maybe
> figure out a way to pace myself?  I can dedicate a good amount of time to it
> everyday.  Any advice on what is the best way to learn Python?  I am a
> fairly educated individual with a natural sciences degree (forestry), so I
> also have a decent math background.  Are there any constraints
> mathematically or logic "wise" that would prevent me from building a firm
> grasp of this language?

Keep at it.

Everyone is different, so don't worry about how long it takes you vs.
how long others might take. If you have no programming background,
there's a lot to learn. Using Python is a good choice, I think, 'cos
it gets a lot of extranious crud that many other languages insist on
out of your way, but there's still a lot to learn.

The best way to learn? Go through the tutorials - but if you get an
idea for a mini-project of your own, don't be afraid to dive off and
give it a go. Try to solve you own problems for a while, 'cos that's a
valuable skill, but don't get to the point of frustration. Ask for
help here or on the tutor mailing list[1].

And have fun.

[1] http://mail.python.org/mailman/listinfo/tutor

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to think like a computer scientist

2005-11-15 Thread Simon Brunning
On 14/11/05, john boy <[EMAIL PROTECTED]> wrote:
> Does anyone know if there is an "answer key" to all of the exercises in "how
> to think like a computer scientist"sure would be a lot easier to refer
> to that instead of tying up this forum with questions about exercises I'm
> sure that have been asked before

Dunno. But I do know tou won't learn that much just looking at the
answers. You'll come on a lot faster by getting it wrong, working out
*why* you've got it wrong, and fixing it.

Don't worry about asking questions. That's what the list and
(especially) the tutor list are for.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: compare list

2005-11-15 Thread Simon Brunning
On 15/11/05, Shi Mu <[EMAIL PROTECTED]> wrote:
> it does not work.
> >>> len(set(lisA).intersection(set(lisB))) == 2
> Traceback (most recent call last):
>   File "", line 1, in ?
> NameError: name 'set' is not defined

'set' is introduced as a built-in at Python 2.4. If you have 2.3,
there's an analogous module.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: compare list

2005-11-15 Thread Simon Brunning
On 15/11/05, Shi Mu <[EMAIL PROTECTED]> wrote:
> Yes, i am using python 2.3,
> I have used from sets import *
> but still report the same error:
> > > Traceback (most recent call last):
> > >   File "", line 1, in ?
> > > NameError: name 'set' is not defined

I said analogous, not identical. try (untested):

from sets import Set as set

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: compare list

2005-11-15 Thread Simon Brunning
On 15/11/05, Ben Bush <[EMAIL PROTECTED]> wrote:
> an error reported:
> Traceback (most recent call last):
>   File
> "C:\Python23\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py",
> line 310, in RunScript
> exec codeObject in __main__.__dict__
>   File "C:\temp\try.py", line 8, in ?
> from sets import Set as set
> ImportError: cannot import name Set
> >>>

Works for me. You don't have a sets module of your own, do you? Try
this, and report back what you see:

import sets
print sets.__file__
print dir(sets)

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: compare list

2005-11-15 Thread Simon Brunning
On 15/11/05, Ben Bush <[EMAIL PROTECTED]> wrote:
> I found I named the following python file as sets.py, which brought the
> problem (is that right?). i changed it to other name and it works.
> But the logic output is wrong.
> from sets import Set as set
> lisA=[1,2,5,9]
> lisB=[9,5,0,2]
> lisC=[9,5,0,1]
> def two(sequence1, sequence2):
>set1, set2 = set(sequence1), set(sequence2)
>return len(set1.intersection(set2)) == 2
>  print two(lisA,lisB)
> False(should be true!)

It looks to me like A and B have three members in common - 2, 5 and 9.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can anyone tell me if pygame and Tkinter can work together?

2005-11-16 Thread Simon Brunning
On 16/11/05, Nathan Pinno <[EMAIL PROTECTED]> wrote:
> It worked, but unfornately I can't use this line as it brings up errors:
>
> from Tkinter (or pygame) import *
>
> Anyway around this little bug?

What's the error?

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Adding through recursion

2005-11-18 Thread Simon Brunning
On 18 Nov 2005 05:22:47 -0800, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> There is problaly a really simple answer to this, but why does this
> function print the correct result but return "None":
>
> def add(x, y):
> if x == 0:
> print y
> return y
> else:
> x -= 1
> y += 1
> add(x, y)
>
> print add(2, 4)
>
> result:
> 6
> None

Every function returns a value. If you don't use an explicit return
keyword, None is returned implicitly. You print the answer that you
are looking for from within your function, then print the return value
from that function, which, as I've explained, will be None.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Adding through recursion

2005-11-18 Thread Simon Brunning
On 18 Nov 2005 06:30:58 -0800, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> I still don't get it. I tried to test with x = 0 and found that to
> work. How come since the value of y is right and it is printed right it
> "turns into" None when returned by the return statement ?

There is no return statement in your else block. That's where the
Nones are coming from.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread Simon Brunning
On 18 Nov 2005 10:53:04 -0800, Daniel Crespo <[EMAIL PROTECTED]> wrote:
> I would like to know how can I do the PHP ternary operator/statement
> (... ? ... : ...) in Python...

Wait for Python 2.5 - .

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Controlling windows gui applications from python

2005-11-18 Thread Simon Brunning
On 18/11/05, tim <[EMAIL PROTECTED]> wrote:
> Hi all, I'm almost as new to this list as to python so I hope I don't
> get a "this has been answered a 100 times before" or anything...
>
> Currently I am using a program named 'Macro Scheduler' for automating
> programs that don't have a command line version.
> Its a simple scripting language that allows you to automate button
> clicks, mouse movement, starting programs, checking the state of a
> window, changing the focus, type text into an input field...etc.
> Is there a way to do these things from within Python?



--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python weak on the web side?

2005-11-20 Thread Simon Brunning
On 19/11/05, Michael Goettsche <[EMAIL PROTECTED]> wrote:
> On Sunday 20 November 2005 00:24, Tony wrote:
> > If I'd like to learn Python for web-development, what are the options
> > available?
>
> A nice framework is CherryPy: http://www.cherrypy.org
> or Turbogears, which is based on CherryPy: http://www.turbogears.org/

See also Django for CMS type sites.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Controlling windows gui applications from python

2005-11-22 Thread Simon Brunning
On 21/11/05, tim <[EMAIL PROTECTED]> wrote:
> Thanks for this tip, this looks like exactly what I need.
>
> Is there a more extended documentation for watsup somewhere ?

Err, not a lot, no.

> I didn't find info on:
> how to send keystrokes to a program.

You don't do that. WATSUP uses WinGuiAuto, which is a fairly thin
wrapper around the Win32 API. Oh, and it's rubbish.

Rather than sending keysrokes, you instead just set the controls' text
to whatever you want it to be.

> how to control ComboBox elements...

Should be a simple extension to what's already there.

> trying out the examples, here are some problems I am running into:
(snip)

I'm afraid I can't really help you here. I'm a Mac user these days!
You might have some luck with the WATSUP user mailing list -
.

Good luck!

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: user-defined operators: a very modest proposal

2005-11-23 Thread Simon Brunning
On 23/11/05, Joseph Garvin <[EMAIL PROTECTED]> wrote:
> What do you mean by unicode operators? Link?

http://fishbowl.pastiche.org/2003/03/19/jsr666_extended_operator_set

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Converting a flat list to a list of tuples

2005-11-23 Thread Simon Brunning
On 22/11/05, Bengt Richter <[EMAIL PROTECTED]> wrote:
> That would be a counter-intuitive thing to do. Most things go left->right
> in order as the default assumption.

+1

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SelfExtract with zipfile

2005-11-23 Thread Simon Brunning
On 23/11/05, Catalin Lungu <[EMAIL PROTECTED]> wrote:
> Hi,
> I need to compress files in self-extract archive. I use the zipfile module.
> Is there an option or parameter to do that?

No, AFAIK. If you have a command line tool, perhaps you could try driving that.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: user-defined operators: a very modest proposal

2005-11-23 Thread Simon Brunning
On 23/11/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> see also:
>
> http://www.brunningonline.net/simon/blog/archives/000666.html
> http://www.python.org/peps/pep-0666.html

PEP 666 should have been left open. There are a number of ideas that
come up here that should be added to it - and i'm sure there'll be
more.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python as Guido Intended

2005-11-24 Thread Simon Brunning
On 24 Nov 2005 10:21:51 GMT, Antoon Pardon <[EMAIL PROTECTED]> wrote:
> But only Guido, thinks like Guido and then even Guido may now think
> differently than he thought before. And what if Guido had a bad day
> when he came up with something, should we just adopt to what he
> had in mind without questioning them.

No one is suggesting that Guido is perfect. But he's consistently a
better judge of language design than I am, and in all likelihood
better than you, too. If you like Python, it's 'cos you like the
decisions he's made over many years.

Where my first impulse is to think that one of decisions is wrong,
nine times out of ten in time I'll come to find that I was wrong and
he was right.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python as Guido Intended

2005-11-24 Thread Simon Brunning
On 24 Nov 2005 11:30:04 GMT, Antoon Pardon <[EMAIL PROTECTED]> wrote:
> > But he's consistently a
> > better judge of language design than I am, and in all likelihood
> > better than you, too. If you like Python, it's 'cos you like the
> > decisions he's made over many years.
>
> So, that makes that about a lot of things we think alike. Remains
> the question about whose ideas are better about the things we
> disagree.

It might remain for *you* to see the answer to that question. I susp
ect that most of us have answered it to our own satisfaction long since.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Understanding Python Documentation

2005-11-24 Thread Simon Brunning
On 24/11/05, Josh Cronemeyer <[EMAIL PROTECTED]> wrote:
> I have very little experience programming in python but considerable
> experience with java.  One thing that is frustrating me is the differences in
> the documentation style.  Javadocs, at the top level are just a list of
> packages.  Drilling down on a package reveals a list of classes in that
> package, and drilling down on a class reveals a list of methods for that
> class.  Is there something similar for python?
>
> The closest thing I have found to this for python is
> http://www.python.org/doc/2.4.2/modindex.html  which really isn't the same
> thing at all.

I think it is, really. Thing is, Python's standard library is broader
and less nested in structure than Java's, so it stands to reason that
its documetation will be broader and less nested in structure too.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python as Guido Intended

2005-11-24 Thread Simon Brunning
On 24/11/05, Bengt Richter <[EMAIL PROTECTED]> wrote:
> >Where my first impulse is to think that one of decisions is wrong,
> >nine times out of ten in time I'll come to find that I was wrong and
> >he was right.
> >
> You have a reservation about that other 10% ? ;-)

The other 10%, I've just not worked it out yet.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Python book for a non-programmer

2005-11-25 Thread Simon Brunning
I have a non-programming friend who wants to learn Python. It's been
so long since I've been in her shoes that I don't feel qualified to
judge the books aimed at people in her situation. I know of two such
books:




Any recommendations, or otherwise?

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python book for a non-programmer

2005-11-25 Thread Simon Brunning
On 25 Nov 2005 03:23:33 -0800, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> http://www.python.org/doc/Intros.html
>
> and two great texts when she has covered the basics are:
>
> http://diveintopython.org/
>
> http://www.mindview.net/Books/TIPython

I wouldn't have thought either of those was suitable for a
non-programmer. Great for cross-trainers, yes, but neither is intended
as a programming tutorial.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to stop a linux process

2005-11-28 Thread Simon Brunning
On 11/28/05, Glen <[EMAIL PROTECTED]> wrote:
> When I used the following line to play a midi file in linux,
>
> return_value = os.system('timidity test.mid')
>
> I have encountered two problems.
> 1. The python script halts until timidity has finished.
> 2. If I had control of the script, I can't think how I would stop timidity.
>
> Any advice on the 'area' of python I should be looking at would be greatly
> appreciated.

The subprocess module might be worth a look.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-02 Thread Simon Brunning
On 12/2/05, Dave Hansen <[EMAIL PROTECTED]> wrote:
> FWIW, indentation scoping one one of the features that _attracted_ me
> to Python.

+1 QOTW

OK, it's a bit of a cliche. But it's a cliche because it's *true*.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bitching about the documentation...

2005-12-07 Thread Simon Brunning
On 12/7/05, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> But none of them are the cost of Python, which is free. It really isn't a
> scam, nobody is going to come knocking at your door with a surprise bill
> for using Python.

Well, there is the PSU's "Spanish Inquisition" division. Last week
they barged into my office, quite unexpectedly, armed with cushions
and
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: first post: new to pythong. some questions.

2005-12-08 Thread Simon Brunning
On 12/8/05, shawn a <[EMAIL PROTECTED]> wrote:
> Hello. Im brand new to this list and to python.  Ive recently started
> reading about it
>   and am now in the tinkering stage.

Welcome to Python!

>  I have a script im working on that i
> need some
>  asistance debugging. Its super small and should be a snap for you gurus =)
>
>  I have 2 files in a dir off my home dir:
>  mkoneurl.py
>  make_ou_class.py
>
>  --mkoneurl.py--
>  #! /usr/bin/env python
>
>  import make_ou_class
>
>  run = makeoneurl()

You need:

run = make_ou_class.makeoneurl()

See  for why.

(BTW, you would probably have got more of a response with a better
subject line.  is
worth a read.)

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: spacing of code in Google Groups

2005-01-06 Thread Simon Brunning
On Wed, 05 Jan 2005 22:57:33 GMT, JanC <[EMAIL PROTECTED]> wrote:
> Rectangular selection only works with the mouse in SciTE/Scintilla:
> alt-click-drag.

Nope - hold down alt-shift, and select with the cursor keys.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python reading/writing ms-project files?

2005-01-07 Thread Simon Brunning
On 6 Jan 2005 16:05:07 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> any existing or pointers on how to do this?

If you are running on Windows and have a copy of Project, then COM
automation is probably your best bet. See
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/279003 for a
very basic example of COM scripting.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: countint words from an input string

2005-01-07 Thread Simon Brunning
On Fri, 7 Jan 2005 15:58:06 +0100, Øystein Western <[EMAIL PROTECTED]> wrote:
> Try to write som code that will get an input string from the user. Futher
> more, I'd like to have the program to count all the word the user has
> written.
> 
> Startet out like this:
> 
> /-
> s = raw_input("Write a text line")
> print s.split()
> /
> 
> How can I count the words in the split function.

print 'You've entered', len(s.split()), 'words.'

BTW, though newbie questions are quite welcome here, you might find it
beneficial to run through the Python tutorial (at
http://docs.python.org/tut/tut.html and included in the standard
distribution), and to join the tutor mailing list (at
http://mail.python.org/mailman/listinfo/tutor/).

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Getting rid of "self."

2005-01-07 Thread Simon Brunning
On 7 Jan 2005 08:10:14 -0800, Luis M. Gonzalez <[EMAIL PROTECTED]> wrote:
> The word "self" is not mandatory. You can type anything you want
> instead of self, as long as you supply a keyword in its place (it can
> be "self", "s" or whatever you want).

You *can*, yes, but please don't, not if there's any chance that
anyone other than you are going to have to look at your code.
'self.whatever' is clearly an instance attribute. 's.whatever' isn't
clearly anything - the reader will have to go off and work out what
the 's' object is.

The self prefix is a perfectly good convention. Let's stick to it.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Installation

2005-01-12 Thread Simon Brunning
On Tue, 11 Jan 2005 21:00:40 +0100, Fredrik Lundh
<[EMAIL PROTECTED]> wrote:
> Steve Holden wrote:
> 
> > Hmm, effbot.org seems to be down just now. Sure it'll be back soon, though.
> 
> http://news.bbc.co.uk/2/hi/europe/4158809.stm

Good to see that it was effbot.org that was down, rather that the
effbot himself.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Excel module for Python

2005-01-12 Thread Simon Brunning
On Wed, 12 Jan 2005 15:18:09 +0800, sam <[EMAIL PROTECTED]> wrote:
> I m wondering which Excel module is good to be used by Python?

If you are on Windows, and you have Excel, then the Python for Windows
extensions[1] are all you need to drive Excel via COM. O'Reilly's
"Python Programming on Win32" covers COM scripting extensively - and
by good fortune, driving Excel is the example they use, and the COM
scripting chapter is on-line[2].

You'll also need to know the objects and methods that Excel exposes.
These are documented on Microsoft's web site[3], or in the Excel VBA
help, which is an optional part of they Office installation.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/

[1] http://starship.python.net/crew/mhammond/
[2] http://www.oreilly.com/catalog/pythonwin32/chapter/ch12.html
[3] 
http://msdn.microsoft.com/library/en-us/modcore/html/deovrWorkingWithMicrosoftExcelObjects.asp
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Excel module for Python

2005-01-12 Thread Simon Brunning
On Wed, 12 Jan 2005 23:19:44 +0800, sam <[EMAIL PROTECTED]> wrote:
>
> No, I don't use MS windows. I need to generate Excel file by printing
> data to it, just like Perl module Spreadsheet::WriteExcel.

If it's just data that needs to go into your spreadsheet, then I'd
just build a CSV file if I were you. Excel opens them perfectly
happily.

If you need to write out formulae, formratting, that kind of thing,
then I think you'll need to write a 'real' Excel file. I don't have a
clue how to do that - sorry.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unclear On Class Variables

2005-01-13 Thread Simon Brunning
On 13 Jan 2005 07:18:26 EST, Tim Daneliuk <[EMAIL PROTECTED]> wrote:
> I am a bit confused.  I was under the impression that:
> 
> class foo(object):
> x = 0
> y = 1
> 
> means that x and y are variables shared by all instances of a class.
> But when I run this against two instances of foo, and set the values
> of x and y, they are indeed unique to the *instance* rather than the
> class.

I can see why you might think that:

>>> class Spam(object):
... eggs = 4
... 
>>> spam = Spam()
>>> spam2 = Spam()
>>> spam.eggs
4
>>> spam2.eggs
4
>>> spam.eggs = 2
>>> spam.eggs
2
>>> spam2.eggs
4

But you are being mislead by the fact that integers are immutable.
'spam.eggs = 2' is *creating* an instance member - there wasn't one
before. Have a look at what happens with a mutable object:

>>> class Spam(object):
... eggs = [3]
... 
>>> spam = Spam()
>>> spam2 = Spam()
>>> spam.eggs
[3]
>>> spam2.eggs
[3]
>>> spam.eggs.append(5)
>>> spam.eggs
[3, 5]
>>> spam2.eggs
[3, 5]

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: module on files & directories

2005-01-13 Thread Simon Brunning
On Thu, 13 Jan 2005 04:51:22 -0800 (PST), Sara Fwd <[EMAIL PROTECTED]> wrote:
> Hi all
> 
> Can anybody help me find a module or a function that
> looks in a directory and defines whether the objects
> in there are files or directories?

See os.path.isfile() and os.path.isdir() -
.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unclear On Class Variables

2005-01-13 Thread Simon Brunning
On Thu, 13 Jan 2005 08:56:10 -0500, Peter Hansen <[EMAIL PROTECTED]> wrote:
> Simon, it's really not about mutability at all.  You've changed
> the example, 

Err, there *wasn't* an example, not really. The OP just mentioned
'setting the values' of instance members. That *can* mean name
binding, but (to my mind at least) it can also mean calling mutating
methods. I just wanted to show both.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Octal notation: severe deprecation

2005-01-14 Thread Simon Brunning
On Thu, 13 Jan 2005 16:50:56 -0500, Leif K-Brooks <[EMAIL PROTECTED]> wrote:
> Tim Roberts wrote:
> > Stephen Thorne <[EMAIL PROTECTED]> wrote:
> >
> >>I would actually like to see pychecker pick up conceptual errors like this:
> >>
> >>import datetime
> >>datetime.datetime(2005, 04,04)
> >
> >
> > Why is that a conceptual error?  Syntactically, this could be a valid call
> > to a function.  Even if you have parsed and executed datetime, so that you
> > know datetime.datetime is a class, it's quite possible that the creation
> > and destruction of an object might have useful side effects.
> 
> I'm guessing that Stephen is saying that PyChecker should have special
> knowledge of the datetime module and of the fact that dates are often
> specified with a leading zero, and therefor complain that they shouldn't
> be used that way in Python source code.

It would be useful if PyChecker warned you when you specify an octal
literal and where the value would differ from what you might expect if
you didn't realise that you were specifying an octal literal.

x = 04 # This doesn't need a warning: 04 == 4
#x = 09 # This doesn't need a warning: it will fail to compile
x= 012 # This *does* need a warning: 012 == 10

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fuzzy matching of postal addresses

2005-01-18 Thread Simon Brunning
You might find these at least periperally useful:



They refer to address formatting rather than de-duping - but
normalising soulds like a useful first step to me.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: lambda

2005-01-18 Thread Simon Brunning
On 18 Jan 2005 07:51:00 GMT, Antoon Pardon <[EMAIL PROTECTED]> wrote:
> 3 mutating an item in a sorted list *does* *always* cause problems

No, it doesn't. It might cause the list no longer to be sorted, but
that might or might no be a problem.

> More specific the Decimal class is mutable and usable as dict key.

Decimal objects are immutable, so far as I know.

>>> from decimal import Decimal
>>> spam = Decimal('1.2')
>>> eggs = spam
>>> eggs is spam
True
>>> eggs += 1
>>> eggs is spam
False

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: map in Python

2005-01-21 Thread Simon Brunning
On 21 Jan 2005 04:25:27 -0800, Stu <[EMAIL PROTECTED]> wrote:
> I have recently switched over to Python from Perl. I want to do
> something like this in Python:
> 
> @test = ("a1", "a2", "a3");
> map {s/[a-z]//g} @test;
> print @test;
> 
> However, I take it there is no equivalent to $_ in Python. But in that
> case how does map pass the elements of a sequence to a function? I
> tried the following, but it doesn't work because the interpreter
> complains about a missing third argument to re.sub.
> 
> import re
> test = ["a1", "a2", "a3"]
> map(re.sub("[a-z]", ""), test)
> print test

This what you want?

>>> import re
>>> test = ["a1", "a2", "a3"]
>>> test = [re.sub("[a-z]", "", item) for item in test]
>>> test
['1', '2', '3']

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: map in Python

2005-01-21 Thread Simon Brunning
On Fri, 21 Jan 2005 12:37:46 +, Simon Brunning
<[EMAIL PROTECTED]> wrote:
> This what you want?
> 
> >>> import re
> >>> test = ["a1", "a2", "a3"]
> >>> test = [re.sub("[a-z]", "", item) for item in test]
> >>> test
> ['1', '2', '3']

Or, if you *must* use map, you can do:

>>> test = map(lambda item: re.sub("[a-z]", "", item), test)
>>> test
['1', '2', '3']

I much prefer the first list comprehension form myself, but reasonable
men can differ...

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: circular iteration

2005-01-21 Thread Simon Brunning
On 21 Jan 2005 08:31:02 -0800, Flavio codeco coelho <[EMAIL PROTECTED]> wrote:
> hi,
> 
> is there a faster way to build a circular iterator in python that by doing 
> this:
> 
> c=['r','g','b','c','m','y','k']
> 
> for i in range(30):
> print c[i%len(c)]

I don''t know if it's faster, but:

>>> import itertools
>>> c=['r','g','b','c','m','y','k']
>>> for i in itertools.islice(itertools.cycle(c), 30):
... print i

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.1 - 2.4 differences

2005-01-24 Thread Simon Brunning
On Mon, 24 Jan 2005 17:13:44 +0100, BOOGIEMAN <[EMAIL PROTECTED]> wrote:
> I found some e-book about Python 2.1, I want to print it but just to check
> first if sintax of Python 2.1 is same as 2.4 ?

Pretty musch the same, but naturally, some things have changed. See
these documents for the major changes, by release:
 * http://www.python.org/doc/2.2.3/whatsnew/
 * http://www.python.org/doc/2.3/whatsnew/
 * http://www.python.org/doc/2.4/whatsnew/

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "private" variables a.k.a. name mangling (WAS: What is print? A function?)

2005-01-25 Thread Simon Brunning
On Mon, 24 Jan 2005 12:17:13 -0600, Philippe C. Martin
<[EMAIL PROTECTED]> wrote:
> 
> I use "__"for private variables because I must have read on net it was
> the way to do so - yet this seems to have changed - thanks:
> 
> http://www.network-theory.co.uk/docs/pytut/tut_77.html

Nope, that's still the right way to make a member 'really' private.
Stephen was pointing out a very common Python idiom - "private by
convention", and suggesting that using it would be more appropriate.

A member with a single preceding underscore is private by convention.
That is to say, there is no mechanism in place to prevent clients of
the class accessing these members, but they should consider themselves
to have been warned that they do so at their own risk.

If you take the back off the radio, the warranty is void. ;-)

I (and by inference Stephen) feel that this is a more "Pythonic"
approach. Give the programmer the information that they need, but
don't try to stop them from doing what they need to do.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question: "load"ing a shared object in python

2005-01-26 Thread Simon Brunning
On Tue, 25 Jan 2005 23:19:01 +0200, Pro Grammer <[EMAIL PROTECTED]> wrote:
> Hello, all,
> I am not sure if this is the right place to ask, but could you kindly
> tell me how to "load" a shared object (like libx.so) into python, so
> that the methods in the .so can be used? That too, given that the shared
> object was written in c++, compiled with g++ ?

Will ctypes do the trick?

http://starship.python.net/crew/theller/ctypes/

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: fast list lookup

2005-01-26 Thread Simon Brunning
On Wed, 26 Jan 2005 06:45:29 -0800 (PST), Klaus Neuner
<[EMAIL PROTECTED]> wrote:
> what is the fastest way to determine whether list l (with
> len(l)>3) contains a certain element?

If the list isn't sorted, I doubt you'll do better than

if an_element in my_list:
# do whatever

If the list is sorted, have a look at the bisect module.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help With Python

2005-01-26 Thread Simon Brunning
On Wed, 26 Jan 2005 15:55:28 -, Judi Keplar
<[EMAIL PROTECTED]> wrote:
> I am currently taking a course to learn Python and was looking for
> some help.  I need to write a Python statement to print a comma-
> separated repetition of the word, "Spam", written 511 times ("Spam,
> Spam, â Spam").
> 
> Can anybody help me get started?  I am completely new to programming!

Well, I don't want to give it to you on a plate, since it's homework,
but you might find this page useful:
.

I'd also suggest that you have a run through the tutorial -
. It's time well spent! If you don't get
on with that, there's another couple of tutorials available aimed
directly at those new to programming -
 and
.

Lastly, although neophytes are more than welcome here, you might find
the tutor mailing list a good place to ask questions in the early days
of your Python experience. You'll find it here -
.

Good luck, and welcome to Python!

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to operate the excel by python?

2005-06-20 Thread Simon Brunning
On 6/17/05, Hughes, Chad O <[EMAIL PROTECTED]> wrote:
>  
> I have posed a more complete answer to your question, however, it is quite a
> large and It is awaiting approval.  For now, xlRight = -4152.  You can find
> this out by opening up Excel and typing the ALT-F11 combination.  From there
> use the ObjectBrowser.  For example if you type in the word "xlRight"  you
> will see that it is equal to -4152. 

I've had problems with these constants differing between versions
before, so I don't recommend hard coding them. (This was in Word
rather than Excel, AFAICR, but if Bill can do it to us once, he can do
it to us twice.) Luckily, you can use the constants by name:

PythonWin 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit
(Intel)] on win32.
Portions Copyright 1994-2004 Mark Hammond ([EMAIL PROTECTED])
- see 'Help/About PythonWin' for further copyright information.
>>> import win32com.client
>>> excel = win32com.client.gencache.EnsureDispatch("Excel.Application")
>>> win32com.client.constants.xlRight
-4152

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: py2exe problem

2005-06-21 Thread Simon Brunning
On 6/21/05, Austin <[EMAIL PROTECTED]> wrote:
> I use py2exe to build python program to "aa.exe".
> If this program has a bug, after closed this program, it will show
> "aa.exe.log" in this folder.
> Is there any ways to avoid this log file?

It's probably best just have a try/except at the very top level of
your app that logs the exception the way you want it logged. So, if
you currently have:

if __name__ == '__main__':
   main()

you should instead have:

if __name__ == '__main__':
   try:
   main()
   except exception:
   print >> mylog, exception # or whatever...

You are free to ignore the exception altogether if you want to, but I
promise you, you don't want to. ;-)

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get/set class attributes in Python

2005-06-21 Thread Simon Brunning
On 6/12/05, Steve Jorgensen <[EMAIL PROTECTED]> wrote:
> Oops - I thought I cancelled that post when I relized I was saying nothing,

Would that everyone cancelled their posts when they realised that they
weren't saying anything. ;-)

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: FAQ: __str__ vs __repr__

2005-06-21 Thread Simon Brunning
On 6/15/05, Peter Hansen <[EMAIL PROTECTED]> wrote:
> __repr__ shouldn't be anything, if you don't have an actual need for it.
>   Neither should __str__.

Oh, I don't know. __str__ is so frequently useful in debugging and
logging that I always try and do something useful with it.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: getting an object name

2005-06-22 Thread Simon Brunning
On 6/22/05, David Bear <[EMAIL PROTECTED]> wrote:
> Let's say I have a list called, alist. If I pass alist to a function,
> how can I get the name of it?

The effbot put it beautifully:

"The same way as you get the name of that cat you found on your porch:
the cat (object) itself cannot tell you its name, and it doesn't
really care -- so the only way to find out what it's called is to ask
all your neighbours (namespaces) if it's their cat (object) ... and
don't be surprised if you'll find that it's known by many names, or no
name at all!"

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Dr. Dobb's Python-URL! - weekly Python news and links (Jun 22)

2005-06-22 Thread Simon Brunning
QOTW: "Python is more concerned with making it easy to write good programs
than difficult to write bad ones." - Steve Holden

"Scientists build so that they can learn. Programmers and engineers learn
so that they can build." - Magnus Lycka

"It happens that old Java programmers make one module per class when they
start using Python. That's more or less equivalent of never using more
than 8.3 characters in filenames in modern operating systems, or to make
a detour on your way to work because there used to be a fence blocking the
shortest way a long time ago." - Magnus Lycka


Python doesn't currently have a case or switch statement. Case blocks
are easily simulated with if, elif, and else, but would Python's
readability benefit from having it built in?:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/29e45afc78adcd15

A Podcast worth listening to at last. Guido speaks on Python's history
and community:
http://www.itconversations.com/shows/detail545.html
http://www.itconversations.com/shows/detail559.html

If your class implements __eq__ but not __ne__, (a = b) does not imply
!(a != b). If this something that should be fixed, or just a "gotcha"?

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/f6e0986b2c0f01c0

John Machin instructively analyzes several of Excel's defects as a
data-management vehicle, obliquely highlighting Python's Zen.  Tim
Roberts follows up with a small but potentially crucial addendum
pertinent, among others, to those who deal with USA "zip codes":

http://groups-beta.google.com/group/comp.lang.python/index/browse_frm/thread/d14b13c8bc6e8515/

Recent (unreleased) work on distutils allows you to automatically
upload packages to PyPI:
http://www.amk.ca/diary/archives/003937.html

Text files and line endings; Python helps you out on Windows, which can
be a little confusing:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/2d3f61b949bca0e9

Kalle wants to protect his instance attributes. He's warned off the
idea, but at the same time, alex23 demonstrates an interesting way of
doing it using properties():

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/9f7c29fed95d7586

Creating a Python iterator by wrapping any callable:

http://bob.pythonmac.org/archives/2005/06/14/python-iterators-and-sentinel-values/

Richard Lewis wants resumable exceptions. Python doesn't have them,
but Peter Hansen shows him how to achieve what he wants, and Willem
shows us how resumable exceptions work in Lisp:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/e3dafce228dd4258

Jan Danielsson is confused about the difference between __str__ and
__repr__, and what they are both for:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/b37f1e3fae1154d6

The Kamaelia Framework; communicating with and linking Python generators:
http://www.bbc.co.uk/rd/pubs/whp/whp113.shtml

Ron Adams proposes an "also" block to be executed if a "for" loop's
"else" block isn't, and more controversially, that the "else" block's
meaning be switched:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/b15de260c5ca02e0

How you convince your marketing drones that switching from Python to
Java would be A Bad Thing?

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/5b6d1ff54640e9b1

Why should an ambitious 14-year-old look at Python? (And why source-code
hiding is a waste of time.)

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/107a4da1dd45b915



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

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

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily  
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html 
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

For far, FAR more Python reading than any one mind should
absorb, much of it quite interesting, several pages index
much of the universe of Pybloggers.
http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog
http://www.planetpy

Dr. Dobb's Python-URL! - weekly Python news and links (Jun 22)

2005-06-22 Thread Simon Brunning
QOTW: "Python is more concerned with making it easy to write good programs
than difficult to write bad ones." - Steve Holden

"Scientists build so that they can learn. Programmers and engineers learn
so that they can build." - Magnus Lycka

"It happens that old Java programmers make one module per class when they
start using Python. That's more or less equivalent of never using more
than 8.3 characters in filenames in modern operating systems, or to make
a detour on your way to work because there used to be a fence blocking the
shortest way a long time ago." - Magnus Lycka


Python doesn't currently have a case or switch statement. Case blocks
are easily simulated with if, elif, and else, but would Python's
readability benefit from having it built in?:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/29e45afc78adcd15

A Podcast worth listening to at last. Guido speaks on Python's history
and community:
http://www.itconversations.com/shows/detail545.html
http://www.itconversations.com/shows/detail559.html

If your class implements __eq__ but not __ne__, (a = b) does not imply
!(a != b). If this something that should be fixed, or just a "gotcha"?

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/f6e0986b2c0f01c0

John Machin instructively analyzes several of Excel's defects as a
data-management vehicle, obliquely highlighting Python's Zen.  Tim
Roberts follows up with a small but potentially crucial addendum
pertinent, among others, to those who deal with USA "zip codes":

http://groups-beta.google.com/group/comp.lang.python/index/browse_frm/thread/d14b13c8bc6e8515/

Recent (unreleased) work on distutils allows you to automatically
upload packages to PyPI:
http://www.amk.ca/diary/archives/003937.html

Text files and line endings; Python helps you out on Windows, which can
be a little confusing:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/2d3f61b949bca0e9

Kalle wants to protect his instance attributes. He's warned off the
idea, but at the same time, alex23 demonstrates an interesting way of
doing it using properties():

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/9f7c29fed95d7586

Creating a Python iterator by wrapping any callable:

http://bob.pythonmac.org/archives/2005/06/14/python-iterators-and-sentinel-values/

Richard Lewis wants resumable exceptions. Python doesn't have them,
but Peter Hansen shows him how to achieve what he wants, and Willem
shows us how resumable exceptions work in Lisp:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/e3dafce228dd4258

Jan Danielsson is confused about the difference between __str__ and
__repr__, and what they are both for:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/b37f1e3fae1154d6

The Kamaelia Framework; communicating with and linking Python generators:
http://www.bbc.co.uk/rd/pubs/whp/whp113.shtml

Ron Adams proposes an "also" block to be executed if a "for" loop's
"else" block isn't, and more controversially, that the "else" block's
meaning be switched:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/b15de260c5ca02e0

How you convince your marketing drones that switching from Python to
Java would be A Bad Thing?

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/5b6d1ff54640e9b1

Why should an ambitious 14-year-old look at Python? (And why source-code
hiding is a waste of time.)

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/107a4da1dd45b915



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

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

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily  
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html 
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

For far, FAR more Python reading than any one mind should
absorb, much of it quite interesting, several pages index
much of the universe of Pybloggers.
http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog
http://www.planetpy

Re: suggestions invited

2005-06-24 Thread Simon Brunning
On 23 Jun 2005 13:46:18 -0700, Peter Herndon <[EMAIL PROTECTED]> wrote:
> Reasonable enough.  As per Mike's suggestion below, building a few web
> pages to document the apps is a good start.  To expand on that idea,
> you could write daemons/cron jobs, perhaps in Python if Python runs on
> OS/400,

http://www.iseriespython.com/

> that monitor each app's status and log that information to the
> web server.

I'm ot sure how you'd define an 'application' on a '400. You just have
a bunch of progams in libraries. I'm not sure what the 'status' of an
application might meain, either, in general terms. This is really very
pooly specified.

> You could then write a web application that takes the
> monitoring data and formats it appropriately for human consumption.

Running a Python web application on a '400 would be a pretty daunting
task, if it's even possible.

> Perhaps an RSS or Atom feed for each application's status.
> 
> I don't know anything about OS/400, but if it has a tool similar to
> syslog, you could configure the application hosts to report their
> status to a remote syslogd, perhaps on your web server, and parse the
> log file for the status data.

QHST is similar to syslog - but what's an application host in 400 terms?

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thoughts on Guido's ITC audio interview

2005-06-28 Thread Simon Brunning
On 6/26/05, John Roth <[EMAIL PROTECTED]> wrote:
> What's being ignored is that type information is useful for other things
> than compile type checking. The major case in point is the way IDEs
> such as IntelliJ and Eclipse use type information to do refactoring, code
> completion and eventually numerous other things. A Java programmer
> using IntelliJ or Eclipse can eliminate the advantage that Python
> used to have, and possibly even pull ahead.

I'm a Java programmer as my day job, most of the time, and I use
Eclipse. I'm fairly proficient with it, but nevertheless I'm more
productive with Python and SciTE than I am with Java and Eclipse.
Eclipse helps a lot, true - I certainly wouldn't want to code Java
without it or something like it - but it's not enought to pull ahead
of Python's inherent superiority.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thoughts on Guido's ITC audio interview

2005-06-28 Thread Simon Brunning
On 6/27/05, Sakesun Roykiattisak <[EMAIL PROTECTED]> wrote:
> 1. Automatic refactoring never solve the readability issue.

Eclipse's refactorings are a great boon, I find. Refectoring is never
*fully* automatic, of course, but the ability to, for example, select
a chunk of code and have it extracted into a separate method with all
needed arguments and the return value worked out for you is very
helpful. All you have to do is give the new method a name. And this
sort of thing can certainly improve readability.

> 2. I've never been lucky enough to have enough resource for those IDE.

Eclipse is indeed a memory hog of the first order.

> 3. Python solve my problem.

Mine too - but I'm not free to choose.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Modules for inclusion in standard library?

2005-06-29 Thread Simon Brunning
On 6/28/05, John Roth <[EMAIL PROTECTED]> wrote:
> I'd definitely like to see ctypes. I can agree with the segfault
> issue, but I think that some design work would eliminate that.

I'm not sure that it would. Ctypes allows you, as one colleague
memorably put it, to "poke the operating system with a stick". You are
always going to be able to use ctypes to provoke spectacular crashes
of the kind that you can never get with 'ordinary' Python.

Having said that, I'd like to see ctypes in the standard library
anyway, with a suitably intimidating warning in the docs about the
trouble you can get yourself into with it.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Dr. Dobb's Python-URL! - weekly Python news and links (Jun 29)

2005-06-29 Thread Simon Brunning
QOTW: "And what defines a 'python activist' anyway?  Blowing up Perl
installations worldwide?" - Ivan Van Laningham

"Floating point is about nothing if not being usefully wrong." - Robert Kern


Sibylle Koczian needs to sort part of a list. His first attempt made
the natural mistake - sorting a *copy* of part of the list: 

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/9b7da3bed2719f18

Kevin Dangoor compares ZODB and pysqlite with SQLObject:
http://www.blueskyonmars.com/2005/06/18/zodb-vs-pysqlite-with-sqlobject/

Uwe Mayer needs a little convincing about "consenting adults" philosophy:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/d4d8738a6e8281ff

Zope 2.8.0 is released:
http://article.gmane.org/gmane.comp.web.zope.announce/987

Guido's ITC audio interview sparks off a discussion about the
advantages of static typing in terms of tool support:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/d5aee06316a0412b

Only c.l.py can go *this* far off topic without flames:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/1be27ccd50534e1b

Is there any good stuff left that Python should steal from other
languages?

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/d297170cfbf1bb34

Peter Gengtsson reminds himself and us how useful the \b regular
expression special element is: 
http://www.peterbe.com/plog/slash_b

Are there any 3rd party modules that you'd like to see included in
the standard library?

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/cd236084973530dc

Is Python a good language for teaching children to program?

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/68a3ac09b4937c88



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

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

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily  
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html 
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

For far, FAR more Python reading than any one mind should
absorb, much of it quite interesting, several pages index
much of the universe of Pybloggers.
http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog
http://www.planetpython.org/
http://mechanicalcat.net/pyblagg.html

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.

http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce

Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous
tradition early borne by Andrew Kuchling, Michael Hudson and Brett
Cannon of intelligently summarizing action on the python-dev mailing
list once every other week.
http://www.python.org/dev/summary/

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

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

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

The Python Business Forum "further[s] the interests of companies
that base their business on ... Python."
http://www.python-in-business.org

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

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

Kurt B. Kaiser publishes a weekly report on faults and patches.
http://www.google.com/groups?as_usubject=weekly%20python%20patch
   
Cetus collects Python hyperlinks.
http://www.cetus-links.org/oo_python.html

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

Re: When someone from Britain speaks, Americans hear a "British accent"...

2005-06-30 Thread Simon Brunning
On 29 Jun 2005 15:34:11 -0700, Luis M. Gonzalez <[EMAIL PROTECTED]> wrote:
> What's exactly the "cockney" accent?
> Is it related to some place or it's just a kind of slang?

A cockney is a *real* Londoner, that is, someone born within the City
of London, a.k.a The Square Mile. More specifically, it's someone born
"within the sound of Bow Bells" - i.e. close to St Mary le Bow, London
- . This is within the
theoretical sound of Bow Bells, you understand - there have been
frequent and lengthy periods during which Bow Bells have not been rung
at all. There are in fact no longer any hospitals with maternity units
within the sound of Bow Bells, so there will be vanishingly few
cockneys born in future.

Strangely enough, this makes *me* a cockney, though I've never lived
in the square mile, and my accent is pretty close to received. I do
*work* in the City, though!

The cockney accent used to be pretty distinct, but these days it's
pretty much merged into the "Estuary English" accent common throughout
the South East of England.

> I'm not sure, but I think that I read somewhere that it is common in
> some parts of London, and that it is a sign of a particular social
> class, more than a regionalism. Is that true?

Cockney was London's working class accent, pretty much, thought it was
frequently affected by members of the middle classes. Estuary English
has taken over its position as the working class accent these days,
but with a much wider regional distribution.

How off topic is this? Marvellous!

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Modules for inclusion in standard library?

2005-06-30 Thread Simon Brunning
On 6/29/05, Christopher Arndt <[EMAIL PROTECTED]> wrote:

(snip)

> Most of these are probably not elegible due to license issues but I'd
> love to see SQLite support added to Python-out-of-the-box.

Adding sqllite to the standard library has been discussed before:
http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/fd150297c201f814

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Modules for inclusion in standard library?

2005-06-30 Thread Simon Brunning
On 6/29/05, Thomas Heller <[EMAIL PROTECTED]> wrote:
> 
> To me, this sounds that *at least* a PEP would be needed to convince
> Guido.  Or, to record the reasoning why it cannot be included.

I have a feeling that Guido won't allow ctypes into the standard
library since it can crash Python. I don't know about you, but that's
I interpret this -
.

I am prepared to be wrong, though. Only Tim can channel Guido! 

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Dr. Dobb's Python-URL! - weekly Python news and links (Jun 29)

2005-06-30 Thread Simon Brunning
QOTW: "And what defines a 'python activist' anyway?  Blowing up Perl
installations worldwide?" - Ivan Van Laningham

"Floating point is about nothing if not being usefully wrong." - Robert Kern


Sibylle Koczian needs to sort part of a list. His first attempt made
the natural mistake - sorting a *copy* of part of the list: 

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/9b7da3bed2719f18

Kevin Dangoor compares ZODB and pysqlite with SQLObject:
http://www.blueskyonmars.com/2005/06/18/zodb-vs-pysqlite-with-sqlobject/

Uwe Mayer needs a little convincing about "consenting adults" philosophy:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/d4d8738a6e8281ff

Zope 2.8.0 is released:
http://article.gmane.org/gmane.comp.web.zope.announce/987

Guido's ITC audio interview sparks off a discussion about the
advantages of static typing in terms of tool support:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/d5aee06316a0412b

Only c.l.py can go *this* far off topic without flames:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/1be27ccd50534e1b

Is there any good stuff left that Python should steal from other
languages?

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/d297170cfbf1bb34

Peter Gengtsson reminds himself and us how useful the \b regular
expression special element is: 
http://www.peterbe.com/plog/slash_b

Are there any 3rd party modules that you'd like to see included in
the standard library?

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/cd236084973530dc

Is Python a good language for teaching children to program?

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/68a3ac09b4937c88



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

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

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily  
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html 
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

For far, FAR more Python reading than any one mind should
absorb, much of it quite interesting, several pages index
much of the universe of Pybloggers.
http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog
http://www.planetpython.org/
http://mechanicalcat.net/pyblagg.html

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.

http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce

Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous
tradition early borne by Andrew Kuchling, Michael Hudson and Brett
Cannon of intelligently summarizing action on the python-dev mailing
list once every other week.
http://www.python.org/dev/summary/

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

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

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

The Python Business Forum "further[s] the interests of companies
that base their business on ... Python."
http://www.python-in-business.org

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

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

Kurt B. Kaiser publishes a weekly report on faults and patches.
http://www.google.com/groups?as_usubject=weekly%20python%20patch
   
Cetus collects Python hyperlinks.
http://www.cetus-links.org/oo_python.html

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

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Jun 29)

2005-07-01 Thread Simon Brunning
On 7/1/05, Peter Maas <[EMAIL PROTECTED]> wrote:
> Simon Brunning schrieb:
> > Sibylle Koczian needs to sort part of a list. His first attempt made
> > the natural mistake - sorting a *copy* of part of the list:
> 
> I think it was _her_ first attempt.

Ooops! Sorry, Sibylle.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   6   >