Re: Zope 3

2006-04-25 Thread Derick van Niekerk
This looks more or less like what I am looking for to learn Zope3! As
is mentioned elsewhere in this thread Zope3 is *nothing* like Zope2 and
after starting to learn the one, I knew nothing about the other.
*Everything* is different - from the interface to the design
methodologies.

One thing Zope seems to keep pushing is extreme programming - until
recently, I thought it is a joke, like extreme ironing, but it seems
like a very popular style of programming. I am astounded by how much I
need to learn to call myself a programmer!

Anyway - If some of you can give me a little insight to what you use to
develop on the web using Python, I'd appreciate it. I've heard good
things about cherrypy, django, mod_python, zope, etc., etc. There is
just so little time - I'd gladly sacrifice a little power / flexibility
for an easier learning curve. This will be my first python web
project...

Thanks for the feedback - it helps a lot :)
Derick

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


Re: Introspection Class/Instance Name

2006-04-25 Thread Roland Heiber
*binarystar* wrote:
> Hello there,
> 
> what method would you use to return the name of the class and/or 
> instance introspectively eg.
> 
> class Bollocks:
> 
> def __init__( self ):
>
> print self.__method_that_returns_class_name__()
> print self.__method_that_returns_instance_name__()
> 
> 
> instance_of_bollocks= Bollocks()
> 
> # Which outputs
> 
> 'Bollocks'
> 'instance_of_bollocks'
> 
> 
> 
> I have been scouring the 2.4 docs ... I am sure it is frustratingly simple
> 
> thx in advance
> 
> **

Hi,

take a look at self.__class__.__name__ for the Class-name.

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


Re: how to browse using urllib2 and cookeilib the correct way

2006-04-25 Thread jnair
ok , got it . Thanks

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


Introspection Class/Instance Name

2006-04-25 Thread *binarystar*
Hello there,

what method would you use to return the name of the class and/or 
instance introspectively eg.

class Bollocks:

def __init__( self ):

print self.__method_that_returns_class_name__()
print self.__method_that_returns_instance_name__()


instance_of_bollocks= Bollocks()

# Which outputs

'Bollocks'
'instance_of_bollocks'



I have been scouring the 2.4 docs ... I am sure it is frustratingly simple

thx in advance

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


Re: how to browse using urllib2 and cookeilib the correct way

2006-04-25 Thread Edward Elliott
[EMAIL PROTECTED] wrote:
> can anybody explain, in the first case why i need to do two attempts.

I would guess it's because redhat requires your browser to submit a session
cookie with the login form.  In the urllib2 example, the first request you
make tries to submit login form data directly.  Since it's your first hit
on their site, you don't have a cookie yet.  People browsing interactively
would at least load the login page first before submitting it.

Your twill example takes care of this by requesting a page before trying to
login.

That would be my guess.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: search an entire website given the homepage URL

2006-04-25 Thread Fredrik Lundh
"Bell, Kevin" wrote:
> I would like some feedback about my actual intention though, which is to
> scrape local newspaper websites for the names of people that I work
> with.  Twice this month, colleagues have unknowingly been in the
> newspaper, and only became aware of it because someone stumbled across
> the line in the article.

http://www.google.com/alerts?hl=en
http://www.pubsub.com/
http://www.technorati.com/

(etc)





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


Re: search an entire website given the homepage URL

2006-04-25 Thread Fredrik Lundh
"Bell, Kevin" wrote:

> Well I certainly am learning a lot.  I never said I intended to download
> anyone's entire website, as was assumed, but it's been fun to see how
> folks feel about it anyway!

never?

"If I want to search through the entire python website give[n] the
homepage, how would I go about it?"

how do you plan "to search though the entire website" by "going through
all pages" to "parse out all the links and drill though them" without actually
downloading anything ?





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


Passing Exceptions Across Threads

2006-04-25 Thread Adam Mullins
Hello, I'm writing a physics simulator back-end with a built-in,
threaded server that for the moment is quite simple. I've faced a few
problems in writing this code, however, as it's the first time I've
played with threading. For the moment, everything works decently, but I
need (or rather, want) a method for passing caught exceptions in
sub-threads to the main thread to be raised there. Although this
solution isn't the only one, I feel it will be the most elegant (the
thread/class will be called inside the main module within a try/except
structure, which makes the program a bit more modular, in my opinion,
and cleaner).

Here is my code so far:
http://rafb.net/paste/results/UESOWB24.html

You can see near the top where I clumsily tried to a hack a function
into threading._MainThread, in the hopes that if it were called from a
sub-thread it would execute in the main thread. This is seemingly not
so.

Many thanks for any help.

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


Re: Xah's Edu Corner: Criticism vs Constructive Criticism

2006-04-25 Thread Roedy Green
On 25 Apr 2006 12:21:43 -0700, "Xah Lee" <[EMAIL PROTECTED]> wrote,
quoted or indirectly quoted someone who said :

>Criticism versus Constructive Criticism

I think you would do better to put this sort of thing on a website
rather than post it in a newsgroup.  It is too pretentious for a
newsgroup.  Newsgroups are about question and answer.
-- 
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MinGW and Python

2006-04-25 Thread Edward Elliott
Alex Martelli wrote:
> I believe the single figure is a useful summary.  Even the most
> sophisticated benchmarks are eventually boiled down to single figures,
> as in "so many SPECmarks" etc, because in everyday discourse a scalar is
> what you can reasonably discuss.  Sure, philosophically speaking it
> makes no sense to say that a compiler is better or worse than another at
> optimization, without adding a lawyer's brief worth of qualifications
 ^^
hey is that a shot at me? ;)

> each and every time.  In real life, it's a useful and practical
> temporary simplification, and engineers (as opposed to mathematicians
> and philosophers) have a bias towards practical usefulness.

I agree for benchmarks in general.  It's more this particular benchmark I
object to as not being representative.  It's like the difference between
SPECmark testing various CPU functions and Winstone measuring real-world
application performance.  If you're a CPU designer counting coup, SPECmark
matters.  For just about everyone else, Winstone tells you more.  And when
you're talking about small (less than an order of magnitude) differences in
SPECmark, platform/system/application issues becomes the dominant factor in
performance.  A CPU that's twice as fast won't help my i/o-bound server.

>From an engineering standpoint, the pybench number isn't that useful to me. 
It tells me little about the practical speed of my application on two
different python interpreters.  That's all I'm saying.  No need to sic the
philosophers on me (a fate I would not wish on my worst enemy). :)

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


how to browse using urllib2 and cookeilib the correct way

2006-04-25 Thread jnair
Hi ,

I am using python2.4 "urllib2" and "cookelib".
In line "5" below i provide my credentials to
login into a web site.During the first attempt i "fail",
judging from the output of line "6".
I try again and the second time i succeed,judging
from the output of line "8".

Now using the "twill" module (http://www.idyll.org/~t/www-tools/twill/)
it suceeds in the  first attempt(lines "10" to "19").

can anybody explain, in the first case why i need to do two attempts.

1) >>>import urllib2,urllib,cookielib
2) >>>cj = cookielib.CookieJar()
3) >>>opener = urllib2.build_opener( urllib2.HTTPCookieProcessor(cj))
4) >>>data = urllib.urlencode   ( { "username" : "user" ,
 "password" :"" } )
5) >>>fp = opener.open(
"https://rhn.redhat.com/rhn/LoginSubmit.do",data )
6) >>>fp.url

'https://rhn.redhat.com/rhn/ReLogin.do?url_bounce=/network/index.pxt'
7) >>>fp = opener.open(
"https://rhn.redhat.com/rhn/LoginSubmit.do",data )
8) >>>fp.url
   'https://rhn.redhat.com/network/index.pxt'

#twill module

10) >>>from twill.commands import *
11) >>>go("https://rhn.redhat.com";)
12) ==> at https://rhn.redhat.com
13) 'https://rhn.redhat.com'
14) >>>fv("2","username","user")
15) >>>fv("2","password","")
16) >>>submit()
17) Note: submit is using submit button: name="None", value=" Â  Sign
In  "
18) >>>url('https://rhn.redhat.com/network/index.pxt')
19) 'https://rhn.redhat.com/network/index.pxt'

Thanks
jn
jn

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


Re: MinGW and Python

2006-04-25 Thread Edward Elliott
Alex Martelli wrote:
> I assume you mean "compare pybench on Python 2.4.3 compiled under" etc.

Yep

> Unfortunately, I suspect the ex-officio gcc defenders will only react by
> finding yet another quibble (anything to avoid admitting that gcc may
> not be as good at optimizing as a _Microsoft_ product -- perish the
> thought!), therefore I'm disinclined to invest my scarce free time in
> that particular endeavour.

No problem.  I don't expect anyone to follow through, it was more a
suggestion to forestall rampant speculation. :)

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


how to save python interpreter's command history

2006-04-25 Thread Sakcee
this has been a problem for me for some time.

I want to save the interpretters command history to a file, there is a
history file in my user directory .pyhistory but it saves only like 500
or so

how can I make it save all the commands and not delete it,  any other
suggestions that people use is welcome


thanks

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


Re: OOP / language design question

2006-04-25 Thread Alex Martelli
Duncan Booth <[EMAIL PROTECTED]> wrote:
   ...
> Actually, this is quite an interesting example becaue it wouldn't work in
> C++: if you tried the same trick the call to dothis from the base 
> constructor (even assuming it is virtual) would actually call Base.dothis.

Yep.

> I think you have demonstrated that you can do some things in Python which
> you simply cannot do in static languages like C++: assigning to derived
> attributes before calling a base initialiser, and calling a virtual method
> from a base initialiser. I'm not arguing about that. What I don't have
> though is an example of code where doing this would actually be a good
> thing.

A recognized idiom/pattern in C++ or Java is known as "two-phase
construction" (yes, there's a two-phase destruction counterpart): have
minimal, near-empty constructors, then a separate virtual Init method
which does the actual construction work (often with a framework or at
least a factory to ensure that Init gets in fact called).

Each use case of this idiom/pattern relies on virtual methods (most
generally in a Template Method design pattern) at initialization.

E.g.: build a composite window by iteratively building subwindows
(including decorators) as enumerated by a virtual method.  Initialize a
database-connection object by delegating some parts (such as connection,
local or over the net, and authentication, etc etc) to virtual methods.
And so on, and so forth.


> What I think I'm trying to get at is that I believe that most situations
> where someone actually tries to do something in the base initialiser which
> requires calling a virtual method are probably also cases where the 
> initialiser is doing too much: i.e. separating the 
> construction/initialisation from actually doing something is usually a good
> idea.

But why should that be?  Template Method is perhaps the MOST generally
useful design pattern -- why would it be any less useful in
initialization than elsewhere?!


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


how to browse using urllib2 and cookeilib the correct way

2006-04-25 Thread jnair
Hi ,

I am using python2.4 "urllib2" and "cookelib".
In line "5" below i provide my credentials to
login into a web site.During the first attempt i "fail",
judging from the output of line "6".
I try again and the second time i succeed,judging
from the output of line "8".

