Re: Fwd: Re: Comparing Dictionaries

2007-07-30 Thread Steven D'Aprano
On Mon, 30 Jul 2007 14:06:29 -0500, Kenneth Love wrote: > >>From: "Steven D'Aprano" <[EMAIL PROTECTED]> >>Newsgroups: comp.lang.python >>Subject: Re: Comparing Dictionaries >>Date: Sat, 28 Jul 2007 10:21:14 +1000 >>To: python-list@python.org >> >>On Fri, 27 Jul 2007 14:11:02 -0500, Kenneth Love w

Re: What is the "functional" way of doing this?

2007-07-30 Thread [EMAIL PROTECTED]
On Jul 30, 4:39 pm, Paul Rubin wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > > Recursion is common in functional programming: > > > def f(n, l=None): > > if l == None: > > l = [] > > if n > 0: > > return f(n/26, l + [n%26]) > > els

Re: Help text embedding in C code?

2007-07-30 Thread Carsten Haese
On Mon, 2007-07-30 at 16:24 -0700, James Stroud wrote: > Hello All, > > I have a python module I wrote in C some time ago and I have since > forgotten how to use my functions and so I wanted to add some > doc-strings such that "help(function_name)" would give some help in the > interactive inte

Re: Help text embedding in C code?

2007-07-30 Thread James Stroud
Carsten Haese wrote: > On Mon, 2007-07-30 at 16:24 -0700, James Stroud wrote: > >>Hello All, >> >>I have a python module I wrote in C some time ago and I have since >>forgotten how to use my functions and so I wanted to add some >>doc-strings such that "help(function_name)" would give some help

Re: OOP in Python book?

2007-07-30 Thread Steve Holden
James Stroud wrote: > Dick Moores wrote: >> At 01:27 PM 7/28/2007, Dennis Lee Bieber wrote: >> >>> On Fri, 27 Jul 2007 16:27:57 -0700, Dick Moores <[EMAIL PROTECTED]> >>> declaimed the following in comp.lang.python: >>> >>> Well, the publisher is Prentice Hall, "The world's leading educat

Pysqlite storing file as blob example

2007-07-30 Thread rustyhowell
I'm trying to store binary data in a sqlite database and call into the db using pysqlite 3. What I've got so far is this: import sqlite con = sqlite.connect(DB_PATH) cur = con.cursor() query = """create table t1( ID INTEGER PRIMARY KEY, dataBLOB );""" cur.execute(query)

Re: TypeError: unsupported operand type(s) for -: 'Decimal' and 'Decimal'. Why?

2007-07-30 Thread John Machin
On Jul 31, 9:31 am, Zentrader <[EMAIL PROTECTED]> wrote: > > from decimal import Decimal > > > In [21]: a = Decimal() > > > In [22]: class Decimal(object): > >: pass > >: > > > In [23]: b = Decimal() > > > In [24]: a - b > > Perhaps I don't understand what you are doing here, bu

www.cerocom.com

2007-07-30 Thread Natalia
.. www.cerocom.com .. You will be able to ask yourself: Is Internet a good investment for my company? So that an investment would have to do I of this type? Really is going to serve to me to have a Web site? So that to be in

Re: yield keyword usage

