Re: [Tutor] datetime.strptime not matching timezone in format

2010-05-04 Thread Abhishek Mishra
%Z stands for time zone name in letters Eg. IST or EDT or GMT, so it would
fail to parse +05:30

However I do not have a solution to your problem but a footnote as hint -
http://docs.python.org/library/time.html#id1

-- Abhishek

On Tue, May 4, 2010 at 3:17 PM, vishwajeet singh wrote:

> Dear All,
>
> I am trying to convert date string to datetime using datetime.strptime and
> when there is timezone part in string conversion is throwing errors.
>
> Here is what I am doing
> string_date = somedate.strftime("%a, %d %b %Y %H:%M:%S %Z")
>
> and than later in some other part of code
> actual_date = datetime.strptime(string_date,"%a, %d %b %Y %H:%M:%S %Z")
>
> I am getting following error for this conversion "*time data 'Tue, 04 May
> 2010 14:59:45 +05:30' does not match format '%a, %d %b %Y %H:%M:%S %Z'*"
>
>  All formats without timezone works perfectly fine.
>
> --
> Vishwajeet Singh
> +91-9657702154 | dextrou...@gmail.com | http://bootstraptoday.com
> Twitter: http://twitter.com/vishwajeets | LinkedIn:
> http://www.linkedin.com/in/singhvishwajeet
>
> ___
> 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] datetime.strptime not matching timezone in format

2010-05-04 Thread Abhishek Mishra
On Tue, May 4, 2010 at 4:22 PM, vishwajeet singh wrote:

>
> On Tue, May 4, 2010 at 4:17 PM, Abhishek Mishra wrote:
>
>> %Z stands for time zone name in letters Eg. IST or EDT or GMT, so it would
>> fail to parse +05:30
>>
>>Ahh...ok thanks for pointing that out but this is kind of stranges as I
> am using same format to convert than why it's not converting it in IST ?
>
>
Interestingly, I guess the timezone environment variable is not set on my
system .

>>> datetime.today()
datetime.datetime(2010, 5, 4, 16, 25, 28, 381390)
>>> d = datetime.today()
>>> string_date = d.strftime("%a, %d %b %Y %H:%M:%S %Z")
>>> string_date
'Tue, 04 May 2010 16:25:32 '
>>>
^^ notice absence of time zone

An interesting discussion on same issue -
http://old.nabble.com/strptime-and-timezones-td18967515.html

>>> import time
>>> time.tzname
('IST', 'IST')
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help

2010-05-14 Thread Abhishek Mishra
Not sure if I understood the problem exactly, but you could linearize the
text by using something like this  --

>>> foo = '''ACTGTGTTC
... ACGTCGACC
... AVGTT
... ACGTTaGTC'''
>>> foo
'ACTGTGTTC\nACGTCGACC\nAVGTT\nACGTTaGTC'
>>> linear1 = ''.join(foo.split('\n'))
>>> linear1
'ACTGTGTTCACGTCGACCAVGTTACGTTaGTC'
>>>
>>> linear2 = foo.replace('\n','')
>>> linear2
'ACTGTGTTCACGTCGACCAVGTTACGTTaGTC'
>>>

>>> linear1 = ''.join(foo.split('\n'))
>>> linear2 = foo.replace('\n','')

^^ these are the two ways in which you can linearize the input text by
removing all  '\n'

after that you can grab 7th to 11th character like this -

>>> linear2[6:11]
'TTCAC'

^^ notice that the index is zero based, so 7th character actually 6 as its
index.

2010/5/14 she haohao 

>
>
> Hi,
>
>
> I am a beginner in python and I have a problem here and I hope someone can
> help me.
>
> Your help is greatly appreciated.
>
> Question.
>
> Say I have a .fa file and I want to print a subsequence from the file
> without the \n how can i do it.
>
> Example: Inside the test.fa file I have
>
> >chromosome 1
> ACTGTGTTC
> ACGTCGACC
> AVGTT
> ACGTTaGTC
>
> so if I say i wan the subsequence starting from the 7th character to the
> 11th(i.e when i let p=(7+11)/2=9 and v=2) character.(excluding the first
> line), mean I want TTCAC.
>
> So how should I write the code so that \n does not appear if i want p=10
> and v=3.
>
> Thanks for the help.
>
> Have a wonderful day ahead!
> Angeline
>
>
> --
> Hotmail: Powerful Free email with security by Microsoft. Get it 
> now.
>
> ___
> 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