Now using the "twill" module (http://www.idyll.org/~t/www-tools/twill/)
it suceeds in the  first attempt(lines "10" to "19").

can anybody explain, in the first case why i need to do two attempts.


1) >>>import urllib2,urllib,cookielib
2) >>>cj = cookielib.CookieJar()
3) >>>opener = urllib2.build_opener( urllib2.HTTPCookieProcessor(cj))
4) >>>data = urllib.urlencode( { "username" : "user" , "password" :
"" } )
5) >>>fp = opener.open(
"https://rhn.redhat.com/rhn/LoginSubmit.do",data )
6) >>>fp.url

'https://rhn.redhat.com/rhn/ReLogin.do?url_bounce=/network/index.pxt'
7) >>>fp = opener.open(
"https://rhn.redhat.com/rhn/LoginSubmit.do",data )
8) >>>fp.url
   'https://rhn.redhat.com/network/index.pxt'



#twill module

10) >>>from twill.commands import *
11) >>>go("https://rhn.redhat.com";)
12) ==> at https://rhn.redhat.com
13) 'https://rhn.redhat.com'
14) >>>fv("2","username","eipl")
15) >>>fv("2","password","ensim1234")
16) >>>submit()
17) Note: submit is using submit button: name="None", value=" Â  Sign
In  "
18) >>>url('https://rhn.redhat.com/network/index.pxt')
19) 'https://rhn.redhat.com/network/index.pxt'

Thanks 
Jitu

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


Re: MinGW and Python

2006-04-25 Thread Alex Martelli
Edward Elliott <[EMAIL PROTECTED]> wrote:

> Alex Martelli wrote:
> > At the same time, if the 14% slowdown is representative, then it's not
> > true that the compiler responsible for it "optimizes as well" as the
> > other; indeed, "does not optimize particularly well", under such a
> > hypothesis, would be far from a "beyond BS" assertion.
> 
> Maybe someone with access to Windows and some free time could compare
> pybench compiled under msvc and mingw.  The best way to test the compiler
> is to eliminate all other variables.

I assume you mean "compare pybench on Python 2.4.3 compiled under" etc.
Unfortunately, I suspect the ex-officio gcc defenders will only react by
finding yet another quibble (anything to avoid admitting that gcc may
not be as good at optimizing as a _Microsoft_ product -- perish the
thought!), therefore I'm disinclined to invest my scarce free time in
that particular endeavour.


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


Re: MinGW and Python

2006-04-25 Thread Alex Martelli
Edward Elliott <[EMAIL PROTECTED]> wrote:

> Alex Martelli wrote:
> > about MacOSX, which also uses gcc: 14% faster pybench using Python 2.4.3
> 
> this is the second time I've seen that 14% figure.  OOC, where does it come
> from?  the data sets you posted show an average 12.6% speedup.  14 is an
> odd way to round. :)

I believe 12.6% is the result if you pick the faster speed as a
denominator (and so it's the right figure for a _slowdown_,
hypothetically moving from fast to slow case), 14% if you pick the
slower speed as a denominator (i.e., for a _speedup_).

Of course if you work with times rather than speeds it's the other way
around.


> I don't think it's very useful to talk about average speedups from a
> benchmark of equally-weighted feature tests.  the data shows wildly varying
> differences in performance for each test.  a real-world application could
> be much slower or much faster on either platform depending on its feature
> mix.  not the type of thing that's amenable to expression as a single
> value.

I believe the single figure is a useful summary.  Even the most
sophisticated benchmarks are eventually boiled down to single figures,
as in "so many SPECmarks" etc, because in everyday discourse a scalar is
what you can reasonably discuss.  Sure, philosophically speaking it
makes no sense to say that a compiler is better or worse than another at
optimization, without adding a lawyer's brief worth of qualifications
each and every time.  In real life, it's a useful and practical
temporary simplification, and engineers (as opposed to mathematicians
and philosophers) have a bias towards practical usefulness.


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


Re: 345 free programming books

2006-04-25 Thread Jonathan Daugherty
# http://ttcom.blogspot.com/2006/04/345-free-online-programming-books.html

It seems this has been making the rounds today.  The Practical
PostgreSQL link is also broken; OpenDocs Publishing ceased to exist
starting several months ago.

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


Re: 345 free programming books

2006-04-25 Thread Terry Reedy

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Check it out, ^_^
>
> http://ttcom.blogspot.com/2006/04/345-free-online-programming-books.html

Some of the urls on the listing page
http://ttshare.googlepages.com/probooks.htm
 are not properly marked up as and diplayed as links.  I believe this is 
because of the leading hyphen on '-html'.  Look in the Python section for 
Text Processing..., Python Image..., and Dive ...

It is a good idea to view your own pages as actually served to the public 
;-)

tjr



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


Re: cgi subprocess, cannot get output

2006-04-25 Thread James Stroud
Jakub Piotr Nowak wrote:
> Hello,
> 
> In the following cgi program, I cannot get subprocess output.
> I print the header, flush stdout to prepare it to new content,
> but variable 'o' is always empty.
> 
> Could somebody help me with that? 
> 
> def main():
>   print "Content-type: text/html\n\n"
>   sys.stdout.flush()
> 
>   if form.has_key('sentence'):
> input = form['sentence'].value
> 
> o = Popen(['./tinki', input], stdout=PIPE).communicate()[0]
> result = cgi.escape(o)
> 
> results['xmlfile'] = result
> results['sentence'] = input
> 
>   content['output'] = (output % results)
>   print template % content
> 
> 
> Best regards,

What kind of script is tinki? I had a bitch of a problem like this with 
perl and ended up just writing to a file. No idea why I couldn't get the 
stdout.

James

-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


REMINDER: BayPIGgies: April 26, 7:30pm (Google)

2006-04-25 Thread Aahz
NOTE: Special date of WEDNESDAY April 26 at Google, usual time of 7:30pm

Please show up by 7:15 so we can start the meeting on time!

This does not change the usual May meeting on May 11 at Google; stay
tuned for an announcement of that.


Special meeting!  One of the lead developers of Django is in town!  Jacob
Kaplan-Moss will be talking about Django at Google.  He says he'll be
fine-tuning the talk until the last minute but plans to cover:

* How Django came into being -- a bit about the Journal-World, the
problems that Django was designed to solve, some bits about its
evolution, and a glance at how *we* use Django today.

* What writing Django apps look -- I'll show off some real code and
talk about each of the bits of Django's stack.  This'll be the bulk
of the talk.

* What's in store for the future of Django -- there's some awesome
community work going on, as well as some under-the-radar stuff we're
working on that I'll try to preview or at least talk about.


BayPIGgies meetings alternate between IronPort (San Bruno, California)
and Google (Mountain View, California).  For more information and
directions, see http://baypiggies.net/


Before the meeting, we sometimes meet at 6pm for dinner.  Discussion of
dinner plans is handled on the BayPIGgies mailing list.  

Advance notice:  We have speakers for May.  We are currently setting up
the schedule for the rest of the year.  Please e-mail
[EMAIL PROTECTED] if you want to suggest an agenda (or volunteer to
give a presentation).
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"Argue for your limitations, and sure enough they're yours."  --Richard Bach
-- 
http://mail.python.org/mailman/listinfo/python-list


Drawing charts and graphs.

2006-04-25 Thread Jonathan Daugherty
Hello,

I'm looking at a number of chart-drawing libraries and modules for
Python and I'd like to know which one people tend to consider the
best.

I've tried gdchart2 but its interface seems somewhat limited, and
pychart looks nice.  I'd like to find something that will let me draw
graphs similar to those created by RRDtool.

Thanks!

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


345 free programming books

2006-04-25 Thread ttdevelop
Check it out, ^_^

http://ttcom.blogspot.com/2006/04/345-free-online-programming-books.html

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


How to avoid using files to store intermediate results

2006-04-25 Thread André
I wrote a small wxPython based app to test code snippets.
(google for "python lightning compiler" if you want to see the full
code).

In the basic mode, I redirect the standard input and output and
execute the code taken from the editor window so that the result
appears in the output window.

Here are the 4 main lines of code to accomplish this:

sys.stdout = self.outputWindow
sys.stderr = self.outputWindow
user_code = self.PythonEditor.GetText()
exec user_code in myGlobals

For example, if I have the following situation:
input window
print "Hello world!"


the result of running the program will be this:
output window===
Hello world!


Simple enough :-)  [Actually, there's more to it, but this description
should suffice for illustration purposes.]


Now, I want to be able to test the code using the doctest module.

I can't use exec as doctest.testmod() will be testing my entire
application, not simply the code in the input window!

The solution I chose was to
1. Create a new file which contains the code to be tested with the
appropriate "doctest" call.
2. Run this file with Python, redirecting the result to a second file.
3. Read the result from the second file into a string.
4. Print the string (which, because of redirection) appears in the
output window.

Here are the main lines of code to do this:

sys.stdout = self.outputWindow
sys.stderr = self.outputWindow
user_code = self.PythonEditor.GetText()

user_code += "\nimport doctest\ndoctest.testmod()"

f = open('_doctest_file.py', 'w')
f.write(user_code)
f.close()

if verbose:
   os.popen("python _doctest_file.py -v> _doctest_file.output")
else:
   os.popen("python _doctest_file.py> _doctest_file.output")
result = open("_doctest_file.output", 'r').read()
print result

##
While this works, I find it "messy", as it creates some intermediate
files.  I was wondering if there was a better way to do things all in
memory, in an OS independent way.

[Note that the complete application is approximately 665 lines long
... a bit too much to post all here :-)]

André

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


Re: MySQLdb "begin()" -

2006-04-25 Thread shearichard
Thanks for your advice. In fact subsquent to posting I started using
...

conn.autocommit = False

... as a synonm for ...

conn.begin()