2007-07-30 Thread Steve Holden
Ehsan wrote: > hi > coulde any one show me the usage of "yield" keyword specially in this > example: > > > """Fibonacci sequences using generators > > This program is part of "Dive Into Python", a free Python book for > experienced programmers. Visit http://diveintopython.org/ for the > latest

Re: What is the "functional" way of doing this?

2007-07-30 Thread Ricardo Aráoz
> On Jul 30, 4:39 pm, Paul Rubin wrote: >> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: >>> Recursion is common in functional programming: >>> def f(n, l=None): >>> if l == None: >>> l = [] >>> if n > 0: >>> return f(n/26, l + [n%26]) >>> el

Re: Pysqlite storing file as blob example

2007-07-30 Thread Carsten Haese
On Tue, 2007-07-31 at 00:25 +, [EMAIL PROTECTED] wrote: > I'm trying to store binary data in a sqlite database and call into the > db using pysqlite 3. > What I've got so far is this: > > import sqlite > con = sqlite.connect(DB_PATH) > cur = con.cursor()mean > query = """create table t1( >

Re: What is the "functional" way of doing this?

2007-07-30 Thread James Stroud
beginner wrote: > Hi, > > If I have a number n and want to generate a list based on like the > following: > > def f(n): > l=[] > while n>0: > l.append(n%26) > n /=26 > return l > > I am wondering what is the 'functional' way to do the same. > > Thanks, > beginner

Re: What is the "functional" way of doing this?

2007-07-30 Thread James Stroud
James Stroud wrote: > py> f = lambda n, r=None: f(n/26, (r if r else [])) + [n%26] if n/26 > else [n%26] > py> f(30) > [17, 1, 20, 12] > py> f(3) > [1, 18, 9, 22] > py> f(3000) > [4, 11, 10] > py> f(1000) > [1, 12, 12] > > Oops, those are backwards. Should be: f = lambda n, r=None: [n

Re: Relative-importing *

2007-07-30 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : (snip) > I do take your point that importing * has the potential to unexpectedly > clobber names you didn't intend, Another problem is that it makes harder to know from which module a name comes from. > and that's a good reason to avoid it > unless you have a good reaso

Re: Relative-importing *

2007-07-30 Thread Bruno Desthuilliers
Paul Rubin a écrit : > Steven D'Aprano <[EMAIL PROTECTED]> writes: > >>I read "from module import *" as explicitly saying "clobber the current >>namespace with whatever names module exports". That's what from does: it >>imports names into the current namespace. It isn't some sort of easy to >>miss

Re: Where do they tech Python officialy ?

2007-07-30 Thread Bruno Desthuilliers
Omari Norman a écrit : > On Mon, Jul 23, 2007 at 10:48:10PM -0700, Paul Rubin wrote: > > >>If you're having trouble with Python because you're new at >>programming, I can sympathize--I don't think it's the most >>beginner-friendly of languages despite the efforts in that direction >>by the desig

Re: making a variable available in a function from decorator

2007-07-30 Thread Bruno Desthuilliers
Evan Klitzke a écrit : > On 7/30/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > >>is it possible to do this without passing it as a function argument? >> > Sort of. Functions are objects in python, so you can set attribute on them. > E.g. > > def foo(): > return foo.c > > foo.c = 1 > pr

Re: What is the "functional" way of doing this?

2007-07-30 Thread James Stroud
Ricardo Aráoz wrote: >>On Jul 30, 4:39 pm, Paul Rubin wrote: >> >>>"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: >>> Recursion is common in functional programming: def f(n, l=None): if l == None: l = [] if n > 0: return f(

Re: What is the "functional" way of doing this?

2007-07-30 Thread Paul Rubin
James Stroud <[EMAIL PROTECTED]> writes: > def f(n): >if n>0: > yield n%26 > for i in f(n/26): >yield i Right, this mutates i though. Let's say we have a library function itertools.iterate() and that we ignore (as we do with functions like "map") that it uses mutation under

Re: Why no maintained wrapper to Win32?

2007-07-30 Thread Gilles Ganault
On Sun, 29 Jul 2007 21:49:04 -0700, sturlamolden <[EMAIL PROTECTED]> wrote: >Why inflict suffering on yourself with MFC when you can use wxPython >or PyGTK? Because I'd like to avoid having to pack several MB + having to install the toolkit. Considering the size of the typical Python script, it se

Where can I get a complete user interface about pylibpcap?

2007-07-30 Thread Evan
A web-link would do, becuase of I don't know how many parameters I need to use in function about pylibpcap. Or what kind of parameters I need to use/transfer? I'm very gratefully if you can help on this question. Thanks, -- http://mail.python.org/mailman/listinfo/python-list

Free SMS from Computer Worldwide

2007-07-30 Thread lowboman
Hello there I invite you to check out my site http://www.nocostsms.com you can send free sms text messages from your computer to any mobile phone and receive replies in you email account, also check out cell phone forums out while your there -- http://mail.python.org/mailman/listinfo/python-list

Re: From D

2007-07-30 Thread [EMAIL PROTECTED]
Gabriel Genellina wrote: > En Tue, 24 Jul 2007 11:10:53 -0300, Stargaming <[EMAIL PROTECTED]> > escribió: > >> On Tue, 24 Jul 2007 03:19:53 -0700, bearophileHUGS wrote: >> >>> There are various things I like about the D language that I think Python >>> too may enjoy. Here are few bits (mostly sy

[2.5] Reading a two-column file into an array?

2007-07-30 Thread Gilles Ganault
Hello I'm sure there's a much easier way to read a two-column, CSV file into an array, but I haven't found it in Google. Should I use the Array module instead? = a = [] i = 0 #itemitem p = re.compile("^(.+)\t(.+)$") for line in textlines: m = p.search(line) if m:

Re: [2.5] Reading a two-column file into an array?

2007-07-30 Thread Erik Max Francis
Gilles Ganault wrote: > I'm sure there's a much easier way to read a two-column, CSV file into > an array, but I haven't found it in Google. > > Should I use the Array module instead? The csv module? Or just .rstrip and .split? -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.co

Re: Reading a two-column file into an array?

2007-07-30 Thread Nagarajan
On Jul 31, 9:03 am, Gilles Ganault <[EMAIL PROTECTED]> wrote: > Hello > > I'm sure there's a much easier way to read a two-column, CSV file into > an array, but I haven't found it in Google. > > Should I use the Array module instead? > > = > a = [] > i = 0 > > #itemitem > p = re.compile("^(

Re: Where do they tech Python officialy ?

2007-07-30 Thread Star
MIT's freshman survey, EECS 1 is taught in Python and Scheme, soon to be just Python. -Star On Wed, 25 Jul 2007, Bruno Desthuilliers wrote: Omari Norman a écrit : On Mon, Jul 23, 2007 at 10:48:10PM -0700, Paul Rubin wrote: If you're having trouble with Python because you're new at program

Re: Reading a two-column file into an array?

2007-07-30 Thread Jay Loden
Nagarajan wrote: > On Jul 31, 9:03 am, Gilles Ganault <[EMAIL PROTECTED]> wrote: >> Hello >> >> I'm sure there's a much easier way to read a two-column, CSV file into >> an array, but I haven't found it in Google. >> >> Should I use the Array module instead? [...snip] > a = [] > import csv > read

Re: Why no maintained wrapper to Win32?

2007-07-30 Thread Martin v. Löwis
> Guess I have the answer as to no one seems to write GUI apps for > Windows natively :-) That's certainly an important factor. If I wanted to ship a small application, I would write a web server, and run that locally. GUI programming is so last-century :-) Regards, Martin -- http://mail.python.

Re: Reading a two-column file into an array?

2007-07-30 Thread Marc 'BlackJack' Rintsch
On Mon, 30 Jul 2007 21:57:17 -0700, Nagarajan wrote: > a = [] > import csv > reader = csv.reader(open("filename", "r"), delimiter='\t' ) > for row in reader: > a.append( row ) I would keep a reference to the file to close it properly and the loop can be replaced by a call to `list()`: import

<    1   2