Re: [Tutor] Risk Dice Program

2015-01-27 Thread Mark Lawrence
On 28/01/2015 01:28, Alan Gauld wrote: On 28/01/15 00:09, Mark Lawrence wrote: To get round that you need to explicitly compare o_die1 to both values: if (o_die1 > d_die1) or (o_die1 > d_die2): I consider the chained comparisons shown here https://docs.python.org/3/reference/expressio

Re: [Tutor] Risk Dice Program

2015-01-27 Thread Alan Gauld
On 28/01/15 00:09, Mark Lawrence wrote: To get round that you need to explicitly compare o_die1 to both values: if (o_die1 > d_die1) or (o_die1 > d_die2): I consider the chained comparisons shown here https://docs.python.org/3/reference/expressions.html#not-in to be far more Pythonic.

Re: [Tutor] functions first?

2015-01-27 Thread Alex Kleider
On 2015-01-27 16:10, Steven D'Aprano wrote: On Tue, Jan 27, 2015 at 08:39:17AM -0800, Alex Kleider wrote: I use the docopt module to collect command line options and then configparser to read a file. Some of the values (such as a port number, for example) must then be adjusted. An example is a

Re: [Tutor] functions first?

2015-01-27 Thread Steven D'Aprano
On Tue, Jan 27, 2015 at 08:39:17AM -0800, Alex Kleider wrote: > I use the docopt module to collect command line options and then > configparser to read a file. > Some of the values (such as a port number, for example) must then be > adjusted. An example is > a port number which I want to conver

Re: [Tutor] Risk Dice Program

2015-01-27 Thread Mark Lawrence
On 27/01/2015 23:09, Alan Gauld wrote: On 27/01/15 19:12, Dillon Cortez wrote: problem is that if any of the offensive dice is bigger > than only one of the defensive dice, the program shows the offense as the winner, def winner(): if o_die1 > d_die1 or d_die2: print "The off

Re: [Tutor] Problem with chap. 3. 'Craps Roller'

2015-01-27 Thread Danny Yoo
On Tue, Jan 27, 2015 at 2:07 PM, joseph dorsten wrote: > When I run the program I get: NameError: name 'die1' is not > defined However I defined die1 in the program as die1 = > random,randint (1, 6) Thanks for any help, joe Hi Joe, Unfortunately, this is insufficient information.

Re: [Tutor] Execution of local data

2015-01-27 Thread Alan Gauld
On 27/01/15 22:47, jarod...@libero.it wrote: I create a list of local object: but I can't execute as object only as string: ena = Rnaseq(options.configura, options.rst) job_1 = ena.trimmomatic() job_2 = ena.star() job_3 = ena.wiggle() job_4 = ena.rnaseqc()

Re: [Tutor] Problem with chap. 3. 'Craps Roller'

2015-01-27 Thread Alan Gauld
On 27/01/15 22:07, joseph dorsten wrote: When I run the program I get: NameError: name 'die1' is not defined However I defined die1 in the program as die1 = random,randint (1, 6) Thanks for any help, joe Which program? Your subject says chapter 3, but of which book? There are doz

Re: [Tutor] Execution of local data

2015-01-27 Thread Danny Yoo
On Tue, Jan 27, 2015 at 2:47 PM, jarod...@libero.it wrote: > I create a list of local object: but I can't execute as object only as > string: > ena = Rnaseq(options.configura, options.rst) > job_1 = ena.trimmomatic() > job_2 = ena.star() > job_3 = ena.wiggle() >

Re: [Tutor] Risk Dice Program

2015-01-27 Thread Alan Gauld
On 27/01/15 19:12, Dillon Cortez wrote: problem is that if any of the offensive dice is bigger > than only one of the defensive dice, the program shows the offense as the winner, def winner(): if o_die1 > d_die1 or d_die2: print "The offense has won" The problem is that the c

[Tutor] Execution of local data

2015-01-27 Thread jarod...@libero.it
I create a list of local object: but I can't execute as object only as string: ena = Rnaseq(options.configura, options.rst) job_1 = ena.trimmomatic() job_2 = ena.star() job_3 = ena.wiggle() job_4 = ena.rnaseqc() job_5 = ena.picard_sort_sam()

Re: [Tutor] Using if statement with csv file

2015-01-27 Thread Matthew Ruffalo
On 01/27/2015 08:04 AM, Tammy Miller wrote: > I have a csv file. I would like to create a filter or if statement on a > column but it is not producing the right results. It displays everythingHere > is the example:import csvwith open('test.csv') as csvfile:reader = > csv.DictReader(csvfile)f

[Tutor] Problem with chap. 3. 'Craps Roller'

2015-01-27 Thread joseph dorsten
When I run the program I get: NameError: name 'die1' is not defined However I defined die1 in the program as die1 = random,randint (1, 6) Thanks for any help, joe ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription

