On Tue, 11 Dec 2012 16:39:27 +, duncan smith wrote:
[snip]
> >>> alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
> >>> key = "XPMGTDHLYONZBWEARKJUFSCIQV"
> >>> mapping = {}
> >>> for i, ch in enumerate(alpha):
> mapping[ch] = key[i]
mapping = dict(zip(alpha, key))
--
To email me, substitute nowhe
On 12 December 2012 07:52, Ross Ridge wrote:
> John Gordon wrote:
> > def encode(plain):
> > '''Return a substituted version of the plain text.'''
> > encoded = ''
> > for ch in plain:
> >encoded += key[alpha.index(ch)]
> > return encoded
>
> Terry Reedy wrote:
> >The tu
John Gordon wrote:
> def encode(plain):
> '''Return a substituted version of the plain text.'''
> encoded = ''
> for ch in plain:
>encoded += key[alpha.index(ch)]
> return encoded
Terry Reedy wrote:
>The turns an O(n) problem into a slow O(n*n) solution. Much better to
>
On 12/10/2012 5:59 PM, John Gordon wrote:
def encode(plain):
'''Return a substituted version of the plain text.'''
encoded = ''
for ch in plain:
encoded += key[alpha.index(ch)]
return encoded
The turns an O(n) problem into a slow O(n*n) solution. Much better to
build a
On 10/12/12 22:38, qbai...@ihets.org wrote:
I need help with a program i am doing. it is a cryptography program. i am given
a regular alphabet and a key. i need to use the user input and use the regular
alphabet and use the corresponding letter in the key and that becomes the new
letter. i hav
On Tue, Dec 11, 2012 at 9:38 AM, wrote:
> I need help with a program i am doing. it is a cryptography program. i am
> given a regular alphabet and a key. i need to use the user input and use the
> regular alphabet and use the corresponding letter in the key and that becomes
> the new letter. i
2012/12/10 :
> I need help with a program i am doing. it is a cryptography program. i am
> given a regular alphabet and a key. i need to use the user input and use the
> regular alphabet and use the corresponding letter in the key and that becomes
> the new letter. i have the basic code but nee
In qbai...@ihets.org
writes:
> """ crypto.py
> Implements a simple substitution cypher
> """
> alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
> key = "XPMGTDHLYONZBWEARKJUFSCIQV"
> def main():
> keepGoing = True
> while keepGoing:
> response = menu()
> if response == "1":
> plain
"gerardob" wrote in message
news:29276755.p...@talk.nabble.com...
I am trying to read an xml using minidom from python library xml.dom
This is the xml file:
-
AB
100
2
--
This is the python code:
On 2010-07-27, gerardob wrote:
>
> I am trying to read an xml using minidom from python library xml.dom
>
> This is the xml file:
> -
>
>
>
> AB
> 100
>
> 2
>
>
snip...
>
>for counter, line in enumerate(fileIN):
>newline = line.replace(oldstring, newstring)
>if newline != line:
>print 'match at line', counter+1
>fileOUT.write(newline)
"enumerate" - haven't seen that before. Nice!
Thanks
--
http://mail.python.org/m
goldtech <[EMAIL PROTECTED]> wrote:
> Question1: The replace method - If a string does not have the target
> replacement "newstring", then newline equals oldstring? Ie. oldstring
> is not changed in any way? Seems to be what I observe but just want to
> confirm this.
Yes.
>
> Question2: I'm us
[EMAIL PROTECTED] writes:
> On 4 Apr, 21:47, Alexander Schmolck <[EMAIL PROTECTED]> wrote:
> > [EMAIL PROTECTED] writes:
> > > Thank you very much, your code works perfectly!
> >
> > One thing I forgot: you might want to make the whitespace handling a bit
> > more
> > robust/general e.g. by using
On 4 Apr, 21:47, Alexander Schmolck <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] writes:
> > Thank you very much, your code works perfectly!
>
> One thing I forgot: you might want to make the whitespace handling a bit more
> robust/general e.g. by using something along the lines of
>
> set_phra
[EMAIL PROTECTED] writes:
> Thank you very much, your code works perfectly!
One thing I forgot: you might want to make the whitespace handling a bit more
robust/general e.g. by using something along the lines of
set_phrase.replace(' ', r'\w+')
'as
--
http://mail.python.org/mailman/listinfo/p
On 4 Apr, 17:39, Alexander Schmolck <[EMAIL PROTECTED]> wrote:
> All the code is untested, but should give you the idea.
>
>
>
>
>
> [EMAIL PROTECTED] writes:
> > Hi all!
>
> > I have a file in which there are some expressions such as "kindest
> > regard" and "yours sincerely". I must create a phyt
Alexander Schmolck <[EMAIL PROTECTED]> writes:
> That doesn't work. What about "kindest\nregard"? I think you're best of
> reading the whole file in (don't forget to close the files, BTW).
I should have written "that may not always work, depending of whether the set
phrases you're interested in c
All the code is untested, but should give you the idea.
[EMAIL PROTECTED] writes:
> Hi all!
>
> I have a file in which there are some expressions such as "kindest
> regard" and "yours sincerely". I must create a phyton script that
> checks if a text contains one or more of these expressions an
"Richard Schneiderman" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I really enjoyed your article. I will try to understand this.
> Will you be doing more of this in the future with more complicated
examples?
>
I'm giving two presentations at PyCon at the end of February, so I thin
I really enjoyed your article. I will try to understand this.
Will you be doing more of this in the future with more complicated examples?
Paul McGuire wrote:
> "Dave" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> OK, I'm stumped.
>>
>> I'm trying to find newline characters (
"Dave" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> OK, I'm stumped.
>
> I'm trying to find newline characters (\n, specifically) that are NOT
> in comments.
>
> So, for example (where "<-" = a newline character):
> ==
> 1: <-
> 2: /*<-
> 3:
This is great, thanks!
--
http://mail.python.org/mailman/listinfo/python-list
Dave wrote:
> OK, I'm stumped.
>
> I'm trying to find newline characters (\n, specifically) that are NOT
> in comments.
>
> So, for example (where "<-" = a newline character):
> ==
> 1: <-
> 2: /*<-
> 3: --<-
> 4: comment<-
> 5:
Hi,
> for punctuation in punctuations:
> line=line.replace(punctuation,'')
I would use maketrans or even a regex instead. However, If you care
about speed, it is well known that in some cases regex take more
time than multiple replaces. Even the maketrans could take more time
(I don't
On 13 Jul 2005 07:49:02 -0700, Michael Jordan <[EMAIL PROTECTED]> wrote:
> hey, i have this huge text file and i need to go through and remove all
> punctuation and every instance of the phrase "fruitloops=$" where $ is
> any number 0-100" um, and yeah this is homework but i've tried to no
> avail
Use .replace function to replace punctuation (you didn't say
exactly what that means but just to get you started):
#
# Extend this list as needed
#
punctuations=',.;:()'
#
# Open input and output files
#
ifp=open(inputfilename,'r')
ofp=open(outputfilename,'w')
#
# Strip out the punctuation charact
"vincent wehren" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> "Nicholas Graham"
> | Any suggestions?
> Take a look at the built-in functions ord() and chr()
> -- Chapter 2.1 of the manual.
And more generally, read all of Chap.2 of the Library Reference on builtin
functions an
"Nicholas Graham" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
|
| I'm writing a program that requires some string manipulations. Let's say
| I have a string
|
| s='x'
|
| Now, the ascii code for 'x' is 0x78. I want to be able to perform
| operations on this number, and prin
28 matches
Mail list logo