... and as you say that does the job. (Sorry i should have said it's
not practicable to turn off autocommit always [or rather it may be but
I'm not about to shake the boat to that extent just now ;-]

As to what I was reading yes it's here ...

http://www.devshed.com/index2.php?option=content&task=view&id=210&pop=1&page=0&hide_js=1

... or more succinctly ...

http://tinyurl.com/s6yd2

... page down to ...

"connection.begin() - start a transaction"

... that article refers to version 0.92 of MySQLdb so clearly it was
either wrong then or for some weird reason the method has been dropped.

thanks again.

richard.

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


Re: MySQLdb "begin()" -

2006-04-25 Thread shearichard
"What do i expect the begin method to do" ?

Explicitly start a transaction (and therefore suppress autocommits) in
an environment where autocommit is on.

No i haven't read the pep, thanks for that.

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


Re: can someone explain why ..

2006-04-25 Thread Grant Edwards
On 2006-04-25, Schüle Daniel <[EMAIL PROTECTED]> wrote:

>> I'm not familiar with Tkinter, but it seems as thought with 2,
>> the "image" variable is garbage collected after the
>> constructor of Main is called. With 1, you save a reference to
>> the image, so it does not get garbage collected.

Correct.

> image is local variable of imageLabel

Actually it's a parameter to the constructor that was called to
create the "imageLabel" object.

> I would expect that in case imageLabel lives, it should hold
> alife objects bound to its local variables

It would.  Therefore the "image" object apparently isn't bound
to a local variable in the object imageLabel.

> I am just curious *why* reference to image is not hold by
> imageLabel which on his part is hold by frame1...

Good question.  Untold millions of programmers have tripped
over that bug.  Well, would you believe untold dozens?  I know
I did.  It's a common enough problem that it's given special
mention in a couple books on Tkinter.

My _guess_ is that this is one of the misfeatures resulting
from the way Tkinter is implimented: it's not a real binding of
Python to the tk library.  It's a Python wrapper around a TCL
interpreter which is bound to the tk library (or something like
that). This results in some counter-intuitive (non-pythonic)
behaviors like the one you discovered with bitmap images and
labels.

-- 
Grant Edwards   grante Yow!  I feel like I'm
  at   in a Toilet Bowl with a
   visi.comthumbtack in my forehead!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Building a Dynamic Library (libpython.so) for Python 2.4.3 Final

2006-04-25 Thread Dean
I've been trying to make python a dynamic library. I downloaded Python 
2.4.3 Final from the Python web site and I cannot get it to create the 
library.

I've tried using the directive:

--enable-shared

and

--enable-shared=yes

and both of them had the same effect of creating a bunch of parts of 
the python interpreter in .so format but not in creating a single
libpython2.4.so.X.Y file. I could probably hack something together 
using ar but I would prefer to do it "correctly" by setting some 
options. I'm compiling under OpenBSD 3.5.

Thanks for any advice.

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


Re: python application ideas.

2006-04-25 Thread alex23
Anthony Greene wrote:
> Hello, I know this isn't really a python centric question, but I'm seeking
> help from my fellow python programmers. I've been learning python for the
> past year and a half, and I still haven't written anything substantial nor
> have I found an existing project which blows my hair back.

The Ubuntu project offers bounties for adding needed functionality to
their distro, a lot of which is provided through python:

http://www.ubuntu.com/community/bounties
https://wiki.ubuntu.com/IdeaPool

Nothing like Ca$h Prize$ to get that hair ruffled :)

- alex23

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


Re: can someone explain why ..

2006-04-25 Thread Grant Edwards
On 2006-04-25, Farshid Lashkari <[EMAIL PROTECTED]> wrote:
> Schüle Daniel wrote:
>> I don't understand what is the difference between commented lines
>> 1 and 2
>> 
>> with 1 uncommented and 2 commented it works as expected
>> with 1 commented and 2 uncommented the picture doesn't appear
>
>
> I'm not familiar with Tkinter, but it seems as thought with 2, the 
> "image" variable is garbage collected after the constructor of Main is 
> called. With 1, you save a reference to the image, so it does not get 
> garbage collected.

Yes. That's exactly correct.  It's sort of a FAQ. See the
highlighted note at the bottom of 

http://effbot.org/tkinterbook/bitmapimage.htm

-- 
Grant Edwards   grante Yow!  LOU GRANT froze
  at   my ASSETS!!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I have problems with creating the classic game Wumpus. the file: http://esnips.c

2006-04-25 Thread [EMAIL PROTECTED]

[EMAIL PROTECTED] wrote:
> the file is on that side. But apparently you have to register to
> download it.. =(  But i can send it to anone who is willing to look
> trough it. just send me an email [EMAIL PROTECTED]

Ok, e-mail it to me.

But I cannot guarantee anything. I'll peruse it at my leisure.

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


do while loop

2006-04-25 Thread
suggest  add do while loop in later version

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


Re: Xah's Edu Corner: Criticism vs Constructive Criticism

2006-04-25 Thread rambam
> "Xah Lee" <[EMAIL PROTECTED]> writes:
>
> A large amount of free, constructive criticism follows.

Just the usual repetitive content free stream-of-consciousness
material that Xah Lee is notorious for.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help finding

2006-04-25 Thread Scott David Daniels
Gary Wessle wrote:
> Hi
> 
> I am going through some tutorials, how do I find out about running a
> script from the python prompt?
Normally you don't do that.
What OS and Python versions are you using?
Do think about following the advice in "smart questions".

> is there a online ref and how to access it?
Yes.
Your install may have one, what OS?
Start here:
 http://www.python.org/about/gettingstarted/
or
 http://www.python.org/doc/faq/
or
 http://wiki.python.org/moin/
or
 http://www.python.org/doc/

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


Re: Xah's Edu Corner: Criticism vs Constructive Criticism

2006-04-25 Thread Terry Reedy

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Would these contestants please GET OFF THE LIST with their
> non-Python-related contentiousness?
[snip long repost of the very stuff complained about]



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


Re: can someone explain why ..

2006-04-25 Thread Schüle Daniel
[..]

> These are the only lines of code that reference "imageLabel":
> 
> imageLabel = Label(master = frame1, image = image)
> imageLabel.pack()
> 
> 
> Unless the constructor of Label adds a reference of itself to frame1, 
> imageLabel will also become garbage collected at the end of the 
> constructor. Are you sure this is the case?

yes, now i see it
even can frame1 be dead after __init__
it binds itself too root with

frame1 = Frame(master = root)
frame1.pack(side = LEFT)

frame1.pack may append frame1 to root's list of all
widgets, we cannot see it, but it also may not do it

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


Re: search an entire website given the homepage URL

2006-04-25 Thread Terry Reedy

"Bell, Kevin" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I would like some feedback about my actual intention though, which is to
> scrape local newspaper websites for the names of people that I work
> with.  Twice this month, colleagues have unknowingly been in the
> newspaper, and only became aware of it because someone stumbled across
> the line in the article.  To write a script that would crawl around
> testing for my own name, or that of my colleagues, wouldn't seem uncouth
> to me, but I'm new at this stuff.  It seems impolite for newspapers to
> use someone's name without informing them of it, for sure, but you can't
> count on journalists to call you up.  Would this application of a spider
> be impolite?

If the site has an index, I would use that.
If the site has pages at fixed urls accessible to public indexes (Google, 
Yahoo, etc) I would use one of those.  (Google, at least, will search a 
specific site.)
If the site has a robots.txt file requesting robots and spiders to restrict 
themselvres, I would honor the request.
Failing the above, I might write something to once a day, during off hours, 
download and examine articles in the appropriate category.

tjr



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


Re: can someone explain why ..

2006-04-25 Thread Farshid Lashkari
Schüle Daniel wrote:
> thx for quick reply :)
> 
> image is local variable of imageLabel
> I would expect that in case imageLabel lives, it should
> hold alife objects bound to its local variables
> 
> I am just curious *why* reference to image is not hold by imageLabel
> which on his part is hold by frame1 .. which is hold by global root

These are the only lines of code that reference "imageLabel":

imageLabel = Label(master = frame1, image = image)
imageLabel.pack()


Unless the constructor of Label adds a reference of itself to frame1, 
imageLabel will also become garbage collected at the end of the 
constructor. Are you sure this is the case?

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


Re: cmd module "busy waiter" ?

2006-04-25 Thread placid

Dennis Lee Bieber wrote:
> On 23 Apr 2006 23:49:51 -0700, "placid" <[EMAIL PROTECTED]> declaimed the
> following in comp.lang.python:
>
> > Just wondering if the cmd module in python uses "busy waiting" for
> > "polling" user command input as this is inefficient.
> >
>   Use the Source...
>
>   At least on 2.3.x...
>
>   Last paragraph of the docstring:
>
>
> These interpreters use raw_input; thus, if the readline module is
> loaded,
> they automatically support Emacs-like command history and editing
> features.



i dont know Emacs, and im using Windows XP (cant find readline module,
only for *nix ), does that mean it still busy waits...


> --
>  > == <
>  >   [EMAIL PROTECTED]  | Wulfraed  Dennis Lee Bieber  KD6MOG <
>  >  [EMAIL PROTECTED] |   Bestiaria Support Staff   <
>  > == <
>  >   Home Page: <
>  >Overflow Page: <

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


Re: can someone explain why ..

2006-04-25 Thread Schüle Daniel
Farshid Lashkari schrieb:
> Schüle Daniel wrote:
>> I don't understand what is the difference between commented lines
>> 1 and 2
>>
>> with 1 uncommented and 2 commented it works as expected
>> with 1 commented and 2 uncommented the picture doesn't appear
> 
> 
> I'm not familiar with Tkinter, but it seems as thought with 2, the 
> "image" variable is garbage collected after the constructor of Main is 
> called. With 1, you save a reference to the image, so it does not get 
> garbage collected.

thx for quick reply :)

image is local variable of imageLabel
I would expect that in case imageLabel lives, it should
hold alife objects bound to its local variables

I am just curious *why* reference to image is not hold by imageLabel
which on his part is hold by frame1 .. which is hold by global root

Regards, Daniel

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


help finding

2006-04-25 Thread Gary Wessle
Hi

I am going through some tutorials, how do I find out about running a
script from the python prompt?
is there a online ref and how to access it?


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


Re: can someone explain why ..

2006-04-25 Thread Farshid Lashkari
Schüle Daniel wrote:
> I don't understand what is the difference between commented lines
> 1 and 2
> 
> with 1 uncommented and 2 commented it works as expected
> with 1 commented and 2 uncommented the picture doesn't appear


I'm not familiar with Tkinter, but it seems as thought with 2, the 
"image" variable is garbage collected after the constructor of Main is 
called. With 1, you save a reference to the image, so it does not get 
garbage collected.

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


can someone explain why ..

2006-04-25 Thread Schüle Daniel
I don't understand what is the difference between commented lines
1 and 2

with 1 uncommented and 2 commented it works as expected
with 1 commented and 2 uncommented the picture doesn't appear

here is my code

#!/usr/bin/env python

from Tkinter import *
from Tkconstants import *

root = None

class Main:
 def __init__(self):
 global root
 root = Tk(className = "Zeitrechner")
 root.config(borderwidth = 5, relief = GROOVE)
 root.geometry("0x0+100+50")

 #self.im = image = PhotoImage(file = "./flower1.gif")  #1
 image = PhotoImage(file = "./flower1.gif") #2
 frame1 = Frame(master = root, borderwidth = 3, relief = SUNKEN)
 imageLabel = Label(master = frame1, image = image)

 root.minsize(width = image.width(), height = image.height())
 root.maxsize(width = 2*image.width(), height = image.height())

 imageLabel.pack()
 frame1.pack(side = LEFT)

 def mainloop(self):
 root.mainloop()

main = Main()
main.mainloop()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Xah's Edu Corner: Criticism vs Constructive Criticism

2006-04-25 Thread John Bokma
Ari Johnson <[EMAIL PROTECTED]> wrote:

24. Learn when not to reply to a troll (and bother several groups while 
doing so).

-- 
John Bokma  Freelance software developer
&
Experienced Perl programmer: http://castleamber.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MS VC++ Toolkit 2003, where?

