Hey all,
I edited my code, and it seems to choose a new number each time. Maybe I didn't
run my test long enough the first time?
I should have spotted the problem of
choice(range(3))
a mile away. I edited that bit, and now I think it's running right. (25 rounds
of Rock, Paper, Scissors s
"Nathan Pinno" <[EMAIL PROTECTED]> wrote
> But can anyone explain why I can shorten the code?
There are a few things you could do but one very powerful
trick is to use a table driven approach. Thus:
rps = {0:'rock',1:'paper',2:'scissors'} # use zero to match list
index
results = [
On 2/15/07, Nathan Pinno <[EMAIL PROTECTED]> wrote:
> and that was a suggestion. (Thanks!) But can anyone explain why I can
> shorten the code? I looked at it a long while yesterday, and came up with
> nothing. The only thing I decided was to try to get it to the GUI stage.
If you take a look at
Rikard Bosnjakovic wrote:
> On 2/15/07, Nathan Pinno <[EMAIL PROTECTED]> wrote:
>
>
>> and that was a suggestion. (Thanks!) But can anyone explain why I can
>> shorten the code? I looked at it a long while yesterday, and came up with
>> nothing. The only thing I decided was to try to get it to t
The one thing people told me when i started learning python was that python
has this lovely structure called dictionaries. Your particular problem is
very easy to solve using dictionaries in about 12 lines (i coded it myself
just to see ;-)).
For instance you could define the various values as a
2007/2/14, Alan Gauld <[EMAIL PROTECTED]>:
Because hitting Reply and sending to a list would only be
consistent if the list was the originator of the message.
Some mailing lists do implement this bizarre and
non-standard email behaviour but thankfully the Python
community doesn't! This behaviour
Hi list,
I have a function with two arguments (say f(x,y))
and second which returns tuple (say def g(): return (xx,yy))
my question is how to put returned values from g() as
arguments to f ?
the direct way generates error:
f(g())
TypeError: ff() takes exactly 2 arguments (1 given)
and the ha
[EMAIL PROTECTED] wrote:
>
> Hi list,
>
> I have a function with two arguments (say f(x,y))
> and second which returns tuple (say def g(): return (xx,yy))
>
> my question is how to put returned values from g() as
> arguments to f ?
>
> the direct way generates error:
>
> f(g())
> TypeError: ff
[EMAIL PROTECTED] schrieb:
>Hi list,
>
>I have a function with two arguments (say f(x,y))
>and second which returns tuple (say def g(): return (xx,yy))
>
>my question is how to put returned values from g() as
>arguments to f ?
>
>
There is a special *-operator, which inserts the components of an
On 2/15/07, Andre Engels <[EMAIL PROTECTED]> wrote:
> It's getting to be the majority of mailing lists that do it the other way,
> and I find it quite irritating that this list does not - I have had several
> times that I sent a mail, and after sending it, sometimes long after sending
> it, I real
On 2/14/07, Mike Hansen <[EMAIL PROTECTED]> wrote:
> The following tutor faq has an explanation:
>
> http://www.python.org/infogami-faq/tutor/tutor-why-do-my-replies-go-to-t
> he-person-who-sent-the-message-and-not-to-the-list/
I think the argument in that "explanation" sucks.
A asks something,
On 2/14/07, Mike Hansen <[EMAIL PROTECTED]> wrote:
> The following tutor faq has an explanation:
>
> http://www.python.org/infogami-faq/tutor/tutor-why-do-my-replies-go-to-t
> he-person-who-sent-the-message-and-not-to-the-list/
It seems like this is designed for the 5% case when it makes th
"Richard Querin" <[EMAIL PROTECTED]> wrote
>>
>> > The following tutor faq has an explanation:
>> >
>> > http://www.python.org/infogami-faq/tutor/tutor-why-do-my-replies-go-to-t
>> > he-person-who-sent-the-message-and-not-to-the-list/
>
> It seems like this is designed for the 5% case when it makes
"Geoframer" <[EMAIL PROTECTED]> wrote
> Probably this is not unlike Alan suggest, but i got confused when i
> read
> about tables. Unless he means dictionaries instead.
I meant tables in a generic sense. I actually started using
a dictionary then changed to a list because its more generic..
But
On 2/15/07, Alan Gauld <[EMAIL PROTECTED]> wrote:
I dunno about you but 95% of my email is private, only
about 5% comes from mailing lists.
Yeah, me too, but I guess it seems easier to just hit 'reply' 100% of the
time and have it go to the right recipient. My point really was that 95% of
t
2007/2/15, ALAN GAULD <[EMAIL PROTECTED]>:
> realize I sent it to the sender instead of the list,
> so I send a second message after it.
So do you find it odd when dealing with normal email
and you hit reply and it only goes to the sender?
No, because it is sent by the sender to me, not to
Hello,
This is my first post. I have just begun to code with python. My goal is to
convert about a dozen or
so DOS/Windows batch scripts(.bat) and vbscripts(.vbs) that I use on a
day-to-day basis to python so
that they can be run on either my windows or linux workstations.
The first things th
Mark Bystry wrote:
> The first things that I want to learn is how to do basic stuff like copying,
> moving, and deleting
> files around from folder to folder. I have been in the help section of python
> (copyfile section)
> but I do not understand what I am doing wrong.
Welcome to Python. You
Hey Mark, welcome aboard!
There are a few different approaches you could take to convert your
scripts. If most of your scripts are related to copying/moving files,
I'd have a look at Python's shutil module. I think it'll work in both
Windows and Linux but I don't have a Windows machine handy to
If you import os, os.path, and shutil (only the ones you need,
although I wind up using all three for this sort of task), you can do
all that you have in mind and more.
os.path opens up some pretty painless methods for doing things like
testing to make sure the file exists in a given location befo
"Mark Bystry" <[EMAIL PROTECTED]> wrote
> My goal is to convert about a dozen or so DOS/Windows batch
> scripts(.bat) and vbscripts(.vbs) that I use on a day-to-day basis
> to python
You might want to look at my Using the OS topic in my tutorial
It covers basic file manipulation and starting
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Mark Bystry
> Sent: Thursday, February 15, 2007 10:04 AM
> To: tutor@python.org
> Subject: [Tutor] Convert my .bat and .vbs to .py
>
> Hello,
>
> This is my first post. I have just begun to code wi
I can confirm it works nicely in Windows. I have a script I use
several times daily to create working directories on a local
workstation by copying over arbitrarily deep directory trees into an
"original files" directory under a root directory named by job number.
The local workstation on which I h
Wow! Got a lot of responses to my post. Thanks everyone. After reading all of
them, I may have to
learn by example after all. I'm going to try Alan Gauld's tutorials first.
Mark
Alan Gauld wrote the following on 2/15/2007 12:39 PM:
> "Mark Bystry" <[EMAIL PROTECTED]> wrote
>
>> My goal is to
You guys are great! I'm not sure how I found this mailing list but I'm glad
that I subscribed.
Mark
Rob Andrews wrote the following on 2/15/2007 1:23 PM:
> We're good like that. heh
>
> On 2/15/07, Mark Bystry <[EMAIL PROTECTED]> wrote:
>> Wow! Got a lot of responses to my post. Thanks everyone
The major reason for not setting Reply-To: thelist is that it makes it
*SLIGHTLY* more difficult to post something to the list and replys should
go to the sender. IHMO, one should have to go to a little bit of effort
before posting a message that may go to thousands of recipients.
Using the ``mut
Well, immediately I am having problems. Be patient with me.
This what I have...
copy_file.py
import os
import shutil as sh
sh.copy('C:\testing_it.txt', 'D:\')
raw_input("Done!")
...and it's not working.
Ahh, yes. Your main trouble seems to be the use of \ instead of / in
'C:\testing_it.txt'
Windows uses \, whereas python uses /. So you can replace 'c:\'
with your choice of the following:
'c:/' (replacing \ with /)
r'c:\' (the 'r' before the string tells python it's a raw string)
'c:\
Mark Bystry wrote:
> Well, immediately I am having problems. Be patient with me.
We will be, you're doing great so far :-)
>
> This what I have...
>
> copy_file.py
>
>
> import os
> import shutil as sh
>
> sh.copy('C:\testing_it.txt', 'D:\')
Backsl
Jeez! I'm retarded. It works like a charm now.
Thanks for that Rob
Mark
Rob Andrews wrote the following on 2/15/2007 2:29 PM:
> Ahh, yes. Your main trouble seems to be the use of \ instead of / in
> 'C:\testing_it.txt'
>
> Windows uses \, whereas python uses /. So you can replace 'c:\'
> wi
Hey Mark,
Mark Bystry wrote:
> sh.copy('C:\testing_it.txt', 'D:\')
Also have a look at the os.path module. Because you want these scripts
to work on both Linux and Windows, using os.path will let you avoid
writing platform specific code to handle your slashes.
For example:
import os
path_parts_l
Ahh. Great tip Eric. Thank-you.
Mark
Eric Walstad wrote the following on 2/15/2007 2:58 PM:
> Hey Mark,
> Mark Bystry wrote:
>> sh.copy('C:\testing_it.txt', 'D:\')
>
> Also have a look at the os.path module. Because you want these scripts
> to work on both Linux and Windows, using os.path will
I downloaded py2exe and I thought it was a program that you just browsed
your driver and gave it the .py file and it would do the rest. But I
downloaded it and I cannot figure out how to use it. Please help.
_
Get in the mood for Va
On 2/16/07, C. Gander <[EMAIL PROTECTED]> wrote:
> I downloaded py2exe and I thought it was a program that you just browsed
> your driver and gave it the .py file and it would do the rest. But I
> downloaded it and I cannot figure out how to use it. Please help.
You don't have to "figure it out",
Bill Campbell wrote:
> The major reason for not setting Reply-To: thelist is that it makes it
> *SLIGHTLY* more difficult to post something to the list and replys should
> go to the sender. IHMO, one should have to go to a little bit of effort
> before posting a message that may go to thousands of
On Thu, Feb 15, 2007, Luke Paireepinart wrote:
>Bill Campbell wrote:
>> The major reason for not setting Reply-To: thelist is that it makes it
>> *SLIGHTLY* more difficult to post something to the list and replys should
>> go to the sender. IHMO, one should have to go to a little bit of effort
>>
On Thu, 15 Feb 2007, Bill Campbell wrote:
> Having the Reply-To: to the original poster minimizes the probability of
> somebody sending mail to a list that was intended for the original poster
> (which may be private).
Well, no. It minimizes the probability of someone sending mail to a list.
37 matches
Mail list logo