[Tutor] Match on current line and next line. Possible?

2005-02-08 Thread Tom Tucker
Hello! How can I instruct Python to match on the current line and the next line? Assumptions; - We are reading in one line at a time BROKEN EXAMPLE (discussion) ## file = open('/somefile','r').readlines() for line in file: match_one = re.search('^Python', line)

[Tutor] Does Python have anything like Perls format output?

2005-04-23 Thread Tom Tucker
Good evening! Does Python have a print function similar to Perl format output (example below)? Thanks Tom format STDOUT = @< @ @<<< [EMAIL PROTECTED] [EMAIL PROTECTED] $code, $date,$descript,$amt, $balance ___

[Tutor] Is it possible to load variable into a regex string?

2005-04-27 Thread Tom Tucker
Hello all! I am trying to pass a variable to my re.compile string (see broken example below). Is something like this possible? Thanks! regexstring = 'H\sb' textstring = 'BLAH blah' match = re.compile((%s) % (regexstring)) # ? if match.search(line): print "I found it!" Tom ___

[Tutor] Python sort with a delimiter

2005-05-11 Thread Tom Tucker
Good morning! Does Python have a sort function thats supports a delimiter? For example, I want to sort the below hostnames, based on the city. Thanks! Tom Hostnames to be sorted - sys01-xxx-austin-tx sys02-xxx-austin-tx sys01-yyy-austin-tx sys01-xxx-newa

Re: [Tutor] Python sort with a delimiter

2005-05-11 Thread Tom Tucker
Interesting! Thank you! On 5/11/05, Kent Johnson <[EMAIL PROTECTED]> wrote: > Tom Tucker wrote: > > Good morning! Does Python have a sort function thats supports a delimiter? > > For example, I want to sort the below hostnames, based on the city. > > This is easy t

[Tutor] Pickling in plain English

2005-05-24 Thread Tom Tucker
I am having trouble understanding the c|Pickle modules. What does serializing and de-serializing objects mean? I have read the below urls and I "think" I understand the process, but I can't visualize the beneifts. Can someone kindly explain pickling in lamens terms? Thanks, Tom http://effbot

Re: [Tutor] Pickling in plain English

2005-05-24 Thread Tom Tucker
here to those of us who need it, thank > you so very much. > > Tom Cloyd > > On Tue, 24 May 2005 16:32:50 -0700, <[EMAIL PROTECTED]> wrote: > > > Quoting Tom Tucker <[EMAIL PROTECTED]>: > > > >> I am having trouble understanding the c|Pickle modul

[Tutor] Covert numbers to hex fails

2005-05-24 Thread Tom Tucker
Good evening! I am trying to pass a number variable and have it converted to hex. Any recommendations on how to achieve this? Thank you. FAILS -- >>> value = 1234567890 >>> hexoutput = hex('%d' % (value)) Traceback (most recent call last): File "", line 1, in ? TypeError: hex() argume

Re: [Tutor] Covert numbers to hex fails

2005-05-24 Thread Tom Tucker
Thanks!I see the mistake. On 5/24/05, Tony Meyer <[EMAIL PROTECTED]> wrote: > > FAILS > > -- > > >>> value = 1234567890 > > >>> hexoutput = hex('%d' % (value)) > > Traceback (most recent call last): > > File "", line 1, in ? > > TypeError: hex() argument can't be converted to hex >

Re: [Tutor] Covert numbers to hex fails

