On 3/16/2015 5:04 PM, Alan Gauld wrote:
On 16/03/15 20:39, Doug Basberg wrote:
I would like to pass the contents of a dictionary from one program to
another through a file. So, what is the elegant way to pass a
dictionary by
file?
The elegant way may be not to use a file.
A Python diction
On 3/9/2015 9:50 AM, Alan Gauld wrote:
Somebody posted a question asking how to fond out if a file
exists. The message was in the queue and I thought I'd approved
it but it hasn't shown up yet. Sorry to the OP if I've messed up.
The answer is that you use the os.path.exists() function.
It take
Thanks for the Shameless Plug, Alan.
I went to Amazon, scanned through your book, and learned some things
about "sets" that will help me in my job.
Bought the Kindle version. Great stuff.
On 1/15/2015 8:53 AM, Alan Gauld wrote:
On 15/01/15 14:07, dw wrote:
I would like to find a source,
Twelve years ago, I started with "The Quick Python Book". Harms and
McDonald. Manning Pub.
I learned a lot in a hurry.
I still use it for reference once in a while to refresh my memory.
On 1/6/2015 1:46 PM, Stephen Nelson-Smith wrote:
Hello,
My son is interested in programming, and has da
A dictionary would work well here. Read each element of the lists into
the dictionary using the integer as the key with a list of strings as
the values.
{1: ['A', 'AA'], 2: ['B'], 3: ['C', 'CC'], 4: ['D', 'DD']}
Then output the contents in the required format.
This may take more lines of code t
I seldom hear anyone mention "The Quick Python Book" by Daryl Harms and
Kenneth McDonald (Manning). It was the book I found most useful when I
started programming Python. I still keep it nearby and refer to it
occasionally as a familiar memory refresher, even though I have been
writing Python cod
I love this [Tutor] list. There are always new tricks that change the
way I write code. And it makes me like Python more every day.
I keep a script file with "notes" on the things I learn here and I refer
to these notes frequently. Here are the notes I made for this thread:
""" iterate/map/modu
Very nice trick. Thanks.
P.S. You can still use:
s = raw_input(question).lower()[:1]
if s == ...:
-Original Message-
From: Danny Yoo [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 06, 2007 5:53 PM
To: David Heiser
Cc: tutor@python.org
Subject: Re: [Tutor] Engarde
What if the user enters "maybe".
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of Alan Gauld
Sent: Thursday, June 07, 2007 1:45 AM
To: tutor@python.org
Subject: Re: [Tutor] Engarde program was: i++
"David Heiser" <[EMAIL PROT
or..
def is_yes(question):
while True:
try:
s = raw_input(question).lower()[0]
if s == 'y':
return True
elif s == 'n':
return False
except:
pass ## This traps the condition where a user
Or you can try something like:
x = r"C:\My\Doc\;D:\backup"
x = x.replace("\\", ";")
x = x.split(";")
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Kent Johnson
Sent: Saturday, March 31, 2007 9:42 PM
To: Andrei Petre
Cc: tutor@python.org
Subject: Re: [
May I invite EVERYONE to NOT introduce political or religious elements
into these discussions. It has no place here and can destroy this
excellent discussion group. I've seen it happen.
PLEASE take it elsewhere.
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Beh
Here is a snippet of code that may work for you:
#---
import telnetlib
HOST = "myServer"
Username = "bob"
Password = "fido"
LoginList = ['=login:', '%s=password:' % (Username), '%s=$' %
(Password)] ## Like an Expect script
Terminator = "$"
print "CONNECTING:"
T
Title: Message
I have
code that uses variables to hold escaped characters like "\n" or "\03". As long
as the assignment is done within the code, like self.crChar = "\n", there is no
problem. But When I try to read the same character string from a text file
and assign it, the string is seen
You can make it simpler by not splitting the input file into lines.
Treat it as a single string.
in_put = open('test.html', 'r').read()
replace_words = ['TWY', 'RWY', 'WIP']
for replace_word in replace_words:
in_put = in_put.replace(replace_word, "" + replace_word + "")
Title: Message
Chris,
This looks similar to what I do for my job. I
would be happy to help you, if I
can.
My first question is, how would you like the output
to look? Can you manually create a model of the email text you want to
send?
My second question is, can you create the
email
That worked just dandy. Thanks.
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Kent Johnson
Sent: Thursday, June 22, 2006 1:03 PM
Cc: tutor@python.org
Subject: Re: [Tutor] Escape sequences
David Heiser wrote:
> I have code that assigns esc
x27;resetString']".
Simple ASCII strings work fine, but the escape sequences don't work and
the code fails. "print self.resetString" returns "\\03", instead of a
nonprintable character.
Any ideas?
David Heiser
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Here's a simple Python script that will do it. It's not very
sophisticated, but it's easy to modify for special cases.
import os, string
def Find(TargetString, DIR, Names):
for Name in Names:
if Name != "Search.py":
try:
TargetFile = DIR + "/" + Name
Is this what you're asking for?
# Scaler.py
#
def scale(OldList, NewMin, NewMax):
NewRange = float(NewMax - NewMin)
OldMin = min(x)
OldMax = max(x)
OldRange = float(OldMax - OldMin)
ScaleFactor = NewRange / OldRange
print '\nEquasion: NewValue = ((OldValue - ' + str(Old
Here's one approach to the problem (using bogus codon values).
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of sjw28
Sent: Monday, March 06, 2006 8:37 AM
To: tutor@python.org
Subject: [Tutor] Analysing genetic code (DNA) using python
I have many note
I believe you can submit the new config content as a blob where blob =
string.join(lines). It looks like your "switch" uses IOS, not CatOS, so
make sure you send "config t" first.
And I would strip out the \r's.
Then maybe:
tn.write("\03") # Assures the device
Title: Message
The
following works with the Cisco switch that I have available. Cisco 4006
with CatOS 6.2. It may not work with your model/OS or your switch may be
configured differently. For instance, the default prompt terminates with
"(enable)" so I used "tn.read_until(')')" instead of
23 matches
Mail list logo