[Tutor] Risk Dice Program

2015-01-27 Thread Dillon Cortez
I’m trying to write a program for the dice in a game of risk. It runs but the problem is that if any of the offensive dice is bigger than only one of the defensive dice, the program shows the offense as the winner, even when the defense should win. Can you help me out with this? here’s the code

Re: [Tutor] functions first?

2015-01-27 Thread Alex Kleider
On 2015-01-27 00:15, Alan Gauld wrote: On 27/01/15 02:04, Alex Kleider wrote: Please correct me if I am wrong, but I've assumed that it is proper to define all functions before embarking on the main body of a program. No, you can do it either way round. Top-Down or Bottom-Up as they are known

Re: [Tutor] functions first?

2015-01-27 Thread Alex Kleider
On 2015-01-26 22:30, Ben Finney wrote: Alex Kleider writes: Please correct me if I am wrong, but I've assumed that it is proper to define all functions before embarking on the main body of a program. I would say rather that as much code as possible should be in small well-defined functions,

Re: [Tutor] Using if statement with csv file

2015-01-27 Thread Mark Lawrence
On 27/01/2015 18:20, Danny Yoo wrote: On Tue, Jan 27, 2015 at 5:04 AM, Tammy Miller wrote: I have a csv file. I would like to create a filter or if statement on a column but it is not producing the right results. It displays everythingHere is the example:import csvwith open('test.csv') as csv

Re: [Tutor] Using if statement with csv file

2015-01-27 Thread Danny Yoo
> > In your code, you are comparing a string (an element of your CSV row) > with a number. Whoops, forgot to include recommendations. You probably do not want to have comparisons of mixed type. As we have found, the result we get back is arbitrary and capricous. Rather, we probably want to comp

Re: [Tutor] Using if statement with csv file

2015-01-27 Thread Danny Yoo
On Tue, Jan 27, 2015 at 5:04 AM, Tammy Miller wrote: > I have a csv file. I would like to create a filter or if statement on a > column but it is not producing the right results. It displays everythingHere > is the example:import csvwith open('test.csv') as csvfile:reader = > csv.DictReader

Re: [Tutor] Using if statement with csv file

2015-01-27 Thread Alan Gauld
On 27/01/15 13:04, Tammy Miller wrote: I have a csv file. I would like to create a filter or if statement on a column but it is not producing the right results. It displays everythingHere is the example:import csvwith open('test.csv') as csvfile:reader = csv.DictReader(csvfile)for row in r

Re: [Tutor] Python for linux

2015-01-27 Thread Alan Gauld
On 27/01/15 16:50, Reuben wrote: I wish to know which python module works well with Linux commands Most Python modules work on Linux if you are running your Python program on a Linux machine. e.g. Searching a string in file, number of occurrences of a string in a file, Thee isn't a speci

[Tutor] Using if statement with csv file

2015-01-27 Thread Tammy Miller
I have a csv file. I would like to create a filter or if statement on a column but it is not producing the right results. It displays everythingHere is the example:import csvwith open('test.csv') as csvfile:reader = csv.DictReader(csvfile)for row in reader:if row['Absent'] > 10 prin

Re: [Tutor] Python for linux

2015-01-27 Thread Patrick Thunstrom
You're actually asking multiple subquestions here, let me start by asking a clarifying question: When you say "log in to the Linux machine" I assume you mean you need to access a remote host? Your script will be running locally? Next your other questions: Checking permissions of a file: Look int

[Tutor] Python for linux

2015-01-27 Thread Reuben
Hello, I wish to know which python module works well with Linux commands - for e.g. Searching a string in file, number of occurrences of a string in a file, what is the permission of a file. To test this operation I need my python script to login into the Linux machine and then perform the above

Re: [Tutor] functions first?

2015-01-27 Thread Alex Kleider
On 2015-01-27 03:18, Steven D'Aprano wrote: On Mon, Jan 26, 2015 at 06:04:10PM -0800, Alex Kleider wrote: Please correct me if I am wrong, but I've assumed that it is proper to define all functions before embarking on the main body of a program. I find myself breaking this rule because I want to

Re: [Tutor] functions first?

2015-01-27 Thread Steven D'Aprano
On Mon, Jan 26, 2015 at 06:04:10PM -0800, Alex Kleider wrote: > Please correct me if I am wrong, but I've assumed that it is proper to > define all functions before embarking on the main body of a program. > I find myself breaking this rule because I want to set the default > values of some named

Re: [Tutor] functions first?

2015-01-27 Thread Alan Gauld
On 27/01/15 02:04, Alex Kleider wrote: Please correct me if I am wrong, but I've assumed that it is proper to define all functions before embarking on the main body of a program. No, you can do it either way round. Top-Down or Bottom-Up as they are known. Usually its a muxture of both. But mo