RE: Scraping a web page

2009-04-08 Thread Lawrence D'Oliveiro
In message , Support Desk wrote: > You could do something like below to get the rendered page. > > Import os > site = 'website.com' > X = os.popen('lynx --dump %s' % site).readlines() I wonder how easy it would be to get the page image in SVG format? I believe the Gecko HTML engine in Firefox

Re: Injecting python function in an embedded python engine

2009-04-08 Thread prakash jp
import os ch = os.system("import -window root temp.png") print ch after that no way to store the screen shot regards Prakash On Mon, Apr 6, 2009 at 10:28 PM, Roberto Fichera wrote: > Hi All in the list, > > I've embedded python v2.6.x engine into my application without any problem. > Now I woul

TypeError: object cannot be interpreted as an index

2009-04-08 Thread tleeuwenb...@gmail.com
It started with this error message... "TypeError: object cannot be used as an index" foo = {} someObject = someClass() foo[someObject] = "hello" Obviously, there are some known reasons why objects may not be indexes, such as if they are not hashable (as in the case of lists). However, I'm not get

Re: Q: "Best" book for teaching

2009-04-08 Thread John Yeung
On Apr 6, 10:37 am, grkunt...@gmail.com wrote: > I am considering teaching an "introduction to programming" > course for continuing education adults at a local community > college. These would people with no programming experience, > but I will require a reasonable facility with computers. > > What

Help with setting up Tkinter

2009-04-08 Thread Eclipse
>>> import _tkinter >>> import Tkinter >>> Tkinter._test >>> -- http://mail.python.org/mailman/listinfo/python-list

Help with setting up Tkinter

2009-04-08 Thread Eclipse
G'day All I was following the instructions (listed at bottom of post) from the PythonInfo Wiki which says to run three tests. I ran the tests and test 1 and 2 worked Test 3 gave me an error - can anyone help ??? Tks in advance Pete >>> import _tkinter >>> import Tkinter >>> Tkinter._test >

Re: Help with setting up Tkinter

2009-04-08 Thread Chris Rebert
On Wed, Apr 8, 2009 at 1:15 AM, Eclipse wrote: import _tkinter import Tkinter Tkinter._test > That last input line should be: Tkinter._test() Note the parens, which do matter (Python != Ruby/Smalltalk). Try again and see if you get an actual error. Cheers, Chris -- I have a b

Re: Help with setting up Tkinter

2009-04-08 Thread koranthala
On Apr 8, 1:20 pm, Eclipse wrote: > G'day All > > I was following the instructions (listed at bottom of post) from the > PythonInfo Wiki which says to run three tests. > > I ran the tests and test 1 and 2 worked > > Test 3 gave me an error - > > can anyone help ??? > > Tks in advance > > Pete > >

Re: more fun with iterators (mux, demux)

2009-04-08 Thread pataphor
On 07 Apr 2009 02:05:59 GMT Steven D'Aprano wrote: > The demuxer can't be an iterator, since it needs to run through the > entire collection. Then your demuxer obviously cannot handle infinite sequences. > def demux(it, n): > collectors = [[] for i in xrange(n)] > i = 0 > for item

Re: TypeError: object cannot be interpreted as an index

2009-04-08 Thread Peter Otten
tleeuwenb...@gmail.com wrote: > It started with this error message... "TypeError: object cannot be > used as an index" > > foo = {} > someObject = someClass() > foo[someObject] = "hello" "interpreted" or "used"? If the former, 'foo' may be a list rather than a dict, and someClass a classic cla

Why does Python show the whole array?

2009-04-08 Thread Gilles Ganault
Hello I'd like to go through a list of e-mail addresses, and extract those that belong to well-known ISP's. For some reason I can't figure out, Python shows the whole list instead of just e-mails that match: === script test = "t...@gmail.com" isp = ["gmail.com", "yahoo.com"] for item in isp:

Re: Why does Python show the whole array?

2009-04-08 Thread Ulrich Eckhardt
Gilles Ganault wrote: > test = "t...@gmail.com" > isp = ["gmail.com", "yahoo.com"] > for item in isp: > if test.find(item): > print item > === output > gmail.com > yahoo.com > === > > Any idea why I'm also getting "yahoo.com"? find() returns the index where it is found or -1 if it is not

Re: Why does Python show the whole array?

