Re: itertools.groupby

2007-05-27 Thread Paul Rubin
Raymond Hettinger <[EMAIL PROTECTED]> writes: > On May 27, 8:28 pm, Paul Rubin wrote: > > I use the module all the time now and it is great. > Thanks for the accolades and the great example. Thank YOU for the great module ;). Feel free to use the example in the docs i

Re: What's the best way to iniatilize a function

2007-05-27 Thread Jack
Thanks Steven, for the reply. Very helpful. I've got a lot to learn in Python :) Some questions: > (1) Python can automatically free most data structures and close open > files, but if your needs are more sophisticated, this approach may not be > suitable. Since it's a wrapper of a DLL or .so f

gui application on cross platform

2007-05-27 Thread james_027
Hi, I am using delphi to develop gui application, and wish to make a shift to python. here are some of my question/concern... 1. is python develop gui application a cross platform? just like java swing? 2. delphi makes things easy for me like coding for a specific event on a specific component, c

Re: Help with PySMS

2007-05-27 Thread DJ Fadereu
On May 28, 1:53 am, Petr Jakes <[EMAIL PROTECTED]> wrote: > Maybe you can try python binding for gammu, which works great for me. > HTH > Petr Jakes > > http://cihar.com/gammu/python/ I'm going to try and setup Gammu today. I'm using a DKU-2 cable connection. The Gammu guide says that:"Before you