2006-04-25 Thread Ross Ridge
Martin v. Löwis wrote:
> Right. MingW (GNU ld) was (apparently) changed to support that shortly
> after I started including libpython24.a files with the Windows
> distributions.

A bug in binutils support for short import library records was fixed
about year ago.  You need to use MinGW binutils 2.16.91 or newer if you
want to link with any of the ".lib" files included with Python 2.4.

   Ross Ridge

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


Re: MinGW and Python

2006-04-25 Thread sturlamolden
Look what I just found:

http://jove.prohosting.com/iwave/ipython/pyMinGW.html

A build process for python 2.4.2 (i.e. not the latest) for MinGW.

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


Re: Plotting package?

2006-04-25 Thread Lou Pecora
In article <[EMAIL PROTECTED]>,
 "Andrew Koenig" <[EMAIL PROTECTED]> wrote:

> This may be a foolish question, but what's the most straightforward way to 
> plot a bunch of data in Python?
> 
> That is, I want to write a program that does some number crunching, and then 
> I want to change some parameters and watch how the changes affect the 
> results.  I could produce a file to hand to gnuplot, but that's a bit of a 
> pain; so I'm wondering if there is a widely used package to which I can give 
> my x-y pairs and have it produce a graph for me with axes, scaling, etc.

I second all other recommendations on matplotlib.

-- Lou Pecora  (my views are my own) REMOVE THIS to email me.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MinGW and Python

2006-04-25 Thread sturlamolden

Martin v. Löwis wrote:

> Please believe me: there is currently no build process that
> gives the same results as the build process used. It might
> be fairly easy to create one, but none exists as of today.

I tried to build with MinGW this eveing and it failed. I believe you We
need to make a build process for MinGW.

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


Re: MinGW and Python

2006-04-25 Thread Neil Hodgson
sturlamolden:

> Uh .. I actually think it could be an EULA violation to publish mingw
> vs. msvc benchmarks without permission from Microsoft. I don't want to
> part of anything illegal or have M$ lawyers breathing down my back. If
> we are going to do this, then we must do it properly and get the
> permissions we need.

The EULA attempted to stop disclosing benchmarks of .NET code, not 
C++ code. The most recent version of the EULA has replaced that with 
permission to disclose benchmarks of .NET code provided some conditions 
are met: full disclosure of benchmark code and environment; latest 
release of .NET; compliance with 'best practices'. Its still stupid as 
it would be in Microsoft's interest to encourage benchmarking .NET but 
not quite as stupid as before.

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


Re: MinGW and Python

2006-04-25 Thread Robert Kern
Edward Elliott wrote:
> Ross Ridge wrote:
> 
>>MSVCRT.DLL ... It's not
>>exactly "endorsed", Microsoft would rather you use it's current
>>compiler and runtime, but it is the standard "official" Windows system
>>C library.
> 
> Does it comply with the ANSI C89 standard?  I'm still not seeing why mingw
> can't just link python to it.

It can.

-- 
Robert Kern
[EMAIL PROTECTED]

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

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


Re: MinGW and Python

2006-04-25 Thread sturlamolden

Edward Elliott wrote:

> Sorry, I didn't mean you personally, I meant "you" in the general sense.

OK :-)

I've just tried to build Python 2.4.3 with MinGW (MSYS 1.0.10, GCC
3.4.2):

$ ./configure --prefix=/c/Python243-mingw
$ make

The build then failed on posixmodule.c.


Sturla Molden


