Re: [Tutor] module import problems

2010-04-26 Thread Rayon
I have a project folder report_db in that project folder I have to packages _modules and _ tables report_db \ _tables _modules I want to import some functions from _tables to _modules so I can use them in a function in _modules. From: bob g

Re: [Tutor] Which Designer

2010-04-26 Thread Alan Gauld
"Steve Willoughby" wrote However, there are some real disadvantages to Tk(inter) as well, chiefly that it is a least-common denominator which does a passable job of running GUIs but they don't look consistent with the native look of Windows or OS/X The new themed widgets in Tk have changed t

Re: [Tutor] module import problems

2010-04-26 Thread Rayon
my bad it was a simple error I was calling it form the wrong module thanks From: Rayon Sent: Monday, April 26, 2010 3:47 AM To: bob gailer ; tutor@python.org Subject: Re: [Tutor] module import problems I have a project folder report_db in that project folder I have to packages _modules and

[Tutor] Programming pic chips with python

2010-04-26 Thread Humphrey
hi there I am new to python and i want to ask if python can be used in electronics like for programming programmable chips like the PIC16F series. I want to used it specifically in power conversion systems like Sine wave inverters and uninterpretable power supply systems kindest regards Hump

Re: [Tutor] Programming pic chips with python

2010-04-26 Thread Steve Willoughby
On Mon, Apr 26, 2010 at 12:18:45PM +0200, Humphrey wrote: > I am new to python and i want to ask if python can be used in electronics > like for programming programmable chips like the PIC16F series. I want to > used it specifically in power conversion systems like Sine wave inverters and > unin

[Tutor] Problem iterating over csv.DictReader

2010-04-26 Thread Matthew Williams
Dear All, I have noticed this odd behaviour in the CSV DictReader Class, and at a loss to understand/ get around it. The aim is to read in a CSV file, and then iterate over the lines. The problem (seems) to be that once you have iterated over it once, you can't do it again. I don't know if

Re: [Tutor] Programming pic chips with python

2010-04-26 Thread Alan Gauld
"Humphrey" wrote I am new to python and i want to ask if python can be used in electronics like for programming programmable chips like the PIC16F series. It depends on your chip development environment. If the programmer connects to a PC (via serial or USB for example) then usually there

Re: [Tutor] Problem iterating over csv.DictReader

2010-04-26 Thread Serdar Tumgoren
> I have noticed this odd behaviour in the CSV DictReader Class, and at a > loss to understand/ get around it. > > The aim is to read in a CSV file, and then iterate over the lines. The > problem (seems) to be that once you have iterated over it once, you can't do > it again. > > This is expected b

[Tutor] what is wrong with this code?

