[Tutor] Guidance on jump-starting to learn Python

2008-07-17 Thread Steve Poe
I have the challenge / opportunity to learn Python quickly. I
am technically-minded, but I am not a programmer. When I have
tried / used Python before (I've written 5-6 python programs/utilities),
it has been solving a particular issue but not learning the proper
structure/procedures
to learn Python (nor any other programming language).
I humbly admit I have cut corners, so I have bad habits. I have been advised
to start with
the basics but at an accelerated pace.

Any recommended "homework" assignments?

I have two books as well:
Core Python Programming from Wesley Chun , Second Edition.
Python Programming for the Absolute Beginner, Second Edition.

Thanks so much for your advice/help in advance.

Steve
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Online class/education for Python?

2008-07-19 Thread Steve Poe
Anyone taken or know of any online classes
teaching Python? I know O'Reilly Press
teaches online technical courses, through the University of
Illinois, but no Python
.

Thanks.

Steve
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Online class/education for Python?

2008-07-20 Thread Steve Poe
Joe,

It's an online class without a specific time. The class runs for six weeks
with two assignments
per week.

Steve

On Sun, Jul 20, 2008 at 3:51 PM, Joe Bennett <[EMAIL PROTECTED]> wrote:

> What time where the classes? Web site seems to be missing that info...
>
>
> -Joe
>
>
>
> On Sun, Jul 20, 2008 at 1:08 AM, Dick Moores <[EMAIL PROTECTED]> wrote:
> > At 02:45 PM 7/19/2008, David wrote:
> >>
> >> Steve Poe wrote:
> >>>
> >>> Anyone taken or know of any online classes
> >>> teaching Python? I know O'Reilly Press
> >>> teaches online technical courses, through the University of
> >>> Illinois, but no Python
> >>> .
> >>>
> >>> Thanks.
> >>>
> >>> Steve
> >>>
> 
> >>>
> >>> ___
> >>> Tutor maillist  -  Tutor@python.org
> >>> http://mail.python.org/mailman/listinfo/tutor
> >>>
> >> I  am new to Python so this one was pretty good for me;
> >>
> >>
> http://www.ed2go.com/cgi-bin/ed2go/newcrsdes.cgi?course=ipy&title=Introduction
> ^to^Python^2.5^Programming&departmentnum=WP&path=1
> >
> > This does look good. I'm thinking about the $129.
> >
> > 1. Is there a problem set for each lesson? Are they corrected or
> commented
> > on?
> > 2. How do you ask for help from the instructor? By email? In a forum? Was
> he
> > helpful?
> >
> > Thanks,
> >
> > Dick Moores
> >
> ===
> > Have you seen Kelie Feng's video introducing the terrific and free IDE,
> > Ulipad? Download it from my website.
> > <http://www.rcblue.com/u3/> Get Ulipad 3.9 from
> > <http://code.google.com/p/ulipad/downloads/list>
> > Use svn for the latest revision <http://ulipad.googlecode.com/svn/trunk/
> >
> > Mailing list for Ulipad: <http://groups-beta.google.com/group/ulipad>
> > ___
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] understanding join

2008-07-30 Thread Steve Poe

Hi tutor list,

Just trying to add some clarity to the built-in function strings using  
join. The Python help
screen says it returns a string which is a concatenation of strings in  
sequence. I am concatenating

the string I am working on that maybe an issue of its own.

Here's my example:

string ='ab'

so, if I type:

print  string.join(string)

aabb

but if string is 'abc'

print string.join(string)
aabcbabcc


print string ='a' returns on a in this example, whit string='a '  
returns aa. So, I am not catching

the pattern.

Thanks.

Steve



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] checking for expected types from input file

2008-07-30 Thread Steve Poe

Bryan,

How about checking your input to see if they are digits or not?
>>> input_data = '123ABC'
>>> print input_data.isdigit()
False
>>> input_data = '1234567889'
>>> print input_data.isdigit()
True
>>> input_data = '123ABC'
>>> print input_data.isdigit()
False

or something like:

while INPUT.has_key('ReferencePositionX').isdigit() =='True':

refx = float(INPUT['ReferencePositionX'])/10
refy = float(INPUT['ReferencePositionY'])/10
refz = float(INPUT['ReferencePositionZ'])/10




Steve

On Jul 30, 2008, at 6:43 PM, Bryan Fodness wrote:

I am populating a dictionary from an input file, and would like to  
create an error code if a string is sent to a variable that expects  
a float or int.


INPUT = {}
for line in open(infile):
input_line = line.split(' = ')
INPUT[input_line[0].strip()] = input_line[1].strip()

if INPUT.has_key('ReferencePositionX'):
refx = float(INPUT['ReferencePositionX'])/10
refy = float(INPUT['ReferencePositionY'])/10
refz = float(INPUT['ReferencePositionZ'])/10

