Steven D'Aprano | 1 Mar 13:03 2012

Re: new to programming and wondering about an IDE for Python on Linux

On Mon, Feb 27, 2012 at 07:22:20AM -0800, John Jensen wrote:
> Hi All,
> 
> I'm new to programming and wondering about an IDE for Python on Linux. 
> I'd appreciate any feedback on this and good tutorials or books on 
> Python 3 and the IDEs suggested. There are many available and I'm 
> wondering what you as users find effective.

Personally, I find that Linux and the standard tool chain it provides is 
an IDE, no need for a dedicated IDE application.

http://blog.sanctum.geek.nz/series/unix-as-ide/

My IDE of choice is KDE's "kate" text editor, plus a terminal app that 
supports multiple tabs. I run at least one Python interactive 
interpreter in one tab, for testing code snippets, calling interactive 
help, etc., and other tabs for controlling my source repository 
(mercurial), running scripts, etc.

Oh, and a browser for searching the web. I prefer DDG:

http://duckduckgo.com/

which has dedicated Python support.

--

-- 
Steven

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
(Continue reading)

Brad Hudson | 2 Mar 18:03 2012
Picon

python + sharepoint

Can someone assist in a very basic task of retrieving a '.txt' file
from a sharepoint document library using Python 2.4 standard
libraries? I'm certain, I need to build up some form of authentication
to pass, but do not know where to begin. Also, I do not want to
attempt to customize or install additional packages to the server for
this (Solaris).

Note: url is changed below for obvious reasons, but the traceback is untouched.