Re: os.path.walk not pruning descent tree (and I'm not happy with that behavior?)

2007-05-27 Thread Gabriel Genellina
En Sun, 27 May 2007 22:39:32 -0300, Joe Ardent <[EMAIL PROTECTED]> escribió: > Good day, everybody! From what I can tell from the archives, this is > everyone's favorite method from the standard lib, and everyone loves > answering questions about it. Right? :) Well, in fact, the preferred (and

Re: itertools.groupby

2007-05-27 Thread Raymond Hettinger
On May 27, 8:28 pm, Paul Rubin wrote: > I use the module all the time now and it is great. Thanks for the accolades and the great example. FWIW, I checked in a minor update to the docs: +++ python/trunk/Doc/lib/libitertools.tex Mon May 28 07:23:22 2007 @@ -138,6 +13

Re: ten small Python programs

2007-05-27 Thread DJ Fadereu
> > You could try this wiki page: > > http://rosettacode.org/wiki/Main_Page > > It has a fair amount of Python examples as well as many more other > languages (doing the same algorithm). > > Hope this helps. > > Adonis THIS IS GREAT :) Thanx! -- http://mail.python.org/mailman/listinfo/python-l

Re: os.path.walk not pruning descent tree (and I'm not happy with that behavior?)

2007-05-27 Thread Peter Otten
Joe Ardent wrote: > Good day, everybody! From what I can tell from the archives, this is > everyone's favorite method from the standard lib, and everyone loves > answering questions about it. Right? :) I don't know what to make of the smiley, so I'll be explicit: use os.walk() instead of os.pat

Re: PHP5 programmer learning Python

2007-05-27 Thread Luis M . González
On May 27, 12:41 pm, romiro <[EMAIL PROTECTED]> wrote: > Hi all, > > I'm a PHP5 developer looking to "broaden my horizons" so to speak by > learning a new language. I emphasize the 5 in PHP since I have fully > engrossed myself in the full OOP of version 5 with my own ground-up > projects as well a

Re: Newbie question - better way to do this?

2007-05-27 Thread Paul Rubin
Eric <[EMAIL PROTECTED]> writes: > words is a big long array of strings. What I want to do is find > consecutive sequences of words that have the first letter capitalized, > and then call doSomething on them. (And you can ignore the fact that > it won't find a sequence at the very end of words, t

Re: itertools.groupby

2007-05-27 Thread Paul Rubin
Raymond Hettinger <[EMAIL PROTECTED]> writes: > The groupby itertool came-out in Py2.4 and has had remarkable > success (people seem to get what it does and like using it, and > there have been no bug reports or reports of usability problems). > All in all, that ain't bad (for what 7stud calls a po

Re: Why isn't this query working in python?

2007-05-27 Thread Steve Holden
[EMAIL PROTECTED] wrote: > > On May 27, 2007, at 4:01 PM, Steve Holden wrote: > >> erikcw wrote: >>> On May 26, 8:21 pm, John Machin <[EMAIL PROTECTED]> wrote: On May 27, 5:25 am, erikcw <[EMAIL PROTECTED]> wrote: > On May 25, 11:28 am, Carsten Haese <[EMAIL PROTECTED]> wr

Unsubscribing from the mailing list

2007-05-27 Thread [EMAIL PROTECTED]
Hi All, I do not know if this is the correct group to ask this question. But since mailman is python-based I thought i would ask here. I had subscribed to a mailing list called [EMAIL PROTECTED] adventitiously. I then wanted to reverse my decision and so tried to unsubscribe from the mailing list

Re: python -- prolog bridge error

2007-05-27 Thread yuce
Hello, PySWIP requires "libpl.dll" to be on the path. There are two ways to do this: 1) Add 'bin' directory of SWI-Prolog to the PATH (it's C:\Program Files \pl\bin on my system), 2) Or, copy 'libpl.dll' and 'pthreadVC.dll' to C:\WINDOWS\system32 That should solve the problem, happy hacking :)

os.path.walk not pruning descent tree (and I'm not happy with that behavior?)

2007-05-27 Thread Joe Ardent
Good day, everybody! From what I can tell from the archives, this is everyone's favorite method from the standard lib, and everyone loves answering questions about it. Right? :) Anyway, my question regards the way that the visit callback modifies the names list. Basically, my simple example is:

Re: itertools.groupby

2007-05-27 Thread Steve Howell
--- Raymond Hettinger <[EMAIL PROTECTED]> wrote: > > FWIW, I wrote those docs. Suggested improvements > are > welcome; however, I think they already meet a > somewhat > high standard of quality: > I respectfully disagree, and I have suggested improvements in this thread. Without even reading

RE: Xml parser

2007-05-27 Thread Eiwot
Let's try http://pyxml.sourceforge.net/ Cheers Python Articles at http://pyarticles.blogspot.com/> Date: Sat, 26 May 2007 10:02:06 +0200> From: [EMAIL PROTECTED]> Subject: Re: Xml parser> To: python-list@python.org> > XiaQ wrote:> > You can use DOM> > http://diveintopython.org/, Chapter 9> > "a

Re: itertools.groupby

2007-05-27 Thread Steve Howell
--- Carsten Haese <[EMAIL PROTECTED]> wrote: > [...] It's an abstract code pattern for an abstract use > case. I question the use of abstract code patterns in documentation, as they just lead to confusion. I really think concrete examples are better in any circumstance. Also, to the OP's ori

Re: itertools.groupby

2007-05-27 Thread Raymond Hettinger
On May 27, 2:59 pm, Steve Howell <[EMAIL PROTECTED]> wrote: > These docs need work. Please do not defend them; > please suggest improvements. FWIW, I wrote those docs. Suggested improvements are welcome; however, I think they already meet a somewhat high standard of quality: - there is an accur

Re: Why isn't this query working in python?

2007-05-27 Thread Carsten Haese
On Sun, 2007-05-27 at 16:39 -0400, [EMAIL PROTECTED] wrote: > > sql = """SELECT payment_id FROM amember_payments WHERE > > member_id=%s AND expire_date > NOW() AND completed=1 AND (product_id > >>> 11 AND product_id <21)""", (self.uid) > > > > > And doesn't the above comma, need to b

Re: itertools.groupby

2007-05-27 Thread Carsten Haese
On Sun, 2007-05-27 at 14:59 -0700, Steve Howell wrote: > Huh? How is code that uses itertools.groupby not an > actual example of using itertools.groupby? Here's how: """ The returned group is itself an iterator that shares the underlying iterable with groupby(). Because the source is shared, whe

CGI + appscript newbie question/problem

2007-05-27 Thread Andres Francisco Rojas
Hey everyone. So I'm more or less new to Python, just wanted to say that right up front so please excuse any silly questions. Generally what I'm trying to do is control a Mac OS X application through a website via Python and appscript. I have successfully got Apache running and configured to run

Re: Is PEP-8 a Code or More of a Guideline?

2007-05-27 Thread Ben Finney
Paul McGuire <[EMAIL PROTECTED]> writes: > It is a bit reassuring that I am not the only one who turns a blind > eye to this part of the PEP, that l_c_w_u bothers others as well. I see similar support for lower_case, and opposition to camelCase. It's nice that we're both reassured by what we see.

Re: unit testing

2007-05-27 Thread Steve Howell
Let me preface every reply here by YMMV. I strongly, strongly encourage people to tap into the unit testing community for all tools that are available to them. Also, let me say that despite any place where Steven and I disagree about the mechanics of unit testing, we're in firm agreement that UNI

Re: What's the best way to iniatilize a function

2007-05-27 Thread Steven D'Aprano
On Sun, 27 May 2007 10:51:46 -0700, Jack wrote: > I have a set of functions to wrap a library. For example, > > mylib_init() > mylib_func() > mylib_exit() > > or > > handle = mylib_init() > mylib_func(handle) > mylib_exit(handle) > > In order to call mylib_func(), mylib_init() has to be called

Re: unit testing

2007-05-27 Thread Steven Bethard
Steve Howell wrote: > --- Steven Bethard <[EMAIL PROTECTED]> wrote: >> Have you tried py.test? >> >> http://codespeak.net/py/dist/test.html >> >> I've heard good things about it, but haven't gotten >> around to trying it >> yet. Here's a two-line test suite from the page >> above: >> >>

Re: Error in optparse documentation

2007-05-27 Thread John Machin
On May 28, 7:54 am, Shatadal <[EMAIL PROTECTED]> wrote: > In the python documentation section 14.3.2.6 (http://docs.python.org/ > lib/optparse-generating-help.html) in the last line it is written > > "options that have a default value can include %default in the help > string--optparse will replace

Re: Newbie question - better way to do this?

2007-05-27 Thread Steve Howell
--- Steven D'Aprano wrote: > On Sun, 27 May 2007 14:55:42 -0700, John Machin > wrote: > > Bzzzt. > Bzzzt! Can we please refrain from buzzer sounds in this mostly civil forum, even if one beep deserves another? __

Re: Error in optparse documentation

2007-05-27 Thread Steven Bethard
Shatadal wrote: > In the python documentation section 14.3.2.6 (http://docs.python.org/ > lib/optparse-generating-help.html) in the last line it is written > > "options that have a default value can include %default in the help > string--optparse will replace it with str() of the option's default

Re: Newbie question - better way to do this?

2007-05-27 Thread Steven D'Aprano
On Sun, 27 May 2007 14:55:42 -0700, John Machin wrote: > On May 28, 12:46 am, Steven D'Aprano > <[EMAIL PROTECTED]> wrote: >> On Sun, 27 May 2007 06:44:01 -0700, Eric wrote: >> > words is a big long array of strings. What I want to do is find >> > consecutive sequences of words that have the firs

Re: ten small Python programs

2007-05-27 Thread Adonis Vargas
Steve Howell wrote: > I've always thought that the best way to introduce new > programmers to Python is to show them small code > examples. You could try this wiki page: http://rosettacode.org/wiki/Main_Page It has a fair amount of Python examples as well as many more other languages (doing

Re: How to do this in python with regular expressions

2007-05-27 Thread snorble
On May 25, 6:51 am, Jia Lu <[EMAIL PROTECTED]> wrote: > Hi all > > I'm trying to parsing html with re module. > > html = """ > > > > DATA1DATA2DATA3 HT>DATA4 > > > DATA5DATA6DATA7DATA8 > > > """ > > I want to get DATA1-8 from that string.(DATA maybe not english words.) > Can anyone tell me h

Re: Newbie question - better way to do this?

2007-05-27 Thread Steve Howell
--- John Machin <[EMAIL PROTECTED]> wrote: (And you can > > > ignore the fact that > > > it won't find a sequence at the very end of > words, that is fine for my > > > purposes). > > [...] > > Bzzzt. Needs the following code at the end: > if accumulator: > doSomething(accumulator) > FWIW th

Re: Newbie question - better way to do this?

2007-05-27 Thread John Machin
On May 28, 12:46 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sun, 27 May 2007 06:44:01 -0700, Eric wrote: > > words is a big long array of strings. What I want to do is find > > consecutive sequences of words that have the first letter capitalized, > > and then call doSomething on them. (

Error in optparse documentation

2007-05-27 Thread Shatadal
In the python documentation section 14.3.2.6 (http://docs.python.org/ lib/optparse-generating-help.html) in the last line it is written "options that have a default value can include %default in the help string--optparse will replace it with str() of the option's default value. If an option has no

Re: Help with PySMS

2007-05-27 Thread Petr Jakes
Maybe you can try python binding for gammu, which works great for me. HTH Petr Jakes http://cihar.com/gammu/python/ -- http://mail.python.org/mailman/listinfo/python-list

Re: itertools.groupby

2007-05-27 Thread Steve Howell
--- Carsten Haese <[EMAIL PROTECTED]> wrote: > On Sun, 2007-05-27 at 10:17 -0700, 7stud wrote: > > Bejeezus. The description of groupby in the docs > is a poster child > > for why the docs need user comments. Can someone > explain to me in > > what sense the name 'uniquekeys' is used this > exa

Re: itertools.groupby

2007-05-27 Thread Steve Howell
--- paul <[EMAIL PROTECTED]> wrote: > > > > Regarding the pitfalls of groupby in general (even > > assuming we had better documentation), I invite > people > > to view the following posting that I made on > > python-ideas, entitled "SQL-like way to manipulate > > Python data structures": > > >

expat parser

2007-05-27 Thread Sebastian Bassi
I have this code: import xml.parsers.expat def start_element(name, attrs): print 'Start element:', name, attrs def end_element(name): print 'End element:', name def char_data(data): print 'Character data:', repr(data) p = xml.parsers.expat.ParserCreate() p.StartElementHandler = start_e

Re: Can python create a dictionary from a list comprehension?

2007-05-27 Thread Pierre Quentel
On 27 mai, 22:55, erikcw <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to turn o list of objects into a dictionary using a list > comprehension. > > Something like > > entries = {} > [entries[int(d.date.strftime('%m'))] = d.id] for d in links] > > I keep getting errors when I try to do it. Is i

Re: Can python create a dictionary from a list comprehension?

2007-05-27 Thread Stefan Sonnenberg-Carstens
erikcw schrieb: > Hi, > > I'm trying to turn o list of objects into a dictionary using a list > comprehension. > > Something like > > entries = {} > [entries[int(d.date.strftime('%m'))] = d.id] for d in links] > > I keep getting errors when I try to do it. Is it possible? Do > dictionary objects

Re: Can python create a dictionary from a list comprehension?

2007-05-27 Thread half . italian
On May 27, 1:55 pm, erikcw <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to turn o list of objects into a dictionary using a list > comprehension. > > Something like > > entries = {} > [entries[int(d.date.strftime('%m'))] = d.id] for d in links] > > I keep getting errors when I try to do it. Is

Re: Why isn't this query working in python?

2007-05-27 Thread erikcw
On May 27, 4:01 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > erikcw wrote: > > On May 26, 8:21 pm, John Machin <[EMAIL PROTECTED]> wrote: > >> On May 27, 5:25 am, erikcw <[EMAIL PROTECTED]> wrote: > > >>> On May 25, 11:28 am, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Fri, 2007-05-25 at 09

Can python create a dictionary from a list comprehension?

2007-05-27 Thread erikcw
Hi, I'm trying to turn o list of objects into a dictionary using a list comprehension. Something like entries = {} [entries[int(d.date.strftime('%m'))] = d.id] for d in links] I keep getting errors when I try to do it. Is it possible? Do dictionary objects have a method equivalent to [].appe

Re: Why isn't this query working in python?

2007-05-27 Thread davelist
On May 27, 2007, at 4:01 PM, Steve Holden wrote: > erikcw wrote: >> On May 26, 8:21 pm, John Machin <[EMAIL PROTECTED]> wrote: >>> On May 27, 5:25 am, erikcw <[EMAIL PROTECTED]> wrote: >>> >>> >>> On May 25, 11:28 am, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Fri, 2007-05-25 at 09:51

Re: Is PEP-8 a Code or More of a Guideline?

2007-05-27 Thread Roy Smith
Ben Finney <[EMAIL PROTECTED]> wrote: > Is C no longer a "major" language? The long-standing convention there > is for lower_case_with_underscores. Which dates back to the days of ASR-33's which only had one case (upper case, as a matter of fact). Does nobody else remember C compilers which acc

Re: ten small Python programs

2007-05-27 Thread Paul Rubin
Steven Bethard <[EMAIL PROTECTED]> writes: > I think I would rewrite the current unit-testing example to use the > standard library unittest module:: I think these days we're supposed to like doctest better than unittest. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why isn't this query working in python?

2007-05-27 Thread Steve Holden
erikcw wrote: > On May 26, 8:21 pm, John Machin <[EMAIL PROTECTED]> wrote: >> On May 27, 5:25 am, erikcw <[EMAIL PROTECTED]> wrote: >> >> >> >>> On May 25, 11:28 am, Carsten Haese <[EMAIL PROTECTED]> wrote: On Fri, 2007-05-25 at 09:51 -0500, Dave Borne wrote: >> I'm trying to run the follo

Re: itertools.groupby

2007-05-27 Thread paul
Steve Howell schrieb: > --- Steve Howell <[EMAIL PROTECTED]> wrote: > >> --- 7stud <[EMAIL PROTECTED]> wrote: >> >>> Bejeezus. The description of groupby in the docs >> is >>> a poster child >>> for why the docs need user comments. > > Regarding the pitfalls of groupby in general (even > assum

Re: Why isn't this query working in python?

2007-05-27 Thread Steve Holden
Steve Howell wrote: > --- erikcw <[EMAIL PROTECTED]> wrote: ('SELECT payment_id FROM amember_payments WHERE >> member_id=%s AND expire_date > NOW() AND completed=1 AND >> (product_id >11 AND product_id <21)', (1608L,)) () >> Here is a copy of the table schema and the first 2 >>

Re: Is PEP-8 a Code or More of a Guideline?

2007-05-27 Thread Paul Rubin
Paul McGuire <[EMAIL PROTECTED]> writes: > code about once/year. But it does mean that additions to the external > API to the std lib will contain method calls such as get_files, > send_message, delete_record, etc. I think this just promotes a > perception of Python as "so last century." I think

Re: itertools.groupby

2007-05-27 Thread Carsten Haese
On Sun, 2007-05-27 at 10:17 -0700, 7stud wrote: > Bejeezus. The description of groupby in the docs is a poster child > for why the docs need user comments. Can someone explain to me in > what sense the name 'uniquekeys' is used this example: > > > import itertools > > mylist = ['a', 1, 'b', 2,

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- Steven Bethard <[EMAIL PROTECTED]> wrote: > > > > Maybe this is the first good example that > motivates a > > hyperlink to alternatives. Would you accept the > idea > > that we keep my original example on the > SimplePrograms > > page, but we link to a UnitTestingPhilosophies > page, > > and

unit testing

2007-05-27 Thread Steve Howell
--- Steven Bethard <[EMAIL PROTECTED]> wrote: > Have you tried py.test? > > http://codespeak.net/py/dist/test.html > > I've heard good things about it, but haven't gotten > around to trying it > yet. Here's a two-line test suite from the page > above: > > def test_answer(): >

Re: ten small Python programs

2007-05-27 Thread Steven Bethard
Steve Howell wrote: > --- Steven Bethard <[EMAIL PROTECTED]> wrote: > >> Steve Howell wrote: >>> --- Steven Bethard <[EMAIL PROTECTED]> >> wrote: I think I would rewrite the current unit-testing example to use the standard library unittest module:: # Let's write reus

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- Steven Bethard <[EMAIL PROTECTED]> wrote: > Steve Howell wrote: > > --- Steven Bethard <[EMAIL PROTECTED]> > wrote: > >> I think I would rewrite the current unit-testing > >> example to use the > >> standard library unittest module:: > >> > >> # Let's write reusable code, and unit test

Re: ten small Python programs

2007-05-27 Thread Steven Bethard
Steve Howell wrote: > --- Steven Bethard <[EMAIL PROTECTED]> wrote: > >> I think I would rewrite the current unit-testing >> example to use the >> standard library unittest module:: >> >> # Let's write reusable code, and unit test it. >> def add_money(amounts): >> # do arithmet

Re: Is PEP-8 a Code or More of a Guideline?

2007-05-27 Thread Ben Finney
Stefan Sonnenberg-Carstens <[EMAIL PROTECTED]> writes: > I prefer mixedCaseStyle, and I think that should be "standard", I dislike it. It's inconsistent, and confusingly similar to TitleCaseStyle used for class names in Python. > as this style is commonly used in all "major" languages , for > ex

Re: Is PEP-8 a Code or More of a Guideline?

2007-05-27 Thread Ben Finney
"OKB (not okblacke)" <[EMAIL PROTECTED]> writes: > Underscores are harder to type than any alphanumeric character. I know of no keyboard layout in common use where it's more complicated than +, exactly the same as a single uppercase letter. Care to enlighten me? -- \"Conscien

Re: ten small Python programs

2007-05-27 Thread Steven Bethard
Steve Howell wrote: > --- Steven Bethard <[EMAIL PROTECTED]> wrote: >> I think I would rewrite the current unit-testing >> example to use the >> standard library unittest module:: >> >> # Let's write reusable code, and unit test it. >> def add_money(amounts): >> # do arithmetic

Re: itertools.groupby

2007-05-27 Thread Steve Howell
--- Steve Howell <[EMAIL PROTECTED]> wrote: > > --- 7stud <[EMAIL PROTECTED]> wrote: > > > Bejeezus. The description of groupby in the docs > is > > a poster child > > for why the docs need user comments. > Regarding the pitfalls of groupby in general (even assuming we had better documenta

Re: itertools.groupby

2007-05-27 Thread Steve Howell
--- 7stud <[EMAIL PROTECTED]> wrote: > > I'd settle for a simple explanation of what it does > in python. > The groupby function prevents you have from having to write awkward (and possibly broken) code like this: group = [] lastKey = None for item in items: newKey = item.k

Re: Is PEP-8 a Code or More of a Guideline?

2007-05-27 Thread OKB (not okblacke)
Carsten Haese wrote: > On Sun, 2007-05-27 at 07:30 +, OKB (not okblacke) wrote: >> Underscores are harder to type than any alphanumeric >> character. > > This is a discussion about underscores versus capital letters > denoting the word boundaries in identifiers. How is an

Re: Is PEP-8 a Code or More of a Guideline?

2007-05-27 Thread [EMAIL PROTECTED]
Stefan Sonnenberg-Carstens wrote: > Paul McGuire schrieb: > > I'm starting a new thread for this topic, so as not to hijack the one > > started by Steve Howell's excellent post titled "ten small Python > > programs". > > > > In that thread, there was a suggestion that these examples should > > conf

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- Steven Bethard <[EMAIL PROTECTED]> wrote: > > I think I would rewrite the current unit-testing > example to use the > standard library unittest module:: > > # Let's write reusable code, and unit test it. > def add_money(amounts): > # do arithmetic in pennies so as not to

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- Steven Bethard <[EMAIL PROTECTED]> wrote: > I think I would rewrite the current unit-testing > example to use the > standard library unittest module:: > > # Let's write reusable code, and unit test it. > def add_money(amounts): > # do arithmetic in pennies so as not to >

Announcing: ACM SIGAPL apl 2007 -- Arrays and Objects

2007-05-27 Thread Mike Kent
The APL 2007 conference, sponsored by ACM SIGAPL, has as its principal theme "Arrays and Objects" and, appropriately, is co-located with OOPSLA 2007, in Montreal this October. APL 2007 starts with a tutorial day on Sunday, October 21, followed by a two-day program on Monday and Tuesday, October

Re: itertools.groupby

2007-05-27 Thread Steve Howell
--- 7stud <[EMAIL PROTECTED]> wrote: > Bejeezus. The description of groupby in the docs is > a poster child > for why the docs need user comments. I would suggest an example with a little more concreteness than what's currently there. For example, this code... import itertools syslog_messa

What's the best way to iniatilize a function

2007-05-27 Thread Jack
I have a set of functions to wrap a library. For example, mylib_init() mylib_func() mylib_exit() or handle = mylib_init() mylib_func(handle) mylib_exit(handle) In order to call mylib_func(), mylib_init() has to be called once. When it's done, or when program exits, mylib_exit() should be called

Re: itertools.groupby

2007-05-27 Thread 7stud
On May 27, 11:28 am, Steve Howell <[EMAIL PROTECTED]> wrote: > --- 7stud <[EMAIL PROTECTED]> wrote: > > Bejeezus. The description of groupby in the docs is > > a poster child > > for why the docs need user comments. Can someone > > explain to me in > > what sense the name 'uniquekeys' is used thi

Re: itertools.groupby

2007-05-27 Thread Steve Howell
--- 7stud <[EMAIL PROTECTED]> wrote: > Bejeezus. The description of groupby in the docs is > a poster child > for why the docs need user comments. Can someone > explain to me in > what sense the name 'uniquekeys' is used this > example: [...] > The groupby method has its uses, but it's behavi

itertools.groupby

2007-05-27 Thread 7stud
Bejeezus. The description of groupby in the docs is a poster child for why the docs need user comments. Can someone explain to me in what sense the name 'uniquekeys' is used this example: import itertools mylist = ['a', 1, 'b', 2, 3, 'c'] def isString(x): s = str(x) if s == x:

Re: ten small Python programs

2007-05-27 Thread Steven Bethard
Steve Howell wrote: > --- Steven Bethard <[EMAIL PROTECTED]> wrote: >> Very cool! Do you mind putting this up on the Wiki >> somewhere so that we >> can link to it more easily? Maybe something like: >> >> http://wiki.python.org/moin/SimplePrograms >> > > Done. I think I would rewrite the cu

Re: PHP5 programmer learning Python

2007-05-27 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Gabriel Genellina <[EMAIL PROTECTED]> wrote: >En Sun, 27 May 2007 12:41:36 -0300, romiro <[EMAIL PROTECTED]> escribió: > >> Anyway, my first question was if anyone knows of a tutorial that >> focuses on PHP -> Python learning, in such that there might be a block >> o

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- Wildemar Wildenburger <[EMAIL PROTECTED]> wrote: > Steve Howell wrote: > > # def defines a method in Python > > def say_hello(name): > > print 'hello', name > > say_hello('Jack') > > say_hello('Jill') > > > Doesn't def define methods *xor* functions, > depending on

Re: Why isn't this query working in python?

2007-05-27 Thread Steve Howell
--- erikcw <[EMAIL PROTECTED]> wrote: > > > > > ('SELECT payment_id FROM amember_payments WHERE > member_id=%s AND > > > expire_date > NOW() AND completed=1 AND > (product_id >11 AND product_id > > > <21)', (1608L,)) > > > () > > > > Here is a copy of the table schema and the first 2 > rows. >

[ANN] argparse 0.8 - Command-line parsing library

2007-05-27 Thread Steven Bethard
=== Announcing argparse 0.8 === The argparse module is an optparse-inspired command line parser that improves on optparse by supporting: * positional arguments * sub-commands * required options * options with a variable number of args * better usage message

Re: PyPI bdist_wininst upload failing

2007-05-27 Thread Steven Bethard
Steven Bethard wrote: > Gabriel Genellina wrote: >> En Sun, 27 May 2007 12:19:03 -0300, Steven Bethard >> <[EMAIL PROTECTED]> escribió: >> >>> Also, I couldn't get the StringIO code from there to work: >>> >>> >>> import StringIO >>> >>> content = open('argparse-0.8.0.win32.exe').read() >> >> Us

Re: Large Amount of Data

2007-05-27 Thread Jack
John, thanks for your reply. I will then use the files as input to generate an index. So the files are temporary, and provide some attributes in the index. So I do this multiple times to gather different attributes, merge, etc. "John Machin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROT

Re: PHP5 programmer learning Python

2007-05-27 Thread Steve Howell
--- romiro <[EMAIL PROTECTED]> wrote: > I've recently tried > C#, a very short > lived re-attempt at C++ and Java, and Ruby. To the extend that you're familiar with C++/Java/Ruby, you may find this link as an interesting way to see how Python looks: http://www.dmh2000.com/cjpr/cmpframe.html

Re: Is PEP-8 a Code or More of a Guideline?

2007-05-27 Thread Paul McGuire
On May 27, 3:35 am, Ben Finney <[EMAIL PROTECTED]> wrote: > Paul McGuire <[EMAIL PROTECTED]> writes: > > At this point, I realized that I was taking things too far > > off-topic, so I decided to start a new thread. > > So, uh, what's the purpose of this thread? Did you have a specific > point to st

Re: PHP5 programmer learning Python

2007-05-27 Thread 7stud
On May 27, 9:41 am, romiro <[EMAIL PROTECTED]> wrote: > Hi all, > > I'm a PHP5 developer looking to "broaden my horizons" so to speak by > learning a new language. I emphasize the 5 in PHP since I have fully > engrossed myself in the full OOP of version 5 with my own ground-up > projects as well as

Re: PHP5 programmer learning Python

2007-05-27 Thread Steve Howell
--- romiro <[EMAIL PROTECTED]> wrote: > > Anyway, my first question was if anyone knows of a > tutorial that > focuses on PHP -> Python learning, in such that > there might be a block > of PHP code alongside an example of how to do the > same thing in > Python. I know exactly what you mean, an

Re: PHP5 programmer learning Python

2007-05-27 Thread Gabriel Genellina
En Sun, 27 May 2007 12:41:36 -0300, romiro <[EMAIL PROTECTED]> escribió: > Anyway, my first question was if anyone knows of a tutorial that > focuses on PHP -> Python learning, in such that there might be a block > of PHP code alongside an example of how to do the same thing in I don't know of a

Re: PHP5 programmer learning Python

2007-05-27 Thread darren kirby
quoth the romiro: > Hi all, ... > Anyway, my first question was if anyone knows of a tutorial that > focuses on PHP -> Python learning, in such that there might be a block > of PHP code alongside an example of how to do the same thing in > Python. One example of something I've already mapped a com

Re: PyPI bdist_wininst upload failing

2007-05-27 Thread Steven Bethard
Gabriel Genellina wrote: > En Sun, 27 May 2007 12:19:03 -0300, Steven Bethard > <[EMAIL PROTECTED]> escribió: > >> Also, I couldn't get the StringIO code from there to work: >> >> >>> import StringIO >> >>> content = open('argparse-0.8.0.win32.exe').read() > > Use open("...","rb").read() - the

Re: ten small Python programs

2007-05-27 Thread Wildemar Wildenburger
Steve Howell wrote: > # def defines a method in Python > def say_hello(name): > print 'hello', name > say_hello('Jack') > say_hello('Jill') > Doesn't def define methods *xor* functions, depending on the context? And in this example, say_hello (*yuck*, underscores ...) is

PHP5 programmer learning Python

2007-05-27 Thread romiro
Hi all, I'm a PHP5 developer looking to "broaden my horizons" so to speak by learning a new language. I emphasize the 5 in PHP since I have fully engrossed myself in the full OOP of version 5 with my own ground-up projects as well as some work with PRADO (http://pradosoft.com) I've dabbled with a

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- BartlebyScrivener <[EMAIL PROTECTED]> wrote: > > For the person new to programming (doesn't come from > C or other > languages), I think you need to add a separate > explanation of string > formatting and how it works, or at least add a > comment that tells them > you are using string format

Re: PyPI bdist_wininst upload failing

2007-05-27 Thread Gabriel Genellina
En Sun, 27 May 2007 12:19:03 -0300, Steven Bethard <[EMAIL PROTECTED]> escribió: > Also, I couldn't get the StringIO code from there to work: > > >>> import StringIO > >>> content = open('argparse-0.8.0.win32.exe').read() Use open("...","rb").read() - the "b" is important on Windows. -- Gab

Re: Why isn't this query working in python?

2007-05-27 Thread erikcw
On May 26, 8:21 pm, John Machin <[EMAIL PROTECTED]> wrote: > On May 27, 5:25 am, erikcw <[EMAIL PROTECTED]> wrote: > > > > > On May 25, 11:28 am, Carsten Haese <[EMAIL PROTECTED]> wrote: > > > > On Fri, 2007-05-25 at 09:51 -0500, Dave Borne wrote: > > > > > I'm trying to run the following query: >

Re: a bug in python windows service?

2007-05-27 Thread Gabriel Genellina
En Sun, 27 May 2007 09:07:36 -0300, momobear <[EMAIL PROTECTED]> escribió: >> Instead of extending join(), write a specific method to signal the >> quitEvent or just let the caller signal it. And I don't see in this >> example why do you need two different events (one on the thread, another >> on

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- BartlebyScrivener <[EMAIL PROTECTED]> wrote: > On May 26, 1:43 pm, Steve Howell > <[EMAIL PROTECTED]> wrote: > > -- > > # def defines a method in Python > > def tax(itemCharge, taxRate = 0.05): > > return itemCharge * taxRate > > print '%.2f' % tax(11.35) > > p

Re: PyPI bdist_wininst upload failing

2007-05-27 Thread Steven Bethard
John Machin wrote: > On May 27, 4:20 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: >> Steven Bethard wrote: >>> I just tried to upload new versions of the argparse module to PyPI, but >>> it seems like I can no longer upload Windows installers: > [snip] >> That seems a little weird to me. Are the b

Re: Help with PySMS

2007-05-27 Thread Paul Boddie
DJ Fadereu wrote: > > I need an SMS server running on my WinXP PC, as soon as possible. I'm > currently using a Nokia 6300 phone which has the S60 platform. I > downloaded the PySMS by Dave Berkeley from > http://www.wordhord.co.uk/pysms.html and started testing it, but I > haven't been able to get

Re: File monitoring for all drive

2007-05-27 Thread Tim Golden
[rohit] >>> i want to detect all file change operations(rename,delete,create) >>> on ALL THE DRIVES of the hard disk >>> using the method ReadDirectoryChanges API , i.e program no. 3 in the >>> webpagehttp://tgolden.sc.sabren.com/python/win32_how_do_i/watch_directory_fo... >>> . >>> Please sugg

Re: Is PEP-8 a Code or More of a Guideline?

2007-05-27 Thread Steve Howell
--- Gabriel Genellina <[EMAIL PROTECTED]> wrote: > > Underscores are not always easily available on non > us-layout keyboards, > like \ and @ and many other "special" characters. A > language that requires > more symbols than the 26 english letters has to make > room somewhere - > keyboard

Re: Is PEP-8 a Code or More of a Guideline?

2007-05-27 Thread Gabriel Genellina
En Sun, 27 May 2007 10:20:49 -0300, Carsten Haese <[EMAIL PROTECTED]> escribió: > On Sun, 2007-05-27 at 07:30 +, OKB (not okblacke) wrote: >> Underscores are harder to type than any alphanumeric character. > > This is a discussion about underscores versus capital letters denoting > the

Re: totally lost newbie

2007-05-27 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Steve Howell wrote: >> def key_func(item): >> return (len(item), item) >> >> data = ['viking', 'spam', 'parrot', 'ham', 'eric'] >> data.sort(key=key_func) >> print data >> > > Marc, when did the key feature get introduced, 2.4 or > 2.5? I'm asking on behalf of the n

Re: Newbie question - better way to do this?

2007-05-27 Thread Steve Howell
--- Eric <[EMAIL PROTECTED]> wrote: > I have some working code, but I realized it is just > the way I would > write it in C, which means there is probably a > better (more pythonic) > way of doing it. > > Here's the section of code: > > accumulate = firstIsCaps = False > accumStart = i

  1   2   >