2010-04-26 Thread Norman Khine
hello, i have a list of tables i want to drop: user_tables = ['notification', 'userNotification', 'product_comments', 'product_donation_paypalTransaction', 'product_donation', 'productList_recommended', 'productList_user_assoc', 'profile_values'] drop_user_tables = """DROP TABLE IF EXISTS db2.%s"

Re: [Tutor] what is wrong with this code?

2010-04-26 Thread Serdar Tumgoren
> user_tables = ['notification', 'userNotification', 'product_comments', > 'product_donation_paypalTransaction', 'product_donation', > 'productList_recommended', 'productList_user_assoc', > 'profile_values'] > > drop_user_tables = """DROP TABLE IF EXISTS db2.%s""" > > try: >cursor.execute(drop_

Re: [Tutor] what is wrong with this code?

2010-04-26 Thread Norman Khine
thanks for the reply. On Mon, Apr 26, 2010 at 7:18 PM, Serdar Tumgoren wrote: > >> user_tables = ['notification', 'userNotification', 'product_comments', >> 'product_donation_paypalTransaction', 'product_donation', >> 'productList_recommended', 'productList_user_assoc', >> 'profile_values'] >> >>

Re: [Tutor] what is wrong with this code?

2010-04-26 Thread Norman Khine
On Mon, Apr 26, 2010 at 7:45 PM, Norman Khine wrote: > thanks for the reply. > > On Mon, Apr 26, 2010 at 7:18 PM, Serdar Tumgoren wrote: >> >>> user_tables = ['notification', 'userNotification', 'product_comments', >>> 'product_donation_paypalTransaction', 'product_donation', >>> 'productList_rec

Re: [Tutor] Problem iterating over csv.DictReader

2010-04-26 Thread Sander Sweers
On 26 April 2010 15:00, Matthew Williams wrote: > What I'm looking for is a way to explicity reset the iterator, to tell it to > go back to the beginning. You will need to use the seek method on the fileobject. f = open('insert your csv file here.csv', 'rb') #Note the b in 'rb' #Do your process

Re: [Tutor] what is wrong with this code?

2010-04-26 Thread Steve Willoughby
On Mon, Apr 26, 2010 at 07:53:17PM +0200, Norman Khine wrote: > ok this worked, > > cursor.execute(drop_user_tables % ",".join(user_tables)) > > it seems that DROP TABLE (and other DDL statements) don't technically > take SQL parameters. That's correct. The point of using %s as a placeholder f

[Tutor] For loop breaking string methods

2010-04-26 Thread C M Caine
Why does this not work: >>> L = [' foo ','bar '] >>> for i in L: i = i.strip() >>> L [' foo ', 'bar '] >>> # note the leading whitespace that has not been removed. But this does: >>> L = [i.strip() for i in L] >>> L ['foo', 'bar'] What other strange behaviour should I expect from for loops?

Re: [Tutor] For loop breaking string methods

2010-04-26 Thread bob gailer
On 4/26/2010 3:38 PM, C M Caine wrote: Why does this not work: By "work" you mean "do what I want it to do". >>> L = [' foo ','bar '] >>> for i in L: i = i.strip() This creates a new local variable named i. It does not affect L. This has nothing to do with loops nor is it strange behav

Re: [Tutor] For loop breaking string methods

2010-04-26 Thread C M Caine
Thank you for the clarification, bob. For any future readers of this thread I include this link[1] to effbot's guide on lists, which I probably should have already read. My intention now is to modify list contents in the following fashion: for index, value in enumerate(L): L[0] = some_func(v

Re: [Tutor] For loop breaking string methods

2010-04-26 Thread Sander Sweers
On 26 April 2010 21:38, C M Caine wrote: > Why does this not work: L = [' foo ','bar '] for i in L: >     i = i.strip() str.strip() _returns_ a *new* string and leaves the original string alone. The reason being that string are immutable so can not be changed. >>> s1 = ' foo ' >>> s1[1

Re: [Tutor] For loop breaking string methods

2010-04-26 Thread Alan Gauld
"C M Caine" wrote My intention now is to modify list contents in the following fashion: for index, value in enumerate(L): L[0] = some_func(value) I think you mean: L[index] = some_func(value) Is this the standard method? Or use a List copmprehension. L = [some_func(value) for

Re: [Tutor] For loop breaking string methods

2010-04-26 Thread C M Caine
>> What other strange behaviour should I expect from for loops? > > You should read up on immutable data types like strings and tuples. > Start with [1]. > > Greets > Sander > > [1] http://docs.python.org/reference/datamodel.html > Thank you kindly for your reply, I'll be sure to read up on it. C

Re: [Tutor] For loop breaking string methods

2010-04-26 Thread C M Caine
On 26 April 2010 23:45, Alan Gauld wrote: > > "C M Caine" wrote >> >> My intention now is to modify list contents in the following fashion: >> >> for index, value in enumerate(L): >>   L[0] = some_func(value) > > I think you mean: >     L[index] = some_func(value) Yes, I do >> Is this the stand

Re: [Tutor] For loop breaking string methods

2010-04-26 Thread Dave Angel
C M Caine wrote: Thank you for the clarification, bob. For any future readers of this thread I include this link[1] to effbot's guide on lists, which I probably should have already read. My intention now is to modify list contents in the following fashion: for index, value in enumerate(L):