./Modules/posixmodule.c:308: warning: function declaration isn't a
prototype
./Modules/posixmodule.c: In function `posix_ttyname':
./Modules/posixmodule.c:1162: warning: implicit declaration of function
`ttyname'
./Modules/posixmodule.c:1162: warning: assignment makes pointer from
integer without a cast
./Modules/posixmodule.c: In function `posix_mkdir':
./Modules/posixmodule.c:1791: error: too many arguments to function
`mkdir'
./Modules/posixmodule.c: In function `posix_execv':
./Modules/posixmodule.c:2199: warning: passing arg 2 of `execv' from
incompatible pointer type
./Modules/posixmodule.c: In function `posix_execve':
./Modules/posixmodule.c:2332: warning: passing arg 2 of `execve' from
incompatible pointer type
./Modules/posixmodule.c:2332: warning: passing arg 3 of `execve' from
incompatible pointer type
./Modules/posixmodule.c: In function `posix_fork':
./Modules/posixmodule.c:2847: warning: implicit declaration of function
`fork'
./Modules/posixmodule.c: In function `posix_openpty':
./Modules/posixmodule.c:2909: error: `O_NOCTTY' undeclared (first use
in this function)
./Modules/posixmodule.c:2909: error: (Each undeclared identifier is
reported only once
./Modules/posixmodule.c:2909: error: for each function it appears in.)
./Modules/posixmodule.c:2912: error: `SIGCHLD' undeclared (first use in
this function)
./Modules/posixmodule.c:2914: warning: implicit declaration of function
`grantpt'
./Modules/posixmodule.c:2919: warning: implicit declaration of function
`unlockpt'
./Modules/posixmodule.c:2924: warning: implicit declaration of function
`ptsname'
./Modules/posixmodule.c:2924: warning: assignment makes pointer from
integer without a cast
./Modules/posixmodule.c:2931: warning: implicit declaration of function
`ioctl'
./Modules/posixmodule.c:2931: error: `I_PUSH' undeclared (first use in
this function)
./Modules/posixmodule.c: In function `posix_getegid':
./Modules/posixmodule.c:2973: warning: implicit declaration of function
`getegid'
./Modules/posixmodule.c: In function `posix_geteuid':
./Modules/posixmodule.c:2986: warning: implicit declaration of function
`geteuid'
./Modules/posixmodule.c: In function `posix_getgid':
./Modules/posixmodule.c:2999: warning: implicit declaration of function
`getgid'
./Modules/posixmodule.c: In function `posix_getppid':
./Modules/posixmodule.c:3121: warning: implicit declaration of function
`getppid'
./Modules/posixmodule.c: In function `posix_getuid':
./Modules/posixmodule.c:3163: warning: implicit declaration of function
`getuid'
./Modules/posixmodule.c: In function `posix_kill':
./Modules/posixmodule.c:3193: warning: implicit declaration of function
`kill'
./Modules/posixmodule.c: In function `posix_wait':
./Modules/posixmodule.c:4970: warning: implicit declaration of function
`wait'
./Modules/posixmodule.c: In function `posix_pipe':
./Modules/posixmodule.c:5511: warning: implicit declaration of function
`pipe'
./Modules/posixmodule.c: At top level:
./Modules/posixmodule.c:382: warning: 'posix_error_with_filename'
defined but not used
./Modules/posixmodule.c:534: warning: 'posix_fildes' defined but not
used
./Modules/posixmodule.c:6223: warning: 'conv_confname' defined but not
used
./Modules/posixmodule.c:7126: warning: 'setup_confname_table' defined
but not used
make: *** [Modules/posixmodule.o] Error 1

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


Re: search an entire website given the homepage URL

2006-04-25 Thread Bell, Kevin
Fredrik wrote:
to grab entire sites ?

try doing that on a commercial data provider's site, and chances are
that you'll end up being banned (or sued) within hours ...
-

Me:

Nope, I never said that to start with...

Well I certainly am learning a lot.  I never said I intended to download
anyone's entire website, as was assumed, but it's been fun to see how
folks feel about it anyway!

I would like some feedback about my actual intention though, which is to
scrape local newspaper websites for the names of people that I work
with.  Twice this month, colleagues have unknowingly been in the
newspaper, and only became aware of it because someone stumbled across
the line in the article.  To write a script that would crawl around
testing for my own name, or that of my colleagues, wouldn't seem uncouth
to me, but I'm new at this stuff.  It seems impolite for newspapers to
use someone's name without informing them of it, for sure, but you can't
count on journalists to call you up.  Would this application of a spider
be impolite?




Bell, Kevin wrote:
>>use a search engine (try the search box in the upper right corner).
> 
> 
>>using a spider to download the entire site just so you can "search
> 
> through >it" is bloody impolite.
> 
> Really?  I'd argue that's impolite only if you're an impolite person 
> with a rude agenda, which is not what I had in mind, but thanks for 
> the ethics lecture as well as the pointer ; )  I assure you that I 
> harbor no nefarious scheme.  Isn't it common for folks to watch the 
> stock market, or real estate listings, for example?
> 
> I'll look into to tools you mentioned, and thanks again!
> 
> 
I think Fredrik's right: the intarweb is supposed to be distributed, not
live on your desktop. Folk who watch the stock market don't download
twenty years' worth of data in one afternoon, they generally subscribe
to real-time feeds that are relatively low volume.

regards
  Steve


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


Re: proposed Python logo

2006-04-25 Thread [EMAIL PROTECTED]
The simplest and most widely known Monty Python image I can think of is
a dead parrot.
So maybe an upside-down parrot?
Could be nice and colorful too, not to mention memorable.

It is true that many won't make the connection between some kind of
Monty Python image and the Python language, as they wouldn't even
recognize the image. Outside the UK Monty Python isn't quite so popular
as some may think.

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


Re: Looking for resources for making the jump from Java to Python easier and more productive

2006-04-25 Thread Bruno Desthuilliers
bruno at modulix a écrit :
> Lawrence D'Oliveiro wrote:
> 
>>In article <[EMAIL PROTECTED]>,
>> bruno at modulix <[EMAIL PROTECTED]> wrote:
>>
>>
>>
>>>Lawrence D'Oliveiro wrote:
>>>
> 
> (snip)
> 
I suppose this is an instance of the more general rule: "using OO when 
you don't have to".
>>>
>>>Lawrence, I'm afraid you're confusing OO with "statically-typed
>>>class-based". FWIW, dynamic typing is part of OO since Smalltalk.
>>
>>
>>I wasn't talking about dynamic typing, I was talking about subclassing, 
>>which is very much a part of OO.
> 
> 
> What you wrote implies (well, at least I understand it that way)

... but I may just have it totally wrong !-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MinGW and Python

2006-04-25 Thread Edward Elliott
Ross Ridge wrote:
> MSVCRT.DLL ... It's not
> exactly "endorsed", Microsoft would rather you use it's current
> compiler and runtime, but it is the standard "official" Windows system
> C library.

Does it comply with the ANSI C89 standard?  I'm still not seeing why mingw
can't just link python to it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MinGW and Python

2006-04-25 Thread Edward Elliott
"Martin v. Löwis" wrote:
> Well, you are not compiling with neither mingw, nor cygwin; you are
> compiling with gcc in either case.

touche, mr. pedant. :)

> Well, there is no native C library on Microsoft Windows: the system
> simply doesn't include an official C library (I know there is crtdll.dll
> and msvcrt.dll, but these aren't "endorsed" system C libraries).

don't know what you mean by "endorsed".  does it lack features of the C89
ANSI standard?
 
> For Windows, that would require not to use any of the standard C
> functionality, since the system doesn't provide that functionality out
> of the box. 

That would be a problem then.  So what happens when you compile python with
msvc, and why can't mingw just replicate that?

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

Re: Can one query full name (or version) of selected packages at pypi?

2006-04-25 Thread Caleb Hattingh
Hi Martin

Pretty much exactly what I wanted :)

How up-to-date does Debian keep its package list for python addons, or
are you running Unstable?   My big problem, being in South Africa, is
that I have to get any distros on cover CDs or order from
distro-resellers, and they never have Testing or Unstable.   Broadband
hasn't exactly hit the local market, although things might be looking
up in a few years or so.

keep well
Caleb

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


Re: MinGW and Python

2006-04-25 Thread Edward Elliott
sturlamolden wrote:
> Edward Elliott wrote:
>> Couldn't you compile the msvc-python code under gcc/mingw?
> 
> Yes I could, but I cannot compile the code under msvc for comparison. I
> only have MinGW. If build the mingw binary then someone else has to
> build the msvc binary for comparison. Then we could do pybenches on the
> same computer.

Sorry, I didn't mean you personally, I meant "you" in the general sense.

 
> Uh .. I actually think it could be an EULA violation to publish mingw
> vs. msvc benchmarks without permission from Microsoft. I don't want to
> part of anything illegal or have M$ lawyers breathing down my back. If
> we are going to do this, then we must do it properly and get the
> permissions we need.

Why, because of a "no benchmarks" clause in the EULA?  First, I'm fairly
certain that clause is uneforceable.  Second, it's not worth MS's time to
come after you.  Third, even if they did, they'd have an incredibly tough
time showing that any harm occured from your actions, leaving them with no
recovery.  Fourth, if it somehow came to that, you'd have organizations
like the EFF lining up at your door to take the case gratis.  I'm assuming
US law here.

Not saying you should do it, just that the risk in my opinion is extremely
low.  I am a law student, but this is not legal advice.

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


Re: Multithreading and Queue

2006-04-25 Thread robert
Jeffrey Barish wrote:
> Several methods in Queue.Queue have warnings in their doc strings that they
> are not reliable (e.g., qsize).  I note that the code in all these methods
> is bracketed with lock acquire/release.  These locks are intended to
> protect the enclosed code from collisions with other threads.  I am
> wondering whether I understand correctly that the reason these methods are
> still not reliable is that from the point where a thread calls qsize (for
> example) to the point in Queue where a thread acquires a lock there is a
> bunch of code, none of which is protected by a lock, (and moreover there is
> another bunch of code between the point where a thread releases a lock and
> then actually returns to the calling program) and so despite the locks in
> Queue it is still possible for values to change before a thread acts on
> them.

That warnings are quite meaningless: If you get a certain q size, it 
might be changed the next moment/OP anyway.

simply len() is the same as that

 def qsize(self):
 """Return the approximate size of the queue (not reliable!)."""
 self.mutex.acquire()
 n = self._qsize()
 self.mutex.release()
 return n
 ...
 def _qsize(self):
 return len(self.queue)


All that time-consuming locking in Queue is quite unnecessary. As 
assumed in many other locations in the std lib, list.append() / .pop() / 
len() are atomic. Thus doing in a single location a IndexError-catch on 
a .pop() race, and all care is done.

(the only additional guarantee through that lock's ( at .append() time) 
is that the q size is never one over the exact "maximum" - but thats 
pedantic in a threaded multi-producer mess.)

The whole CallQueue in 
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/491281 for 
example doesn't use a single lock - though its an inter-thread 
communication hot spot.

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


cgi subprocess, cannot get output

2006-04-25 Thread Jakub Piotr Nowak
Hello,

In the following cgi program, I cannot get subprocess output.
I print the header, flush stdout to prepare it to new content,
but variable 'o' is always empty.

Could somebody help me with that? 

def main():
  print "Content-type: text/html\n\n"
  sys.stdout.flush()

  if form.has_key('sentence'):
input = form['sentence'].value

o = Popen(['./tinki', input], stdout=PIPE).communicate()[0]
result = cgi.escape(o)

results['xmlfile'] = result
results['sentence'] = input

  content['output'] = (output % results)
  print template % content


Best regards,
-- 
Jakub P. Nowak
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MinGW and Python

2006-04-25 Thread [EMAIL PROTECTED]
sturlamolden wrote:
> But as long as the cygwin dll is there, it creates an overhead for any
> system call. The worst overhead is associated with the Unix fork()
> system call, which Cygwin must emulate as there are no Win32
> equivalent. In particular, a fork() on Unix will be optimized with
> copy-on-write semantics in the kernel, but Cygwin cannot emulate that
> as it has no access to the Windows kernel.

Cygwin doesn't do COW fork() for historical reasons.  Windows 95/98
didn't expose support for such a thing, but NT, XP, etc do  (pass NULL
as the SectionHandle parameter to ZwCreateProcess or the older
NtCreateProcess to do a COW duplicate of the calling process).

Cygwin at one point had a fork() implementation using this in the
development tree (or being discussed on the mailing lists) but decided
not to use it since it wasn't much faster than full-copy fork for some
reason, and it would've split the code for NT/95.

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


Re: MinGW and Python

2006-04-25 Thread Ross Ridge

Martin v. Löwis wrote:
> Well, there is no native C library on Microsoft Windows: the system
> simply doesn't include an official C library (I know there is crtdll.dll
> and msvcrt.dll, but these aren't "endorsed" system C libraries).

MSVCRT.DLL has been a standard system compent of Windows since at least
Windows 98.  Many other system components depend on it.  Essentially,
MSVCRT.DLL is an "undocumented" part of the Windows API.  It's not
exactly "endorsed", Microsoft would rather you use it's current
compiler and runtime, but it is the standard "official" Windows system
C library.

Ross Ridge

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


Re: Xah's Edu Corner: Criticism vs Constructive Criticism

2006-04-25 Thread mfmorss
Would these contestants please GET OFF THE LIST with their
non-Python-related contentiousness?

Mark F. Morss
Principal Analyst, Market Risk
American Electric Power


   
 Ari Johnson   
 <[EMAIL PROTECTED] 
 com>   To 
 Sent by:  python-list@python.org  
 python-list-bounc  cc 
 es+mfmorss=aep.co 
 [EMAIL PROTECTED]  Subject 
   Re: Xah's Edu Corner: Criticism vs  
   Constructive Criticism  
 04/25/2006 03:39  
 PM
   
   
   
   




"Xah Lee" <[EMAIL PROTECTED]> writes:

A large amount of free, constructive criticism follows.

1. Learn where to post things.

> Criticism versus Constructive Criticism

2. Learn when to capitalize words in a title.

> Xah Lee, 2003-01

3. Learn when to post things.

> A lot intelligent people are rather confused about criticism,
> especially in our “free-speech” free-for-all internet age. When
> they say “constructive criticisms are welcome” they mostly mean
> “bitching and complaints not welcome”. Rarely do people actually
> mean that “criticism without suggestion of possible solutions are not
> welcome” or “impolite criticism not welcome”.

4. Try "many."

5. Learn how to use commas.

6. Nobody says "constructive criticisms are welcome."  They use the
singular, as should you.

7. Learn how to use commas.

8. Learn how to use parallel structure.

> Such discernment is important. Wanton bitching as internet-using geeks
> are used to is not criticism is any form.

9. Generally, the use of sentence forms like "such  is
" is even frowned upon in legal writing anymore; but it
is almost never appropriate to use the word "bitching" in the next
sentence.

> People can be respected and make a living out of criticisms, called
> critics, but not bitching. And when one really value opinions, you
> often want criticism without qualifications. Just be happy that
> valuable criticisms may come to you free from the experts in the
> public. The instant you qualify what kind of feedback are welcome, your
> feedback is compromised. (this is particularly so for political or
> controversial subjects)

10. You're still insisting that criticism in the general sense is a
plural thing.  It is not.  Also, these "criticisms" are not what we
call "critics."  We call the people making them critics.  I'd let this
one slide but you bounce back and forth too many times in one sentence
to get away with it.

11. Learn how to match a verb to its noun.

12. You still haven't figured out when to use "criticisms."  I'll give
you another hint: nowhere within your writing.

13. Learn when your "expert" criticism is apropos and when it is not.

14. If you can't figure out when not to pluralize the word criticism,
I don't know why I expect you to know when to use "is" instead of
"are."  However, I still recommend you learn this not-so-subtle
point of English grammar.

15. Sentences in parentheses are still sentences - capitalize and
punctuate appropriately.

16. When you make a sweeping, general statement, it helps to support
it with some kind of logically-related evidence.

> One easy way for many of the unix geeks to understand this is the
> cryptology industry.

17. Learn when to capitalize proper nouns.

18. The cryptology industry is not a "way."  It is an industry.  Learn
how to write clear sentences that use words in meaningful ways.  One
way to do this is to utilize verbs.

> If one really desires valuable criticisms that is polite or with
> solutions or “constructive” (whatever that means), one usually have
> to pay.

19. The rule is that third-person singular subjects take "is" and
third-person plural subjects take "are."  You seem to have this
backwards.

20. If you are offering a dissertation on constructive criticism, you
ought to define the term rather than using a parenthetical
shoulder-shrug like this.

21. Third-person singular subjects take "has," not "have."

22. When you write something, even when it is not welcome or not
relevant to the place you post it, it is helpful to actually make
a point rather than just making several statements of things which
altern

released: RPyC 2.50A

2006-04-25 Thread gangesmaster
Remote Python Call 2.50 release-candidate

http://rpyc.wikispaces.com


-tomer

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


Re: Zope 3

2006-04-25 Thread Bruno Desthuilliers
Steve Juranich a écrit :
> bruno at modulix wrote:
> 
> 
>>Actually, the OP was asking about Zope3, which is a *very* different
>>beast.
> 
> 
> Okay, so my ignorance is showing (/me pauses to stuff it back where it
> belongs).  So is there some big master diff, along the lines of "What's new
> in Python X.X" that I could look at to get an idea of what z3 has that 2.9
> (which I'm currently still cutting my teeth on) doesn't?  

This is not an incremental change, it's a complete redesign and rewrite 
and a different architecture. Almost nothing of what you learn with Zope 
2.x will hold with Zope3.

> I've looked at
> the documentation on the main Zope page (zope.org) and all of the documents
> I've seen are apparently geared towards Zope 2.X.  Where are the Zope3
> docs?

You can start here:
http://www.zope.org/DevHome/Wikis/DevSite/Projects/ComponentArchitecture/FrontPage

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


Re: search an entire website given the homepage URL

2006-04-25 Thread Steve Holden
Bell, Kevin wrote:
>>use a search engine (try the search box in the upper right corner).
> 
> 
>>using a spider to download the entire site just so you can "search
> 
> through >it" is bloody impolite.
> 
> Really?  I'd argue that's impolite only if you're an impolite person
> with a rude agenda, which is not what I had in mind, but thanks for the
> ethics lecture as well as the pointer ; )  I assure you that I harbor no
> nefarious scheme.  Isn't it common for folks to watch the stock market,
> or real estate listings, for example?
> 
> I'll look into to tools you mentioned, and thanks again!
> 
> 
I think Fredrik's right: the intarweb is supposed to be distributed, not 
live on your desktop. Folk who watch the stock market don't download 
twenty years' worth of data in one afternoon, they generally subscribe 
to real-time feeds that are relatively low volume.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Love me, love my blog  http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: OOP / language design question

2006-04-25 Thread Bruno Desthuilliers
Duncan Booth a écrit :
> bruno at modulix wrote:
> 
> 
>>class Base(object):
>>  def __init__(self, arg1):
>>self.attr1 = arg1
>>self.dothis()
>>
>>  def dothis(self):
>>return self.attr1
>>
>>class Derived(Base):
>>  def __init__(self, arg1, arg2=0):
>>self.attr2 = arg2
>>Base.__init__(self, arg1)
>>
>>  def dothis(self):
>>return self.attr1 + self.attr2
>>
>>(snip)
>>
>>
>>>Perhaps if the base __init__ calls an overridden 
>>>method, but at that point it sounds to me like something wants
>>>refactoring. 
>>
>>Why so ? This is a well-known pattern (template method). I don't see
>>what's wrong with it.
> 
> 
> Apart from the fact that you can delete the method 'dothis' from both 
> classes with no effect on the code?

Mmmm... Oh, I see. Agreed, this is not a very good example.

 >>class Base(object):
>>  def __init__(self, arg1):
>>self.attr1 = arg1
>>self.attr42 = self.dothis()

Is that better ?-)

Ok, let's be serious now...

> Actually, this is quite an interesting example becaue it wouldn't work in 
> C++: if you tried the same trick the call to dothis from the base 
> constructor (even assuming it is virtual) would actually call Base.dothis.

> I think you have demonstrated that you can do some things in Python which 
> you simply cannot do in static languages like C++: assigning to derived 
> attributes before calling a base initialiser, and calling a virtual method 
> from a base initialiser. I'm not arguing about that. What I don't have 
> though is an example of code where doing this would actually be a good 
> thing.

I don't have any concrete example at hand, but I can tell you I've done 
such things often enough.

> What I think I'm trying to get at is that I believe that most situations 
> where someone actually tries to do something in the base initialiser which 
> requires calling a virtual method

I'm afraid I fail to see what's so special about 'virtual' methods - and 
FWIW, since all methods in Python are virtual, if you don't want to call 
virtual methods in the initializer, you won't get very far !-)

> are probably also cases where the 
> initialiser is doing too much: i.e. separating the 
> construction/initialisation from actually doing something is usually a good 
> idea.

What if some of the things one have to do at initialization is also used 
elsewhere ? You would not duplicate code, would you ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MinGW and Python

2006-04-25 Thread sturlamolden

Edward Elliott wrote:

> Couldn't you compile the msvc-python code under gcc/mingw?

Yes I could, but I cannot compile the code under msvc for comparison. I
only have MinGW. If build the mingw binary then someone else has to
build the msvc binary for comparison. Then we could do pybenches on the
same computer.

Uh .. I actually think it could be an EULA violation to publish mingw
vs. msvc benchmarks without permission from Microsoft. I don't want to
part of anything illegal or have M$ lawyers breathing down my back. If
we are going to do this, then we must do it properly and get the
permissions we need.

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


Re: Plotting package?

2006-04-25 Thread John Hunter
> "Andrew" == Andrew Koenig <[EMAIL PROTECTED]> writes:

Andrew> This may be a foolish question, but what's the most
Andrew> straightforward way to plot a bunch of data in Python?


in matplotlib/pylab

  from pylab import figure, show
  x = range(10)
  y = [val**2 for val in x]
  fig = figure()
  ax = fig.add_subplot(111)
  ax.plot(x,y)
  ax.set_title('My first plot')
  ax.set_xlabel('x')
  ax.set_ylabel('y')
  show()

Tutorial: http://matplotlib.sourceforge.net/tutorial.html
Screenshots: http://matplotlib.sourceforge.net/screenshots.html

JDH

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


Re: MinGW and Python

2006-04-25 Thread Ross Ridge

sturlamolden wrote:
> MinGW can compile MFC. Download Windows Platform SDK and you get the
> MFC source.

Do not do this.  The Platform SDK's EULA does not permit you to
redistribute anything you build from the MFC sources included in the
SDK.  The only way to get a copy of MFC that you can legitimately use
in anything you distribute you need to buy a Microsoft C++ compiler.

   Ross Ridge

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


Re: Plotting package?

2006-04-25 Thread Jorge Godoy
Andrew Koenig wrote:

> This may be a foolish question, but what's the most straightforward way to
> plot a bunch of data in Python?
> 
> That is, I want to write a program that does some number crunching, and
> then I want to change some parameters and watch how the changes affect the
> results.  I could produce a file to hand to gnuplot, but that's a bit of a
> pain; so I'm wondering if there is a widely used package to which I can
> give my x-y pairs and have it produce a graph for me with axes, scaling,
> etc.

I liked the output of PyChart.  It is pretty easy to use.  Also, I don't
know what you're doing with numbers, but there's rpy to use with R.

-- 
Jorge Godoy  <[EMAIL PROTECTED]>

"Quidquid latine dictum sit, altum sonatur."
- Qualquer coisa dita em latim soa profundo.
- Anything said in Latin sounds smart.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MinGW and Python

2006-04-25 Thread Ross Ridge

sturlamolden wrote:
> MinGW and Cygwin GCC is actually the same compiler.

Not exactly.  They're both GCC, but the MinGW compiler that you can
download from MinGW WWW site is a native Win32 appliction, while the
"MinGW" compiler included with Cygwin and invoked by "-mno-cygwin" is a
Cygwin application.

Ross Ridge

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


Re: Plotting package?

2006-04-25 Thread [EMAIL PROTECTED]
Try matplotlib, it's pretty nice and easy to use.

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


Re: list example

2006-04-25 Thread Andrew Koenig
"PAolo" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

> for i in range(1,10):
>if i%2:
>odd.append(i)
>else:
>even.append(i)

In 2.5 you'll be able to say

for i in range(1,10):
(odd if i%2 else even).append(i)

Whether you want to do this is another question entirely, of course.


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


Plotting package?

2006-04-25 Thread Andrew Koenig
This may be a foolish question, but what's the most straightforward way to 
plot a bunch of data in Python?

That is, I want to write a program that does some number crunching, and then 
I want to change some parameters and watch how the changes affect the 
results.  I could produce a file to hand to gnuplot, but that's a bit of a 
pain; so I'm wondering if there is a widely used package to which I can give 
my x-y pairs and have it produce a graph for me with axes, scaling, etc.


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


Re: MinGW and Python

2006-04-25 Thread Martin v. Löwis
sturlamolden wrote:
>> - there is no build process available to do that
> 
> In MSYS:
> 
> $ ./configure --prefix=/c/mingw
> $ make
> $ make install
> 
> This should be obvious to any with Unix experience.
> 
> MinGW actually distribute precompiled Python binaries as well (in
> MSYS-DTK).

So how does that deal with the various extension modules that
PCbuild/readme.txt mentions? Do I get winsound.pyd? _msi.pyd
(in 2.5)?

Please believe me: there is currently no build process that
gives the same results as the build process used. It might
be fairly easy to create one, but none exists as of today.

>> - people building extensions to Python must be able to do so with
>>   Microsoft C++, since some of these extensions are written using MFC.
> 
> MinGW can compile MFC. Download Windows Platform SDK and you get the
> MFC source.

Did you actually try that? Last I tried, GCC would refuse to compile
the MinGW header files.

Even if you succeed, I don't think the SDK license will allow you
to distribute your binary, and it *will* be incompatible the official
MFC binary. MSVC++ has its own object layout, vtable layout, name
mangling, so you can't use GCC to link against MSVC-compiled
C++ libraries.

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


Re: MinGW and Python

2006-04-25 Thread Martin v. Löwis
Edward Elliott wrote:
> Thanks for that very informative post!  To clarify, mingw (aka gcc
> -mno-cygwin) has no POSIX layer like cygwin.  Because your post could also
> be (incorrectly) interpreted to mean mingw removes the cygwin dll
> dependency by just linking it in statically.  But I googled and this is not
> the case.

Well, you are not compiling with neither mingw, nor cygwin; you are
compiling with gcc in either case.

The question is what C library (and header files) you use: with cygwin,
you use cygwin1.dll (and its header files); with mingw, you use
msvcrt.dll (or some other MS CRT), along with the a GNU version of the
Microsoft header files.

> Couldn't you compile the msvc-python code under gcc/mingw?  If the code
> sticks to C standards, and mingw can link to native libs, it should work. 

Well, there is no native C library on Microsoft Windows: the system
simply doesn't include an official C library (I know there is crtdll.dll
and msvcrt.dll, but these aren't "endorsed" system C libraries).

> The only problem is if python relies on some msvc-specific weirdness under
> msvc.  While there's much weirdness in msvc, I would expect a
> cross-platform app like python to stay away from it.

For Windows, that would require not to use any of the standard C
functionality, since the system doesn't provide that functionality out
of the box. So Python itself never uses and msvcrt weirdness (well,
some, but that could be dropped easily) - yet still, the Python
binary will depend on a specific version of the MS CRT.

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


Re: search an entire website given the homepage URL

2006-04-25 Thread Fredrik Lundh
"Bell, Kevin" wrote:

> >use a search engine (try the search box in the upper right corner).
>
> >using a spider to download the entire site just so you can "search
> through >it" is bloody impolite.
>
> Really?  I'd argue that's impolite only if you're an impolite person
> with a rude agenda, which is not what I had in mind, but thanks for the
> ethics lecture as well as the pointer ; )

downloading entire sites for personal purposes is considered rude by
many web administrators, no matter what agenda you have.

> I assure you that I harbor no nefarious scheme.  Isn't it common for folks
> to watch the stock market, or real estate listings, for example?

to grab entire sites ?

try doing that on a commercial data provider's site, and chances are
that you'll end up being banned (or sued) within hours ...





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


Re: MinGW and Python

2006-04-25 Thread Martin v. Löwis
Brian Elmegaard wrote:
>> That is simply not true. 
> 
> Actually, you answered me then too. I misunderstood after reading
> http://sebsauvage.net/python/mingw.html.
> 
> Is the information on that page not correct? Has it never been? 

It's not correct, to the best of my knowledge. However, since
very few people use it, support for mingw keeps breaking
(inadvertently), so there might be bugs that prevent it from
working *for you*.

At the point this was written (apparently around Python 2.2)
it was possible to build Python extensions with MingW (the page
actually explains you how to do that), so "Under Windows, if you
do not have the costly Microsoft Visual C++, you cannot
install Python extensions written in C" wasn't even true
at the time it was written. You couldn't use distutils, but
you could certainly have built extensions by invoking the
compiler manually.

There were times when cygwin couldn't link with .DLLs unless
they were created with GNU ld, but these times are long past
history.

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


pCFITSIO problems

2006-04-25 Thread Tommy Grav
I am trying to install pCFITSIO on my Mac (Mac OS X.4.  Numarray is already installed and imports fine in python (ActivePhyton v2.4.2), but when I try to build pCFITSIO itfails in finding a number of .h files for numarray. [tgravi] Desktop/pCFITSIO-0.99.3 ->python setup.py buildrunning buildrunning build_pyrunning build_extbuilding 'pcfitsio' extensiongcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fPIC -fno-common -dynamic -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I/usr/local/cfitsio/include/ -I/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4 -c pcfitsio_wrap.c -o build/temp.darwin-8.6.0-Power_Macintosh-2.4/pcfitsio_wrap.oIn file included from /Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:55,                 from pcfitsio_wrap.c:50:/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/pyport.h:396: warning: 'struct winsize' declared inside parameter list/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/pyport.h:397: warning: 'struct winsize' declared inside parameter listIn file included from pcfitsio_wrap.c:566:fitsio.h:2:34: error: numarray/arrayobject.h: No such file or directoryBut it does not seem like numarray left any files like this on the system. Anyone run into this problem as well andknow of a fix? Or is there another fits extension out there? CheersTommy[EMAIL PROTECTED]http://homepage.mac.com/tgrav/"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction"                         -- Albert Einstein -- 
http://mail.python.org/mailman/listinfo/python-list

Re: Xah's Edu Corner: Criticism vs Constructive Criticism

2006-04-25 Thread Ari Johnson
"Xah Lee" <[EMAIL PROTECTED]> writes:

A large amount of free, constructive criticism follows.

1. Learn where to post things.

> Criticism versus Constructive Criticism

2. Learn when to capitalize words in a title.

> Xah Lee, 2003-01

3. Learn when to post things.

> A lot intelligent people are rather confused about criticism,
> especially in our “free-speech” free-for-all internet age. When
> they say “constructive criticisms are welcome” they mostly mean
> “bitching and complaints not welcome”. Rarely do people actually
> mean that “criticism without suggestion of possible solutions are not
> welcome” or “impolite criticism not welcome”.

4. Try "many."

5. Learn how to use commas.

6. Nobody says "constructive criticisms are welcome."  They use the
singular, as should you.

7. Learn how to use commas.

8. Learn how to use parallel structure.

> Such discernment is important. Wanton bitching as internet-using geeks
> are used to is not criticism is any form.

9. Generally, the use of sentence forms like "such  is
" is even frowned upon in legal writing anymore; but it
is almost never appropriate to use the word "bitching" in the next
sentence.

> People can be respected and make a living out of criticisms, called
> critics, but not bitching. And when one really value opinions, you
> often want criticism without qualifications. Just be happy that
> valuable criticisms may come to you free from the experts in the
> public. The instant you qualify what kind of feedback are welcome, your
> feedback is compromised. (this is particularly so for political or
> controversial subjects)

10. You're still insisting that criticism in the general sense is a
plural thing.  It is not.  Also, these "criticisms" are not what we
call "critics."  We call the people making them critics.  I'd let this
one slide but you bounce back and forth too many times in one sentence
to get away with it.

11. Learn how to match a verb to its noun.

12. You still haven't figured out when to use "criticisms."  I'll give
you another hint: nowhere within your writing.

13. Learn when your "expert" criticism is apropos and when it is not.

14. If you can't figure out when not to pluralize the word criticism,
I don't know why I expect you to know when to use "is" instead of
"are."  However, I still recommend you learn this not-so-subtle
point of English grammar.

15. Sentences in parentheses are still sentences - capitalize and
punctuate appropriately.

16. When you make a sweeping, general statement, it helps to support
it with some kind of logically-related evidence.

> One easy way for many of the unix geeks to understand this is the
> cryptology industry.

17. Learn when to capitalize proper nouns.

18. The cryptology industry is not a "way."  It is an industry.  Learn
how to write clear sentences that use words in meaningful ways.  One
way to do this is to utilize verbs.

> If one really desires valuable criticisms that is polite or with
> solutions or “constructive” (whatever that means), one usually have
> to pay.

19. The rule is that third-person singular subjects take "is" and
third-person plural subjects take "are."  You seem to have this
backwards.

20. If you are offering a dissertation on constructive criticism, you
ought to define the term rather than using a parenthetical
shoulder-shrug like this.

21. Third-person singular subjects take "has," not "have."

22. When you write something, even when it is not welcome or not
relevant to the place you post it, it is helpful to actually make
a point rather than just making several statements of things which
alternate between obvious and nonsensical.

> This post is archived at:
> http://xahlee.org/UnixResource_dir/writ/criticism.html

23. If something from three years ago is on the web, it is indexed by
Google.  If someone wants to read it, they will find it via
Google.  There is no need to post it on inappropriate newsgroups.

>
>Xah
>[EMAIL PROTECTED]
>  ∑ http://xahlee.org/

(This isn't constructive criticism, but just a question:) Are you the
sum of your web page?

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

Re: Multithreading and Queue

2006-04-25 Thread Tim Peters
[Jeffrey Barish]
> Several methods in Queue.Queue have warnings in their doc strings that they
> are not reliable (e.g., qsize).  I note that the code in all these methods
> is bracketed with lock acquire/release.  These locks are intended to
> protect the enclosed code from collisions with other threads.  I am
> wondering whether I understand correctly that the reason these methods are
> still not reliable is that from the point where a thread calls qsize (for
> example) to the point in Queue where a thread acquires a lock there is a
> bunch of code, none of which is protected by a lock, (and moreover there is
> another bunch of code between the point where a thread releases a lock and
> then actually returns to the calling program) and so despite the locks in
> Queue it is still possible for values to change before a thread acts on
> them.

Pretty much, yes.  qsize() knows perfectly well what the exact size of
the queue is at the time it computes it, but by the time qsize's
_caller_ gets the result, any number of other threads may have run for
any amount of time, so the actual size of the queue at the instant the
caller uses the result may be anything whatsoever.  A specific
application may be able to get stronger guarantees by disciplining its
use of threads in exploitable ways, but nothing stronger can be said
in the _general_ case.
-- 
http://mail.python.org/mailman/listinfo/python-list


Multithreading and Queue

2006-04-25 Thread Jeffrey Barish
Several methods in Queue.Queue have warnings in their doc strings that they
are not reliable (e.g., qsize).  I note that the code in all these methods
is bracketed with lock acquire/release.  These locks are intended to
protect the enclosed code from collisions with other threads.  I am
wondering whether I understand correctly that the reason these methods are
still not reliable is that from the point where a thread calls qsize (for
example) to the point in Queue where a thread acquires a lock there is a
bunch of code, none of which is protected by a lock, (and moreover there is
another bunch of code between the point where a thread releases a lock and
then actually returns to the calling program) and so despite the locks in
Queue it is still possible for values to change before a thread acts on
them.
-- 
Jeffrey Barish

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


Re: MS VC++ Toolkit 2003, where?

2006-04-25 Thread Martin v. Löwis
Fredrik Lundh wrote:
> however, note that the FAQ entry says that you can use an existing
> LIB file as well, so Python's standard import library should work.

Right. MingW (GNU ld) was (apparently) changed to support that shortly
after I started including libpython24.a files with the Windows
distributions.

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


Xah's Edu Corner: Criticism vs Constructive Criticism

2006-04-25 Thread Xah Lee
Criticism versus Constructive Criticism

Xah Lee, 2003-01

A lot intelligent people are rather confused about criticism,
especially in our “free-speech” free-for-all internet age. When
they say “constructive criticisms are welcome” they mostly mean
“bitching and complaints not welcome”. Rarely do people actually
mean that “criticism without suggestion of possible solutions are not
welcome” or “impolite criticism not welcome”.

Such discernment is important. Wanton bitching as internet-using geeks
are used to is not criticism is any form.

People can be respected and make a living out of criticisms, called
critics, but not bitching. And when one really value opinions, you
often want criticism without qualifications. Just be happy that
valuable criticisms may come to you free from the experts in the
public. The instant you qualify what kind of feedback are welcome, your
feedback is compromised. (this is particularly so for political or
controversial subjects)

One easy way for many of the unix geeks to understand this is the
cryptology industry.

If one really desires valuable criticisms that is polite or with
solutions or “constructive” (whatever that means), one usually have
to pay.

This post is archived at:
http://xahlee.org/UnixResource_dir/writ/criticism.html

   Xah
   [EMAIL PROTECTED]
 ∑ http://xahlee.org/

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

Re: python application ideas.

2006-04-25 Thread Scott David Daniels
Anthony Greene wrote:
> So true man, I guess I need to truly sit down and determine these things.
> I love to do a lot of things, read, hang out, skate, which are a few
> amongst other things
 From the skating:

OK, say you have a 3-d surface, what is the path a ball bearing with a
particular momentum takes over time.  Can you display that: the 3-D
surface, the position as an animation?  Sure you can.  VPython gives
you all the display capabilities you need.  Start with 2-D and an
straight line.  Then move either to a more complex curve or 3-D
next.  The reason for using VPython is to get 3-D solved for you so
you can work on the position and momentum updates.  It even will do
anaglyph (colored glasses) and cross-eyed 3-D rendering, though the
default is to simply give you a 2-D window into the 3-D world.

If you do this, you might play with designing a virtual skate park.

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


PyThreadState_SetAsyncExc and native extensions

2006-04-25 Thread gabriel . becedillas
Does anyone know if PyThreadState_SetAsyncExc stops a thread while its
inside a native extension ?
I'm trying to stop a testing script that boils down to this:

while True:
print "aaa"
native_extension_call()
print "bbb"

Using PyThreadState_SetAsyncExc the module doesn't stop but if I add
more print statements to increase the chance that
PyThreadState_SetAsyncExc is called when the module is executing Python
code, the module stops.

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


Re: python application ideas.

2006-04-25 Thread [EMAIL PROTECTED]
Thats the best way to go about it.  Python I find is fun because you
can just play with the interpreter throwing commands at it and really
just working with syntax and usually POC ideas.  The most useful ideas
usually just come to you.  I recieved a pretty barebones MP3 player
from my sister for my birthday.  I didnt have anything on the lines of
file management or playlist management software whatsoever, so I
decided to write some custom software (in Tkinter btw) to quickly and
efficiently move around songs and playlists with it's basic removable
drive format.  Its all in what you need, and what you need a 'solution'
for.  Try not to think of 'ideas' per se, try to think of problems that
need solutions.

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


parallel computing

2006-04-25 Thread Sori Schwimmer
Hi All,

While working on a project, I discovered lots of
little opportunities for real parallelism. For
instance, the following class initialization:

from pg import DB

class example:
  def __init__(self):
# find somehow HOST1, HOST2
   
self.member1=DB('database1',host=HOST1).query("SELECT...").getresult()
self.member2=self.my_aux_func()
# some more processing here
   
self.member3=DB('database1',host=HOST2).query("SELECT...").getresult()
# other things here

will ask other physical computers to do some of the
work... and wait for the results.

Wouldn't be nice, in the spirit of occam (the
language) to do it like the following?

from pg import DB

class example:
  def __init__(self):
# find somehow HOST1, HOST2
par:
 
self.member1=DB('database1',host=HOST1).query("SELECT...").getresult()
  seq:
self.member2=self.my_aux_func()
# some more processing here
 
self.member3=DB('database1',host=HOST2).query("SELECT...").getresult()
# other things here

I know, we have thread(s), but is not the same. Things
built in the language are faster, as they are
C-compiled rather than Python-interpreted. The syntax
is pretty simple and expressive. It simply gives, IMO,
more power to the programmer.

Is it worth for a PEP?

Regards,
Sorin Schwimmer

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python application ideas.

2006-04-25 Thread Edward Elliott
Thomas Bartkus wrote:
> Tis the conundrum of programming in general.  If all you know how to do is
> write code - then you truly have nothing to do.  What *other* interests do
> you have?  Hobbies? Job Skills?
> What *does* "blow your hair back" ;-)
> 
> That's where your programming ideas need to come from.

yeah, learning experiences only come from enjoyable tasks.  lord knows the
countless boring, uninspired assignments handed down in a cs degree program
teach absolutely nothing.  oh wait...

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


Re: Zope 3

2006-04-25 Thread Rene Pijlman
Steve Juranich:
>is there some big master diff, along the lines of "What's new
>in Python X.X" that I could look at to get an idea of what z3 has that 2.9
>(which I'm currently still cutting my teeth on) doesn't? 

It's a redesign.
Z2: mixin base classes
Z3: component architecture with interfaces

>Where are the Zope3 docs?

Google!

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


Re: I have problems with creating the classic game Wumpus. the file: http://esnips.com/webfolder/b71bfe95-d363-4dd3-bfad-39999a9e36d0

2006-04-25 Thread conny . ledin
the file is on that side. But apparently you have to register to
download it.. =(  But i can send it to anone who is willing to look
trough it. just send me an email [EMAIL PROTECTED]

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


Re: I have problems with creating the classic game Wumpus. the file: http://esnips.c

2006-04-25 Thread conny . ledin
the file is on that side. But apparently you have to register to
download it.. =(  But i can send it to anone who is willing to look
trough it. just send me an email [EMAIL PROTECTED]

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


Re: MinGW and Python

2006-04-25 Thread Edward Elliott
sturlamolden wrote:
> MinGW and Cygwin GCC is actually the same compiler. On Cygwin you can
> remove the dependency on the cygwin dll by compiling with -mno-cygwin.
> But as long as the cygwin dll is there, it creates an overhead for any
> system call. 

Thanks for that very informative post!  To clarify, mingw (aka gcc
-mno-cygwin) has no POSIX layer like cygwin.  Because your post could also
be (incorrectly) interpreted to mean mingw removes the cygwin dll
dependency by just linking it in statically.  But I googled and this is not
the case.

Back to the original point about whether mingw compilation is necessary
given the python compiles under cygwin: Yes, it is.  There can't be an
apples-to-apples comparison between gcc and msvc-compiled python with the
cygwin POSIX layer in the way.

Couldn't you compile the msvc-python code under gcc/mingw?  If the code
sticks to C standards, and mingw can link to native libs, it should work. 
The only problem is if python relies on some msvc-specific weirdness under
msvc.  While there's much weirdness in msvc, I would expect a
cross-platform app like python to stay away from it.


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


Re: Zope 3

2006-04-25 Thread [EMAIL PROTECTED]
I have been using ZOPE (mostly with CMF/Plone) for a couple years now.
MY recolleciton of the initial leraning curve, was hours reading
through source code, newsgroups, web site, outdated garbage, days long
marathons of coffee, beer and very little sleep.

After about 2 weeks of this horrible mindnumbing headache - the eureka
moment hit, and it has proven itself to be  a fairly robust application
server environment, and has really delivered for me in terms of being
able to quickle create web apps.

I would say though the question of Zope is not a question of
implementation language - it is it's own thing.  I think a lot of the
talk of adding typing to python has emerged from the Zope camp.  So the
question you should ask yourself, not do I want to use python or php -
it's more do I want to use Zope?  Zope is pretty well supported and
seems to have a good bit of momentum (compared to other python based
app servers)

My experince is that the learning curve is steep, and the path is
heavily littered with debris.  But, once the initial curve is passed -
the results seems almost magical (at least compared to other app server
environments I have worked with)

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


Re: Probability Problem

2006-04-25 Thread Tim Peters
[Elliot Temple]
> I think I got it. I noticed my code is essentially the same as Tim
> Peter's (plus the part of the problem he skipped). I read his code 20
> minutes before recreating mine from Alex's hints. Thanks!
>
> def main():
>  ways = ways_to_roll()
>  total_ways = float(101**10)
>  running_total = 0
>  for i in range(1000-390+1):
>  j = i + 390
>  running_total += ways[i] * ways[j]
>  print running_total / total_ways**2
>  print ways[:10]
>
> def ways_to_roll():
>  result = [1]
>  for i in xrange(10):
>  result = combine([1] * 101, result)
>  return result
>
> def combine(a, b):
>  results = [0] * (len(a) + len(b) - 1)
>  for i, ele in enumerate(a):
>  for j, ele2 in enumerate(b):
>  results[i+j] += ele * ele2
>  return results
>
> main()
> # output: 3.21962542309e-05 and
> # [1, 10, 55, 220, 715, 2002, 5005, 11440, 24310, 48620]
> # 3.21962542309e-05 is 32 out of a million

You should sanity-check the computation by generalizing it, then
applying it to a case so small you can easily work out the result via
exhaustive enumeration by hand.

For example, suppose you took integers from the much smaller set {0,
1}, and did that only twice.  Then the possible sums and their
probabilities are clearly:

   0  1/4
   1  1/2
   2  1/4

If you did this twice, what's the probability that the sums differ by
1?  Suitably generalized, your program above would compute 1/4.  Is
that actually right?  It depends on what exactly "the sums differ by
1" means.  If it means the second sum is one larger than the first
sum, 1/4 is correct.  Ditto if it means the second sum is one smaller
than the first sum.  But if it means 1 is the absolute value of the
difference of the sums, the right answer is 1/2.  I'm not sure which
meaning you have in mind, but the last one was my guess.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The whitespaceless frontend

2006-04-25 Thread Edward Elliott
[EMAIL PROTECTED] wrote:
> It's less explicit than self. but it's shorter, this improves typing,
> and allows to produce more compact code:
> 
> return "".join(["Graph(", repr($o), ", ", repr($nodeData), ")"])
> 
> Instead of:
> 
> return "".join(["Graph(", repr(self.o), ", ", repr(self.nodeData),
> ")"])


It also creates a special case.  Object attributes are generally accessed as
obj.foo, while $foo only works from within obj.  There are more tradeoffs
involved than just compactness and syntax gestalt.

If compactness is all you want, shorten self to s.  Personally I like 'me'
as it's both shorter and more vernacular:

def do_GET (me):
me.send_response (200, "ok")

As an added bonus, you get to channel Cookie Monster when you program. :)

c = Cookie ("good enough") # for me

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


Re: search an entire website given the homepage URL

2006-04-25 Thread Bell, Kevin
>use a search engine (try the search box in the upper right corner).

>using a spider to download the entire site just so you can "search
through >it" is bloody impolite.

Really?  I'd argue that's impolite only if you're an impolite person
with a rude agenda, which is not what I had in mind, but thanks for the
ethics lecture as well as the pointer ; )  I assure you that I harbor no
nefarious scheme.  Isn't it common for folks to watch the stock market,
or real estate listings, for example?

I'll look into to tools you mentioned, and thanks again!


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


Re: Tkinter: Dynamic entry widget

2006-04-25 Thread Fredrik Lundh
"Arne" wrote:

> I want to create entry widgets dynamically.
> var = ["one", "two", "three"]
> i=0
> for x in var:
> textbox = "t_", x
> textbox = entry(frame)
> textbox.grid(row=4+i, column=0)
> i = i + 1
> This works ok. On the window are the entries like I want.
>
> When I want to get to entered data from the entry widget. I am not able to
> get them.
> The statement: t_one.get()
> dosent work. I am getting an error message that t_one is not global defined.

there's no t_one variable in your program.  assigning some stuff to
a variable doesn't create a variable with that name (if your python
tutorial told you that you could do that, make sure you get your
money back).

the usual way to store a list of values (widgets) is to use a list:

var = []
for x in range(3):
textbox = entry(frame)
textbox.grid(row=4+i, column=0)
var.append(textbox)

print var[0].get() # returns the content of the first textbox
print var[1].get() # same, for the second textbox
print var[2].get() # same, for the third textbox





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


Re: I have problems with creating the classic game Wumpus. the file: http://esnips.c

2006-04-25 Thread [EMAIL PROTECTED]

connyledin wrote:
> Im trying to create a version of the game Wumpus. Mine is called
> Belzebub. But im STUCK! And its due tuesday 2 maj. Im panicing! Can
> some one help me??
> here is the file:
> http://esnips.com/webfolder/b71bfe95-d363-4dd3-bfad-3a9e36d0
>
> What i have the biggest problems with now is between line 8 and 23.
> How i can move the character trough the game. Other parts of the game
> that have with the movement to do is between line 83-114 and 123-143.
>
> This is part of the spec:
> "The player walks around in the hallways, finds and tries to kill
> Wumpus (Belzebub). The game finishes when the player or Belzebub dies.
>  The player has bombs which he can shoot. When he shoots he can
> controll th ebombs for three moves, north, south, east or west three
> times. If he is not careful he can shoot himself, ex first move:
> north. second move south.
>  Let every room be represented by the object room. In the object,
> information of what exists in the room is stored. (Belzebub,
> teleporters, fire traps, acid traps or nothing). and where the
> halways leads. (north hallway leads to room 17, the east to room 2
> etc.). Create a list of room objects to represent the hallways (every
> room have has a number).
>  The content of the rooms shall be randomized in the beginning of
> the program. Aproximatly 20% of the rooms should contain traps, 30%
> should contain teleporters and in one of the rooms is Belzebub. One
> room can not contain more than one danger, no traps and teleporters
> together etc.
>  Teleporters transports the player from one room to another
> random room. If the player encounters a trap o Belzebub he is killed
> and GAME OVER.
>  The halways should also be randomized in the beginning of the
> program. Like this:
>
> * Create a list with all the room numbers and shuffle it so all of
> the rooms is in a mixed order. ex. [5 2 12 18 9 1 3 6 14 19 11 7 17 4
> 20 16 10 15 8 13]
>
> * Connect the rooms in east-west direction so that the east hallway
> from room 5 leads to room 2 and the west hallway from room to leads
> back to room 5 etc. The last room in the lest should be connected
> with the first.
>
> * Shuffle a new list and do the same thing in north-south direction.
>
> Once again the file: http://esnips.com/webfolder/b71bfe95-d363-4dd3-
> bfad-3a9e36d0

Once again, that's not a file. And enclose your URLs in <>, that way
Google won't split them.

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


  1   2   3   >