# ./get_file.py
Traceback (most recent call last):
  File "./get_file.py", line 7, in ?
    result = urllib2.urlopen(url).readlines()
  File "/usr/lib/python2.4/urllib2.py", line 130, in urlopen
    return _opener.open(url, data)
  File "/usr/lib/python2.4/urllib2.py", line 364, in open
    response = meth(req, response)
  File "/usr/lib/python2.4/urllib2.py", line 471, in http_response
    response = self.parent.error(
  File "/usr/lib/python2.4/urllib2.py", line 402, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.4/urllib2.py", line 337, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.4/urllib2.py", line 480, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 400: Bad Request
[root <at> ilhsf001h001]# cat get_file.py
#!/usr/bin/env python

import urllib2
(Continue reading)

Hs Hs | 2 Mar 20:11 2012
Picon

number of mismatches in a string

Hi:
I have the following table and I am interested in calculating mismatch ratio. I am not completely clear how to do this and any help is deeply appreciated. 

Length     Matches
77      24A0T9T36
71      25^T9^T37
60      25^T9^T26
62      42A19


In length column I have length of the character string. 
In the second column I have the matches my reference string. 


In fist case, where 77 is length, in matches from left to right, first 24 matched my reference string following by a extra character A, a null (does not account to proble) and extra T, 9 matches, extra T and 36 matches.  Totally there are 3 mismatches

In case 2, I lost 2 characters (^ = loss of character compared to reference sentence)   - 

TOMISAGOODBOY
T^MISAGOOD^OY   (here I lost 2 characters)  = I have 2 mismatches
TOMISAGOOODBOOY (here I have 2 extra characters O and O) = I have two mismatches


In case 4: I have 42 matches, extra A and 19 matches = so I have 1 mismatch


How can that mismatch number from matches string.
1. I have to count how many A or T or G or C (believe me only these 4 letters will appear in this, i will not see Z or B or K etc)
2. ^T or ^A or ^G or ^C will also be a mismatch


desired output:

Length     Matches   mismatches
77      24A0T9T36    3 
71      25^T9^T37     2
60      25^T9^T26     2
62      42A19             1
10      6^TTT1           3


thanks 
Hs.

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Albert-Jan Roskam | 2 Mar 22:14 2012
Picon

Re: number of mismatches in a string

Hi,

I do not completely follow you, but perhaps you could check out this page: http://code.activestate.com/recipes/576869-longest-common-subsequence-problem-solver/
Another source of inspiration could be the levenshtein distance.
 
Regards,
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a
fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
From: Hs Hs <ilhs_hs <at> yahoo.com>
To: "tutor <at> python.org" <tutor <at> python.org>
Sent: Friday, March 2, 2012 8:11 PM
Subject: [Tutor] number of mismatches in a string

Hi:
I have the following table and I am interested in calculating mismatch ratio. I am not completely clear how to do this and any help is deeply appreciated. 

Length     Matches
77      24A0T9T36
71      25^T9^T37
60      25^T9^T26
62      42A19


In length column I have length of the character string. 
In the second column I have the matches my reference string. 


In fist case, where 77 is length, in matches from left to right, first 24 matched my reference string following by a extra character A, a null (does not account to proble) and extra T, 9 matches, extra T and 36 matches.  Totally there are 3 mismatches

In case 2, I lost 2 characters (^ = loss of character compared to reference sentence)   - 

TOMISAGOODBOY
T^MISAGOOD^OY   (here I lost 2 characters)  = I have 2 mismatches
TOMISAGOOODBOOY (here I have 2 extra characters O and O) = I have two mismatches


In case 4: I have 42 matches, extra A and 19 matches = so I have 1 mismatch


How can that mismatch number from matches string.
1. I have to count how many A or T or G or C (believe me only these 4 letters will appear in this, i will not see Z or B or K etc)
2. ^T or ^A or ^G or ^C will also be a mismatch


desired output:

Length     Matches   mismatches
77      24A0T9T36    3 
71      25^T9^T37     2
60      25^T9^T26     2
62      42A19             1
10      6^TTT1           3


thanks 
Hs.


_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
bob gailer | 2 Mar 22:47 2012
Picon

Re: number of mismatches in a string

On 3/2/2012 2:11 PM, Hs Hs wrote:
Hi:
I have the following table and I am interested in calculating mismatch ratio. I am not completely clear how to do this and any help is deeply appreciated. 

Length     Matches
77      24A0T9T36
71      25^T9^T37
60      25^T9^T26
62      42A19


In length column I have length of the character string. 
In the second column I have the matches my reference string. 


In fist case, where 77 is length, in matches from left to right, first 24 matched my reference string following by a extra character A, a null (does not account to proble) and extra T, 9 matches, extra T and 36 matches.  Totally there are 3 mismatches

In case 2, I lost 2 characters (^ = loss of character compared to reference sentence)   - 

TOMISAGOODBOY
T^MISAGOOD^OY   (here I lost 2 characters)  = I have 2 mismatches
TOMISAGOOODBOOY (here I have 2 extra characters O and O) = I have two mismatches


In case 4: I have 42 matches, extra A and 19 matches = so I have 1 mismatch


How can that mismatch number from matches string.
1. I have to count how many A or T or G or C (believe me only these 4 letters will appear in this, i will not see Z or B or K etc)
2. ^T or ^A or ^G or ^C will also be a mismatch


desired output:

Length     Matches   mismatches
77      24A0T9T36    3 
71      25^T9^T37     2
60      25^T9^T26     2
62      42A19             1
10      6^TTT1           3


I am sorry but I do not understand, and do not have the patience to wade through all the above in the hopes of gaining insight.

Perhaps you could restate the problem in a way that makes it crystal clear.
-- Bob Gailer 919-636-4239 Chapel Hill NC
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Terry Carroll | 2 Mar 22:34 2012

Re: Which computer operating system is best for Python developers?

(Re Python on Windows 7)

On Thu, 23 Feb 2012, Tim Golden wrote:

> On 23/02/2012 09:00, Alan Gauld wrote:
>
>> If you do a reinstall, download the ActiveState version rather
>> than the Python.org version.
>
> I also recommend the ActiveState distro.

I am going to "third" Alan's and Tim's recommendations of the Activestate 
distribution; and further suggest that you use the 32-bit version, anod 
not the 64-bit version, even if you have the 64-bit Windows 7.  Some 
Python extensions are built only for 32-bit Python and will not work with 
64-bit.

I recently ran into this on two modules; one was PIL and I cannot remember 
the other.  The easy fix was to uninstall the 64-bit Python and install 
32-bit in its place.

I'm referrng to Python 2.7 above.
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Jerry Hill | 2 Mar 23:00 2012
Picon

Re: number of mismatches in a string

On Fri, Mar 2, 2012 at 2:11 PM, Hs Hs <ilhs_hs <at> yahoo.com> wrote:
> Hi:
> I have the following table and I am interested in calculating mismatch
> ratio. I am not completely clear how to do this and any help is deeply
> appreciated.
>
> Length     Matches
> 77      24A0T9T36
> 71      25^T9^T37
> 60      25^T9^T26
> 62      42A19
>
>
> In length column I have length of the character string.
> In the second column I have the matches my reference string.
>
>
> In fist case, where 77 is length, in matches from left to right, first 24
> matched my reference string following by a extra character A, a null (does
> not account to proble) and extra T, 9 matches, extra T and 36 matches.
>  Totally there are 3 mismatches
>
> In case 2, I lost 2 characters (^ = loss of character compared to reference
> sentence)   -
>
> TOMISAGOODBOY
> T^MISAGOOD^OY   (here I lost 2 characters)  = I have 2 mismatches
> TOMISAGOOODBOOY (here I have 2 extra characters O and O) = I have two
> mismatches
>
>
> In case 4: I have 42 matches, extra A and 19 matches = so I have 1 mismatch
>
>
> How can that mismatch number from matches string.
> 1. I have to count how many A or T or G or C (believe me only these 4
> letters will appear in this, i will not see Z or B or K etc)
> 2. ^T or ^A or ^G or ^C will also be a mismatch
>
>
> desired output:
>
> Length     Matches   mismatches
> 77      24A0T9T36    3
> 71      25^T9^T37     2
> 60      25^T9^T26     2
> 62      42A19             1
> 10      6^TTT1           3
>

It looks like all you need to do is count the number of A, T, C, and G
characters in your Matches column.  Maybe something like this:

differences = [
    [77, '24A0T9T36'],
    [71, '25^T9^T37'],
    [60, '25^T9^T26'],
    [62, '42A19']
]

for length, matches in differences:
    mismatches = 0
    for char in matches:
        if char in ('A', 'T', 'G', 'C'):
            mismatches += 1
    print length, matches, mismatches

which produces the following output:
77 24A0T9T36 3
71 25^T9^T37 2
60 25^T9^T26 2
62 42A19 1

--

-- 
Jerry
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Brad Hudson | 2 Mar 23:14 2012
Picon

Re: python + sharepoint

On Fri, Mar 2, 2012 at 11:03 AM, Brad Hudson <brad.hudson <at> gmail.com> wrote:
> Can someone assist in a very basic task of retrieving a '.txt' file
> from a sharepoint document library using Python 2.4 standard
> libraries? I'm certain, I need to build up some form of authentication
> to pass, but do not know where to begin. Also, I do not want to
> attempt to customize or install additional packages to the server for
> this (Solaris).
>
> Note: url is changed below for obvious reasons, but the traceback is untouched.
>
> # ./get_file.py
> Traceback (most recent call last):
>  File "./get_file.py", line 7, in ?
>    result = urllib2.urlopen(url).readlines()
>  File "/usr/lib/python2.4/urllib2.py", line 130, in urlopen
>    return _opener.open(url, data)
>  File "/usr/lib/python2.4/urllib2.py", line 364, in open
>    response = meth(req, response)
>  File "/usr/lib/python2.4/urllib2.py", line 471, in http_response
>    response = self.parent.error(
>  File "/usr/lib/python2.4/urllib2.py", line 402, in error
>    return self._call_chain(*args)
>  File "/usr/lib/python2.4/urllib2.py", line 337, in _call_chain
>    result = func(*args)
>  File "/usr/lib/python2.4/urllib2.py", line 480, in http_error_default
>    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
> urllib2.HTTPError: HTTP Error 400: Bad Request
> [root <at> ilhsf001h001]# cat get_file.py
> #!/usr/bin/env python
>
> import urllib2
>
> url = 'http://myserver.com/myfile.txt'
>
> result = urllib2.urlopen(url).readlines()
>
> print result
> #

Still no response on this one, but I did find a 'rather ugly' solution
using subprocess for wget to get a file from sharepoint...

#!/usr/bin/env python

import getpass
import re
import shlex
from subprocess import Popen, PIPE

# build sharepoint user/pw
# note: shlex.split requires both a raw and escaped domain string
user = r'DOMAIN\\ID'
pw = getpass.getpass('password: ')
url = 'http://myserver.com/myfile.txt'
cmd = 'wget --no-proxy --user=%s --password=%s -O- %s' % (user, pw, url)
# create the args for subprocess.Popen
args = shlex.split(cmd)
# get the tuple from the command
s = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate()
# parse the stdout part of the tuple to get the exact list I want
vms = s[0].rstrip().split('\n')
vms[:] = (re.sub('\|.*$', '', vm.rstrip()) for vm in sorted(vms))
vms[:] = (vm for vm in vms if not re.search('primary', vm))
print vms
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Alan Gauld | 3 Mar 00:22 2012

Re: number of mismatches in a string

On 02/03/12 19:11, Hs Hs wrote:

> 1. I have to count how many A or T or G or C (believe me only these 4
> letters will appear in this, i will not see Z or B or K etc)

This suggests to me that its related to chromosome analysis or somesuch?

There are some python libraries for biochemistry work.
Maybe you should Google for that and see if there is something
already out there that can do what you want?

Your explanation doesn't really make sense to me outside that context 
and, since I'm not a biologist, it doesn't mean that much in that 
context either!

--

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Steven D'Aprano | 3 Mar 03:28 2012

Re: python + sharepoint

Brad Hudson wrote:
> Can someone assist in a very basic task of retrieving a '.txt' file
> from a sharepoint document library using Python 2.4 standard
> libraries? 

What's a sharepoint document library?

How would you retrieve a text file from it *without* using Python?

[...]
> Note: url is changed below for obvious reasons, but the traceback is untouched.

Not obvious to me.

[...]
> urllib2.HTTPError: HTTP Error 400: Bad Request

Does this help?

http://www.checkupdown.com/status/E400.html

My wild guess is that sharepoint (whatever that is) is expecting something in 
the url request that you're not giving; or that it doesn't like your useragent 
and/or referer and lies about the problem.

--

-- 
Steven
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Gmane