2005-05-25 Thread Tom Tucker
Alan, Thanks! Your response was helpful. I was trying to pass a number variable to the hex object. The output associated with this would be referenced in the hexoutput variable. I guess this is as simple as hexoutput = "%X" % (value) Thanks again for the help, Tom On 5/25/05, Alan G <[E

Re: [Tutor] Multiple lines with the command line

2007-04-16 Thread Tom Tucker
Have you tried the "email" module? http://docs.python.org/lib/module-email.html On 4/16/07, Kharbush, Alex [ITCSV] <[EMAIL PROTECTED]> wrote: I want to use the UNIX Mail program with python I need multiple entries with the os.system(cmd)line I will need something like this #output to uni

Re: [Tutor] Multiple lines with the command line

2007-04-16 Thread Tom Tucker
of', 'my', 'message'] #!/usr/bin/env python import sys message = sys.argv[1:] # save message variable to a file # execute mail command < file On 4/16/07, Tom Tucker < [EMAIL PROTECTED]> wrote: Have you tried the "email" module? http://docs.python.or

Re: [Tutor] version and path

2007-05-14 Thread Tom Tucker
I would use the traditional Unix find command to find the various versions installed. find / -name "python*" On 5/14/07, linda.s <[EMAIL PROTECTED]> wrote: > how to check how many versions of Python i have in my mac machine? > also, how to put the path to the version I desire? > Thanks a lot! >

Re: [Tutor] Web

2007-05-14 Thread Tom Tucker
Jeff, Can you clarify what you are looking to do. You have a small program that you want to distribute via Internet (allow users to view, download, etc)? You want to use Python to create a website? Integrate your program into a web page (modpython for example). On 5/14/07, Jeff Molinari <[EMAIL

Re: [Tutor] version and path

2007-05-14 Thread Tom Tucker
Does this help? On 5/14/07, linda. s <[EMAIL PROTECTED]> wrote: > On 5/14/07, Tom Tucker <[EMAIL PROTECTED]> wrote: > > I would use the traditional Unix find command to find the various > > versions installed. > > > > find / -name "python*"

Re: [Tutor] (no subject)

2007-05-18 Thread Tom Tucker
Very cool! Where is Inky, Blinky, Pinky, and Clyde? ;-) Maybe dog catchers would be better foes for Dusty. On 5/18/07, Teresa Stanton <[EMAIL PROTECTED]> wrote: Hi all: Remember when I was having problems moving my .gif around my Tkinter maze? Well, I was going about it all wrong (as some poi

[Tutor] Continue Matching after First Match

2007-05-18 Thread Tom Tucker
person objectClass: posixAccount objectClass: shadowAccount objectClass: inetorgperson objectClass: organizationalPerson loginShell: /usr/bin/ksh homeDirectory: /home/jtucker dn: uid=ttucker,ou=people,dc=companyA,dc=com loginShell: /usr/bin/zsh host: hostZ host: hostC uid: ttucker cn: Tom Tucker sn: Tu

Re: [Tutor] Continue Matching after First Match

2007-05-18 Thread Tom Tucker
Disregard! Looks like part of my problem is the regex string. On 5/18/07, Tom Tucker <[EMAIL PROTECTED]> wrote: Please forgive the colors, just trying to help illustrate my question. The below code snipet works as designed, however the regex matches once and exits. I want it to co

Re: [Tutor] Continue Matching after First Match

2007-05-21 Thread Tom Tucker
rtin Walsh <[EMAIL PROTECTED]> wrote: Hi Tom, Tom Tucker wrote: > Why the cStringIO stuff? The input data shown below is collected from > os.popen. I was trying to find an easy way of matching my regex. Ah, ldap... Oh yes, Matching with a string seemed easier than looping t

Re: [Tutor] string replacement

2007-05-21 Thread Tom Tucker
One way is... CODE #!/usr/bin/python handle = file("test.txt",'a') number = 1 for num in range(1,5): handle.write("TestingSome%s\n" % (number)) handle.write("something%s-test\n" % (number)) number += 1 handle.close() OUTPUT TestingSome1 something1-

Re: [Tutor] leave tutorial

2007-05-30 Thread Tom Tucker
http://mail.python.org/mailman/listinfo/tutor On 5/30/07, Kriti Satija <[EMAIL PROTECTED]> wrote: i want to leave the tutorial Looking for people who are YOUR TYPE? Find them at in.groups.yahoo.com ___ Tutor maillist - Tutor@python.org http

Re: [Tutor] how can I compare a local directory or file with a remote one

2007-06-20 Thread Tom Tucker
What are we comparing? Size of files, number of files in a directory, md5sum of the files, directory size, etc? What about rsync? You can use rsync to compare directories between a source and destiantion system and just report differences. For example, comparing /etc directores between two RHEL

Re: [Tutor] Regular Expression help

2007-06-27 Thread Tom Tucker
I think I have a solution. File (0012,0042) Clinical Trial Subject Reading ID LO 1 (0012,0050) Clinical Trial Time Point ID LO 1 (0012,0051) Clinical Trial Time Point Description ST 1 (0012,0060) Clinical Trial Coordinating Center Name LO 1 (0018,0010) Contrast/Bolus

Re: [Tutor] how do I input " as part of a string?

2007-07-13 Thread Tom Tucker
Try escaping the quotes. f = open("data.ini","w") f.write("my \"car\" has been a great one for me") f.close() ~ >cat data.ini my "car" has been a great one for me On 7/13/07, elis aeris <[EMAIL PROTECTED]> wrote: also, why does the interpreter restart when I run this? f = open("data.ini"

Re: [Tutor] automate daily tasks

2007-09-11 Thread Tom Tucker
Are you looking for a method to automate the execution of your Python program? Is that the question? If yes, have you tried using cron or at jobs (man cron or man at). Tom On 9/11/07, chinni <[EMAIL PROTECTED]> wrote: > > Hi all, > > I am working on MAC OS x my project is updating all ready insta

Re: [Tutor] Tutor Digest, Vol 43, Issue 36

2007-09-12 Thread Tom Tucker
d degrade the version and save it and > > run > > updates manually..so,that can any one plz..tell me how to start from > > first > > step... > > > > -- > > Best Regards, > > M.Srikanth Kumar, > > -- next part ------ > >

Re: [Tutor] how to add arguments to a command line program

2007-09-14 Thread Tom Tucker
See optparse or sys.argv. On 9/14/07, shawn bright <[EMAIL PROTECTED]> wrote: > > lo there all, > > i want to write a program that will be called from another program. > I need to pass it one variable. > i s

Re: [Tutor] how to match regular expression from right to left

2007-09-16 Thread Tom Tucker
Yep, looks like it. >>> line = 'us::blah blah2 1002 blah3' >>> import re >>> TAG_pattern = re.compile(r"(us::.*) .*(1002|1003).*$") >>> if TAG_pattern.search(line): ... print 'we have a match' ... we have a match >>> >>> line2 ='us::blah blah2 1001 blah3' >>> if TAG_pattern.search(line2): ...

Re: [Tutor] data type conversion for print statement

2007-09-25 Thread Tom Tucker
Excerpt from an email Danny Yoo sent to me and the list in 2005. I had the same question. ;-) Hi Tom, The 'print' statement is hardcoded to add a space between elements. print is meant to make output easy, at the cost of control. If we need more fine-grained control over output, we may want t

Re: [Tutor] killing bash, sshd... dangerous?

2007-10-28 Thread Tom Tucker
Instead of reading in an outputfile (.ps), try reading from command output. The correct terminology escapes me (for file in os.popen(cmd).readlines():). Are you looking for a auto logout method? For example if no activity after X minutes kill the shell. Bash and a few other shells have this func

[Tutor] Where did those spaces come from?

2005-09-12 Thread Tom Tucker
Tutor, Good evening!    The goal is to parse a simple file and grab column one.  Then print each value horizontally separated by a comma. Why is Python adding a space padding between each value?   Please see below. Thanks ahead of time. INPUT_FILE # unwanted lines removed ##

[Tutor] stfftime question

2006-07-04 Thread Tom Tucker
Below is an example of me converting a datetime to milliseconds on a Mac running Pythong 2.3.5. The same working code on a Solaris system with Python 2.3.2 fails. Any thoughts? What arguments am I missing? >From my Mac # Python 2.3.5 (#1, Oct 5 2005, 11:07:27) [GCC 3.3 20030304 (A

Re: [Tutor] stfftime question

2006-07-04 Thread Tom Tucker
= time.mktime(t1.timetuple())+(t1.microsecond/1000.) t2tuple = time.mktime(t2.timetuple())+(t2.microsecond/1000.) delta = (t2tuple - t1tuple) * 1000 print delta On 7/4/06, Tom Tucker <[EMAIL PROTECTED]> wrote: > Below is an example of me converting a datetime to milliseconds on a > Mac run

[Tutor] Matching on multiple log lines

2006-10-28 Thread Tom Tucker
I would appreciate any recommendations or assistance on how to read and parse this log. The log is constantly growing and has the potential of being large. For this reason, we are reading in line by line. How do I match on multiple lines, while reading a log line by line. Hopefully the logic e

Re: [Tutor] rsync python script

2008-03-21 Thread Tom Tucker
The success or failure could be confirmed by checking the exit status and/or confirming host77 has the same /var/lib file structure as the source host. The later is the most accurate, however a bit more complicated to confirm. As for determining the reason for failure, possible causes off the top o

Re: [Tutor] int to string

2008-03-21 Thread Tom Tucker
>>> y = 3 >>> type(y) >>> x = str(y) >>> type(x) On Fri, Mar 21, 2008 at 8:05 PM, elis aeris <[EMAIL PROTECTED]> wrote: > how do I convert int to string? > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor >

Re: [Tutor] append string

2008-03-21 Thread Tom Tucker
Strings are immutable, you can't append to them. How about this >>> mystring = 'Elis' >>> mystring.append('Aeris') Traceback (most recent call last): File "", line 1, in AttributeError: 'str' object has no attribute 'append' >>> mystring + ' Aeris' 'Elis Aeris' >>> x = mystring + ' Aeri

[Tutor] Library for Disk Usage (UNIX)

2008-03-26 Thread Tom Tucker
Hello all. I'm looking for a builtin Python library capable of providing similar output to what the unix df command provides. Obviously, I'm trying to avoid a system call if possible. I'm looking for the following fields at a mimimum, total size, used, and /path. Suggestions? I was looking at os

Re: [Tutor] Supported platform

2008-05-21 Thread Tom Tucker
I would check the docs on the www.python.org website. >From the main page "Python runs on Windows, Linux/Unix, Mac OS X, OS/2, Amiga, Palm Handhelds, and Nokia mobile phones. Python has also been ported to the Java and .NET virtual machines." On Wed, May 21, 2008 at 2:11 PM, Amit Kumar <[E

[Tutor] Init Script (RHEL 5 Linux)

2011-03-07 Thread Tom Tucker
Hello. I am trying implement a *one time* execution of an init script. Any recommendation on how to fork or detach this script from the normal init 3 execution process so that it doesn't hold up other activities? Thanks Here is the high level logic. 1. Execute script 1. perform these

Re: [Tutor] Mac IDE

2011-09-29 Thread Tom Tucker
Another IDE to consider that supports the MAC OS is PyCharm from JetBrains. On Thu, Sep 29, 2011 at 7:50 AM, Wayne Werner wrote: > On Thu, Sep 29, 2011 at 5:50 AM, Walter Prins wrote: > >> On 29 September 2011 10:42, Robert Johansson < >> robert.johans...@math.umu.se> wrote: >> >>> Hi, >>> >

Re: [Tutor] python telnet

2011-10-22 Thread Tom Tucker
Take a look at pyexpect. I have used this mod to ssh into juniper firewalls, excute a command, save results and exit. Instead of exiting you can drop down to interactive mode. On Oct 22, 2011 3:40 PM, "Rayon" wrote: > ** ** > > ** ** > > ** ** > > *From:* Rayon [mailto:ra...@gtt.co.gy] > *Sent:*

[Tutor] Iterate Suggestion

2012-04-14 Thread Tom Tucker
Hello all. Any suggestions how I could easily iterate over a list and print the output 3 across (when possible)? One method I was considering was removing the recently printed item from the list, checking list length, etc. Based on the remaining length of the list I would then print X across. Ya

Re: [Tutor] Iterate Suggestion

2012-04-14 Thread Tom Tucker
All, Thanks for the help. On Sat, Apr 14, 2012 at 1:33 PM, Bod Soutar wrote: > > > On 14 April 2012 18:29, Bod Soutar wrote: > >> >> >> On 14 April 2012 16:27, Tom Tucker wrote: >> >>> >>> Hello all. Any suggestions how I could easily

Re: [Tutor] ssh connection

2012-12-17 Thread Tom Tucker
One option is PyExpect http://www.noah.org/python/pexpect/ On Mon, Dec 17, 2012 at 8:40 AM, Ufuk Eskici wrote: > Hello All, > > Can we make an SSH connection with Pyhton 3.3 ? > > I want to connecto to my router, send commands and receive outputs. > > Thanks. > Ufuk > > __

[Tutor] For Loop Question

2012-12-23 Thread Tom Tucker
Python Gurus, I got a question for ya. Below I have three instance variables (self.A, self.B, etc). How can I use the below for loop for A, B, C to also call those instance variables? Example ### . . self.A = 1 self.B= 2 self.C= 3 myDict = {'A': 1, 'B':