Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77359 > unrolled thread
| Started by | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| First post | 2014-08-31 17:02 -0400 |
| Last post | 2014-08-31 22:52 -0600 |
| Articles | 20 on this page of 28 — 10 participants |
Back to article view | Back to comp.lang.python
This could be an interesting error Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-31 17:02 -0400
Re: This could be an interesting error Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-31 17:07 -0400
Re: This could be an interesting error Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-31 22:38 +0100
Re: This could be an interesting error Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-31 18:04 -0400
Re: This could be an interesting error Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-31 23:26 +0100
Re: This could be an interesting error Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-31 18:42 -0400
Re: This could be an interesting error Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-09-01 00:21 +0100
Re: This could be an interesting error Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-31 20:08 -0400
Re: This could be an interesting error Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-09-01 01:56 +0100
Re: This could be an interesting error Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-01 12:53 +1000
Re: This could be an interesting error Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-09-01 07:34 +0100
Re: This could be an interesting error Ned Batchelder <ned@nedbatchelder.com> - 2014-08-31 22:12 -0400
Re: This could be an interesting error Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-31 22:54 -0400
Re: This could be an interesting error Larry Hudson <orgnut@yahoo.com> - 2014-08-31 21:55 -0700
Re: This could be an interesting error Chris Angelico <rosuav@gmail.com> - 2014-09-01 15:12 +1000
Re: This could be an interesting error Rustom Mody <rustompmody@gmail.com> - 2014-08-31 23:53 -0700
Re: This could be an interesting error MRAB <python@mrabarnett.plus.com> - 2014-08-31 22:53 +0100
Re: This could be an interesting error Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-31 18:07 -0400
Re: This could be an interesting error Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-01 12:12 +1000
Re: This could be an interesting error Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-31 22:13 -0400
Re: This could be an interesting error Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-09-01 19:25 +1200
Re: This could be an interesting error Michael Torrie <torriem@gmail.com> - 2014-08-31 16:10 -0600
Re: This could be an interesting error Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-31 18:31 -0400
Re: This could be an interesting error Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-31 20:04 -0400
Re: This could be an interesting error MRAB <python@mrabarnett.plus.com> - 2014-09-01 01:23 +0100
Re: This could be an interesting error Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-31 20:35 -0400
Re: This could be an interesting error Michael Torrie <torriem@gmail.com> - 2014-08-31 22:15 -0600
Re: This could be an interesting error Michael Torrie <torriem@gmail.com> - 2014-08-31 22:52 -0600
Page 1 of 2 [1] 2 Next page →
| From | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| Date | 2014-08-31 17:02 -0400 |
| Subject | This could be an interesting error |
| Message-ID | <pm270ap6g01k6a5ip10ij1lgtebsrv00mr@4ax.com> |
import math
import random
import sys
ex='Hey buddy get away from the car'
newex = ex.split()
sentence=""
print (newex)
wait = input (" Wait")
def pigword(test):
for x in range(len(test)):
if test[x] in "AEIOUaeiou":
stem = test [x:]
prefix = test [:x]
pigword = stem + prefix + "ay"
print ("Stem ",stem)
print ("Prefix",prefix)
print (pigword)
break
return (pigword)
for x in range(len(newex)):
sentence = sentence + pigword(newex[x])+ " "
print (sentence)
wait = input (" Wait")
The program seems to work and it does work with everything I have
tried so far. The one exception is if you change "the" to "my" (in
the first line) the program crashes.
Traceback (most recent call last):
File "C:\Documents and
Settings\Administrator\Desktop\Functions\test.py", line 25, in
<module>
sentence = sentence + pigword(newex[x])+ " "
File "C:\Documents and
Settings\Administrator\Desktop\Functions\test.py", line 22, in pigword
return (pigword)
UnboundLocalError: local variable 'pigword' referenced before
assignment
>>>
[toc] | [next] | [standalone]
| From | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| Date | 2014-08-31 17:07 -0400 |
| Message-ID | <rg370a54f55ol9rhj10hhv7eso15a58asb@4ax.com> |
| In reply to | #77359 |
I forgot to mention this is supposed to be piglatin. It prints the
prefix and the suffix before printing the translated word.
On Sun, 31 Aug 2014 17:02:51 -0400, Seymore4Head
<Seymore4Head@Hotmail.invalid> wrote:
>import math
>import random
>import sys
>
>ex='Hey buddy get away from the car'
>newex = ex.split()
>sentence=""
>
>print (newex)
>wait = input (" Wait")
>
>def pigword(test):
> for x in range(len(test)):
> if test[x] in "AEIOUaeiou":
> stem = test [x:]
> prefix = test [:x]
> pigword = stem + prefix + "ay"
> print ("Stem ",stem)
> print ("Prefix",prefix)
> print (pigword)
> break
> return (pigword)
>
>for x in range(len(newex)):
> sentence = sentence + pigword(newex[x])+ " "
> print (sentence)
> wait = input (" Wait")
>
>The program seems to work and it does work with everything I have
>tried so far. The one exception is if you change "the" to "my" (in
>the first line) the program crashes.
>
>
>Traceback (most recent call last):
> File "C:\Documents and
>Settings\Administrator\Desktop\Functions\test.py", line 25, in
><module>
> sentence = sentence + pigword(newex[x])+ " "
> File "C:\Documents and
>Settings\Administrator\Desktop\Functions\test.py", line 22, in pigword
> return (pigword)
>UnboundLocalError: local variable 'pigword' referenced before
>assignment
>>>>
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2014-08-31 22:38 +0100 |
| Message-ID | <mailman.13666.1409521108.18130.python-list@python.org> |
| In reply to | #77359 |
On 31/08/2014 22:02, Seymore4Head wrote:
> import math
> import random
> import sys
>
> ex='Hey buddy get away from the car'
> newex = ex.split()
> sentence=""
>
> print (newex)
> wait = input (" Wait")
>
> def pigword(test):
> for x in range(len(test)):
Please read up on how to use for loops as the above is usually a code smell.
> if test[x] in "AEIOUaeiou":
> stem = test [x:]
> prefix = test [:x]
> pigword = stem + prefix + "ay"
> print ("Stem ",stem)
> print ("Prefix",prefix)
> print (pigword)
> break
> return (pigword)
This is Python so please get rid of those unnecessary brackets. Having
done that assume that you have an empty test so your loop never gets
entered, the local pigword never gets assigned before the return hence
your UnboundLocalError.
>
> for x in range(len(newex)):
Ditto.
> sentence = sentence + pigword(newex[x])+ " "
> print (sentence)
> wait = input (" Wait")
>
> The program seems to work and it does work with everything I have
> tried so far. The one exception is if you change "the" to "my" (in
> the first line) the program crashes.
>
>
> Traceback (most recent call last):
> File "C:\Documents and
> Settings\Administrator\Desktop\Functions\test.py", line 25, in
> <module>
> sentence = sentence + pigword(newex[x])+ " "
> File "C:\Documents and
> Settings\Administrator\Desktop\Functions\test.py", line 22, in pigword
> return (pigword)
> UnboundLocalError: local variable 'pigword' referenced before
> assignment
>>>>
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| Date | 2014-08-31 18:04 -0400 |
| Message-ID | <ki670a9s60nu01707ttcpucra04ee5rdne@4ax.com> |
| In reply to | #77361 |
On Sun, 31 Aug 2014 22:38:12 +0100, Mark Lawrence
<breamoreboy@yahoo.co.uk> wrote:
>On 31/08/2014 22:02, Seymore4Head wrote:
>> import math
>> import random
>> import sys
>>
>> ex='Hey buddy get away from the car'
>> newex = ex.split()
>> sentence=""
>>
>> print (newex)
>> wait = input (" Wait")
>>
>> def pigword(test):
>> for x in range(len(test)):
>
>Please read up on how to use for loops as the above is usually a code smell.
>
>> if test[x] in "AEIOUaeiou":
>> stem = test [x:]
>> prefix = test [:x]
>> pigword = stem + prefix + "ay"
>> print ("Stem ",stem)
>> print ("Prefix",prefix)
>> print (pigword)
>> break
>> return (pigword)
>
>This is Python so please get rid of those unnecessary brackets. Having
Having brackets must have been required in earlier versions maybe. I
will give it a try without it.
Without this video, I don't think I would have been able to write any
of this code yet.
I was watching her thinking, that would be really useful for the
piglatin example:
https://www.youtube.com/watch?v=rkx5_MRAV3A
51 min
>done that assume that you have an empty test so your loop never gets
>entered, the local pigword never gets assigned before the return hence
>your UnboundLocalError.
>
>>
>> for x in range(len(newex)):
>
>Ditto.
>
>> sentence = sentence + pigword(newex[x])+ " "
>> print (sentence)
>> wait = input (" Wait")
>>
>> The program seems to work and it does work with everything I have
>> tried so far. The one exception is if you change "the" to "my" (in
>> the first line) the program crashes.
>>
>>
>> Traceback (most recent call last):
>> File "C:\Documents and
>> Settings\Administrator\Desktop\Functions\test.py", line 25, in
>> <module>
>> sentence = sentence + pigword(newex[x])+ " "
>> File "C:\Documents and
>> Settings\Administrator\Desktop\Functions\test.py", line 22, in pigword
>> return (pigword)
>> UnboundLocalError: local variable 'pigword' referenced before
>> assignment
>>>>>
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2014-08-31 23:26 +0100 |
| Message-ID | <mailman.13669.1409523992.18130.python-list@python.org> |
| In reply to | #77363 |
On 31/08/2014 23:04, Seymore4Head wrote: > On Sun, 31 Aug 2014 22:38:12 +0100, Mark Lawrence >> >> This is Python so please get rid of those unnecessary brackets. > > Having brackets must have been required in earlier versions maybe. > No :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| Date | 2014-08-31 18:42 -0400 |
| Message-ID | <4u870addqootc65rs6996s88fg3gihqc09@4ax.com> |
| In reply to | #77361 |
On Sun, 31 Aug 2014 22:38:12 +0100, Mark Lawrence
<breamoreboy@yahoo.co.uk> wrote:
>On 31/08/2014 22:02, Seymore4Head wrote:
>> import math
>> import random
>> import sys
>>
>> ex='Hey buddy get away from the car'
>> newex = ex.split()
>> sentence=""
>>
>> print (newex)
>> wait = input (" Wait")
>>
>> def pigword(test):
>> for x in range(len(test)):
>
>Please read up on how to use for loops as the above is usually a code smell.
>
>> if test[x] in "AEIOUaeiou":
>> stem = test [x:]
>> prefix = test [:x]
Unnecessary brackets?
I tried deleting the brackets and that doesn't seem to work. I tried
changing the brackets to parenthesizes and that didn't work. Although
I would prefer brackets to parenthesizes as you don't need shift to
type them.
>> pigword = stem + prefix + "ay"
>> print ("Stem ",stem)
>> print ("Prefix",prefix)
>> print (pigword)
>> break
>> return (pigword)
>
>This is Python so please get rid of those unnecessary brackets. Having
>done that assume that you have an empty test so your loop never gets
>entered, the local pigword never gets assigned before the return hence
>your UnboundLocalError.
>
>>
>> for x in range(len(newex)):
>
>Ditto.
>
>> sentence = sentence + pigword(newex[x])+ " "
>> print (sentence)
>> wait = input (" Wait")
>>
>> The program seems to work and it does work with everything I have
>> tried so far. The one exception is if you change "the" to "my" (in
>> the first line) the program crashes.
>>
>>
>> Traceback (most recent call last):
>> File "C:\Documents and
>> Settings\Administrator\Desktop\Functions\test.py", line 25, in
>> <module>
>> sentence = sentence + pigword(newex[x])+ " "
>> File "C:\Documents and
>> Settings\Administrator\Desktop\Functions\test.py", line 22, in pigword
>> return (pigword)
>> UnboundLocalError: local variable 'pigword' referenced before
>> assignment
>>>>>
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2014-09-01 00:21 +0100 |
| Message-ID | <mailman.13671.1409527293.18130.python-list@python.org> |
| In reply to | #77368 |
On 31/08/2014 23:42, Seymore4Head wrote:
> On Sun, 31 Aug 2014 22:38:12 +0100, Mark Lawrence
> Unnecessary brackets?
> I tried deleting the brackets and that doesn't seem to work. I tried
> changing the brackets to parenthesizes and that didn't work. Although
> I would prefer brackets to parenthesizes as you don't need shift to
> type them.
>
>>> pigword = stem + prefix + "ay"
>>> print ("Stem ",stem)
>>> print ("Prefix",prefix)
>>> print (pigword)
>>> break
>>> return (pigword)
These ^ ^
>>
>> This is Python so please get rid of those unnecessary brackets. Having
>> done that assume that you have an empty test so your loop never gets
>> entered, the local pigword never gets assigned before the return hence
>> your UnboundLocalError.
>>
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| Date | 2014-08-31 20:08 -0400 |
| Message-ID | <l1e70a1e6osbg30l62cqmunf818vbji54m@4ax.com> |
| In reply to | #77370 |
On Mon, 01 Sep 2014 00:21:14 +0100, Mark Lawrence
<breamoreboy@yahoo.co.uk> wrote:
>On 31/08/2014 23:42, Seymore4Head wrote:
>> On Sun, 31 Aug 2014 22:38:12 +0100, Mark Lawrence
>> Unnecessary brackets?
>> I tried deleting the brackets and that doesn't seem to work. I tried
>> changing the brackets to parenthesizes and that didn't work. Although
>> I would prefer brackets to parenthesizes as you don't need shift to
>> type them.
>>
>>>> pigword = stem + prefix + "ay"
>>>> print ("Stem ",stem)
>>>> print ("Prefix",prefix)
>>>> print (pigword)
>>>> break
>>>> return (pigword)
>
>These ^ ^
Those are parenthesis :P
But not having to use them is a time saver.
Thanks
>>>
>>> This is Python so please get rid of those unnecessary brackets. Having
>>> done that assume that you have an empty test so your loop never gets
>>> entered, the local pigword never gets assigned before the return hence
>>> your UnboundLocalError.
>>>
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2014-09-01 01:56 +0100 |
| Message-ID | <mailman.13674.1409533205.18130.python-list@python.org> |
| In reply to | #77375 |
On 01/09/2014 01:08, Seymore4Head wrote:
> On Mon, 01 Sep 2014 00:21:14 +0100, Mark Lawrence
> <breamoreboy@yahoo.co.uk> wrote:
>
>> On 31/08/2014 23:42, Seymore4Head wrote:
>>> On Sun, 31 Aug 2014 22:38:12 +0100, Mark Lawrence
>>> Unnecessary brackets?
>>> I tried deleting the brackets and that doesn't seem to work. I tried
>>> changing the brackets to parenthesizes and that didn't work. Although
>>> I would prefer brackets to parenthesizes as you don't need shift to
>>> type them.
>>>
>>>>> pigword = stem + prefix + "ay"
>>>>> print ("Stem ",stem)
>>>>> print ("Prefix",prefix)
>>>>> print (pigword)
>>>>> break
>>>>> return (pigword)
>>
>> These ^ ^
>
> Those are parenthesis :P
> But not having to use them is a time saver.
> Thanks
>
No they are round brackets, as opposed to square or curly.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2014-09-01 12:53 +1000 |
| Message-ID | <5403dfc1$0$29980$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #77379 |
Mark Lawrence wrote: >>>>>> return (pigword) >>> These ^ ^ >> >> Those are parenthesis :P >> But not having to use them is a time saver. >> Thanks >> > > No they are round brackets, as opposed to square or curly. True, they are round brackets, but the word "parentheses" is actually older. According to the Oxford dictionary, the word "parentheses" dates from the middle of the 16th century, although the use of it to refer specifically to the ( and ) symbols is only from the early 20th century. "Bracket" is about a hundred years later, the middle of the 17th century, and didn't start to be used for the ( ) symbols themselves until the middle of the 18th. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2014-09-01 07:34 +0100 |
| Message-ID | <mailman.13685.1409553320.18130.python-list@python.org> |
| In reply to | #77385 |
On 01/09/2014 03:53, Steven D'Aprano wrote: > Mark Lawrence wrote: > >>>>>>> return (pigword) >>>> These ^ ^ >>> >>> Those are parenthesis :P >>> But not having to use them is a time saver. >>> Thanks >>> >> >> No they are round brackets, as opposed to square or curly. > > True, they are round brackets, but the word "parentheses" is actually older. > > According to the Oxford dictionary, the word "parentheses" dates from the > middle of the 16th century, although the use of it to refer specifically to > the ( and ) symbols is only from the early 20th century. "Bracket" is about > a hundred years later, the middle of the 17th century, and didn't start to > be used for the ( ) symbols themselves until the middle of the 18th. > For all I care they could have been around for the entire time that the Jurassic Coast has existed. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| Date | 2014-08-31 22:12 -0400 |
| Message-ID | <mailman.13676.1409537540.18130.python-list@python.org> |
| In reply to | #77375 |
On 8/31/14 8:56 PM, Mark Lawrence wrote:
> On 01/09/2014 01:08, Seymore4Head wrote:
>> On Mon, 01 Sep 2014 00:21:14 +0100, Mark Lawrence
>> <breamoreboy@yahoo.co.uk> wrote:
>>
>>> On 31/08/2014 23:42, Seymore4Head wrote:
>>>> On Sun, 31 Aug 2014 22:38:12 +0100, Mark Lawrence
>>>> Unnecessary brackets?
>>>> I tried deleting the brackets and that doesn't seem to work. I tried
>>>> changing the brackets to parenthesizes and that didn't work. Although
>>>> I would prefer brackets to parenthesizes as you don't need shift to
>>>> type them.
>>>>
>>>>>> pigword = stem + prefix + "ay"
>>>>>> print ("Stem ",stem)
>>>>>> print ("Prefix",prefix)
>>>>>> print (pigword)
>>>>>> break
>>>>>> return (pigword)
>>>
>>> These ^ ^
>>
>> Those are parenthesis :P
>> But not having to use them is a time saver.
>> Thanks
>>
>
> No they are round brackets, as opposed to square or curly.
>
Even if they are also called round brackets, surely we can agree that
parentheses are an accurate term for ( and ).
--
Ned Batchelder, http://nedbatchelder.com
[toc] | [prev] | [next] | [standalone]
| From | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| Date | 2014-08-31 22:54 -0400 |
| Message-ID | <p1n70al8897egjcqun02gku8n9iojnjsjn@4ax.com> |
| In reply to | #77383 |
On Sun, 31 Aug 2014 22:12:10 -0400, Ned Batchelder
<ned@nedbatchelder.com> wrote:
>On 8/31/14 8:56 PM, Mark Lawrence wrote:
>> On 01/09/2014 01:08, Seymore4Head wrote:
>>> On Mon, 01 Sep 2014 00:21:14 +0100, Mark Lawrence
>>> <breamoreboy@yahoo.co.uk> wrote:
>>>
>>>> On 31/08/2014 23:42, Seymore4Head wrote:
>>>>> On Sun, 31 Aug 2014 22:38:12 +0100, Mark Lawrence
>>>>> Unnecessary brackets?
>>>>> I tried deleting the brackets and that doesn't seem to work. I tried
>>>>> changing the brackets to parenthesizes and that didn't work. Although
>>>>> I would prefer brackets to parenthesizes as you don't need shift to
>>>>> type them.
>>>>>
>>>>>>> pigword = stem + prefix + "ay"
>>>>>>> print ("Stem ",stem)
>>>>>>> print ("Prefix",prefix)
>>>>>>> print (pigword)
>>>>>>> break
>>>>>>> return (pigword)
>>>>
>>>> These ^ ^
>>>
>>> Those are parenthesis :P
>>> But not having to use them is a time saver.
>>> Thanks
>>>
>>
>> No they are round brackets, as opposed to square or curly.
>>
>
>Even if they are also called round brackets, surely we can agree that
>parentheses are an accurate term for ( and ).
As a side note, I sometimes wish I had a separate keypad that had the
shift key symbols as the base key. My keyboard has two built in USB
slots that I have never used.
I don't know if a programmer keypad would be a time saver or just more
crap on a desk that has no room anyway.
Since I don't ever expect to be able to type them without thinking
about them, a standard keyboard could come with half sized keys on the
sides.
My keyboard is a Microsoft keyboard that has browser navigation
buttons I never use. I would trade them for programming symbols.
I do use the "calculator" button.
[toc] | [prev] | [next] | [standalone]
| From | Larry Hudson <orgnut@yahoo.com> |
|---|---|
| Date | 2014-08-31 21:55 -0700 |
| Message-ID | <KbCdnXtAU5vKYZ7JnZ2dnUU7-LednZ2d@giganews.com> |
| In reply to | #77386 |
On 08/31/2014 07:54 PM, Seymore4Head wrote:
[snip]
> Since I don't ever expect to be able to type them without thinking
> about them, a standard keyboard could come with half sized keys on the
> sides.
>
While this is definitely OT, I strongly suggest you take the time to learn to touch-type.
(Actually, I would recommend it for everyone.) It's true that it will take time, effort,
practice and diligence, especially time and practice, but if you do make the effort you'll never
regret it.
Eventually you'll find that you think (or read) a word, your fingers will wiggle a little bit
and that word suddenly appears on screen. It's an _*EXTREMELY*_ useful ability -- well worth
the time and effort.
I was able to take it as a summer class in high school some 60+ years ago (I'm old ;-) ), and
I've always been very glad that I did. (Even though I'm still not highly accurate and fairly
frequently make typos, it's still much better than hunt-and-peck typing.) I definitely suggest
it is well worth learning.
-=- Larry -=-
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-09-01 15:12 +1000 |
| Message-ID | <mailman.13681.1409548374.18130.python-list@python.org> |
| In reply to | #77391 |
On Mon, Sep 1, 2014 at 2:55 PM, Larry Hudson <orgnut@yahoo.com.dmarc.invalid> wrote: > While this is definitely OT, I strongly suggest you take the time to learn > to touch-type. (Actually, I would recommend it for everyone.) It's true > that it will take time, effort, practice and diligence, especially time and > practice, but if you do make the effort you'll never regret it. > > Eventually you'll find that you think (or read) a word, your fingers will > wiggle a little bit and that word suddenly appears on screen. It's an > _*EXTREMELY*_ useful ability -- well worth the time and effort. Indeed. And once you have that skill, you basically spend most of your coding time thinking, rather than typing - and the exact keystroke costs stop mattering much. (It makes little difference whether you type at 100wpm or 300wpm if you don't have 100 words to type each minute.) As an added bonus, you'll be able to work blind with barely more difficulty than when you have a screen in front of you. That's not hugely beneficial, but when the time comes, you'll be glad of it. Earlier this year I was typing up a bug report in a program that somehow managed to be so flawed that it could take only two keystrokes per second - so I typed way WAY ahead, then went off and made myself a hot chocolate while it painstakingly processed everything I'd typed. Same goes if, for whatever reason, you can't see your fingers - maybe the lights in your office have gone out, the screen wasn't on UPS, and you need to key in an orderly shutdown command while you're unable to see *anything*. (Which is what the little F and J pips are for. You can align your fingers on the keyboard in the dark.) ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Rustom Mody <rustompmody@gmail.com> |
|---|---|
| Date | 2014-08-31 23:53 -0700 |
| Message-ID | <f83e9d17-01be-4e52-b4cf-9a6515bfff12@googlegroups.com> |
| In reply to | #77392 |
On Monday, September 1, 2014 10:42:46 AM UTC+5:30, Chris Angelico wrote: > On Mon, Sep 1, 2014 at 2:55 PM, Larry Hudson wrote: > > While this is definitely OT, I strongly suggest you take the time to learn > > to touch-type. (Actually, I would recommend it for everyone.) It's true > > that it will take time, effort, practice and diligence, especially time and > > practice, but if you do make the effort you'll never regret it. > > Eventually you'll find that you think (or read) a word, your fingers will > > wiggle a little bit and that word suddenly appears on screen. It's an > > _*EXTREMELY*_ useful ability -- well worth the time and effort. > Indeed. And once you have that skill, you basically spend most of your > coding time thinking, rather than typing - and the exact keystroke > costs stop mattering much. (It makes little difference whether you > type at 100wpm or 300wpm if you don't have 100 words to type each > minute.) > As an added bonus, you'll be able to work blind with barely more > difficulty than when you have a screen in front of you. That's not > hugely beneficial, but when the time comes, you'll be glad of it. > Earlier this year I was typing up a bug report in a program that > somehow managed to be so flawed that it could take only two keystrokes > per second - so I typed way WAY ahead, then went off and made myself a > hot chocolate while it painstakingly processed everything I'd typed. > Same goes if, for whatever reason, you can't see your fingers - maybe > the lights in your office have gone out, the screen wasn't on UPS, and > you need to key in an orderly shutdown command while you're unable to > see *anything*. (Which is what the little F and J pips are for. You > can align your fingers on the keyboard in the dark.) Right. And the next logical conclusion is to use emacs :-) Or vi. ie editors whose default mode of use is mouseless. | Using the mouse is almost always the worst possible violation of | economy of motion, because you have to pick your hand up and fumble | around with it. The mouse is a clumsy instrument, and Emacs gurus | consider it a cache miss when they have to resort to using it. Steve Yegge at https://sites.google.com/site/steveyegge2/effective-emacs Note: (In case its not quite clear) I am being part-facetious. In the emacs (and vi?) worlds this is carried to ridiculous cult-extremes. Yet there's some truth there, for those who are so inclined.
[toc] | [prev] | [next] | [standalone]
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Date | 2014-08-31 22:53 +0100 |
| Message-ID | <mailman.13667.1409521984.18130.python-list@python.org> |
| In reply to | #77359 |
On 2014-08-31 22:02, Seymore4Head wrote:
> import math
> import random
> import sys
>
> ex='Hey buddy get away from the car'
> newex = ex.split()
> sentence=""
>
> print (newex)
> wait = input (" Wait")
>
> def pigword(test):
> for x in range(len(test)):
> if test[x] in "AEIOUaeiou":
> stem = test [x:]
> prefix = test [:x]
> pigword = stem + prefix + "ay"
> print ("Stem ",stem)
> print ("Prefix",prefix)
> print (pigword)
> break
> return (pigword)
>
> for x in range(len(newex)):
> sentence = sentence + pigword(newex[x])+ " "
> print (sentence)
> wait = input (" Wait")
>
> The program seems to work and it does work with everything I have
> tried so far. The one exception is if you change "the" to "my" (in
> the first line) the program crashes.
>
>
> Traceback (most recent call last):
> File "C:\Documents and
> Settings\Administrator\Desktop\Functions\test.py", line 25, in
> <module>
> sentence = sentence + pigword(newex[x])+ " "
> File "C:\Documents and
> Settings\Administrator\Desktop\Functions\test.py", line 22, in pigword
> return (pigword)
> UnboundLocalError: local variable 'pigword' referenced before
> assignment
>>>>
>
'my' doesn't contain a vowel, therefore the condition of the 'if'
statement in 'pigword' is never true, therefore it never binds to the
name 'pigword'.
BTW, you have a function called 'pigword' that has a local name also
called 'pigword'. Try not to do that, because you could easily confuse
yourself.
[toc] | [prev] | [next] | [standalone]
| From | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| Date | 2014-08-31 18:07 -0400 |
| Message-ID | <nv670atca18f0cgqcnd35d574rfm93ntrg@4ax.com> |
| In reply to | #77362 |
On Sun, 31 Aug 2014 22:53:01 +0100, MRAB <python@mrabarnett.plus.com>
wrote:
>On 2014-08-31 22:02, Seymore4Head wrote:
>> import math
>> import random
>> import sys
>>
>> ex='Hey buddy get away from the car'
>> newex = ex.split()
>> sentence=""
>>
>> print (newex)
>> wait = input (" Wait")
>>
>> def pigword(test):
>> for x in range(len(test)):
>> if test[x] in "AEIOUaeiou":
>> stem = test [x:]
>> prefix = test [:x]
>> pigword = stem + prefix + "ay"
>> print ("Stem ",stem)
>> print ("Prefix",prefix)
>> print (pigword)
>> break
>> return (pigword)
>>
>> for x in range(len(newex)):
>> sentence = sentence + pigword(newex[x])+ " "
>> print (sentence)
>> wait = input (" Wait")
>>
>> The program seems to work and it does work with everything I have
>> tried so far. The one exception is if you change "the" to "my" (in
>> the first line) the program crashes.
>>
>>
>> Traceback (most recent call last):
>> File "C:\Documents and
>> Settings\Administrator\Desktop\Functions\test.py", line 25, in
>> <module>
>> sentence = sentence + pigword(newex[x])+ " "
>> File "C:\Documents and
>> Settings\Administrator\Desktop\Functions\test.py", line 22, in pigword
>> return (pigword)
>> UnboundLocalError: local variable 'pigword' referenced before
>> assignment
>>>>>
>>
>'my' doesn't contain a vowel, therefore the condition of the 'if'
>statement in 'pigword' is never true, therefore it never binds to the
>name 'pigword'.
>
Ah. The piglatin example says to use y as a vowel. I forgot to
include it.
Thanks
>BTW, you have a function called 'pigword' that has a local name also
>called 'pigword'. Try not to do that, because you could easily confuse
>yourself.
I am a pro at confusing myself. :)
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2014-09-01 12:12 +1000 |
| Message-ID | <5403d605$0$29981$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #77365 |
Seymore4Head wrote:
>>'my' doesn't contain a vowel, therefore the condition of the 'if'
>>statement in 'pigword' is never true, therefore it never binds to the
>>name 'pigword'.
>>
> Ah. The piglatin example says to use y as a vowel. I forgot to
> include it.
Doesn't matter. What if one of the words doesn't contain any vowel or "y"?
E.g. "Grrr!", "Hmmm", "the nth degree", "tsk tsk", Internet slang such
as "pwn" and "pr0n", or words in Foreign like "cwm" (pronounced "koom",
Welsh for a cirque, which is a type of valley). You still need to deal with
the case that a word contains no vowels at all.
The easiest way is to initialise the "pigword" variable to the word itself,
then if the vowel test never succeeds, the function will return the word
unchanged.
def pigword(word):
"""Return word converted to piglatin."""
pig = word # initialise to the word itself.
blah blah blah # your code goes here
return pig
--
Steven
[toc] | [prev] | [next] | [standalone]
| From | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| Date | 2014-08-31 22:13 -0400 |
| Message-ID | <jbl70ah4mdtmrfj1gmu1t8lo7m33o112hf@4ax.com> |
| In reply to | #77382 |
On Mon, 01 Sep 2014 12:12:20 +1000, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: >Seymore4Head wrote: > >>>'my' doesn't contain a vowel, therefore the condition of the 'if' >>>statement in 'pigword' is never true, therefore it never binds to the >>>name 'pigword'. >>> >> Ah. The piglatin example says to use y as a vowel. I forgot to >> include it. > >Doesn't matter. What if one of the words doesn't contain any vowel or "y"? >E.g. "Grrr!", "Hmmm", "the nth degree", "tsk tsk", Internet slang such >as "pwn" and "pr0n", or words in Foreign like "cwm" (pronounced "koom", >Welsh for a cirque, which is a type of valley). You still need to deal with >the case that a word contains no vowels at all. > >The easiest way is to initialise the "pigword" variable to the word itself, >then if the vowel test never succeeds, the function will return the word >unchanged. > >def pigword(word): > """Return word converted to piglatin.""" > pig = word # initialise to the word itself. > blah blah blah # your code goes here > return pig I will try to add that next. Thanks
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.python
csiph-web