2009-04-08 Thread Albert Hopkins
On Wed, 2009-04-08 at 12:01 +0200, Peter Otten wrote: > Gilles Ganault wrote: > > > I'd like to go through a list of e-mail addresses, and extract those > > that belong to well-known ISP's. For some reason I can't figure out, > > Python shows the whole list instead of just e-mails that match: > >

Re: Why does Python show the whole array?

2009-04-08 Thread Ben Finney
Gilles Ganault writes: > I'd like to go through a list of e-mail addresses, and extract those > that belong to well-known ISP's. For some reason I can't figure out, > Python shows the whole list instead of just e-mails that match: > > === script > test = "t...@gmail.com" > isp = ["gmail.com"

Re: How to go about. On read/write locks

2009-04-08 Thread Piet van Oostrum
> Carl Banks (CB) wrote: >CB> On Apr 6, 2:23 pm, "Diez B. Roggisch" wrote: >>> > This is a classical synchronization problem with a classical solution: >>> > You treat the readers as a group, and the writers individually. So you >>> > have a write lock that each writer has to acquire and rel

Re: Why does Python show the whole array?

2009-04-08 Thread Dave Angel
Gilles Ganault wrote: Hello I'd like to go through a list of e-mail addresses, and extract those that belong to well-known ISP's. For some reason I can't figure out, Python shows the whole list instead of just e-mails that match: === script test = "t...@gmail.com" isp = ["gmail.com", "yah

Re: Why does Python show the whole array?

2009-04-08 Thread Qilong Ren
Remeber the return value of find function of a string is -1 when it fails, which is True. Try: for item in isp: if item in test: print item From: Gilles Ganault Date: April 8, 2009 5:56:34 PM CST To: python-list@python.org Subject: Why does Python show the whole array?

Re: Q: "Best" book for teaching

2009-04-08 Thread Lawrence D'Oliveiro
In message <8e3d0032-5e9f-44c2-9380-1d2383552...@u5g2000vbc.googlegroups.com>, grkunt...@gmail.com wrote: > I am considering teaching an "introduction to programming" course for > continuing education adults at a local community college. These would > people with no programming experience, but

Re: Why does Python show the whole array?

2009-04-08 Thread Peter Otten
Gilles Ganault wrote: > I'd like to go through a list of e-mail addresses, and extract those > that belong to well-known ISP's. For some reason I can't figure out, > Python shows the whole list instead of just e-mails that match: > > === script > test = "t...@gmail.com" > isp = ["gmail.com",

Re: TypeError: object cannot be interpreted as an index

2009-04-08 Thread Piet van Oostrum
> "tleeuwenb...@gmail.com" (tc) wrote: >tc> What, exactly, needs to be in place for an object to be a valid >tc> dictionary key? It must have __hash__ and __cmp__ or __eq__ methods. Newstyle classes inherit these from object. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142B

Re: List of paths

2009-04-08 Thread Nico Grubert
> Here's a tricky case that doesn't show up in your example: > In each case above, the directory names are distinct. > how about: >['/desk', '/desk/ethanallen', '/desk/ikea', > '/desktop', /desktop/pc', '/desktop/mac'] >Should the answer be ['/desk'] or ['/desk', '/desktop'] ? Hi Scott good po

Re: Why does Python show the whole array?

2009-04-08 Thread Gilles Ganault
On Wed, 08 Apr 2009 12:11:55 +0200, Ulrich Eckhardt wrote: >find() returns the index where it is found or -1 if it is not found. Both an >index>0 or a -1 evaluate to True when used as conditional expression. Thanks everyone. I shouldn't have assumed that "if test.find(item):" was necessarily enou

Python-URL! - weekly Python news and links (Apr 8)

2009-04-08 Thread Gabriel Genellina
QOTW: "Those who show promise can advance to our Winter Improve Python to Expert program, for an additional fee, and, be given expert tutoring to help you gain our exemplary A.R.S.E./W.I.P.E certification which is guaranteed to attract certain types of employers by its name alone." - Paddy3118

Re: Why does Python show the whole array?

2009-04-08 Thread andrew cooke
Gilles Ganault wrote: > On Wed, 08 Apr 2009 12:11:55 +0200, Ulrich Eckhardt > wrote: >>find() returns the index where it is found or -1 if it is not found. Both >> an >>index>0 or a -1 evaluate to True when used as conditional expression. > > Thanks everyone. I shouldn't have assumed that "if test

Re: named pipe and Linux

2009-04-08 Thread bobicanprogram
On Apr 7, 1:08 pm, akineko wrote: > Hello everyone, > > I'm trying to use named pipes to fuse a Python program and a C > program. > One side creates pipes using os.mkfifo() and both sides use the same > named pipes (one side reads, another side writes). The read side uses > select.select() to wait

Re: Some test fail on my new Python 2.6

2009-04-08 Thread R. David Murray
Sorin Schwimmer wrote: > > I wanted to replace my old Python 2.4 and tcl/tk 8.4 with tcl/tk 8.5.6 and > Python 2.6, mainly so that I can enjoy ttk. tcl/tk was installed from sources > without any problem, I started a wish and worked. > > Now, for the Python, here are all the issues signaled by

genetic algorithms in Python?

2009-04-08 Thread Esmail
Hello, Anyone using Python for coding up genetic algorithms? If so, would you share your favorite modules/libraries/tools? Thanks, Esmail -- http://mail.python.org/mailman/listinfo/python-list

Re: Adding method to class at run-time: bad style?

2009-04-08 Thread Grant Edwards
On 2009-04-08, Gabriel Genellina wrote: >>> ClientForm.Control = FancyControl >>> ClientForm.CheckboxControl = FancyCheckboxControl >> >> That would work -- but there are probably 8 or 10 different >> Control subclasses. It's a bit tedious mixing them all one at a >> time, and you need

Re: Adding method to class at run-time: bad style?

2009-04-08 Thread Grant Edwards
On 2009-04-08, Gabriel Genellina wrote: >>> class Mixin: # or class Mixin(object) if new-style: >>> def __eq__(self, other): >>> return (self.type == other.type ... >>> def __ne__(self, other): >>> return not self.__eq__(other) >>> class Fanc

Re: Returning different types based on input parameters

2009-04-08 Thread George Sakkis
On Apr 7, 3:18 pm, Adam Olsen wrote: > On Apr 6, 3:02 pm, George Sakkis wrote: > > > For example, it is common for a function f(x) to expect x to be simply > > iterable, without caring of its exact type. Is it ok though for f to > > return a list for some types/values of x, a tuple for others an

Re: SoHo Book Problem

2009-04-08 Thread David C. Ullrich
Never mind (at least tentatively). Later in the day I got an email from the publisher, saying they're going to send me a corrected copy "free". Evidently if you get a bad copy you don't have to complain to the publisher or the retailer, you just have to post a complaint somewhere where Google can

Re: more fun with iterators (mux, demux)

2009-04-08 Thread Neal Becker
pataphor wrote: > On 07 Apr 2009 02:05:59 GMT > Steven D'Aprano wrote: > >> The demuxer can't be an iterator, since it needs to run through the >> entire collection. > > Then your demuxer obviously cannot handle infinite sequences. > >> def demux(it, n): >> collectors = [[] for i in xrang

Simple CGI request and Python reply

2009-04-08 Thread Greg Corradini
Hello, I'm trying to implement something very simple without using a Python WebFramework and I need some advice. I want to send a comma delimited string from the client to a server-side Python script. My initial plan was to use a JavaScript function (see below) called "makerequest" that creates a

Re: CGIXMLRPCRequestHandler example

2009-04-08 Thread O.R.Senthil Kumaran
On Apr 5, 12:24 pm, a...@pythoncraft.com (Aahz) wrote: > [posted & e-mailed, please respond on-group] There was some problem with the CGIXMLRPCRequestHandler code in the SimpleXMLRPC Server. It was not getting the length to read from the CONTENT_LENGTH environement variable ( as it the CGI server

Re: genetic algorithms in Python?

2009-04-08 Thread Mohammed Mediani
I have done something in this direction. I will be happy to share my experience. However, my code is not generic and needs many things to be manually introduced. My GA is standard (selection by roulette wheel or tournament, single point cross). Let me know if you are interested! On Wed, Apr 8, 200

Re: Some test fail on my new Python 2.6

2009-04-08 Thread Sorin Schwimmer
Thanks for the pointers. Here are some answers: > Ok, so DBM wasn't built because it couldn't find the external symbol > 'dbm_firstkey'. I have no idea off the top of my head why that would > happen, but I don't think you really care at the moment since you are > trying to get tkinter working.

Re: Scraping a web page

2009-04-08 Thread Iain King
On Apr 7, 1:44 pm, Tim Chase wrote: > > f = urllib.urlopen("http://www.google.com";) > > s = f.read() > > > It is working, but it's returning the source of the page. Is there anyway I > > can get almost a screen capture of the page? > > This is the job of a browser -- to render the source HTML.  A

Python 3.0 online docs broken

2009-04-08 Thread Jim Garrison
Jim Garrison wrote: Ye Liu wrote: On Apr 6, 6:33 pm, Jim Garrison wrote: I notice the online docs (at docs.python.org/3.0/index.html) were updated today. It seems some of the top-level pages, like Tutorial, "Using Python", "Language Reference" are truncated after the first few paragraphs. Y

Re: genetic algorithms in Python??

2009-04-08 Thread Esmail
Hello Mohammed, Yes, that would great. While I am comfortable with GAs, I'm still rather inexperienced with Python so seeing some implementation examples would be very useful. Thanks, Esmail -- Date: Wed, 8 Apr 2009 17:08:48 +0200 Subject: Re: genetic algorithms in Python? From: medmedi...@gma

how to get back an object from its id() value

2009-04-08 Thread TP
Hi everybody, I have a data structure (a tree) that has one constraint: I can only store strings in this data structure. To know if an object foo already exists in memory, I store "str(id(foo))" in the data structure. OK. But how do I get a usable reference from the id value? For example, if "fo

How to ignore white space changes using difflib?

2009-04-08 Thread Grant Edwards
I'm trying to use difflib to compare strings ignoring changes to white-space (space/tab). According to the doc page, you can do this by specifying a "charjunk" parameter to filter out characters: charjunk: A function that accepts a character (a string of length 1), and returns if the charac

Floor value in math operators

2009-04-08 Thread Avi
Hi, This will be a very simple question to ask all the awesome programmers here: How can I get answer in in decimals for such a math operator: 3/2 I get 1. I want to get 1.5 Thanks in advance, Avi -- http://mail.python.org/mailman/listinfo/python-list

Re: Floor value in math operators

2009-04-08 Thread Chris Rebert
On Wed, Apr 8, 2009 at 9:03 AM, Avi wrote: > Hi, > > This will be a very simple question to ask all the awesome programmers > here: > > How can I get answer in in decimals for such a math operator: > > 3/2 > > I get 1. I want to get 1.5 Add the following line to the top of your program (or use Py

Re: how to get back an object from its id() value

2009-04-08 Thread CTO
> But how do I get a usable reference from the id value? > For example, if "foo" has a method "bar()", how can I call "foo.bar()" > from "str(id(foo))" (say, 149466208). can you just use a weakref instead? It is certainly cleaner than trying to store id's, since an id is only guaranteed to be uniq

Re: how to get back an object from its id() value

2009-04-08 Thread MRAB
TP wrote: Hi everybody, I have a data structure (a tree) that has one constraint: I can only store strings in this data structure. To know if an object foo already exists in memory, I store "str(id(foo))" in the data structure. OK. But how do I get a usable reference from the id value? For exa

Re: how to get back an object from its id() value

2009-04-08 Thread Gary Herron
TP wrote: Hi everybody, I have a data structure (a tree) that has one constraint: I can only store strings in this data structure. To know if an object foo already exists in memory, I store "str(id(foo))" in the data structure. OK. But how do I get a usable reference from the id value? For exa

Re: How to ignore white space changes using difflib?

2009-04-08 Thread Grant Edwards
On 2009-04-08, Grant Edwards wrote: > I'm trying to use difflib to compare strings ignoring changes > to white-space (space/tab). According to the doc page, you > can do this by specifying a "charjunk" parameter to filter out > characters: > >charjunk: A function that accepts a character (a

Re: Floor value in math operators

2009-04-08 Thread Diez B. Roggisch
Avi wrote: > Hi, > > This will be a very simple question to ask all the awesome programmers > here: > > How can I get answer in in decimals for such a math operator: > > 3/2 > > I get 1. I want to get 1.5 You don't say which python-version you have. Depending on that, the answer is different.

Re: how to get back an object from its id() value

2009-04-08 Thread CTO
> You could create a dict with the string as the key and the object as the > value. This will create a strong reference to the object, which is (I'm assuming) undesired behavior. -- http://mail.python.org/mailman/listinfo/python-list

Re: genetic algorithms in Python??

2009-04-08 Thread R. David Murray
Esmail wrote: > Hello Mohammed, > > Yes, that would great. While I am comfortable with GAs, > I'm still rather inexperienced with Python so seeing some > implementation examples would be very useful. A google for 'python genetic algorithms' turns up a number of interesting hits. I also remember

Re: Python 3.0 online docs broken

2009-04-08 Thread Hendrik van Rooyen
"Jim Garrison" > Jim Garrison wrote: > > Ye Liu wrote: > >> On Apr 6, 6:33 pm, Jim Garrison wrote: > >>> I notice the online docs (at docs.python.org/3.0/index.html) were > >>> updated today. It seems some of the top-level pages, like > >>> Tutorial, "Using Python", "Language Reference" are tru

Re: how to get back an object from its id() value

2009-04-08 Thread TP
MRAB wrote: > You could create a dict with the string as the key and the object as the > value. Thanks. But it implies an additional data structure: a dictionnary. I don't know what is the best: * using an additional dict and maintaining it * or using the "di" module proposed by CTO If "di" is r

Re: Floor value in math operators

2009-04-08 Thread Diez B. Roggisch
> > In python2.6 and 3.x, the new behavior is standard. Apparently that is nonsense - it seems to be not standard for 2.6. Which Makes sense I guess. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: how to get back an object from its id() value

2009-04-08 Thread CTO
> I don't know what is the best: > * using an additional dict and maintaining it It works, but as you say, is somewhat inelegant. > * or using the "di" module proposed by CTO Let me be clear: I am not proposing that you use it. It *does* do what you ask- but what you are asking is, all by itself

asynchronous python call

2009-04-08 Thread joeygartin
Complete newbie, so forgive my improper use of Python terminology. I am working with Django and I have to send off a number of emails after a person has filled out a form. What I want is to make a call that goes off to form and send the emails and redirect the user to another view. I have this w

Re: Python syntax

2009-04-08 Thread Mensanator
On Apr 7, 11:39 pm, Lawrence D'Oliveiro wrote: > In message , Steve > > Holden wrote: > > Lawrence D'Oliveiro wrote: > > >> In message <7dd228af- > >> e549-444d-8623-11e951851...@y9g2000yqg.googlegroups.com>, janus99 wrote: > > >>> I messed around with my own comp (windos xp) command prompt ... >

Re: how to get back an object from its id() value

2009-04-08 Thread CTO
Correction: the UserString will be dead on the final line. When I typed it in I had a strong reference still hanging around. -- http://mail.python.org/mailman/listinfo/python-list

Re: 3D plotting in a GUI

2009-04-08 Thread Baris Demir
Stef Mientki wrote: Baris Demir wrote: Hi all, I need to develop a GUI for some scientific data processing operations and this GUI should work well with a 3D plotting module, also with NumPy and SciPy for sure. I made a search about packages but, there are plenty of these modules available.

Re: Floor value in math operators

2009-04-08 Thread David Smith
Avi wrote: > Hi, > > This will be a very simple question to ask all the awesome programmers > here: > > How can I get answer in in decimals for such a math operator: > > 3/2 > > I get 1. I want to get 1.5 > > Thanks in advance, > Avi I'm going to assume your operands are variables instead of

Re: Some test fail on my new Python 2.6

2009-04-08 Thread R. David Murray
Sorin Schwimmer wrote: > > Thanks for the pointers. > > Here are some answers: > > > Ok, so DBM wasn't built because it couldn't find the external symbol > > 'dbm_firstkey'. I have no idea off the top of my head why that would > > happen, but I don't think you really care at the moment since y

Re: How to ignore white space changes using difflib?

2009-04-08 Thread Duncan Booth
Grant Edwards wrote: > Apparently that "filtering out" characters doesn't mean that > they're ignored when doing the comparison. (A bit of a "WTF?" > if you ask me). After some more googling, it appears that I'm > far from the first person who interpreted "filtered out" as > "ignored when compa

Re: more fun with iterators (mux, demux)

2009-04-08 Thread pataphor
On Wed, 08 Apr 2009 10:51:19 -0400 Neal Becker wrote: > What was wrong with this one? > > def demux(iterable, n): > return tuple(islice(it, i, None, n) for (i, it) in > enumerate(tee(iterable, n))) Nothing much, I only noticed after posting that this one handles infinite sequences too. For

Re: 3D plotting in a GUI

2009-04-08 Thread Stef Mientki
Baris Demir wrote: Stef Mientki wrote: Baris Demir wrote: Hi all, I need to develop a GUI for some scientific data processing operations and this GUI should work well with a 3D plotting module, also with NumPy and SciPy for sure. I made a search about packages but, there are plenty of these

Re: how to get back an object from its id() value

2009-04-08 Thread Christian Heimes
TP wrote: > If "di" is reliable, it seems a good solution for my initial constraint > which is the impossibility to store anything but strings in my data > structure. 'di' is dangerous and not reliable. When the original object is freed, then the memory address may be used by another Python object

Re: asynchronous python call

2009-04-08 Thread Tino Wildenhain
Hi, joeygartin wrote: Complete newbie, so forgive my improper use of Python terminology. I am working with Django and I have to send off a number of emails after a person has filled out a form. What I want is to make a call that goes off to form and send the emails and redirect the user to ano

Re: Module caching

2009-04-08 Thread Aaron Scott
> Anyway, this person also posted on mod_python list. One of the things > I highlighted there was that mod_python for some configurations is > multithreaded and as such they may not be properly protecting > variables if they are storing them at global scope. They haven't > responded to any comments

Re: Q: "Best" book for teaching

2009-04-08 Thread Joel Koltner
"Lawrence D'Oliveiro" wrote in message news:grhq75$eb...@lust.ihug.co.nz... > I thought that a good introduction might be to show them how HTML works, and > progress from there to embedding little bits of JavaScript. > > Nothing to do with Python I know, but might be a possibility. If you want t

Computed attribute names

2009-04-08 Thread Dale Amon
There are a number of things which I have been used to doing in other OO languages which I have not yet figured out how to do in Python, the most important of which is passing method names as args and inserting them into method calls. Here are two cases I have been trying to figure out for a curren

Re: Computed attribute names

2009-04-08 Thread Albert Hopkins
On Wed, 2009-04-08 at 19:47 +0100, Dale Amon wrote: > There are a number of things which I have been used > to doing in other OO languages which I have not yet > figured out how to do in Python, the most important > of which is passing method names as args and inserting > them into method calls. He

Re: Computed attribute names

2009-04-08 Thread paul
Dale Amon schrieb: There are a number of things which I have been used to doing in other OO languages which I have not yet figured out how to do in Python, the most important of which is passing method names as args and inserting them into method calls. Here are two cases I have been trying to fi

Re: Computed attribute names

2009-04-08 Thread Dale Amon
On Wed, Apr 08, 2009 at 09:03:00PM +0200, paul wrote: > I'd say you can use: Thanks. I could hardly ask for a faster response on a HowTo than this! signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Q: "Best" book for teaching

2009-04-08 Thread tkp...@hotmail.com
I taught myself Python from Python Programming for the Absolute Beginner by Michael Dawson (which has been mentioned above) and with lots of help from the friendly members of this group, but there's now a free e-book titled Snake Wrangling for Kids by Jason Briggs. You can view it at http://www.bri

Re: Painful?: Using the ast module for metaprogramming

2009-04-08 Thread Martin v. Löwis
> I see how it avoids needing to look at the parent node in general, but > if we were compiling by recursively descending through the AST, then > we would know whether Name's would be loads or stores by the time we > got to them (we would already had to have visited an encompassing > assignment or

Testing the new version of Psyco

2009-04-08 Thread Baz Walter
hello i recently tried out this new version of psyco... http://www.voidspace.org.uk/python/weblog/arch_d7_2009_03_14.shtml#e1063 ...because of the new support for generators. the above link says "To use and test generators, create preferences.py, following the instructions in setup.py" - exce

Re: asynchronous python call

2009-04-08 Thread Aahz
In article <637028a0-58b9-4912-896d-2b17e1341...@q16g2000yqg.googlegroups.com>, joeygartin wrote: > >I am working with Django and I have to send off a number of emails >after a person has filled out a form. What I want is to make a call >that goes off to form and send the emails and redirect the

Re: Python 3.0 online docs broken

2009-04-08 Thread Benjamin Kaplan
On Wed, Apr 8, 2009 at 11:28 AM, Jim Garrison wrote: > Jim Garrison wrote: > >> Ye Liu wrote: >> >>> On Apr 6, 6:33 pm, Jim Garrison wrote: >>> I notice the online docs (at docs.python.org/3.0/index.html) were updated today. It seems some of the top-level pages, like Tutorial, "U

Re: named pipe and Linux

2009-04-08 Thread Thomas Bellman
Cameron Simpson wrote: > On 07Apr2009 10:08, akineko wrote: >| I'm trying to use named pipes to fuse a Python program and a C >| program. >| One side creates pipes using os.mkfifo() and both sides use the same >| named pipes (one side reads, another side writes). The read side uses >| select.sel

Re: Some test fail on my new Python 2.6

2009-04-08 Thread Sorin Schwimmer
Hello again, /usr/local/lib is in /etc/ld.so.conf. The files are real. However, creating symlinks in /usr/lib targeting the libraries in /usr/local/lib, then recompiling, solved the tkinter problem. So, the conclusion is that only /usr/lib is consulted for the tcl/tk libraries. multiprocessing -

Re: Q: "Best" book for teaching

2009-04-08 Thread JBW
On Mon, 06 Apr 2009 07:37:19 -0700, grkuntzmd wrote: > What would be a good book to use as the text for the course? "Python Programming: An Introduction to Computer Science" Franklin, Beedle & Associates, by little Johny Zelle. Accept no substitues! Jim -- http://mail.python.org/mailman/listinf

Re: extract Infobox contents

2009-04-08 Thread J. Cliff Dyer
On Wed, 2009-04-08 at 01:57 +0100, Rhodri James wrote: > On Tue, 07 Apr 2009 12:46:18 +0100, J. Clifford Dyer > wrote: > > > On Mon, 2009-04-06 at 23:41 +0100, Rhodri James wrote: > >> On Mon, 06 Apr 2009 23:12:14 +0100, Anish Chapagain > >> wrote: > >> > >> > Hi, > >> > I was trying to extrac

"str object is not callable" error

2009-04-08 Thread venkat sanaka
HIi everyone. i was using python/c api to call a python function from c and I know the name of the function which i want to call.Is there any way to do that?? This is the method i tried... for eg:This is the python function i wants to call. >>>def add(x): ... return x+10 This is my code i

Re: more fun with iterators (mux, demux)

2009-04-08 Thread Miles
On Wed, Apr 8, 2009 at 1:21 PM, pataphor wrote: > On Wed, 08 Apr 2009 10:51:19 -0400 Neal Becker wrote: > >> What was wrong with this one? >> >> def demux(iterable, n): >>     return tuple(islice(it, i, None, n) for (i, it) in >> enumerate(tee(iterable, n))) > > Nothing much, I only noticed after p

nested looping

2009-04-08 Thread PK
So I'm trying to see whats the cleanest way to do this: I have a checklist = [ax, bx, by, cy ..] (a combination of a,b,c with x and y, either both on one) allist = [a,b,c,] xlist = [x, y, ..] now I wanna loop through alist and xlist and see if the combination exists in checklist so someth

Character strings / Python 3.0 C API

2009-04-08 Thread rch . astra
Hi everybody, I'm doing some experiments with the python 3.0 C API, and I'm having some problems for obtaining character strings. In python 2.X APIs, a function called PyString_AsString was available. This function provided a C string (char*) given a PyObject. But, in python 3.0 API there is no su

Re: genetic algorithms in Python?

2009-04-08 Thread Terry Reedy
Esmail wrote: Hello, Anyone using Python for coding up genetic algorithms? If so, would you share your favorite modules/libraries/tools? Search 'Python genetic algorithm' on Google or elsewhere. -- http://mail.python.org/mailman/listinfo/python-list

Re: genetic algorithms in Python??

2009-04-08 Thread Esmail
R. David Murray wrote: Esmail wrote: Hello Mohammed, Yes, that would great. While I am comfortable with GAs, I'm still rather inexperienced with Python so seeing some implementation examples would be very useful. A google for 'python genetic algorithms' turns up a number of interesting hits.

Re: genetic algorithms in Python?

2009-04-08 Thread Esmail
Terry Reedy wrote: Esmail wrote: Hello, Anyone using Python for coding up genetic algorithms? If so, would you share your favorite modules/libraries/tools? Search 'Python genetic algorithm' on Google or elsewhere. Hi Terry, I did that first, and I came up with a number of hits. The "proble

Re: Character strings / Python 3.0 C API

2009-04-08 Thread Martin v. Löwis
> PyObject* key = PyList_GetItem(moduleKeys,idx); > PyObject* module = PyDict_GetItem( interp->modules, key ); > char* theKeyName = > PySys_WriteStdout("Module '%s'\n", theKeyName); > } > I was not able to obtain theKeyName, knowing that the "key" PyObject > is

Re: nested looping

2009-04-08 Thread Terry Reedy
PK wrote: So I'm trying to see whats the cleanest way to do this: I have a checklist = [ax, bx, by, cy ..] (a combination of a,b,c with x and y, either both on one) Since you will be repeatedly looking for items in checklist, I suggest making it a set instead. allist = [a,b,c,] xlist

Re: more fun with iterators (mux, demux)

2009-04-08 Thread Raymond Hettinger
[Miles] > I assume that "smallish values of n" refers to the fact that > itertools.tee places items into every generator's internal deque, > which islice then skips over, whereas your version places items only > into the deque of the generator that needs it. The pure python equivalent listed in th

Re: Character strings / Python 3.0 C API

2009-04-08 Thread rch . astra
Sorry but it did not help... I tried this: PyObject* key = PyList_GetItem(moduleKeys,idx); char* theKeyName = PyUnicode_AsUTF8String( key ); And this, just in case: PyObject* key = PyList_GetItem(moduleKeys,idx); char* theKeyName = PyUnicode_AsUTF8String( PyObject

Re: Character strings / Python 3.0 C API

2009-04-08 Thread Martin v. Löwis
> The issue is that all PyUnicode* functions are returning PyObjects. > PyString_AsString return value was char*. Is there any real equivalent > of this function? Ah, right. PyString_AsUTF8String returns a bytes object, to which you need to apply PyBytes_AsString to. At the end, you need to decref

Re: nested looping

2009-04-08 Thread Matimus
On Apr 8, 2:15 pm, PK wrote: > So I'm trying to see whats the cleanest way to do this: > > I have a > > checklist = [ax, bx, by, cy  ..] (a combination of a,b,c with x and y, > either both on one) > > allist = [a,b,c,] > xlist = [x, y, ..] > > now I wanna loop through alist and xlist and see i

Re: Character strings / Python 3.0 C API

2009-04-08 Thread rch . astra
Thank you very much for your help Martin, now I got it. Cheers, RC On 9 abr, 00:05, "Martin v. Löwis" wrote: > > The issue is that all PyUnicode* functions are returning PyObjects. > > PyString_AsString return value was char*. Is there any real equivalent > > of this function? > > Ah, right. Py

Decompression with zlib

2009-04-08 Thread Emma Li
Hello, I'm trying to do compression/decompression of stuff with zlib, and I just don't get it... Here is an example. I assume that dec should be "a", but it isn't. dec turns out to be an empty string, and I don't understand why... === import zlib compressor = zlib.compressob

Re: nested looping

2009-04-08 Thread Luis Alberto Zarrabeitia Gomez
Quoting PK : > So I'm trying to see whats the cleanest way to do this: > > I have a > > checklist = [ax, bx, by, cy ..] (a combination of a,b,c with x and y, > either both on one) > > allist = [a,b,c,] > xlist = [x, y, ..] > [...] > now the problem is I want to include alpha in missing l

Re: Q: "Best" book for teaching

2009-04-08 Thread Lawrence D'Oliveiro
In message <756dl.102831$ur4.35...@en-nntp-09.dc1.easynews.com>, Joel Koltner wrote: > If you want to emphasize web usage, I'd be tempted to show them a bit of > HTML and then introduce them to CGI-bin scripts... written in Python. Yes, and show them how to watch /var/log/apache2/error.log to fi

Re: nested looping

2009-04-08 Thread PK
Excellent! Thanks all. Since I need to have this running on python 2.4 as well, I think I'll choose, for alpha in alist: for xy in xlist: if alpha+xy in checklist: break else: missing.append(alpha) jus tested and worked like a charm. Appreciate your help!! On W

Re: TypeError: object cannot be interpreted as an index

2009-04-08 Thread TennesseeLeeuwenburg
On Apr 8, 8:44 pm, Piet van Oostrum wrote: > > "tleeuwenb...@gmail.com" (tc) wrote: > >tc> What, exactly, needs to be in place for an object to be a valid > >tc> dictionary key? > > It must have __hash__ and __cmp__ or __eq__ methods. Newstyle classes > inherit these from object. > -- > Piet

Re: Decompression with zlib

2009-04-08 Thread Albert Hopkins
On Wed, 2009-04-08 at 23:51 +0200, Emma Li wrote: > Hello, > > I'm trying to do compression/decompression of stuff with zlib, and I > just don't get it... > Here is an example. I assume that dec should be "a", but it isn't. dec > turns out to be an empty string, and I don't understand why... >

  1   2   >