Re: [Tutor] How it is better than java

2011-09-20 Thread Mac Ryan
On Tue, 20 Sep 2011 10:27:12 +1000
Steven D'Aprano  wrote:


> There are three misunderstandings with that statement.
> [snip]
> There's also JPype, which claims to give full access to Java
> libraries in Python.

Now: this was one of the best write-ups on the subject I read. Concise,
clear, documented. Nice way to start the day! :o

/mac
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How it is better than java

2011-09-20 Thread Wayne Werner
On Tue, Sep 20, 2011 at 3:21 AM, Mac Ryan  wrote:

> On Tue, 20 Sep 2011 10:27:12 +1000
> Steven D'Aprano  wrote:
>
>
> > There are three misunderstandings with that statement.
> > [snip]
> > There's also JPype, which claims to give full access to Java
> > libraries in Python.
>
> Now: this was one of the best write-ups on the subject I read. Concise,
> clear, documented. Nice way to start the day! :o


Ditto - and as a slight aside, it's interesting to note that .NET languages
(VB, C# specifically) are also compiled into the MSIL which can't run
without the .NET runtime. To my understanding, this is quite similar (or the
same thing) as other "interpreted" languages.

-Wayne
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] OptionParser

2011-09-20 Thread Prasad, Ramit
> from optparse import OptionParser
I am not sure what version of Python you are using but from 2.7+ optparse is 
deprercated. You may want to use that if you can. 

> I don't really understand what dest and action in the arguments to 
> parser.add_option mean.  
Here is your usage:
>>> parser = OptionParser(usage="blahblahblah")
>>> parser.add_option("-f", "--file", dest="filename")

>>> (options, args) = parser.parse_args(['-f filename.csv']) # test in 
>>> interpreter
>>> options.filename
' filename.csv' # Note the space before filename
>>> print options.filename
 filename.csv

See the documentation: http://docs.python.org/library/optparse.html 

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] OptionParser

2011-09-20 Thread Mina Nozar

Thank you Parsad.

I am using Python 2.7.1+

You are right, looks like optparse is replaced by argparse.

My problem was that I was checking output and not options.output.

cheers,
Mina

On 11-09-20 02:27 PM, Prasad, Ramit wrote:

from optparse import OptionParser

I am not sure what version of Python you are using but from 2.7+ optparse is 
deprercated. You may want to use that if you can.


I don't really understand what dest and action in the arguments to 
parser.add_option mean.

Here is your usage:

parser = OptionParser(usage="blahblahblah")
parser.add_option("-f", "--file", dest="filename")



(options, args) = parser.parse_args(['-f filename.csv']) # test in interpreter
options.filename

' filename.csv' # Note the space before filename

print options.filename

  filename.csv

See the documentation: http://docs.python.org/library/optparse.html

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] OptionParser

2011-09-20 Thread Prasad, Ramit
We are glad to help! If you do have future problems feel free to post again, 
but would you mind posting in plain text (or at least without a background)? 
Thanks.

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423



This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] quick data structures question

2011-09-20 Thread Fred G
Hey guys,

I want to write a short script that takes from an input excel file w/ a
bunch of rows and columns.  The two columns I'm interested in are "high
gains" and "genes."  I want the user to write:

>>>Which genes are associated with gains over 20%?

and then I want the script to search through the excel file, find in the
"high gains" column when the number is greater than 20%, and then store the
corresponding genes in that row (but in the "genes" column).  I know this
should be super simple, but I'm having trouble breaking the problem into
smaller, manageable pieces.  For instance, the "high gains" column does not
have just integers, it is in the format %.  Also, I'd like for the final
script to be usable in R if possible, too.

pseudocode is something like this:

for line in lines:
  if item in "high gains" > 20
 create new dictionary
   store genes from "genes" into new dictionary

Much thanks in advance!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] quick data structures question

2011-09-20 Thread delegbede
Hi Fred,

Here is my attempt to solve your task. 

import xlrd

def extract(file_name):
choice_file = xlrd.open_workbook(file_name)
choice_sheet = choice_file.sheet_by_index(0)
gene_dict = {}
for row_num in range(1,choice_sheet.nrows):
row_vals = choice_sheet.row_values(row_num)
if int(row_vals[0] * 100) > 20:
gene_dict[row_vals[1]] = row_vals[0] * 100
return gene_dict

Here are few assumptions I made. 
1. The your excel file has just two column with headers. Column 1 is High gain 
written in % format and column 2 is the gene. 

2. that excel returns % format as decimals which is float in python; hence 
my conversion to int. 

Try this out and let me know how it goes. 

Watch the indents carefully. I typed from my blackberry. 

HTH. 


Sent from my BlackBerry wireless device from MTN

-Original Message-
From: Fred G 
Sender: tutor-bounces+delegbede=dudupay@python.org
Date: Tue, 20 Sep 2011 23:28:43 
To: 
Subject: [Tutor] quick data structures question

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] quick data structures question

2011-09-20 Thread delegbede
As a follow up Fred, you have to install the xlrd package to use it. 
It helps you interact with an excel file even if you don't have excel installed 
on your pc. 
Sent from my BlackBerry wireless device from MTN

-Original Message-
From: Fred G 
Sender: tutor-bounces+delegbede=dudupay@python.org
Date: Tue, 20 Sep 2011 23:28:43 
To: 
Subject: [Tutor] quick data structures question

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor