I just stumbled on this
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> s="hello world"
>>> s=s[::-1]
>>> print s
dlrow olleh
>>>
---
Gil Cosson
Bremerton, Washington
360 620 0431
how to link two files in python
Bollywood news, movie reviews, film trailers and more! Go to
http://in.movies.yahoo.com/___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Hi,
This is how I would do it, although there might be more readable solutions:
s = raw_input("Enter a message: ")
print "".join([s[-letter] for letter in range(len(s)+1)])
Cheers!!
Albert-Jan
--- On Tue, 6/16/09, Alan Gauld wrote:
> From: Alan Gauld
> Subject: Re: [Tutor] Help Needed
> To:
On Tue, Jun 16, 2009 at 6:19 AM, Febin Ameer Ahsen wrote:
> how to link two files in python
A few tips on getting good replies:
1) Start with a descriptive subject, such as "importing a file" or
"appending one file to another"
2) Actually ask a question and describe what you're trying to do.
*Question :*
The first list contains some items, and the second list contains their value
(higher is better).
items = [apple, car, town, phone]
values = [5, 2, 7, 1]
Show how to sort the 'items' list based on the 'values' list so that you end
up with the following two lists:
items = [town, appl
Wayne already explained slicing but I would like to point out the
digit after the second colon changes the default step of the slice.
Usually it defaults to 1, here because no values were given it takes
the entire string and steps backward. You could set it to 2.
First digit, beginning of slice,
On Tue, Jun 16, 2009 at 8:52 AM, Abhishek Tiwari wrote:
> *Question :*
> The first list contains some items, and the second list contains their
> value (higher is better).
>
> items = [apple, car, town, phone]
> values = [5, 2, 7, 1]
>
> Show how to sort the 'items' list based on the 'values' li
"Abhishek Tiwari" wrote
*Ans. 1*
values, items = list(zip(*sorted(zip(values,items), reverse=True)))
Personally I find that just a bit too dense so I'd break it out to:
s = sorted(zip(values,items), reverse=True)
values = [v for v,i in s]
items = [i for v,i in s]
*Ans. 2*
new_values = so
On Tue, Jun 16, 2009 at 9:52 AM, Abhishek
Tiwari wrote:
> Question :
> The first list contains some items, and the second list contains their value
> (higher is better).
>
> items = [apple, car, town, phone]
> values = [5, 2, 7, 1]
>
> Show how to sort the 'items' list based on the 'values' list so
On 6/16/2009 7:49 AM Kent Johnson said...
How do you measure "better"? Speed, clarity, ...?
... or the first method you think of that gives the right result. Where
else would you find your keys once you've found them?
Emile
___
Tutor maillist -
Eddie wrote:
> I downloaded the previous version of PyScripter although couldn't get
> it to work and after googling it, I downloaded Python Portable 1.1
> (Python 2.6.1 as most sites/books recommend this and not 3) which has
> PySCripter included and this then works fine.Ii also downloaded Komod0
Abhishek Tiwari wrote:
> *Question :*
> The first list contains some items, and the second list contains their
> value (higher is better).
>
> items = [apple, car, town, phone]
> values = [5, 2, 7, 1]
>
> Show how to sort the 'items' list based on the 'values' list so that you
> end up with the
Quick question. Say I have a string a="Man" and I want to print the string in
base2. Is there a python function like there is in perl to do this?
Thanks in advance for any input
Sent from my Verizon Wireless BlackBerry
___
Tutor maillist - Tutor@pyth
On Tue, Jun 16, 2009 at 12:46 PM, wrote:
> Quick question. Say I have a string a="Man" and I want to print the string
> in base2. Is there a python function like there is in perl to do this?
> Thanks in advance for any input
do you mean like this:
In [23]: int('Man', 2)
Thanks for the reply I would like to print the string in binary
Man=01001101011101101110
Sent from my Verizon Wireless BlackBerry
-Original Message-
From: Wayne
Date: Tue, 16 Jun 2009 13:13:58
To:
Cc:
Subject: Re: [Tutor] Conversion question
On Tue, Jun 16, 2009 at 12:46 PM, w
xchime...@gmail.com wrote:
> Thanks for the reply I would like to print the string in binary
> Man=01001101011101101110
>
What's M in binary?
Nobody knows...
What's M in encoded in 8-bit ASCII string:
'0b1001101'
Source: bin(ord('M'))
___
Tutor ma
Correct 8-bit ASCII. Sorry about that. I am using Python 2.5.2, which
doesn't support bin. If I upgraded how would I go about converting the
entire string to 8-bit ASCII?
I appreciate your help.
On Tue, Jun 16, 2009 at 3:05 PM, Lie Ryan wrote:
> xchime...@gmail.com wrote:
> > Thanks for th
On Tue, Jun 16, 2009 at 2:25 PM, Tom Green wrote:
> Correct 8-bit ASCII. Sorry about that. I am using Python 2.5.2, which
> doesn't support bin. If I upgraded how would I go about converting the
> entire string to 8-bit ASCII?
>
> I appreciate your help.
you write the conversion yourself.
Thanks I just happened to find the site myself. I guess I have to pass each
character to the function and build the 8-bit ASCII string or is there a
better way to do it?
On Tue, Jun 16, 2009 at 3:37 PM, Wayne wrote:
> On Tue, Jun 16, 2009 at 2:25 PM, Tom Green wrote:
>
>> Correct 8-bit ASCII.
Tom Green wrote:
> Correct 8-bit ASCII. Sorry about that. I am using Python 2.5.2, which
> doesn't support bin. If I upgraded how would I go about converting the
> entire string to 8-bit ASCII?
>
AFAIK, earlier versions of python does not have a function/module that
converts a number to its bi
Hello,
a question for people who know how to write MANIFEST.in:
How to tell to simply include all files in the package (and subdirs)? I tried:
recursive-include *.*
==> warning: sdist: MANIFEST.in, line 1: 'recursive-include' expects
...
recursive-include . *.*
==> warning: no files found ma
Hi Tutors,
I"m using Python 2.6.2 and the IDLE tool (also v. 2.6.2). However, when I
open the editor I cannot seem to change the directory so as to allow for
easy access to my modules. So, for example, the following occurs:
>>>
os.chdir('/Users/elisha/Documents/workspace/CacheNetFramework/src/Tes
I had previously emailed y'all regarding inverting a message input by the user
of the program backwards. After much contemplation on your earlier replies I
came up with the code I have included in this email. The problem I am having
with this code is that the the first character of the message t
You are putting far too much work into the solution. Look up slicing on
the python web page. Then, as an example,
In [1]: s1 = 'hello world'
In [2]: s1[::-1]
Out[2]: 'dlrow olleh'
Hope this helps,
Robert
On Tue, 2009-06-16 at 14:25 -0700, Raj Medhekar wrote:
> I had previously emailed y'all r
So I figured out the solution to the missing letter and I will post my code
here. But I still need help figuring out the other stuff (please see my
original message included in this email)! Thanks for putting up with me. Python
is slowly but surely coming to me! I am psyched since this is the fi
Raj Medhekar wrote:
> So I figured out the solution to the missing letter and I will post my
> code here. But I still need help figuring out the other stuff (please
> see my original message included in this email)! Thanks for putting up
> with me. Python is slowly but surely coming to me! I am psy
Elisha Rosensweig wrote:
> Hi Tutors,
>
> I"m using Python 2.6.2 and the IDLE tool (also v. 2.6.2). However, when
> I open the editor I cannot seem to change the directory so as to allow
> for easy access to my modules. So, for example, the following occurs:
>
> os.chdir('/Users/elisha/Docum
Martin Walsh wrote:
> Elisha Rosensweig wrote:
>> Hi Tutors,
>>
>> I"m using Python 2.6.2 and the IDLE tool (also v. 2.6.2). However, when
>> I open the editor I cannot seem to change the directory so as to allow
>> for easy access to my modules. So, for example, the following occurs:
>>
>> os.chdi
> My Original message:
>
> I had previously emailed y'all regarding inverting a message input by
the user of the program backwards. After much
> contemplation on your earlier replies I came up with the code I have
included in this email. The problem I am having
> with this code is that the the
On 6/15/2009 12:14 PM Michael Powe said...
On Mon, Jun 15, 2009 at 06:34:04AM -0700, Emile van Sebille wrote:
I'm wondering if there might be documented benefits to migrating from my
horse and buggy. :)
Are you in a hurry to get somewhere? ;-)
If 20 LOC/day is average nowadays, how fast do
On Tue, Jun 16, 2009 at 4:27 PM, Essah Mitges wrote:
>
> What I am trying to do is print a high score text file to a pygame window
> it kinda works...I don't know how to go about doing this...
>
Do you know how to print text to a window?
to read a file, just in a terminal window:
f = open('som
"Raj Medhekar" wrote
... I came up with the code I have included in this email.
Wy to complicated!
message = raw_input("Enter your message: ")
print message
high = len(message)
low = -len(message)
begin=None
while begin != "":
begin = int(high)
if begin:
end = int(low)
"Essah Mitges" wrote
What I am trying to do is print a high score text file
to a pygame window it kinda works...
How do you define kinda?
It doesn't look like it works to me.
The function main defined as
def main():
high_file = open_file("high_score.txt", "r")
score = next_block(high_
wrote
mystring="Mary had a little lamb."
mystring.split()
['Mary', 'had', 'a', 'little', 'lamb.']
And then you can use slicing to reverse the created list the same way you
did with the full string.
Or use the reverse() method of the list...
Alan G
__
Raj Medhekar wrote:
So I figured out the solution to the missing letter and I will post my
code here. But I still need help figuring out the other stuff (please
see my original message included in this email)! Thanks for putting up
with me. Python is slowly but surely coming to me! I am psyched
On Tue, Jun 16, 2009 at 8:59 PM, ayyaz wrote:
> The following works also.
>
> msg = raw_input("\nPlease enter a message to print backwards: ")
> x = range(0,len(msg))
> x.reverse()
> for i in x: print msg[i],
or even simpler, allow range to generate the reverse:
range(len(msg)-1, -1, -1)
Some
> Also is there a way to say reverse the string in a way so the reversed
> string would result to "this take" if you use my example? And is there a way
> to stop the loop without the use of break? Thanks for the help!
>
Sure. First take your string S and use S.split() to get a list of the
individu
37 matches
Mail list logo