Re: [Tutor] Python Questions Help

2014-10-26 Thread Dave Angel
Please don't use html mail in a text newsgroup. And especially don't select black on black for your foreground and background colors. Caroline H Wrote in message: > create a new sorted list consisting of all the elements of lst1 that also appears in lst2 . Are you permitted at this stage

Re: [Tutor] Python GPIO Code Help Needed

2014-10-26 Thread Danny Yoo
>> def changed(channel): >> newstate = GPIO.input(channel) >> change = oldstates[channel] and not newstate >> oldstates[channel] = newstate Hi Bill, I would suggest documenting the intent of this function, as it isn't obvious at first. A comment string would be approp

Re: [Tutor] Python GPIO Code Help Needed

2014-10-26 Thread Dave Angel
Please use text mail for posting, and please use reply-list, or whatever your mailer calls it when adding to a thread. So far, you've got at least 3 threads covering a single topic. Bill Bright Wrote in message: > > The code below seems to work. My question is why does oldstates need to be

Re: [Tutor] if you're interested in the code thus far...

2014-10-26 Thread Alan Gauld
On 26/10/14 22:12, Clayton Kirkwood wrote: !On 25/10/14 23:46, Clayton Kirkwood wrote: !> __author__ = 'SYSTEM' ! !You are still setting __author__ which is a bit suspect. !Leave double underscores to python. This is something being created when I started with this file. How are you creating

Re: [Tutor] Python Questions Help

2014-10-26 Thread Alan Gauld
On 26/10/14 22:15, Caroline H wrote: For example, lst1 = [2,5,6,7,2] lst2 = [2,4] it comes up with new_list = [2] when I need it to come up with new_list = [2,2] Check the logic in the if statement. Walk through it and se if it does what you expect. You are basically doing the right thing, e

Re: [Tutor] User Input with Multiple Lines

2014-10-26 Thread eryksun
On Sun, Oct 26, 2014 at 3:25 PM, Malik Brahimi wrote: > So I am working with input that is pasted from a PDF file, and I was > wondering if there is any way I can do so without the program terminating > abruptly because of the newlines. input() and raw_input() grab a single line of text. The rest

Re: [Tutor] Python GPIO Code Help Needed

2014-10-26 Thread Alan Gauld
On 26/10/14 22:42, Bill Bright wrote: Thanks to all for the help. The code below seems to work. My question is why does oldstates need to be multiplied by 32? Its creating 32 instances of True. So you can cater for up to 32 different switch positions. will only read 32 switch changes? That

[Tutor] Python GPIO Code Help Needed

2014-10-26 Thread Bill Bright
Thanks to all for the help. The code below seems to work. My question is why does oldstates need to be multiplied by 32? Does this means the code will only read 32 switch changes? That would be a problem. Code: #!/usr/bin/env python from time import sleep import os import RPi.GPIO as GPIO GPIO

Re: [Tutor] if you're interested in the code thus far...

2014-10-26 Thread Clayton Kirkwood
!-Original Message- !From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On !Behalf Of Alan Gauld !Sent: Sunday, October 26, 2014 2:11 AM !To: tutor@python.org !Subject: Re: [Tutor] if you're interested in the code thus far... ! !On 25/10/14 23:46, Clayton Kirkwood wrote: !>

Re: [Tutor] Python GPIO Code Help Needed

2014-10-26 Thread Bill Bright
Thanks to everyone for the help. The code below seems to work. My question is why does oldstates need to multiplied by 32? Does this mean that the code will only work for 32 switches before I have to reset the Pi? Code: #!/usr/bin/env python from time import sleep import os import RPi.GPIO as G

[Tutor] Python Questions Help

2014-10-26 Thread Caroline H
Hi Python Tutor, I'm having a lot of trouble with this python problem and I'm wondering if you can help me. "Given the lists, lst1 and lst2 , create a new sorted list consisting of all the elements of lst1 that also appears in lst2 . For example, if lst1 is [4, 3, 2, 6, 2] and lst2 is [1, 2, 4], t

Re: [Tutor] User Input with Multiple Lines

2014-10-26 Thread Ben Finney
Malik Brahimi writes: > So I am working with input that is pasted from a PDF file, and I was > wondering if there is any way I can do so without the program > terminating abruptly because of the newlines. Can you construct a *very* short and simple example program, which demonstrates the problem

Re: [Tutor] Auto-response for your message to the "Tutor" mailing list

2014-10-26 Thread Marc Tompkins
On Sun, Oct 26, 2014 at 1:15 PM, Danny Yoo wrote: > > >> why is it I get this messages repeatedly despite having been reading > and writing on the list for over a year now? > > This has happened to me once in a while too. I conjecture that it might > be a bug with Mailman, but I'd have to dive i

[Tutor] User Input with Multiple Lines

2014-10-26 Thread Malik Brahimi
So I am working with input that is pasted from a PDF file, and I was wondering if there is any way I can do so without the program terminating abruptly because of the newlines. I know that multiple lines of input can be achieved via a loop with string concatenation, but this is not what I'm looking

Re: [Tutor] Auto-response for your message to the "Tutor" mailing list

2014-10-26 Thread Danny Yoo
>> why is it I get this messages repeatedly despite having been reading and writing on the list for over a year now? This has happened to me once in a while too. I conjecture that it might be a bug with Mailman, but I'd have to dive into the code to be certain. ___

Re: [Tutor] if you're interested in the code thus far...

2014-10-26 Thread Clayton Kirkwood
Good eyes on the logic !-Original Message- !From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On !Behalf Of Peter Otten !Sent: Sunday, October 26, 2014 3:53 AM !To: tutor@python.org !Subject: Re: [Tutor] if you're interested in the code thus far... ! !Clayton Kirkwood wrote

Re: [Tutor] Auto-response for your message to the "Tutor" mailing list

2014-10-26 Thread Alan Gauld
On 26/10/14 17:18, Dominik George wrote: Hi, Am 26. Oktober 2014 13:20:13 MEZ, schrieb tutor-boun...@python.org: Your message for tutor@python.org, the Python programming tutor list, has been received and is being delivered. This automated response is sent to those of you new to the Tutor list

Re: [Tutor] Auto-response for your message to the "Tutor" mailing list

2014-10-26 Thread Dominik George
Hi, Am 26. Oktober 2014 13:20:13 MEZ, schrieb tutor-boun...@python.org: >Your message for tutor@python.org, the Python programming tutor list, >has been received and is being delivered. This automated response is >sent to those of you new to the Tutor list, to point out a few >resources that can

Re: [Tutor] Python GPIO Code Help Needed

2014-10-26 Thread Alan Gauld
On 26/10/14 01:05, Bill Bright wrote: The code polls the GPIO pins on a Raspberry Pi. > When it detects a switch being flipped, it plays a corresponding audio file. Does that mean in either direction? Or does it only play when the switch goes ON? (I'm not familiar with the Pi (although some

Re: [Tutor] Differentiating vowels from consonants

2014-10-26 Thread Alan Gauld
On 26/10/14 09:01, William Becerra wrote: word = raw_input("Who do You Support: ") vowels = ('a', 'e', 'i', 'o', 'u') You could just use a string vowels = 'aeiou' for letter in word: if letter == vowels: you want if letter in vowels: call = 'Give me an ' + letter + '!'

[Tutor] Differentiating vowels from consonants

2014-10-26 Thread William Becerra
Hello, I'm new to programming Running Python 2.7.8 on Windows 8 OS I was reading http://www.sthurlow.com/python/lesson07/ Here there is an example of the for loop with a Cheerleader program but the program is not able to print grammatically correct. word = raw_input("Who do you go for? ") for l

Re: [Tutor] Python GPIO Code Help Needed

2014-10-26 Thread Anish Tambe
On Sun, Oct 26, 2014 at 6:35 AM, Bill Bright wrote: > I have been working on a piece of code that I got from another tutorial. > The code polls the GPIO pins on a Raspberry Pi. When it detects a switch > being flipped, it plays a corresponding audio file. My problem is, if the > switch remains fl

Re: [Tutor] Python GPIO Code Help Needed

2014-10-26 Thread Crush
Could this work? /usr/bin/env python import os import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(23, GPIO.IN) GPIO.setup(24, GPIO.IN) GPIO.setup(25, GPIO.IN) pin_list = ['GPIO.input(23)', 'GPIO.input(23)', 'GPIO.input(23)'] for item in pin_list: if item == false: os.system('mpg321

Re: [Tutor] Python GPIO Code Help Needed

2014-10-26 Thread Dave Angel
Bill Bright Wrote in message: > I have been working on a piece of code that I got from another tutorial. The > code polls the GPIO pins on a Raspberry Pi. When it detects a switch being > flipped, it plays a corresponding audio file. My problem is, if the switch > remains flipped, the audio rep

Re: [Tutor] Python GPIO Code Help Needed

2014-10-26 Thread Dominik George
Hi, >if ( GPIO.input(23) == False ): >os.system('mpg321 -g 95 a.mp3') while not GPIO.input(23): pass ... would be the simplest solution. -nik ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription opt

Re: [Tutor] if you're interested in the code thus far...

2014-10-26 Thread Peter Otten
Clayton Kirkwood wrote: > for description_position, code_position in zip(description, code): > description_position_len = len(description_position) > current_output_pos += description_position_len > if current_output_pos >= output_line_len: > print(description_output_string) >

Re: [Tutor] if you're interested in the code thus far...

2014-10-26 Thread Alan Gauld
On 25/10/14 23:46, Clayton Kirkwood wrote: __author__ = 'SYSTEM' You are still setting __author__ which is a bit suspect. Leave double underscores to python. import string You are still importing string twice, and you don't use it anywhere that I can see. #PricingDividends

[Tutor] Python GPIO Code Help Needed

2014-10-26 Thread Bill Bright
I have been working on a piece of code that I got from another tutorial. The code polls the GPIO pins on a Raspberry Pi. When it detects a switch being flipped, it plays a corresponding audio file. My problem is, if the switch remains flipped, the audio repeats again and again. What I would like

[Tutor] if you're interested in the code thus far...

2014-10-26 Thread Clayton Kirkwood
__author__ = 'SYSTEM' import string #PricingDividends raw_table = (''' a: Asky: Dividend Yield b: Bid d: Dividend per Share b2: Ask (Realtime) r1: Dividend Pay Date b3: Bid (Realtime)q: Ex-Dividend Date p: Previous Close o: Open Date c1: Chan

Re: [Tutor] Help with running an API

2014-10-26 Thread Anish Tambe
The usage of the api as documented here - https://github.com/zachwill/fred - suggests : >>> import fred # Save your FRED API key. >>> fred.key('my_fred_api_key') # Interact with economic data categories. >>> fred.category() ... Cheers, Anish Tambe On 26 Oct 2014 00:23, "Joel Goldstick" wrote: