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

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 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: 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 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: [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

[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: 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

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

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

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

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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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

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: 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

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: 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

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: 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: 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: 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 Paul Rubin
"[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]) > else: > return l > > print f(1000) Right, this is functional style, but q

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

2007-07-30 Thread Steven D'Aprano
On Mon, 30 Jul 2007 22:48:10 +, 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

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

2007-07-30 Thread [EMAIL PROTECTED]
On Jul 30, 3:48 pm, beginner <[EMAIL PROTECTED]> 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

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

2007-07-30 Thread Zentrader
> 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, but on line 22 you overload Decimal. If you just have a = Decimal() b = Dec

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

2007-07-30 Thread Paul Rubin
beginner <[EMAIL PROTECTED]> writes: > 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. If you're trying to learn functional programming, maybe you should use a functional language li

Help text embedding in C code?

2007-07-30 Thread James Stroud
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 interpreter. In the cPython source, it seems like python wrapper funct

Re: Comparing Dictionaries

2007-07-30 Thread Paul Rubin
Kenneth Love <[EMAIL PROTECTED]> writes: > I will search on Google for more info on Doctest. Doctest is recent. Try: http://python.org/doc/lib/module-doctest.html Diveintopython should probably be updated to use doctest instead of unittest. unittest is Java-descended and doesn't fit into Pytho

Re: win32 question in Python

2007-07-30 Thread Brad Johnson
Cappy2112 gmail.com> writes: > > > Hello Brad, > > If you don't get a reply here, there is a win32 specific Python list > on ActiveState.com wher ethey do talk about excel & other Win32 python > issues. > Thanks, but I believe this you meant to address the OP Shun-Hsien, not me. Just wanted

Re: 128 or 96 bit integer types?

2007-07-30 Thread [EMAIL PROTECTED]
On Jul 29, 11:35 pm, Tim Roberts <[EMAIL PROTECTED]> wrote: > John DeRosa <[EMAIL PROTECTED]> wrote: > >On Sat, 28 Jul 2007 00:19:02 -0700, "[EMAIL PROTECTED]" > ><[EMAIL PROTECTED]> wrote: > > >>For example, how many ways can you put 492 marbles into > >>264 ordered bins such that each bin has at

Re: win32 question in Python

2007-07-30 Thread Cappy2112
Hello Brad, If you don't get a reply here, there is a win32 specific Python list on ActiveState.com wher ethey do talk about excel & other Win32 python issues. On Jul 30, 3:49 pm, Brad Johnson <[EMAIL PROTECTED]> wrote: > Huang, Shun-Hsien ercot.com> writes: > > > > but how do I copy a excel fi

Re: win32 question in Python

2007-07-30 Thread Brad Johnson
Huang, Shun-Hsien ercot.com> writes: > but how do I copy a excel file into > database table by using Python? > I'm not sure if this helps, but you can access the Excel Automation model very easily with: import win32com.client x1 = client.Dispatch("Excel.Application") Now you can use the x1

What is the "functional" way of doing this?

2007-07-30 Thread beginner
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 -- http://mail.python.org/mailman/listinfo/py

Utilizing a raw IDispatch Pointer from Python

2007-07-30 Thread Brad Johnson
I have a C++ application that creates a collection of COM objects. I would like to give the Python interpreter access to these interfaces that were created in C++ land. Stated another way, how can I have Python consume a IDispatch pointer from C++ and wrap it with one of those nice Python classes

Re: yield keyword usage

2007-07-30 Thread [EMAIL PROTECTED]
On Jul 30, 4:40 pm, Erik Jones <[EMAIL PROTECTED]> wrote: > On Jul 30, 2007, at 4:13 PM, 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 Pytho

Re: Directory

2007-07-30 Thread Irmen de Jong
Rohan wrote: > I would like to get a list of sub directories in a directory. > If I use os.listdir i get a list of directories and files in that . > i only want the list of directories in a directory and not the files > in it. > anyone has an idea regarding this. > Look up os.walk (allows you to

Directory

2007-07-30 Thread Rohan
I would like to get a list of sub directories in a directory. If I use os.listdir i get a list of directories and files in that . i only want the list of directories in a directory and not the files in it. anyone has an idea regarding this. -- http://mail.python.org/mailman/listinfo/python-list

Re: yield keyword usage

2007-07-30 Thread Erik Jones
On Jul 30, 2007, at 4:13 PM, 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://diveintop

Re: Comparing Dictionaries

2007-07-30 Thread Paddy
On Jul 30, 8:30 pm, Kenneth Love <[EMAIL PROTECTED]> wrote: > At 03:23 AM 7/28/2007, you wrote: > > >Hi Kenneth, being new to Python i wondered if you at least considered > >Doctests as part of your testing solution. > >Other languages don't have Doctest. > > >- Paddy. > > Until I read your post,

yield keyword usage

2007-07-30 Thread Ehsan
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 version. """ __author__ = "Mark

win32 question in Python

2007-07-30 Thread Huang, Shun-Hsien
Hi, I am new in Python. I have one question in the database application in python. I have one excel file that I want to save in the database table. In the Microsoft access, I can easy do this one by using Docmd .. How do I use this one in Python? I already know how to connect to a databa

Re: OOP in Python book?

2007-07-30 Thread James Stroud
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 >> > educational publisher". Textbooks

Re: How to write GUI and event separately in wxPython??

2007-07-30 Thread Steve Holden
[EMAIL PROTECTED] wrote: > On Jul 30, 11:42 am, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > On Mon, 30 Jul 2007 06:32:55 -0400, Steve Holden wrote: > >>> [x for x in xrange(0, 101)] == [y for y in xrange(101)] > True > >> nitpick: list(xrange(42)) == list(xrange(42)) is slightly mor

Re: How to write GUI and event separately in wxPython??

2007-07-30 Thread star . public
On Jul 30, 11:42 am, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > > > On Mon, 30 Jul 2007 06:32:55 -0400, Steve Holden wrote: > > > >> >>> [x for x in xrange(0, 101)] == [y for y in xrange(101)] > > >> True > nitpick: list(xrange(42)) == list(xrange(42)) is slightly more concise > than the list c

►Watch Satellite Channels on your PC - FREE!◄

2007-07-30 Thread Camron S
Finally Available! Who Else Wants to Watch Satellite TV On Your Computer Without Paying Monthly Fees... FOR FREE? For the very first time, Satellite TV is available on your computer with our "Cutting-Edge" Software! It's as Easy as 1...2...3... 1. Download our TVonPCPro software 2. Click on t

►Watch Satellite Channels on your PC - FREE!◄

2007-07-30 Thread Camron S
Finally Available! Who Else Wants to Watch Satellite TV On Your Computer Without Paying Monthly Fees... FOR FREE? For the very first time, Satellite TV is available on your computer with our "Cutting-Edge" Software! It's as Easy as 1...2...3... 1. Download our TVonPCPro software 2. Click on t

Re: Comparing Dictionaries

2007-07-30 Thread Kenneth Love
At 03:23 AM 7/28/2007, you wrote: >Hi Kenneth, being new to Python i wondered if you at least considered >Doctests as part of your testing solution. >Other languages don't have Doctest. > >- Paddy. Until I read your post, I had never even heard of Doctest. I will look into it. Here is the list

Fwd: Re: Comparing Dictionaries

2007-07-30 Thread Kenneth Love
>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 wrote: > > > The published recipe (based on ConfigParser) did not h

Re: How to write GUI and event separately in wxPython??

2007-07-30 Thread Marc 'BlackJack' Rintsch
On Mon, 30 Jul 2007 11:16:01 -0400, Steve Holden wrote: > Marc 'BlackJack' Rintsch wrote: >> First I thought: Why the unnecessary list comprehension but to my surprise: >> >> In [33]: xrange(42) == xrange(42) >> Out[33]: False >> >> That's strange. >> > Not so strange really. The two xrange obj

Re: problems with logging module

2007-07-30 Thread Gabriel Genellina
En Mon, 30 Jul 2007 03:50:52 -0300, Alia Khouri <[EMAIL PROTECTED]> escribió: > But I'm not letting the logging module off, it's still not the easiest > or most intuitive module to work with. > > For example: a basic Log class that can be programatically configured > would be quicker to work wit

Re: Database objects? Persistence? Sql Server woes

2007-07-30 Thread Diez B. Roggisch
Mike Howarth schrieb: > I've been having a few problems with connecting to SQL Server, initially I > was using dblib however found some problems with returning text fields > whereby all text fields were ignored and it bawked at multiline sql > statements. > > Having found these major stumbling blo

Re: Bug? exec converts '\n' to newline in docstrings!?

2007-07-30 Thread Stargaming
On Mon, 30 Jul 2007 11:00:14 -0500, Edward K Ream wrote: >> The problem is because you are trying to represent a Python > program as a Python string literal, and doing it incorrectly. > > Yes, that is exactly the problem. Thanks to all who replied. Changing > changing '\n' to '\\n' fixed the pr

RE: Free support for Python developers

2007-07-30 Thread Carroll, Barry
Viktor: This is a great idea. Thank you I don't currently have a voice setup on my machine, but will try to get one as soon as possible. I would be pleased to trade English practice for Python support. Regards, Barry [EMAIL PROTECTED] 541-302-1107 We who cut mere s

Re: Database objects? Persistence? Sql Server woes

2007-07-30 Thread Steve Holden
Mike Howarth wrote: > I've been having a few problems with connecting to SQL Server, initially I > was using dblib however found some problems with returning text fields > whereby all text fields were ignored and it bawked at multiline sql > statements. > > Having found these major stumbling block

Python-URL! - weekly Python news and links (Jul 30)

2007-07-30 Thread Gabriel Genellina
QOTW: "If you really want to learn hard-core Python, probably your best bet is: * read everything Tim Peters has ever written in comp.lang.python (this will take a few months), start with "import this" * read everything the PyPy guys have ever written (particularly Christian and

Re: Replacing overloaded functions with closures.

2007-07-30 Thread Terry Reedy
"king kikapu" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | > def func(obj): | > if isinstance(obj, bool): | > return not obj | > elif isinstance(obj, int): | > return obj * 2 | > elif isinstance(obj, basestring): | > return obj + obj | > else: | > raise No

Re: Making Gridded Widgets Expandable

2007-07-30 Thread Jim
On Jul 30, 8:24 am, "Hamilton, William " <[EMAIL PROTECTED]> wrote: > > From: Jim > > Hi, > > I'm looking at page 548 of Programming Python (3rd Edition) by Mark > > Lutz. > > The following GUI script works with no problem, i.e., the rows and > > columns expand: > >

Re: making a variable available in a function from decorator

2007-07-30 Thread Evan Klitzke
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 print foo() Which will print 1. Of course, it

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

2007-07-30 Thread Gilbert Fine
Thanks. I think I have some direction to do logging, to get more information about this problem. It seems that I don't get used to dynamic language yet. -- Gilbert On Jul 30, 7:20 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > > > On Mon, 30 J

Re: pythonic parsing of URL

2007-07-30 Thread GreenH
On Jul 27, 10:04 pm, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sat, 28 Jul 2007 03:10:32 +, GreenH wrote: > > I get some string as below from a library method (qt3 > > QDropEvent.data()) I use. > > file:///C:/Documents%20and%20Settings/Username/My%20Documents/45-61-Abc%20fold-%20den.vru >

Database objects? Persistence? Sql Server woes

2007-07-30 Thread Mike Howarth
I've been having a few problems with connecting to SQL Server, initially I was using dblib however found some problems with returning text fields whereby all text fields were ignored and it bawked at multiline sql statements. Having found these major stumbling blocks I've started using pymssql wh

Re: making a variable available in a function from decorator

2007-07-30 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : (top-post corrected) > > On 30 Jul 2007 06:17:25 GMT, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> > wrote: >> On Sun, 29 Jul 2007 15:22:47 -0700, [EMAIL PROTECTED] wrote: >> >>> I create a variable in a decorator. i want to be able to access that >>> variable in the f

Re: Bug? exec converts '\n' to newline in docstrings!?

2007-07-30 Thread Edward K Ream
> The problem is because you are trying to represent a Python program as a Python string literal, and doing it incorrectly. Yes, that is exactly the problem. Thanks to all who replied. Changing changing '\n' to '\\n' fixed the problem. Edward ---

Re: Replacing overloaded functions with closures.

2007-07-30 Thread Bruno Desthuilliers
king kikapu a écrit : > Hi, > > i am trying, to no avail yet, to take a C#'s overloaded functions > skeleton and rewrite it in Python by using closures. > I read somewhere on the net (http://dirtsimple.org/2004/12/python-is- > not-java.html) that in Python we can reduce code duplication for > over

Re: How to write GUI and event separately in wxPython??

2007-07-30 Thread Steve Holden
Chris Mellon wrote: > On 7/30/07, Steve Holden <[EMAIL PROTECTED]> wrote: >> Marc 'BlackJack' Rintsch wrote: >>> On Mon, 30 Jul 2007 06:32:55 -0400, Steve Holden wrote: >>> >>> [x for x in xrange(0, 101)] == [y for y in xrange(101)] True >>> First I thought: Why the unnecessary list comp

Re: Bug? exec converts '\n' to newline in docstrings!?

2007-07-30 Thread Steve Holden
Edward K Ream wrote: > It looks like both exec and execfile are converting "\n" to an actual > newline > in docstrings! > > Start idle: > > Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on > win32 > [rest of signon deleted] > s = '''\ > strings = 'abc'.split("\n

Re: Bug? exec converts '\n' to newline in docstrings!?

2007-07-30 Thread Diez B. Roggisch
Edward K Ream wrote: > It looks like both exec and execfile are converting "\n" to an actual > newline > in docstrings! > > Start idle: > > Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] > on win32 > [rest of signon deleted] > s = '''\ > strings = 'abc'.split("\n

Re: Replacing overloaded functions with closures.

2007-07-30 Thread king kikapu
> The closures discussed in the article are not a solution for > function overloading. They are a solution for function > composition. Hmmm > > Python generally has no need for function name overloading--if > you really want it you must do it manually using runtime type > checking. > > def fu

Re: How to write GUI and event separately in wxPython??

2007-07-30 Thread Chris Mellon
On 7/30/07, Steve Holden <[EMAIL PROTECTED]> wrote: > Marc 'BlackJack' Rintsch wrote: > > On Mon, 30 Jul 2007 06:32:55 -0400, Steve Holden wrote: > > > >> >>> [x for x in xrange(0, 101)] == [y for y in xrange(101)] > >> True > > > > First I thought: Why the unnecessary list comprehension but to my

Bug? exec converts '\n' to newline in docstrings!?

2007-07-30 Thread Edward K Ream
It looks like both exec and execfile are converting "\n" to an actual newline in docstrings! Start idle: Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32 [rest of signon deleted] >>> s = '''\ strings = 'abc'.split("\n") ''' >>> print s strings = 'abc'.split(" "

Re: Detecting __future__ features

2007-07-30 Thread Steve Holden
Lawrence Oluyede wrote: > Steven D'Aprano <[EMAIL PROTECTED]> wrote: >> Is there any general mechanism? > > I'd just use the expected future feature and if the result is not what I > expect (or Python raises any kind of exception, like using a keyword not > present) I'd think I'm in the past :-)

Re: Events: The Python Way

2007-07-30 Thread kyosohma
On Jul 29, 3:14 pm, "Gianmaria" <[EMAIL PROTECTED]> wrote: > "David Wilson" <[EMAIL PROTECTED]> ha scritto nel messaggionews:[EMAIL > PROTECTED] > > > > > Hi there, > > > Python has no built-in way of doing this. You may consider writing > > your own class if you like this pattern (I personally do

Re: Replacing overloaded functions with closures.

2007-07-30 Thread Neil Cerutti
On 2007-07-30, king kikapu <[EMAIL PROTECTED]> wrote: > i am trying, to no avail yet, to take a C#'s overloaded > functions skeleton and rewrite it in Python by using closures. > I read somewhere on the net > (http://dirtsimple.org/2004/12/python-is- not-java.html) that > in Python we can reduce co

Re: How to write GUI and event separately in wxPython??

2007-07-30 Thread Steve Holden
Marc 'BlackJack' Rintsch wrote: > On Mon, 30 Jul 2007 06:32:55 -0400, Steve Holden wrote: > >> >>> [x for x in xrange(0, 101)] == [y for y in xrange(101)] >> True > > First I thought: Why the unnecessary list comprehension but to my surprise: > > In [33]: xrange(42) == xrange(42) > Out[33]: Fal

Re: Process Control Help

2007-07-30 Thread Azazello
On Jul 28, 1:40 am, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > <[EMAIL PROTECTED]> wrote: > > > I'm attempting to start some process control using Python. I've have > > quite a bit of literature on networking, and have made some tinkering > > servers and clients for different protocols HTT

Re: Cross platform Python app deployment

2007-07-30 Thread vasudevram
On Jul 30, 4:42 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Will McGugan wrote: > > Hi, > > > Is there some reference regarding how to package a Python application > > for the various platforms? I'm familiar with Windows deployment - I use > > Py2Exe & InnoSetup - but I would like more info

RE: Making Gridded Widgets Expandable

2007-07-30 Thread Hamilton, William
> From: Jim > Hi, > I'm looking at page 548 of Programming Python (3rd Edition) by Mark > Lutz. > The following GUI script works with no problem, i.e., the rows and > columns expand: > = > # Gridded Widgets Expandable page 548 > > fro

Replacing overloaded functions with closures.

2007-07-30 Thread king kikapu
Hi, i am trying, to no avail yet, to take a C#'s overloaded functions skeleton and rewrite it in Python by using closures. I read somewhere on the net (http://dirtsimple.org/2004/12/python-is- not-java.html) that in Python we can reduce code duplication for overloaded functions by using closures.

Re: File handle not being released by close

2007-07-30 Thread Jean-Paul Calderone
On Mon, 30 Jul 2007 07:36:00 -0700, [EMAIL PROTECTED] wrote: >Hi, > > [snip] >f=open(fileBeginning+".tmp", 'w') >f.write("Hello") >f.close > You forgot to call close. Try this final line, instead: f.close() Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Detecting __future__ features

2007-07-30 Thread André
On Jul 30, 11:10 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-07-30, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > > > Making the switch between different parser-implementations on > > the fly isn't technically impossible - but really, really, > > really complicated. But then, if it's lame

Re: File handle not being released by close

2007-07-30 Thread Peter Otten
[EMAIL PROTECTED] wrote: > I'm in the process of writing some code and noticed a strange problem > while doing so. I'm working with PythonWin 210 built for Python 2.5. I > noticed the problem for the last py file processed by this script, > where the concerned tmp file is only actually written to

Re: File handle not being released by close

2007-07-30 Thread Eric Brunel
On Mon, 30 Jul 2007 16:36:00 +0200, <[EMAIL PROTECTED]> wrote: > Hi, > > I'm in the process of writing some code and noticed a strange problem > while doing so. I'm working with PythonWin 210 built for Python 2.5. I > noticed the problem for the last py file processed by this script, > where the c

Re: Making Gridded Widgets Expandable

2007-07-30 Thread Eric Brunel
On Mon, 30 Jul 2007 15:59:21 +0200, Jim <[EMAIL PROTECTED]> wrote: > Hi, > I'm looking at page 548 of Programming Python (3rd Edition) by Mark > Lutz. > The following GUI script works with no problem, i.e., the rows and > columns expand: > ==

Re: File handle not being released by close

2007-07-30 Thread Richard Brodie
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm guessing the garbage collector is causing the file to be written, > but shouldn't close do this? Only if you call it ;) -- http://mail.python.org/mailman/listinfo/python-list

Subprocess and pipe-fork-exec primitive

2007-07-30 Thread Rafael Giannetti Viotti
Hi, I am working with the subprocess.py module in Python 2.4.4 and I am confused about it's functionality. It uses the standard pipe-fork-exec method to start a subprocess: # create pipes pid = fork() if pid == 0: # child exec(...) # parent status = waitpid(pid, 0

Re: making a variable available in a function from decorator

2007-07-30 Thread [EMAIL PROTECTED]
is it possible to do this without passing it as a function argument? On 30 Jul 2007 06:17:25 GMT, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Sun, 29 Jul 2007 15:22:47 -0700, [EMAIL PROTECTED] wrote: > > > I create a variable in a decorator. i want to be able to access that > > variab

Re: Detecting __future__ features

2007-07-30 Thread Carsten Haese
On Mon, 2007-07-30 at 14:10 +, Neil Cerutti wrote: > On 2007-07-30, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > > Making the switch between different parser-implementations on > > the fly isn't technically impossible - but really, really, > > really complicated. But then, if it's lameness suc

File handle not being released by close

2007-07-30 Thread bg_ie
Hi, I'm in the process of writing some code and noticed a strange problem while doing so. I'm working with PythonWin 210 built for Python 2.5. I noticed the problem for the last py file processed by this script, where the concerned tmp file is only actually written to when PythonWin is closed. In

Re: encode/decode misunderstanding

2007-07-30 Thread Tim Arnold
"Diez B. Roggisch" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Tim Arnold schrieb: >> Hi, I'm beginning to understand the encode/decode string methods, but I'd >> like confirmation that I'm still thinking in the right direction: >> >> I have a file of latin1 encoded text. Let's

Re: Detecting __future__ features

2007-07-30 Thread Neil Cerutti
On 2007-07-30, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > Making the switch between different parser-implementations on > the fly isn't technically impossible - but really, really, > really complicated. But then, if it's lameness sucks so much, > you might wanna take a stab at it? I was conside

Making Gridded Widgets Expandable

2007-07-30 Thread Jim
Hi, I'm looking at page 548 of Programming Python (3rd Edition) by Mark Lutz. The following GUI script works with no problem, i.e., the rows and columns expand: = # Gridded Widgets Expandable page 548 from Tkinter import * colors = ["

  1   2   >