comp.lang.python - 26 new messages in 9 topics - digest
comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en
comp.lang.python@googlegroups.com
Today's topics:
* Slicing with negative strides - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.python/t/ef887f44e65ca220?hl=en
* problem importing - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/feff52f87e075352?hl=en
* Python Front-end to GCC - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/5f8058e5e17cb7ce?hl=en
* Possibly better loop construct, also labels+goto important and on the fly
compiler idea. - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.python/t/a75134775506798f?hl=en
* Help with guessing game :D - 12 messages, 4 authors
http://groups.google.com/group/comp.lang.python/t/e9631fcdbb48ca2f?hl=en
* Cookie fr*cking problem - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/35051ac2d1e093b3?hl=en
* how to avoid checking the same condition repeatedly ? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/a4db4d2b662bf8d1?hl=en
* How do I update a virtualenv? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/77d81b8041038ef1?hl=en
* Function for the path of the script? - 2 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/76fffeeca6996f8a?hl=en
==============================================================================
TOPIC: Slicing with negative strides
http://groups.google.com/group/comp.lang.python/t/ef887f44e65ca220?hl=en
==============================================================================
== 1 of 3 ==
Date: Tues, Oct 29 2013 2:34 am
From: Mark Lawrence
On 29/10/2013 08:53, Duncan Booth wrote:
> Steven D'Aprano <steve@pearwood.info> wrote:
>
>> Does anyone here use slices (or range/xrange) with negative strides
>> other than -1?
>>
>> E.g. sequence[2:15:-3]
>
> With any negative stride your example is just the empty sequence.
>
>>
>>
>> If so, there is a discussion (long, long, looooooong discussion) on
>> the python-ideas mailing list, debating whether or not to deprecate or
>> change the behaviour of slicing with negative strides. So if you care
>> about the current behaviour, now is the time to stand up and be
>> counted.
>>
>> (Standing up *here* is fine, don't feel that you have to join yet
>> another list.)
>>
> For those of us that don't really want to join another mailing list, could
> you summarise what change is being proposed?
>
Umpteen options have been put forward. IMHO the bookies favourite is
currently being endorsed by Tim Peters and Terry Reedy, yours odds may
vary :)
--
Python is the second best programming language in the world.
But the best has yet to be invented. Christian Tismer
Mark Lawrence
== 2 of 3 ==
Date: Tues, Oct 29 2013 3:21 am
From: Terry Reedy
On 10/29/2013 4:53 AM, Duncan Booth wrote:
> Steven D'Aprano <steve@pearwood.info> wrote:
>
>> Does anyone here use slices (or range/xrange) with negative strides
>> other than -1?
>>
>> E.g. sequence[2:15:-3]
>
> With any negative stride your example is just the empty sequence.
The idea is that one would not have to reverse 2 and 15 to get a
non-empty sequence.
--
Terry Jan Reedy
== 3 of 3 ==
Date: Tues, Oct 29 2013 4:04 am
From: Steven D'Aprano
On Tue, 29 Oct 2013 08:53:08 +0000, Duncan Booth wrote:
> Steven D'Aprano <steve@pearwood.info> wrote:
>
>> Does anyone here use slices (or range/xrange) with negative strides
>> other than -1?
>>
>> E.g. sequence[2:15:-3]
>
> With any negative stride your example is just the empty sequence.
Gah, sorry about that, that's the suggested *new* syntax. Possibly my
subconscious likes it better than my conscious :-)
Try this instead: sequence[15:2:-3]
>> If so, there is a discussion (long, long, looooooong discussion) on the
>> python-ideas mailing list, debating whether or not to deprecate or
>> change the behaviour of slicing with negative strides. So if you care
>> about the current behaviour, now is the time to stand up and be
>> counted.
>>
>> (Standing up *here* is fine, don't feel that you have to join yet
>> another list.)
>>
> For those of us that don't really want to join another mailing list,
> could you summarise what change is being proposed?
* Negative strides should be deprecated and then removed.
* Or just deprecated.
* Or change the semantics of negative strides so that
seq[2:15:-2] works as expected.
* Or get rid of negative indexing.
* Or add new syntax to control whether or not the end points are included.
* Or ...
It's Python-Ideas, otherwise known as Bike-Shed Central :-)
I think the main idea which is likely (since Guido seems to be slightly
leaning that way) is to deprecate negative strides, remove them in a
release or three, and then re-introduce them in Python 4000 but with more
intuitive semantics.
--
Steven
==============================================================================
TOPIC: problem importing
http://groups.google.com/group/comp.lang.python/t/feff52f87e075352?hl=en
==============================================================================
== 1 of 2 ==
Date: Tues, Oct 29 2013 2:46 am
From: "C. Ng"
Hi all,
So I cloned a package xyz from github. OS is ubuntu 12.04.
Then install successfully using "sudo python setup.py install"
Now when I try to import xyz, I get "ImportError: No module named xyz" unless my current working directory is in xyz.
Appreciate your help. Thanks.
== 2 of 2 ==
Date: Tues, Oct 29 2013 3:40 am
From: Peter Otten <__peter__@web.de>
C. Ng wrote:
> Hi all,
> So I cloned a package xyz from github. OS is ubuntu 12.04.
> Then install successfully using "sudo python setup.py install"
> Now when I try to import xyz, I get "ImportError: No module named xyz"
> unless my current working directory is in xyz. Appreciate your help.
> Thanks.
Maybe the author called the toplevel package pyxyz or XYZ -- when you don't
provide the actual package name/github url we can only guess.
Or
$ which python
and
$ sudo which python
point to different Python installations.
==============================================================================
TOPIC: Python Front-end to GCC
http://groups.google.com/group/comp.lang.python/t/5f8058e5e17cb7ce?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Oct 29 2013 4:04 am
From: Antoine Pitrou
Steven D'Aprano <steve+comp.lang.python <at> pearwood.info> writes:
>
> On Fri, 25 Oct 2013 21:36:42 +0100, Mark Lawrence wrote:
>
> > Mind you, the thought of a bot with a Ph.D. is mind boggling.
>
> You can buy degrees on the Internet quite cheaply:
>
> http://en.wikipedia.org/wiki/List_of_animals_with_fraudulent_diplomas
>
> PhD's are more expensive, which leads me to think that Mark Jenssen is
> being a tad flexible with the truth when he claims to have one.
He could be an upper-class twit. He would certainly have his chance in
the yearly competition ;-)
Regards
Antoine.
==============================================================================
TOPIC: Possibly better loop construct, also labels+goto important and on the
fly compiler idea.
http://groups.google.com/group/comp.lang.python/t/a75134775506798f?hl=en
==============================================================================
== 1 of 3 ==
Date: Tues, Oct 29 2013 4:37 am
From: "Skybuck Flying"
> Because it's logical.
"
What is logical?
"
To put the exit condition at the bottom is logical.
The exit condition glues the loop to the code that will be executed next
which is also at the bottom.
Example:
Loop
NextCode
^
Placing the exit ondition near next code makes more sense at least in
situation where I was programming.
I will give you an example:
LoopBegin( Step = 10 )
if ButtonExists then
begin
ClickButton()
end;
LoopEnd( ButtonClicked )
Execute next code...
This loop waits for the button to appear, once it's found it is clicked and
then the loop exits to continue the next code.
Putting this exit condition on the top makes no sense.
Bye,
Skybuck.
== 2 of 3 ==
Date: Tues, Oct 29 2013 5:45 am
From: Dennis Lee Bieber
On Mon, 28 Oct 2013 21:03:50 -0700 (PDT), rurpy@yahoo.com declaimed the
following:
>
>I agree. Wikipedia is convenient but almost never suitable
>as a learning resource. I'll see if I can find a friendlier
>general netiquette link. Recommendations welcome.
>
Probably not the raw RFC then... Section 3.x is most applicable
http://www.ietf.org/rfc/rfc1855.txt
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
== 3 of 3 ==
Date: Tues, Oct 29 2013 7:08 am
From: Steven D'Aprano
On Tue, 29 Oct 2013 12:37:36 +0100, Skybuck Flying wrote:
> To put the exit condition at the bottom is logical.
>
> The exit condition glues the loop to the code that will be executed next
> which is also at the bottom.
Skybuck, please excuse my question, but have you ever done any
programming at all? You don't seem to have any experience with actual
programming languages.
In a while loop, such as in Python, the test is at the top of the loop
because the test is performed at the start of the loop, not the end:
while x > 0:
do_this()
do_that()
It would be inappropriate (as well as ugly!) to put the test at the end
of the loop, like this:
x = 0
while:
do_this()
do_that()
many more lines go here
possibly even pages of code
until finally, at long last
you get to the end where you find the test...
x > 0
... and discover whether or not the while loop was actually entered or
not. Similarly with for-loops, the loop condition is at the beginning
because it runs at the beginning. This would be silly:
for i:
body of loop goes here
could be many many lines of code
even pages of code
but eventually, at long last
we get to the end, and find out
what the first value for i will be
in range(100, 110)
There is one sort of loop where it makes sense to have the loop condition
at the end. Python doesn't have such a loop, but Pascal does: the repeat
until loop. Unlike while, repeat until is always executed at least once,
so the loop condition isn't tested until the end of the loop:
repeat
do this
do that
do something else
until x > 0
[...]
> LoopBegin( Step = 10 )
>
> if ButtonExists then
> begin
> ClickButton()
> end;
>
> LoopEnd( ButtonClicked )
>
> Execute next code...
>
> This loop waits for the button to appear, once it's found it is clicked
> and then the loop exits to continue the next code.
What if the button has already appeared before the loop starts?
I think that is better written as:
# Check the loop condition at the start
while the button does not exist:
wait a bit
# Outside the loop
click the button
(Although such a loop is called a "busy wait" loop, since it keeps the
computer being busy without doing anything useful. There are better ways
to do this than a loop.)
Even in Pascal, I would use a while loop rather than repeat, but if you
insist on using repeat, clicking the button still should go on the
outside of the loop:
# this is wasteful, since even if the button exists, the loop still
# waits a bit, for no good reason
repeat
wait a bit
until the button exists
click the button
> Putting this exit condition on the top makes no sense.
Wait until you actually start programming before deciding what makes
sense or doesn't.
--
Steven
==============================================================================
TOPIC: Help with guessing game :D
http://groups.google.com/group/comp.lang.python/t/e9631fcdbb48ca2f?hl=en
==============================================================================
== 1 of 12 ==
Date: Tues, Oct 29 2013 4:45 am
From: Robert Gonda
Hey guys, so I figured I will give python a shot. I got to exercise that has asked me to create a number guessing game which weren't a problem,
guessesTaken = 0 #This is a "Guesses taken counter"
print("Hello, what's your name?") #Asking the user to input their name
N = raw_input() #What the user's name is
import random #This is importing the random function
number = random.randint(1, 999) #This tells the random function to generate a random number between 1 to 1000
print(N + ", I'm thinking of a number between 1-1000") #Not needed but tells the user their name and tells them that it's thinking of a number betweeen 1 to 1000
while guessesTaken < 10:
print('Take a guess.')
guess = input()
guess = int(guess)
guessesTaken = guessesTaken + 1
if guess < number: #Says that if the guess is too low it will print a message saying that the guess is too low
print('Your guess is too low.')
if guess > number: #Says that if the guess is too high it will print a message saying that the guess is too high
print('Your guess is too high.')
if guess == number:
break #Breaks the loop, meaning it will continue to loop for 10 times while giving them messages from above depending on their results
if guess == number:
guessesTaken = str(guessesTaken)
print("Congrat's, " + N + "! You managed to get the number in " + guessesTaken + " guesses!") #Tells the user they managed to guess it in x number of times
if guess != number: #If the user is unable to guess the number in 10 times it will stop the loop and give the user a message
number = str(number)
print("No, the right number was" + number)
However the problem is that it also asked me to do the following : If at least one of the digit guessed is right it will say "y" otherwise "n" which I can't seem to do :/ any help?
== 2 of 12 ==
Date: Tues, Oct 29 2013 4:53 am
From: Chris Angelico
On Tue, Oct 29, 2013 at 10:45 PM, Robert Gonda
<robertgonda1994@gmail.com> wrote:
> N = raw_input() #What the user's name is
> print(N + ", I'm thinking of a number between 1-1000") #Not needed but tells the user their name and tells them that it's thinking of a number betweeen 1 to 1000
> guess = input()
> guess = int(guess)
Which version of Python are you using? The raw_input call is very
Python 2, but you're using print as a function, and then you're
converting input()'s result to an integer, both of which suggest
Python 3.x. If you're using Python 2, do NOT use input() - it is
dangerous, deceptively so. In Python 3, that problem no longer
applies.
ChrisA
== 3 of 12 ==
Date: Tues, Oct 29 2013 4:54 am
From: Robert Gonda
On Tuesday, 29 October 2013 11:53:55 UTC, Chris Angelico wrote:
> On Tue, Oct 29, 2013 at 10:45 PM, Robert Gonda
>
> <robertgonda1994@gmail.com> wrote:
>
> > N = raw_input() #What the user's name is
>
> > print(N + ", I'm thinking of a number between 1-1000") #Not needed but tells the user their name and tells them that it's thinking of a number betweeen 1 to 1000
>
> > guess = input()
>
> > guess = int(guess)
>
>
>
> Which version of Python are you using? The raw_input call is very
>
> Python 2, but you're using print as a function, and then you're
>
> converting input()'s result to an integer, both of which suggest
>
> Python 3.x. If you're using Python 2, do NOT use input() - it is
>
> dangerous, deceptively so. In Python 3, that problem no longer
>
> applies.
>
>
>
> ChrisA
Hi Chris and thanks for the reply, I'm using python 3.
== 4 of 12 ==
Date: Tues, Oct 29 2013 5:05 am
From: Robert Gonda
On Tuesday, 29 October 2013 11:54:49 UTC, Robert Gonda wrote:
> On Tuesday, 29 October 2013 11:53:55 UTC, Chris Angelico wrote:
>
> > On Tue, Oct 29, 2013 at 10:45 PM, Robert Gonda
>
> >
>
> > <robertgonda1994@gmail.com> wrote:
>
> >
>
> > > N = raw_input() #What the user's name is
>
> >
>
> > > print(N + ", I'm thinking of a number between 1-1000") #Not needed but tells the user their name and tells them that it's thinking of a number betweeen 1 to 1000
>
> >
>
> > > guess = input()
>
> >
>
> > > guess = int(guess)
>
> >
>
> >
>
> >
>
> > Which version of Python are you using? The raw_input call is very
>
> >
>
> > Python 2, but you're using print as a function, and then you're
>
> >
>
> > converting input()'s result to an integer, both of which suggest
>
> >
>
> > Python 3.x. If you're using Python 2, do NOT use input() - it is
>
> >
>
> > dangerous, deceptively so. In Python 3, that problem no longer
>
> >
>
> > applies.
>
> >
>
> >
>
> >
>
> > ChrisA
>
>
>
> Hi Chris and thanks for the reply, I'm using python 3.
Tried to get rid of it but it just gives me an error, that's why I used raw_input
== 5 of 12 ==
Date: Tues, Oct 29 2013 5:58 am
From: Alister
On Tue, 29 Oct 2013 05:05:19 -0700, Robert Gonda wrote:
>>
>> >
>> > converting input()'s result to an integer, both of which suggest
>>
>>
if you need to be checking individual digits you are probably best
keeping the input & number to be checked as strings.
it would then be a trivial task to expand this program to work with words
as well as numbers.
--
"No one gets too old to learn a new way of being stupid."
== 6 of 12 ==
Date: Tues, Oct 29 2013 6:03 am
From: Robert Gonda
On Tuesday, 29 October 2013 12:58:09 UTC, Alister wrote:
> On Tue, 29 Oct 2013 05:05:19 -0700, Robert Gonda wrote:
>
> >>
>
> >> >
>
> >> > converting input()'s result to an integer, both of which suggest
>
> >>
>
> >>
>
>
>
> if you need to be checking individual digits you are probably best
>
> keeping the input & number to be checked as strings.
>
>
>
> it would then be a trivial task to expand this program to work with words
>
> as well as numbers.
>
>
>
>
>
>
>
>
>
> --
>
> "No one gets too old to learn a new way of being stupid."
I see, so how should i do it? I wouldn't mind having no text in it I just need the program to generate the number and the user to try to guess what the number is, so for example if a python would generate num 770 and the user would guess 870 it would say NYN
== 7 of 12 ==
Date: Tues, Oct 29 2013 6:07 am
From: Alister
On Tue, 29 Oct 2013 06:03:55 -0700, Robert Gonda wrote:
> On Tuesday, 29 October 2013 12:58:09 UTC, Alister wrote:
>> On Tue, 29 Oct 2013 05:05:19 -0700, Robert Gonda wrote:
>>
>>
>> >>
>>
>> >> >
>> >> > converting input()'s result to an integer, both of which suggest
>>
>>
>> >>
>>
>> >>
>>
>>
>> if you need to be checking individual digits you are probably best
>>
>> keeping the input & number to be checked as strings.
>>
>>
>>
>> it would then be a trivial task to expand this program to work with
>> words
>>
>> as well as numbers.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> --
>>
>> "No one gets too old to learn a new way of being stupid."
>
> I see, so how should i do it? I wouldn't mind having no text in it I
> just need the program to generate the number and the user to try to
> guess what the number is, so for example if a python would generate num
> 770 and the user would guess 870 it would say NYN
remember that strings are a sequence.
they can be used as iterators & sliced in the same way as lists & tuples.
--
Let a fool hold his tongue and he will pass for a sage.
-- Publilius Syrus
== 8 of 12 ==
Date: Tues, Oct 29 2013 6:10 am
From: Robert Gonda
On Tuesday, 29 October 2013 13:07:08 UTC, Alister wrote:
> On Tue, 29 Oct 2013 06:03:55 -0700, Robert Gonda wrote:
>
>
>
> > On Tuesday, 29 October 2013 12:58:09 UTC, Alister wrote:
>
> >> On Tue, 29 Oct 2013 05:05:19 -0700, Robert Gonda wrote:
>
> >>
>
> >>
>
> >> >>
>
> >>
>
> >> >> >
>
> >> >> > converting input()'s result to an integer, both of which suggest
>
> >>
>
> >>
>
> >> >>
>
> >>
>
> >> >>
>
> >>
>
> >>
>
> >> if you need to be checking individual digits you are probably best
>
> >>
>
> >> keeping the input & number to be checked as strings.
>
> >>
>
> >>
>
> >>
>
> >> it would then be a trivial task to expand this program to work with
>
> >> words
>
> >>
>
> >> as well as numbers.
>
> >>
>
> >>
>
> >>
>
> >>
>
> >>
>
> >>
>
> >>
>
> >>
>
> >>
>
> >> --
>
> >>
>
> >> "No one gets too old to learn a new way of being stupid."
>
> >
>
> > I see, so how should i do it? I wouldn't mind having no text in it I
>
> > just need the program to generate the number and the user to try to
>
> > guess what the number is, so for example if a python would generate num
>
> > 770 and the user would guess 870 it would say NYN
>
>
>
> remember that strings are a sequence.
>
> they can be used as iterators & sliced in the same way as lists & tuples.
>
>
>
>
>
>
>
>
>
> --
>
> Let a fool hold his tongue and he will pass for a sage.
>
> -- Publilius Syrus
Now you have confused me completely, sorry im just new to python and just learning everything :) could you perhaps give me an example? or part of the code that's missing?
== 9 of 12 ==
Date: Tues, Oct 29 2013 6:44 am
From: Mark Lawrence
On 29/10/2013 11:45, Robert Gonda wrote:
As you've already received and responded to advice please could you
read, digest and action this https://wiki.python.org/moin/GoogleGroupsPython
TIA.
--
Python is the second best programming language in the world.
But the best has yet to be invented. Christian Tismer
Mark Lawrence
== 10 of 12 ==
Date: Tues, Oct 29 2013 6:52 am
From: Robert Gonda
On Tuesday, 29 October 2013 13:44:45 UTC, Mark Lawrence wrote:
> On 29/10/2013 11:45, Robert Gonda wrote:
>
>
>
> As you've already received and responded to advice please could you
>
> read, digest and action this https://wiki.python.org/moin/GoogleGroupsPython
>
>
>
> TIA.
>
>
>
> --
>
> Python is the second best programming language in the world.
>
> But the best has yet to be invented. Christian Tismer
>
>
>
> Mark Lawrence
ah okay, sorry didn't know about that
== 11 of 12 ==
Date: Tues, Oct 29 2013 7:25 am
From: Alister
On Tue, 29 Oct 2013 06:10:30 -0700, Robert Gonda wrote:
> On Tuesday, 29 October 2013 13:07:08 UTC, Alister wrote:
>> On Tue, 29 Oct 2013 06:03:55 -0700, Robert Gonda wrote:
>>
>>
>>
>> > On Tuesday, 29 October 2013 12:58:09 UTC, Alister wrote:
>>
>> >> On Tue, 29 Oct 2013 05:05:19 -0700, Robert Gonda wrote:
>>
>>
>> >>
>>
>> >>
>>
>> >> >>
>>
>> >>
>>
>> >> >> >
>> >> >> > converting input()'s result to an integer, both of which
>> >> >> > suggest
>>
>>
>> >>
>>
>> >>
>>
>> >> >>
>>
>> >>
>>
>> >> >>
>>
>> >>
>>
>> >>
>> >> if you need to be checking individual digits you are probably best
>>
>>
>> >>
>> >> keeping the input & number to be checked as strings.
>>
>>
>> >>
>>
>> >>
>>
>> >>
>> >> it would then be a trivial task to expand this program to work with
>>
>> >> words
>>
>>
>> >>
>> >> as well as numbers.
>>
>>
>> >>
>>
>> >>
>>
>> >>
>>
>> >>
>>
>> >>
>>
>> >>
>>
>> >>
>>
>> >>
>>
>> >>
>> >> --
>>
>>
>> >>
>> >> "No one gets too old to learn a new way of being stupid."
>>
>>
>> >
>> > I see, so how should i do it? I wouldn't mind having no text in it I
>>
>> > just need the program to generate the number and the user to try to
>>
>> > guess what the number is, so for example if a python would generate
>> > num
>>
>> > 770 and the user would guess 870 it would say NYN
>>
>>
>>
>> remember that strings are a sequence.
>>
>> they can be used as iterators & sliced in the same way as lists &
>> tuples.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> --
>>
>> Let a fool hold his tongue and he will pass for a sage.
>>
>> -- Publilius Syrus
>
> Now you have confused me completely, sorry im just new to python and
> just learning everything :) could you perhaps give me an example? or
> part of the code that's missing?
you will probably learn more through trial & error than you will from
being given an answer
to shine some more light on my advise try the following
code="7689"
for digit in code:
print(digit)
does this give you any Ideas on how to proceed?
--
If you're right 90% of the time, why quibble about the remaining 3%?
== 12 of 12 ==
Date: Tues, Oct 29 2013 7:40 am
From: Robert Gonda
On Tuesday, 29 October 2013 14:25:10 UTC, Alister wrote:
> On Tue, 29 Oct 2013 06:10:30 -0700, Robert Gonda wrote:
>
>
>
> > On Tuesday, 29 October 2013 13:07:08 UTC, Alister wrote:
>
> >> On Tue, 29 Oct 2013 06:03:55 -0700, Robert Gonda wrote:
>
> >>
>
> >>
>
> >>
>
> >> > On Tuesday, 29 October 2013 12:58:09 UTC, Alister wrote:
>
> >>
>
> >> >> On Tue, 29 Oct 2013 05:05:19 -0700, Robert Gonda wrote:
>
> >>
>
> >>
>
> >> >>
>
> >>
>
> >> >>
>
> >>
>
> >> >> >>
>
> >>
>
> >> >>
>
> >>
>
> >> >> >> >
>
> >> >> >> > converting input()'s result to an integer, both of which
>
> >> >> >> > suggest
>
> >>
>
> >>
>
> >> >>
>
> >>
>
> >> >>
>
> >>
>
> >> >> >>
>
> >>
>
> >> >>
>
> >>
>
> >> >> >>
>
> >>
>
> >> >>
>
> >>
>
> >> >>
>
> >> >> if you need to be checking individual digits you are probably best
>
> >>
>
> >>
>
> >> >>
>
> >> >> keeping the input & number to be checked as strings.
>
> >>
>
> >>
>
> >> >>
>
> >>
>
> >> >>
>
> >>
>
> >> >>
>
> >> >> it would then be a trivial task to expand this program to work with
>
> >>
>
> >> >> words
>
> >>
>
> >>
>
> >> >>
>
> >> >> as well as numbers.
>
> >>
>
> >>
>
> >> >>
>
> >>
>
> >> >>
>
> >>
>
> >> >>
>
> >>
>
> >> >>
>
> >>
>
> >> >>
>
> >>
>
> >> >>
>
> >>
>
> >> >>
>
> >>
>
> >> >>
>
> >>
>
> >> >>
>
> >> >> --
>
> >>
>
> >>
>
> >> >>
>
> >> >> "No one gets too old to learn a new way of being stupid."
>
> >>
>
> >>
>
> >> >
>
> >> > I see, so how should i do it? I wouldn't mind having no text in it I
>
> >>
>
> >> > just need the program to generate the number and the user to try to
>
> >>
>
> >> > guess what the number is, so for example if a python would generate
>
> >> > num
>
> >>
>
> >> > 770 and the user would guess 870 it would say NYN
>
> >>
>
> >>
>
> >>
>
> >> remember that strings are a sequence.
>
> >>
>
> >> they can be used as iterators & sliced in the same way as lists &
>
> >> tuples.
>
> >>
>
> >>
>
> >>
>
> >>
>
> >>
>
> >>
>
> >>
>
> >>
>
> >>
>
> >> --
>
> >>
>
> >> Let a fool hold his tongue and he will pass for a sage.
>
> >>
>
> >> -- Publilius Syrus
>
> >
>
> > Now you have confused me completely, sorry im just new to python and
>
> > just learning everything :) could you perhaps give me an example? or
>
> > part of the code that's missing?
>
>
>
> you will probably learn more through trial & error than you will from
>
> being given an answer
>
>
>
> to shine some more light on my advise try the following
>
>
>
> code="7689"
>
> for digit in code:
>
> print(digit)
>
>
>
> does this give you any Ideas on how to proceed?
>
>
>
>
>
>
>
> --
>
> If you're right 90% of the time, why quibble about the remaining 3%?
Unfortunately I'm not that sort of person, the way my brain learns is by experimenting, but first I need to know exactly what to write. Then I will play around with it and customize it to my needs, sorry to be such a bother guys :/ and thanks again for your help it's appreciated a lot :)
==============================================================================
TOPIC: Cookie fr*cking problem
http://groups.google.com/group/comp.lang.python/t/35051ac2d1e093b3?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Oct 29 2013 5:17 am
From: Neil Cerutti
On 2013-10-29, Steven D'Aprano <steve@pearwood.info> wrote:
> On Mon, 28 Oct 2013 13:20:17 +0000, Neil Cerutti wrote:
>
>> On 2013-10-27, Ben Finney <ben+python@benfinney.id.au> wrote:
>>> I have no particular objection to you responding to those
>>> instances of bad behaviour that I've omitted.
>>
>> So you omitted them, eh?
>>
>> You just omitted the body of the letter, that's all! You've
>> left out the body of the letter, that's all. Yours is not to
>> reason why, Jamison. You've left out the body of the letter!
>>
>> ...
>>
>> Fine. Send it that way, and tell them the body will follow.
>
> Was that the letter made out to the solicitors Hummerdinger,
> Hummerdinger, Hummerdinger, Hummerdinger, and McCormack? As I
> recall, not only did the secretary leave out one of the
> Hummerdingers, but he left out the most important one.
Yep, from, "Animal Crackers." Although I believe it's,
"Hunger-Dunger." You were close though. You were close though,
and I bet you still are. ;)
--
Neil Cerutti
==============================================================================
TOPIC: how to avoid checking the same condition repeatedly ?
http://groups.google.com/group/comp.lang.python/t/a4db4d2b662bf8d1?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Oct 29 2013 6:44 am
From: Neil Cerutti
On 2013-10-28, Nobody <nobody@nowhere.com> wrote:
> On Mon, 28 Oct 2013 09:50:19 +0000, Wolfgang Maier wrote:
>> So my question is: is there an agreed-upon generally best way
>> of dealing with this?
>
> Yes. Just leave the test inside the loop.
>
> If you're sufficiently concerned about performance that you're
> willing to trade clarity for it, you shouldn't be using Python
> in the first place.
When you detect a code small, as Wolfgang did, e.g., "I'm
repeating the same exact test condition in several places," you
should not simply ignore it, even in Python.
--
Neil Cerutti
==============================================================================
TOPIC: How do I update a virtualenv?
http://groups.google.com/group/comp.lang.python/t/77d81b8041038ef1?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Oct 29 2013 7:08 am
From: Skip Montanaro
> Where specifically are these instructions that tell you to put the
> virtualenv under VCS control?
https://devcenter.heroku.com/articles/getting-started-with-python
> As you are a Heroku customer (I'm not), would you be willing to
> suggest they alter them based on advice from this forum?
It's not my job to pretend to be an expert about something I am
clearly not. All I would be doing is passing along your perspective on
the matter. I presume they have reasonable reasons for doing things
the way they do it. It would be better for people expert in VCS issues
to discuss this stuff with the Heroku people, who presumably know a
thing or two about application deployment, and can give you their
perspective on why they use "git push" as a deployment tool.
Skip
==============================================================================
TOPIC: Function for the path of the script?
http://groups.google.com/group/comp.lang.python/t/76fffeeca6996f8a?hl=en
==============================================================================
== 1 of 2 ==
Date: Tues, Oct 29 2013 7:26 am
From: Grant Edwards
On 2013-10-28, Ben Finney <ben+python@benfinney.id.au> wrote:
> Grant Edwards <invalid@invalid.invalid> writes:
>
>> On 2013-10-27, Ben Finney <ben+python@benfinney.id.au> wrote:
>>
>> > What workflow requires you to know the filename of the module, within
>> > the module?
>>
>> If you have a utility that can be used to do several related things,
>> one way to tell that utility which you want to do is with command line
>> arguments.
>
> That's a case for inspecting the command line.
>
>> For example your utility checks sys.argv[1] for a command or option
>> flag. Another way is to give the file multiple names, and check
>> sys.argv[0] to see what name you've been invoked under.
>
> Exactly so. This isn't a use case for finding the filesystem location
> of the module.
Indeed. I was answering a question about a use case knowing the
_filename_, not the path for the file.
--
Grant Edwards grant.b.edwards Yow! I wonder if I should
at put myself in ESCROW!!
gmail.com
== 2 of 2 ==
Date: Tues, Oct 29 2013 7:31 am
From: Grant Edwards
On 2013-10-29, Steven D'Aprano <steve@pearwood.info> wrote:
> On Mon, 28 Oct 2013 21:00:39 -0700, rurpy wrote:
>
>> This was pointed out before but since you said you ignore posts from GG
>> you probably missed it, and will probably miss this one too, and thus
>> continue to post bad information.
>>
>> This is a small but illustrative example of why such broad- brush
>> filtering is a bad idea. But it is your choice.
>
[...]
> If you don't want to be associated with the typical GG posts, you
> have the choice to stop using GG. And just as you make the choice
> that the convenience of GG outweighs the annoyance of being filtered,
> I expect Grant has made the choice that the convenience of avoiding
> unwanted GG posts outweighs the risk of throwing out a useful post or
> two.
At the time I made that choice there was a significant problem with
spam being sent using GG posts. I'm told that the list server
attempted to filter out those posts, but those of us who read this via
Usenet got the full broadside of ads and scams. Based on the S/N
ratio of non-spam GG posts, the choice was pretty obvious.
--
Grant Edwards grant.b.edwards Yow! Edwin Meese made me
at wear CORDOVANS!!
gmail.com
==============================================================================
You received this message because you are subscribed to the Google Groups "comp.lang.python"
group.
To post to this group, visit http://groups.google.com/group/comp.lang.python?hl=en
To unsubscribe from this group, send email to comp.lang.python+unsubscribe@googlegroups.com
To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.python/subscribe?hl=en
To report abuse, send email explaining the problem to abuse@googlegroups.com
==============================================================================
Google Groups: http://groups.google.com/?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home