I have many variables of different types, and I want to do a check  
in case something like ReferencePositionX = abc occurs.


--
"The game of science can accurately be described as a never-ending  
insult to human intelligence." - João Magueijo

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] understanding join

2008-07-30 Thread Steve Poe

Does this look useful?

In [3]: people = [ 'Tom', 'Dick', 'Harry' ]

In [4]: ', '.join(people)
Out[4]: 'Tom, Dick, Harry'

Your confusion is in thinking about the string 'ABC' as a single
entity. For the purposes of join(), it is a sequence of three letters.
The argument to join() is a sequence of strings, not a single string.

Kent



Kent,

Your explanation about my confusion is right on target.  Thank you!

Okay, now let's join people to people and what do we get?

Steve




___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] understanding join

2008-07-30 Thread Steve Poe


Say I have a sequence seq and a string s, and I call s.join(seq).
Here's what it does:

s.join(seq) == seq[0] + s + seq[1] + s + seq[2] + s + ...  + seq[-2] +
s + seq[-1]

So if you call 'abc'.join('ABC'), you get:

  'ABC'[0] + 'abc' + 'ABC'[1] + 'abc' + 'ABC'[2]

which is:

  'A' + 'abc' + 'B' + 'abc' + 'C'

Hope this helps.

--
John.



John,

Your explanation is very help. It does make be wonder the usefulness
of join with strings. Do you have a practical example/situation?

Steve
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] key/value order in dictionaries

2008-07-30 Thread Steve Poe

Hi tutor list,

In dictionaries, I know that the keys are immutable, and the values
can change  What about the place/order of the key/order?  I thought
that they were sequential and they do not change.


>>> D={"AAA":1234,"BBB":3456,"CCC":7890}
>>> print D
{'AAA': 1234, 'BBB': 3456, 'CCC': 7890}
>>> D={}
>>> D={"AAA":1234,"BBB":3456,"CCC":7890,"DDD":,"EEE":,"FFF": 
}

>>> print D
{'AAA': 1234, 'BBB': 3456, 'EEE': , 'FFF': , 'CCC': 7890,  
'DDD': }


If I know the key, then I can find the value, so the order it is in  
the dictionary
should not matter. I am just curious  why this happens.  If I have (4)  
key/value
pairs, the display order is the same as I entered the them. With 5 or  
more key/value

dictionaries, the printed result is not sequential.

Any thoughts?

Steve
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Scan Directory for files

2008-08-02 Thread Steve Poe

Fred,

What is/are the exact error message(s)?

You may want to look at the module glob.

Steve



Ar e you typing this in the python interpreter or
On Aug 1, 2008, at 10:41 PM, Fred @ Mac wrote:


Hello,

new to python, so please go easy on me!

I am using

for f in os.listdir(watch_dir):
   tree = ET.parse(f)
   for shot in tree.findall('Shot'):
..do stuff..

to scan a directory for specific files (xml files specifically).

But my script fails if, for example, a directory also exists in  
"watch_dir"


How can i restructure this so it only returns a list of the .xml  
files in that directory, ignores other files and or directories in  
"watch_dir"


Thanks!

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pexpect

2008-09-20 Thread Steve Poe

James,

I've not used pexpect, but I've done  this on a Cisco switch. I found  
using

time.sleep and read_until of the telnet class to be helpful.

10  tn = telnetlib.Telnet('')
 11 #tn.set_debuglevel(9)
 12 tn.read_until('Username: \xff', 5)
 13 time.sleep(10)
 14 tn.write('\n')
 15 tn.read_until('\r\nPassword: ', 5)
 16 #time.sleep(2)
 17 tn.write('\n')
 18 tn.read_until('#', 5)
 19 tn.write('term len 0 \n')
 20 tn.read_until('#', 5)
 21 tn.write('show version |  i restarted\n')
 22 RouterStartupTimestamp = tn.read_until('#', 2)
 23 tn.read_until('#', 2)
 24 tn.write('show call history voice last 100\n')


HTH,

Steve

On Sep 20, 2008, at 8:43 AM, James wrote:


Folks,

Does anyone here have experience with pexpect? I'm trying to write a
pexpect script which will log into a network device, gather
statistics, and then dump the raw output into a file (or a string so
that I can manipulate it).

I'm not having much luck. Because the connection is telnet I was able
to use wireshark (a sniffer) to see the traffic between my computer
(which is running the pexpect script) and the network device.
Everything seems to go find until I "expect" the network device's
prompt and it just hangs. Eventually pexpect throws an exception and
times out.

I'd be happy to share some code when I get to the computer I've been
testing on. :) In the time being, has anyone seen a problem like this
before?

Thanks!
-j
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor