[Tutor] os.is_file and os.is_dir missing from CPython 3.8.0b?

2019-06-14 Thread Tom Hale
#x27;O_NOATIME', 'EX_OK', 'EX_USAGE', 'EX_DATAERR', 'EX_NOINPUT', 
'EX_NOUSER', 'EX_NOHOST', 'EX_UNAVAILABLE', 'EX_SOFTWARE', 'EX_OSERR', 
'EX_OSFILE', 'EX_CANTCREAT', 'EX_IOERR', 'EX_TEMPFAIL', 'EX_PROTOCOL', 
'EX_NOPERM', 'EX_CONFIG', 'ST_RDONLY', 'ST_NOSUID', 'ST_NODEV', 
'ST_NOEXEC', 'ST_SYNCHRONOUS', 'ST_MANDLOCK', 'ST_WRITE', 'ST_APPEND', 
'ST_NOATIME', 'ST_NODIRATIME', 'ST_RELATIME', 'POSIX_FADV_NORMAL', 
'POSIX_FADV_SEQUENTIAL', 'POSIX_FADV_RANDOM', 'POSIX_FADV_NOREUSE', 
'POSIX_FADV_WILLNEED', 'POSIX_FADV_DONTNEED', 'P_PID', 'P_PGID', 
'P_ALL', 'WEXITED', 'WNOWAIT', 'WSTOPPED', 'CLD_EXITED', 'CLD_DUMPED', 
'CLD_TRAPPED', 'CLD_CONTINUED', 'F_LOCK', 'F_TLOCK', 'F_ULOCK', 
'F_TEST', 'RWF_DSYNC', 'RWF_HIPRI', 'RWF_SYNC', 'RWF_NOWAIT', 
'POSIX_SPAWN_OPEN', 'POSIX_SPAWN_CLOSE', 'POSIX_SPAWN_DUP2', 
'SCHED_OTHER', 'SCHED_FIFO', 'SCHED_RR', 'SCHED_BATCH', 'SCHED_IDLE', 
'SCHED_RESET_ON_FORK', 'XATTR_CREATE', 'XATTR_REPLACE', 
'XATTR_SIZE_MAX', 'RTLD_LAZY', 'RTLD_NOW', 'RTLD_GLOBAL', 'RTLD_LOCAL', 
'RTLD_NODELETE', 'RTLD_NOLOAD', 'RTLD_DEEPBIND', 'GRND_RANDOM', 
'GRND_NONBLOCK', 'MFD_CLOEXEC', 'MFD_ALLOW_SEALING', 'MFD_HUGETLB', 
'MFD_HUGE_SHIFT', 'MFD_HUGE_MASK', 'MFD_HUGE_64KB', 'MFD_HUGE_512KB', 
'MFD_HUGE_1MB', 'MFD_HUGE_2MB', 'MFD_HUGE_8MB', 'MFD_HUGE_16MB', 
'MFD_HUGE_32MB', 'MFD_HUGE_256MB', 'MFD_HUGE_512MB', 'MFD_HUGE_1GB', 
'MFD_HUGE_2GB', 'MFD_HUGE_16GB', 'pathconf_names', 'confstr_names', 
'sysconf_names', 'error', 'waitid_result', 'stat_result', 
'statvfs_result', 'sched_param', 'times_result', 'uname_result', 
'terminal_size', 'DirEntry', '_exit', 'path', 'curdir', 'pardir', 'sep', 
'pathsep', 'defpath', 'extsep', 'altsep', 'devnull', 'supports_dir_fd', 
'supports_effective_ids', 'supports_fd', 'supports_follow_symlinks', 
'SEEK_SET', 'SEEK_CUR', 'SEEK_END', 'makedirs', 'removedirs', 'renames', 
'walk', 'fwalk', '_fwalk', 'execl', 'execle', 'execlp', 'execlpe', 
'execvp', 'execvpe', '_execvpe', 'get_exec_path', 'MutableMapping', 
'_Environ', '_putenv', '_unsetenv', 'getenv', 'supports_bytes_environ', 
'environb', 'getenvb', 'fsencode', 'fsdecode', 'P_WAIT', 'P_NOWAIT', 
'P_NOWAITO', '_spawnvef', 'spawnv', 'spawnve', 'spawnvp', 'spawnvpe', 
'spawnl', 'spawnle', 'spawnlp', 'spawnlpe', 'popen', '_wrap_close', 
'fdopen', '_fspath', 'PathLike'])

>>>>

Thanks,
--
Tom Hale
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Running Lib/test/test_shutil.py

2019-06-13 Thread Tom Hale

Hi all,

I hope this is the best place to ask (please let me know if there is a 
more appropriate list):


Checking out CPython v3.8.0b1, I'm trying to run:

  % python Lib/test/test_shutil.py

I'm getting:

Traceback (most recent call last):
  File "Lib/test/test_shutil.py", line 19, in 
from shutil import (make_archive,
ImportError: cannot import name '_GiveupOnFastCopy' from 'shutil' 
(/usr/lib/python3.7/shutil.py)


Am I trying to run the test file in the right way?

Context: I'm proposing to add /shutil.(sym)?link/ and want to start 
writing my tests with running the existing tests :)


Is there a doc that I've missed?

Cheers!

--
Tom Hale
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Fw: Download issues for Python

2019-06-04 Thread tom milikic


Hi my name is Tom and I come from Brisbane in Australia.  I cannot seem to 
download Python on my computer as I really need it to help with my Quantitative 
Finance studies.  It seems to say that some program is missing from my 
computer?  What do I do? I am running Windows and a Toshiba computer. I have 
looked in the help section and I still cant seem to fix or find the issue with 
why it is not downloading onto my computer?

It states that this is missing from my computer -:

api-ms-win-crt-runtime-l1-1-0.dl

Also Python 3.7.2 and Python 3.7.3 appear in my download folders but when I 
click them nothing happens?

If you can help would be much appreciated

Thanks
Tom


[https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
  Virus-free. 
www.avast.com<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Understanding error in recursive function

2016-04-08 Thread Tom Maher
Hi,

As a test I am trying to write a function that returns the sum of values
attached to one key in a dictionary. I am wondering why the code that I
wrote is returning:
"maximum recursion depth exceeded "
Here is the code:

animals = { 'a': ['aardvark'], 'b': ['baboon'], 'c': ['coati']}

x = animals['a']

def howMany(aDict):

  count = 0

  for value in howMany(aDict):

   count += 1

  return count

howMany(x)


Just wondering why I would be getting that error.


Thanks
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Simple game

2016-03-24 Thread Tom Maher
Here is a simple game I am trying to create:


print "pick a number between 0 and 100 and tell me if it my guess is too
high (h) too low (l) or correct (c)"

guess = 0

print 'my guess is 50'

raw_input('your input ')

n = 50

while raw_input != 'c' or 'h' or 'l':

  if raw_input == 'h':

   guess += 1

   n -= (n/2)

  elif raw_input == "l":

   guess += 1

   n += (n/2)

  elif raw_input == 'c':

   print "It took " + str(guess) + "guesses"

   break

if raw_input is not 'c' or 'h' or 'l':

  print "please input either a c, h, or l"

elif print "game over"


I think its pretty obvious what I'm trying to do here - make a game that
will guess your number between 0 and 100 using a bisection search. I know I
made some embarrassingly obvious mistakes in the math up there but I can
worry about that later.  This is after a couple of attempts and so far my
code basically stops after the raw input prompt. No matter what I input it
doesn't respond. I originally tried to equate raw_input to x as a marker
but thought that maybe that changed the raw_input to be read AS x in the
code even after input. So instead I entered raw_input in every section to
represent the inputted value. Still stops at the prompt. Not sure if it is
something obvious or if it is something I'm oblivious to or what. Any help
is appreciated!


Thanks a lot,

Tom
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] What do each of these functions do?

2016-02-15 Thread Tom Brodle
I have requested help related to a program before, but did not see an answer.  
I am new to the communicating with "tutor", IE I may have missed the answer.  
This time I will simplify my inquiry.
My previous programming has been with "Basic", so please give me a break.
What do the following two lines of code do, individually,  and where in the 
code does the pointer or (program counter) end up after it has finished that 
line, assuming it is the last line of code in each of two programs?

GPIO.cleanup()

quit(code=None)

What document would answer my question?

Thanks



  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Help needed

2016-02-04 Thread Tom Brodle
I am very new  to Python.  I am just practicing code using a simple plug board. 
 The code is working as I want it to but the last message and the original 
looping makes me have questions.  Because the main code works I will just 
abbreviate it.

import GPIO
import time
Gpio setmode (BCM)
led_pin = 18
GPIO setup(led_pin, GPIO)

try:
While true:
Turn LED on
sleep 5 seconds
Turn LED off
sleep .5 seconds  # program was initially designed to keep LED 
turning on and off and that worked.
   # Coming from the world of Basic I 
did/do not understand what made the program loop
   # back to while True: line of code.
   # I  wanted the LED to turn on and 
then off and stay off, so from some Python.org 
   # page I became aware of 
quit(code=None) and inserted it before the line Print("Cleaning up")
  quit(code=None)# I put this line in to stop the looping back 
to While true:.
Print("Cleaning up")
GPIO.cleanup()   # I was told to put this line in but I do not know 
where it goes to do whatever. 
  #The code did turn the LED on once 
and then it did stay off, but it gave me a message that 
  # the  program is still running.  I 
did not think that programs actually did stop until the
  # power was removed.

Thanks
Tom
  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to plot amount of lines but the amount is a input

2015-12-30 Thread Tom Xu
Dear Pythoneers,

sorry for bothering. I want to draw several curves in one graph, but the
amount of curves is not a fixed number.
My homework is below:
---
import matplotlib.pyplot as plt
import math

if __name__=='__main__':
try:
n=int(input('how many curves? '))
ulist=[]
thetalist=[]
for i in range(n):
ulist.append(float(input('Enter velocity: ')))
thetalist.append(float(input('Enter angle: ')))
except ValueError:
print('invalid input')
else:
*generateFr(?) # here I want to draw several curves with
ulist[0], thetalist[0], ulist[1], thetalist[1]... ... ulist[n-1],
thetalist[n-1]*

def generateFr(u, theta):
theta=math.radians(theta)
g=9.8

tflight=2*u*math.sin(theta)/g
intervals=frange(0, tflight, 0.001)

x=[]
y=[]
for t in intervals:
x.append(u*math.cos(theta)*t)
y.append(u*math.sin(theta)*t - 0.5*g*t*t)
drawgraph(x, y)

def frange(start, final, increment):
numbers=[]
while starthttps://mail.python.org/mailman/listinfo/tutor


[Tutor] How to plot amount of lines but the amount is a input

2015-12-30 Thread Tom Xu
Dear Pythoneers,

I want to draw several curves in one graph, but the amount of curves is not
a fixed number.
My homework is below:
---
import matplotlib.pyplot as plt
import math

if __name__=='__main__':
try:
n=int(input('how many curves? '))
ulist=[]
thetalist=[]
for i in range(n):
ulist.append(float(input('Enter velocity: ')))
thetalist.append(float(input('Enter angle: ')))
except ValueError:
print('invalid input')
else:
generateFr(?)

def generateFr(u, theta):
theta=math.radians(theta)
g=9.8

tflight=2*u*math.sin(theta)/g
intervals=frange(0, tflight, 0.001)

x=[]
y=[]
for t in intervals:
x.append(u*math.cos(theta)*t)
y.append(u*math.sin(theta)*t - 0.5*g*t*t)
drawgraph(x, y)

def frange(start, final, increment):
numbers=[]
while starthttps://mail.python.org/mailman/listinfo/tutor


[Tutor] output formatting question

2015-08-06 Thread tom arnall
i have read --  with what i think is a reasonable amount of attention
-- all of the doc' i can find about string formatting in python. for
the life of me, i cannot see how any of the other methods do more than
you can do with, to use a concrete example:

print "Here %s a number: %3d" % ("is",  1)

#OR:

s =   "Here %s a number: %3d" % ("is", 1)
print s

what am i not getting?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] howto create virtual environment for Enthought Training on Debian?

2014-08-19 Thread Tom Roche

I'm running a 64-bit flavor of Debian (LMDE) with GNOME, which includes a 
system python and various python-using applets and applications. I have a 
long-standing interest in scientific software, but only recently acquired some 
spare time and an Enthought Training license. So I'd like to get setup to work 
the Enthought Training exercises, which apparently means installing Canopy 
(formerly EPD), possibly et al. However, the last time I tried to do something 
similar (2 years ago? installing EPD), using the provided installer, it whacked 
some system-python-dependent appss.

I therefore want to install Canopy (and whatever else I need to do the 
Enthought Training that is not independently available via debian packages) 
into a virtual environment (so as not to cause problems with dependencies of my 
system python). How to do this? conda? venv? virtualenv? Unfortunately I'm not 
seeing any howto's on Enthought's site[1].

Please reply to me as well as the list: I'm on the digest, which gets huge. 
Alternatively, add your answer to this StackOverflow[2] (which I setup at 
Enthought's apparent recommendation[1]).

TIA, Tom Roche 

[1]: https://support.enthought.com/home
[2]: 
http://stackoverflow.com/questions/25375171/create-virtual-environment-for-enthought-training-on-debian
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[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': 2, 'C': 1}
for x in [A, B, C]:

  if myDict[x] == (self.%s % (x)): # Invalid if statement.. ;-)
print "Yep, we have a match!"
  else:
print "Sorry..No match!"
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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 maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Trouble running Python on Windows Vista

2012-06-14 Thread Tom Avos
Thanks!!
 


 De: Emile van Sebille 
Para: tutor@python.org 
Enviado: jueves, 14 de junio de 2012 16:35
Asunto: Re: [Tutor] Trouble running Python on Windows Vista
  
On 6/14/2012 12:19 PM Tom Avos said...
> Yes, If I open the file from the IDLE and then I press "f5" it works,
> but I want to know why it does not work if I write the filename after
> the ">>>" prompt . That way is much more handy, I would like to make it
> work.

Once you've got the >>> prompt you're executing python words, not file system 
file names.


IDLE is a development environment and is not a run environment. Further, IDLE 
is or has been known to suffer from various 'leaks' that contribute to oddities 
when made to do as you're asking, so even when you do get it going, it's not a 
stable platform.

I'd-like-apples-to-be-oranges-but-they're-not-ly y'rs,

Emile

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Trouble running Python on Windows Vista

2012-06-14 Thread Tom Avos
Yes, If I open the file from the IDLE and then I press "f5" it works, but I 
want to know why it does not work if I write the filename after the ">>>" 
prompt . That way is much more handy, I would like to make it work.
 
 

____
 De: Kwpolska 
Para: Tom Avos  
Enviado: jueves, 14 de junio de 2012 16:01
Asunto: Re: [Tutor] Trouble running Python on Windows Vista
  
On Thu, Jun 14, 2012 at 8:54 PM, Tom Avos  wrote:
> De: Tom Avos 
> Para: "Flynn, Stephen (L & P - IT)" 
> Enviado: jueves, 14 de junio de 2012 13:19
> Asunto: Re: [Tutor] Trouble running Python on Windows Vista
>
> Great! You're right.. It works from the Command Line :-)
>
> So, how should I call it inside the IDLE?? ... If I write ">>> triangulo.py"
> I get the "NameError"
>
> Thanks again.
>
> De: "Flynn, Stephen (L & P - IT)" 
> Para: Tom Avos 
> Enviado: jueves, 14 de junio de 2012 13:00
> Asunto: RE: [Tutor] Trouble running Python on Windows Vista
>
> Looks like (from the “>>>” prompt) that you’re still inside IDLE when you
> try to fire up the interpreter. This is how one would kick off the python
> code from the command line.
>
> S.
>
> From: Tom Avos [mailto:toma...@yahoo.com.ar]
> Sent: Thursday, June 14, 2012 4:56 PM
> To: Flynn, Stephen (L & P - IT)
> Subject: Re: [Tutor] Trouble running Python on Windows Vista
>
> Hi Stephen,
> I followed your advice, but still no luck... I get the following error
> ("triangulo" highlighted):
>>>> python.exe triangulo.py
> SyntaxError: invalid syntax
>>>>
> Best,
>
>
> De: " Flynn, Stephen (L & P - IT)" 
> Para: Tom Avos 
> Enviado: jueves, 14 de junio de 2012 12:36
> Asunto: RE: [Tutor] Trouble running Python on Windows Vista
>
>
> Hi Tom,
>
>
> “python.exe triangulo.py”
>
>
>
>
> S.
>
>
> From: tutor-bounces+steve.flynn=capita.co...@python.org
> [mailto:tutor-bounces+steve.flynn=capita.co...@python.org] On Behalf Of Tom
> Avos
> Sent: Thursday, June 14, 2012 4:30 PM
> To: tutor@python.org
> Subject: [Tutor] Trouble running Python on Windows Vista
>
> Hi there,
> I'm learning Python. I have to work with a Notebook running Widows Vista
> Home Premium.(have no other choice)
> It works fine when working in Interactive Mode or by  Opening a .py file
> from the IDLE and then running it by pressing F5, but I can not run .py
> files by invoking them from the prompt (neither from IDLE nor Dos Command
> Line);
>
> Every time I try to do this I get the following error:(In this case I'm
> tryig to invoke triangulo.py saved in C:\python27);
>
>>>> triangulo.py
> Traceback (most recent call last):
>   File "", line 1, in 
>     triangulo.py
> NameError: name 'triangulo' is not defined
>>>>
>
> The same happens for every file I want to run by calling them from the
> prompt, although if I double click on any .py file it runs ok.
>
> I've installed Python as follows:
>
> I've downloaded the Python 2.7.3 Windows Installer from
> www.python.org/download/.
> Once I've got it I run the installer and Python was installed on
> C:\Python27, and I've added Python to the my directory by doing set
> path=%path%;C:\python27.
>
> Any ideas will be very welcome :-)
> Thanks in advance for your attention.
>
>
> Click here to report this email as spam.
>
> This email and any attachment to it are confidential.  Unless you are the
> intended recipient, you may not use, copy or disclose either the message or
> any information contained in the message. If you are not the intended
> recipient, you should delete this email and notify the sender immediately.
>
>  Any views or opinions expressed in this email are those of the sender only,
> unless otherwise stated.  All copyright in any Capita material in this email
> is reserved.
>
>  All emails, incoming and outgoing, may be recorded by Capita and monitored
> for legitimate business purposes.
>
>  Capita exclude all liability for any loss or damage arising or resulting
> from the receipt, use or transmission of this email to the fullest extent
> permitted by law.
>
>  This message has been scanned for malware by Websense. www.websense.com
>
>
>
>
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

Open the file in the IDLE editor and press F5.

-- 
Kwpolska <http://kwpolska.tk>
stop html mail      | always bottom-post
www.asciiribbon.org | www.netmeister.org/news/learn2quote.html
GPG KEY: 5EAAEA16   | Arch Linux x86_64, zsh, mutt, vim.
# vim:set textwidth=70:___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Trouble running Python on Windows Vista

2012-06-14 Thread Tom Avos


 De: Tom Avos 
Para: "Flynn, Stephen (L & P - IT)"  
Enviado: jueves, 14 de junio de 2012 13:19
Asunto: Re: [Tutor] Trouble running Python on Windows Vista



Great! You're right.. It works from the Command Line :-)
 
So, how should I call it inside the IDLE?? ... If I write ">>> triangulo.py" I 
get the "NameError"
 
Thanks again.
 

________
 De: "Flynn, Stephen (L & P - IT)" 
Para: Tom Avos  
Enviado: jueves, 14 de junio de 2012 13:00
Asunto: RE: [Tutor] Trouble running Python on Windows Vista
  

 
Looks like (from the “>>>”
prompt) that you’re still inside IDLE when you try to fire up the interpreter. 
This
is how one would kick off the python code from the command line. 
  
S. 
  


  
From:Tom Avos [mailto:toma...@yahoo.com.ar] 
Sent: Thursday, June 14, 2012 4:56
PM
To: Flynn, Stephen (L & P - IT)
Subject: Re: [Tutor] Trouble
running Python on Windows Vista  
  
Hi Stephen,  
I followed
your advice, but still no luck... I get the following error
("triangulo" highlighted):  
>>> python.exe
triangulo.py
SyntaxError: invalid syntax
>>>   
Best,  
   
   
De:" Flynn, Stephen (L & P - IT)"

Para: Tom Avos  
Enviado: jueves, 14 de junio de
2012 12:36
Asunto: RE: [Tutor] Trouble
running Python on Windows Vista  

 
Hi Tom,  
   
   
“python.exe triangulo.py”  
   
   
   
   
S.  
   
   
From:tutor-bounces+steve.flynn=capita.co...@python.org
[mailto:tutor-bounces+steve.flynn=capita.co...@python.org] On Behalf Of Tom Avos
Sent: Thursday, June 14, 2012 4:30
PM
To: tutor@python.org
Subject: [Tutor] Trouble running
Python on Windows Vista   
   
Hi there,   
I'm learning
Python. I have to work with a Notebook running Widows Vista Home Premium.(have
no other choice)   
It works fine
when working in Interactive Mode or by  Opening a .py file from the IDLE
and then running it by pressing F5, but I can not run .py files by invoking
them from the prompt (neither from IDLE nor Dos Command Line);
    
Every time I
try to do this I get the following error:(In this case I'm tryig to invoke 
triangulo.py
saved in C:\python27);
    
>>>
triangulo.py   
Traceback
(most recent call last):
  File "", line 1, in 
    triangulo.py
NameError: name 'triangulo' is not defined
>>>
    
The same happens
for every file I want to run by calling them from the prompt, although if I
double click on any .py file it runs ok.   
    
I've
installed Python as follows:   
    
I've
downloaded the Python 2.7.3
Windows Installer from www.python.org/download/.
Once I've got
it I run the installer and Python was installed on C:\Python27, and I've added
Python to the my directory by doing set path=%path%;C:\python27.   
    
Any ideas
will be very welcome :-)   
Thanks in
advance for your attention.   
 
   
Click here to report this email as spam.   
  
This email and any attachment to it are confidential.  Unless you
are the intended recipient, you may not use, copy or disclose either the
message or any information contained in the message. If you are not the
intended recipient, you should delete this email and notify the sender
immediately. 
  
 Any views or opinions expressed in this email are those of the
sender only, unless otherwise stated.  All copyright in any Capita
material in this email is reserved. 
  
 All emails, incoming and outgoing, may be recorded by Capita and
monitored for legitimate business purposes. 
  
 Capita exclude all liability for any loss or damage arising or
resulting from the receipt, use or transmission of this email to the fullest
extent permitted by law. 
  
 This message has been scanned for malware by Websense. www.websense.com   ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Trouble running Python on Windows Vista

2012-06-14 Thread Tom Avos
Hi there,
I'm learning Python. I have to work with a Notebook running Widows Vista Home 
Premium.(have no other choice)
It works fine when working in Interactive Mode or by  Opening a .py file from 
the IDLE and then running it by pressing F5, but I can not run .py files by 
invoking them from the prompt (neither from IDLE nor Dos Command Line); 
 
Every time I try to do this I get the following error:(In this case I'm tryig 
to invoke triangulo.py saved in C:\python27); 
 
>>> triangulo.py
Traceback (most recent call last):
  File "", line 1, in 
    triangulo.py
NameError: name 'triangulo' is not defined
>>> 
 
The same happens for every file I want to run by calling them from the prompt, 
although if I double click on any .py file it runs ok.
 
I've installed Python as follows:
 
I've downloaded the Python 2.7.3 Windows Installer from 
www.python.org/download/. 
Once I've got it I run the installer and Python was installed on C:\Python27, 
and I've added Python to the my directory by doing set path=%path%;C:\python27.
 
Any ideas will be very welcome :-)
Thanks in advance for your attention.___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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 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. Yah? Is their and easier approach I might be overlooking?
>>>
>>>
>>> For example...
>>>
>>> mylist = ['serverA', 'serverB', 'serverC', 'serverD',' serverE',
>>> 'serverF', 'serverG']
>>>
>>>
>>> Desired Output
>>> 
>>> serverA  serverB  serverC
>>> serverD  serverE  serverF
>>> serverG
>>>
>>> ___
>>> Tutor maillist  -  Tutor@python.org
>>> To unsubscribe or change subscription options:
>>> http://mail.python.org/mailman/listinfo/tutor
>>>
>>>
>> How about something like this
>>
>>
>> mylist =  ['serverA', 'serverB', 'serverC', 'serverD','serverE',
>> 'serverF', 'serverG']
>> tempstr = ""
>> count = 0
>>
>> for item in mylist:
>> count += 1
>> if count == 3:
>> tempstr += (i + "\n")
>> count = 0
>> else:
>> tempstr += (i + " ")
>>
>> print tempstr
>>
>>
>> The above code prepares an empty string variable, and a count variable.
>> On each iteration, it checks to see if the count is equal to 3. If it is,
>> then it appends the current list element to the string and also adds a
>> newline character("\n"), then the count is reset to 0. If the count isn't
>> 3, it simply appends the current list element along with a space.
>>
>> Hope this helps,
>> Bodsda
>>
>>
>> erm, I screwed up my variable names. where you see 'i', this should be
> item (or the other way around).
> My bad.
>
> -- Bodsda
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[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. Yah? Is their and easier approach I might be overlooking?


For example...

mylist = ['serverA', 'serverB', 'serverC', 'serverD',' serverE', 'serverF',
'serverG']


Desired Output

serverA  serverB  serverC
serverD  serverE  serverF
serverG
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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:* 21 October 2011 18:53
> *To:* 'tutor@python.org'
> *Subject:* python telnet
>
> ** **
>
> Can I connect to a telnet session and return data without disconnecting the
> data session.  
>
> ** **
>
> Regards Rayon
>
> ** **
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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,
>>>
>>> ** **
>>>
>>> I know that there is a lot to read about different IDEs on the net but I
>>> have tried a couple and I’m still not pleased. My demands are not that high,
>>> when I’m under Windows I’m happy with IDLE (an interactive shell and debug)
>>> but the problem is with Mac (Python >= 2.7 and OS 10.7). IDLE had serious
>>> problems and TextWrangler had no interactive shell. There’s a lot of other
>>> stuff to try and I would be grateful if someone could spare me some time on
>>> this. 
>>>
>>>
>>>
>> Well, if you're prepared to spend a bit of money, I've heard very good
>> things about Wingware, which is also available on Mac  (Note, not a user
>> myself currently, but has seen it before and been favourably impressed,
>> enough to suggest it here despite not currently actively using it myself.)
>> Link: http://wingware.com/
>
>
> I'll second that. If you're really into IDEs, Wingware is a great one -
> they also have a student/open source license that may be right up your
> alley.
>
> My personal favorite?
>
> Two terminal windows - one with Vim, editing my Python scripts, and another
> with an interactive interpreter. Since you can map keys in Vim, I have 
> mapped to save and run current file. If you're in the habit of editing
> multiple files you could set it up to map  to ask which file you want to
> set as your main .py file. And since you mentioned debug, I usually just use
> pdb if I need debugging. You could easily map a key such as  to insert a
> new line and type 'pdb.set_trace()'. Vim has a fairly steep learning curve,
> but if you spend 30 minutes with the vimtutor you'll be fine. With newer
> versions of Vim you can also write plugins for them in Python.
>
> Of course these capabilities (and many many more) are available with Emacs.
>
> I personally recommend that you learn one (or both) of these editors. They
> will highly improve the speed at which you are able to edit your code.
>
> HTH,
> Wayne
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] newbie needs pypy setup tips

2011-07-30 Thread Tom Roche

I need advice about configuring pypy to run other python code. Why I ask:

I'm running a model implemented in python. Unfortunately a run on "straight" 
python 2.6.x or 2.7.x requires

- 130 min on my ubuntu laptop (on which working would be more convenient)
- 55 min on a better build machine on which I currently have access

However I have read that this model runs 5x faster under pypy, so I wanna get 
me that, but I'm finding the pypy docs pretty inscrutable. Nevertheless, I have 
managed to do

me@it:~$ uname -rv
> 2.6.32-33-generic #70-Ubuntu SMP Thu Jul 7 21:13:52 UTC 2011
me@it:~$ which pypy
> /usr/local/bin/pypy
me@it:~$ ls -al $(which pypy)
> lrwxrwxrwx 1 root root 37 2011-07-30 16:06 /usr/local/bin/pypy -> 
> /opt/pypy-c-jit-1.5.0-alpha0/bin/pypy
me@it:~$ pypy --version
> Python 2.7.1 (b590cf6de419, Apr 30 2011, 02:00:34)
> [PyPy 1.5.0-alpha0 with GCC 4.4.3]

However, when I try to *really* run the @#$%^&! thing, it spews:

me@it:~$ pypy
> debug: WARNING: library path not found, using compiled-in sys.path and 
> sys.prefix will be unset
> 'import site' failed
> Python 2.7.1 (b590cf6de419, Apr 30 2011, 02:00:34)
> [PyPy 1.5.0-alpha0 with GCC 4.4.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> debug: OperationError:
> debug:  operror-type: ImportError
> debug:  operror-value: No module named _pypy_interact

What do I need to do to fix its library path?

TIA, Tom Roche 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] if os.path.exists() or if not os.path.exists()?

2011-03-24 Thread Tom Zych
On Thu, 24 Mar 2011 09:22 -0600, "Susana Iraiis Delgado Rodriguez"
 wrote:
> #This block is wrong, I think here is the problem
> if os.path.exists(shx):
> print 'El archivo ' +shx +' existe'
> else:
> log.write('No existe el archivo ' +shx + "\n")
> if os.path.exists(dbf):
> print 'El archivo ' +dbf +' existe'
> log.write('No existe el archivo ' +dbf + "\n")

I don't know about the rest, but you're missing an "else:" between the
last two lines.

-- 
Tom Zych / freethin...@pobox.com
"Because if they didn't vote for a lizard," said Ford, "the wrong lizard
might get in." -- DNA
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Recursively flatten the list

2011-03-24 Thread Tom Zych
Dharmit Shah wrote:
> I am learning Python and yesterday I cam across a definition wherein I was
> supposed to flatten a list recursively. I am getting the solution properly
> but wanted to know if I can optimize the code further.
>
> #!/usr/bin/env python
> new_list=[]
> def flatten(num_list):
> """
>   >>> flatten([2, 9, [2, 1, 13, 2], 8, [2, 6]])
>   [2, 9, 2, 1, 13, 2, 8, 2, 6]
>   >>> flatten([[9, [7, 1, 13, 2], 8], [7, 6]])
>   [9, 7, 1, 13, 2, 8, 7, 6]
>   >>> flatten([[9, [7, 1, 13, 2], 8], [2, 6]])
>   [9, 7, 1, 13, 2, 8, 2, 6]
>   >>> flatten([[5, [5, [1, 5], 5], 5], [5, 6]])
>   [5, 5, 1, 5, 5, 5, 5, 6]
> """
> global new_list
> for i in num_list:
> if type(i) == type([]):
> new_list = flatten(i)
> else:
> new_list.append(i)
> tmp = new_list
> new_list=[]
> return tmp
>
> if __name__=="__main__":
> import doctest
> doctest.testmod()
>
> PS - My knowledge of Python is still very basic and I am trying to dive into
> it as deeper as I can. Solutions on Stackoverflow.com were beyond my
> understandability.

Using doctest and getting a recursive function right don't strike me as
basic.  This is pretty good for a beginner.

I'll second Peter Otten regarding the use of a global.  It's best to
avoid using globals whenever possible, not just for reentrancy, but for
more readable and maintainable code.  A function should be self-contained
if possible.  There's no reason you can't use a local variable in this
code (and you only need one, not two), and the resulting code would be
more readable.

Regarding this line:
if type(i) == type([]):

This also works:
if type(i) == list:

But this is better:
if isinstance(i, list):

isinstance(obj, class) means "is obj an instance of class or a subtype
of class", so it's more general.

Does anyone see a way to do this with a list comprehension?  I don't.
Would be a neat hack if it can be done.

-- 
Tom Zych / freethin...@pobox.com
"Because if they didn't vote for a lizard," said Ford, "the wrong lizard
might get in." -- DNA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Checksum program

2011-03-23 Thread Tom Zych
Lezlie Kline wrote:

> I'm trying to work out the bugs in a program for calculating the checksum
> (modulo 256) of an input string.  I'm testing it with my full name and I'm a
> beginner with Python.  Here's what I have so far.
> 
> def main():
> print"This program creates a checksum for a message."
> name=raw_input("Please enter the message to encode: ")
> message=name
> output=name
> for i in range(len(message)):
> print"The value of message[i] is ", message[i]
> output=output+name+ord(message[i])
> print"The value of the message is ", output
> checksum=(output)%256
> print"The checksum is ", checksum
> 
> main()

You're not too far off.  Take a good look at everything you do with
`output`.  In particular, note what type of object it is.

Your loop will work but it's not Pythonic - you can iterate over a
sequence directly:

for i in message:
# i = a character (string of length 1) from message
print "Processing", i

-- 
Tom Zych / freethin...@pobox.com
"Because if they didn't vote for a lizard," said Ford, "the wrong lizard
might get in." -- DNA
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] atr in dir Vs. hasattr

2011-03-16 Thread Tom Zych
On Thu, 17 Mar 2011 00:12 +1100, "Steven D'Aprano" 
wrote:
> And here's an example:
> 
>  >>> class C(object):
> ... pass
> ...
>  >>> hasattr(C, '__eq__')
> True
>  >>> '__eq__' in dir(C)
> False

OTOH, I got True in 3.1.1. As the docs say, detailed behavior may change
across releases.

I suppose there must be some reliable way to get a list of *all* an
object's attributes,
but I don't see it.

-- 
Tom Zych / freethin...@pobox.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Static Variable in Functions

2011-03-15 Thread Tom Zych
Steven D'Aprano wrote:
> Most of the common built-in Python objects are immutable:
> ...
> while a few are mutable:
> 
> lists
> dicts
> sets

Also, bytearrays.

-- 
Tom Zych / freethin...@pobox.com

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[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 activities
   2. Check network connectivity
  1. If connectivity: perform these activities
 1. Delete init script os.remove(sys.argv[0])
  2. If no connectivity:
 - Sleep 15 seconds
 - Check connectivity again
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Defining Exceptions

2011-02-02 Thread Tom Brauch
All,

I am a python neophyte and not terrible well versed in programming (as will
become obvious shortly)

I have a script which is reading a serial device on a schedule.  The device
outputs a header at the beginning of every read.  I have a data file which I
am appending and would like to eliminate the header so that I end up with
one master data file.  A copy of the serial readout is:

*
>
6CSV Type Reports2 - Display All Data3 - Display New Data4 - Display Last
Data5 - Display All Flow Stats6 - Display New Flow Stats7 - Display All
5-Min Flow8 - Display New 5-Min Flow9 - Display Error Log>
4 - Display CSV DataStation,
1Time,Conc(mg/m3),Qtot(m3),no(V),WS(MPS),no(V),RH(%),no(V),AT(C),E,U,M,I,L,R,N,F,P,D,C,T,02/02/11
08:00,  0.042, 0.701, 0.004,   0.1, 0.002, 7, 0.012,
-18.0,0,0,0,0,0,0,0,0,0,0,0,0,

I am only interested in the information following the T, in the header.  I
have tried to use an exception to have the script throw out all data prior
to the T, in the header but I don't know how to define this excecption.  My
current script looks as follows:

def cycle(ser,prefix):
inRecovery=False
resp=False
#tm.sleep(30.0)
ser.open()
tm.sleep(2)
ser.write('\n\r\n\r\n\r')
resp=buffer_read(ser)

ser.write('6')
resp=buffer_read(ser)

ser.write('3')
resp=buffer_read(ser)
lines = resp.split('\r\n')
waste=lines.pop()
while True:
try:
lines.remove(waste)
except Exception:
??
for x,row in enumerate(lines):
lines[x]=row.split(',')
if DEBUG: print lines
f=open(prefix,'a')
csvf = csv.writer(f)
csvf.writerows(lines)
f.close()
ser.close()

How do I define the exception so that I get only the data following the
header?

Thanks!
Tomb
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Convert an IP address from binary to decimal

2011-01-18 Thread Tom Lin
于 2011-1-18 21:08, Christian Witts 写道:
> On 18/01/2011 14:45, Tom Lin wrote:
>> Hi guys,
>>
>> Please help me with this:
>> Convert an IP address from binary string to decimal format.There are
>> some preconditions:
>> 1.IP address is in the form of '10010001100'.32 bits with no dot.
>> 2.int(string, base) is not allowed, You have to implement the conversion .
>> 3.Performance should be considered.
>>
>> For example an IP address like ' '
>> would be converted to '255.255.255.255'
>>
>> That's how I implement it. But I think it looks ugly and I wonder if
>> there is a better way to do this.
>>
>> import re
>> import sys
>>
>> def convert(bin_ip):
>> patt = re.compile(r'\d{8}')
>> bin_list = patt.findall(str(bin_ip))
>>
>> dec_list = []
>> for bin in bin_list:
>> sum = 0
>> i = 7
>> for n in bin:
>> if int(n):
>> sum = sum + 2**i
>> i = i - 1
>> dec_list.append(str(sum))
>>
>> dec_ip = '.'.join(dec_list)
>> print dec_ip
>>
>> if __name__ == '__main__':
>> bin_ip = sys.argv[1:]
>> convert(bin_ip)
>>
>>
>> Thanks in advance and excuse my poor English.
>>
>>
>> Best regards,
>> Tom
>>
>>
>> ___
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>   
> If I knew the input to be perfect it would be a simple matter
> '.'.join((str(int(input_ip[x:x+8], 2)) for x in range(4)))
>
Thanks, Chris. Your code looks pretty simple. Awesome!
But one precondition is not to use int(string, base). How would you
implement the conversion?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Convert an IP address from binary to decimal

2011-01-18 Thread Tom Lin
Hi guys,

Please help me with this:
Convert an IP address from binary string to decimal format.There are
some preconditions:
1.IP address is in the form of '10010001100'.32 bits with no dot.
2.int(string, base) is not allowed, You have to implement the conversion .
3.Performance should be considered.

For example an IP address like ' '
would be converted to '255.255.255.255'

That's how I implement it. But I think it looks ugly and I wonder if
there is a better way to do this.

import re
import sys

def convert(bin_ip):
patt = re.compile(r'\d{8}')
bin_list = patt.findall(str(bin_ip))

dec_list = []
for bin in bin_list:
sum = 0
i = 7
for n in bin:
if int(n):
sum = sum + 2**i
i = i - 1
dec_list.append(str(sum))

dec_ip = '.'.join(dec_list)
print dec_ip

if __name__ == '__main__':
bin_ip = sys.argv[1:]
convert(bin_ip)


Thanks in advance and excuse my poor English.


Best regards,
Tom
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] extending a VS python with cygwin

2010-08-09 Thread Tom Roche

summary: how to fix ...

m...@cygwinbox ~/bin/duplicity-0.6.09$ python setup.py install
...
> error: Python was built with Visual Studio 2003;
> extensions must be built with a compiler than can generate
> compatible binaries. Visual Studio 2003 was not found on this
> system. If you have Cygwin installed, you can try compiling with
> MingW32, by passing "-c mingw32" to setup.py.
m...@cygwinbox ~/bin/duplicity-0.6.09$ python -c mingw32 setup.py install
> Traceback (most recent call last):
>   File "", line 1, in 
> NameError: name 'mingw32' is not defined
m...@cygwinbox ~/bin/duplicity-0.6.09$ python setup.py -c mingw32 install
> usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
>or: setup.py --help [cmd1 cmd2 ...]
>or: setup.py --help-commands
>or: setup.py cmd --help
> error: option -c not recognized
m...@cygwinbox ~/bin/duplicity-0.6.09$ python setup.py install -c mingw32 
> usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
>or: setup.py --help [cmd1 cmd2 ...]
>or: setup.py --help-commands
>or: setup.py cmd --help
> error: invalid command 'mingw32'

details:

What's the appropriate syntax to solve the above python build problem?
Why I ask:

I mostly run linux, and I've been using python-based `duplicity`

http://duplicity.nongnu.org/

to back that up. I've got an older winxp box (SP3, uptodate with WU)
which I keep mostly to run ArcGIS, which has happily run many versions
of cygwin (which I keep uptodate) over the years. I'd like to be able to
restore my linux home to my cygwin home for the rare occasions when I
need to use the winxp box. To do that, I'd like to install duplicity on
the cygwin box. That install process (best described by the somewhat
downlevel

http://blog.khorun.com/2008/09/using-duplicity-on-windows-under-cygwin.html

) works for the install of the prerequisite GnuPGInterface and boto
python modules (process=[download tarball, tar xfz, python setup.py
install]) but fails for the install of duplicity itself, with the
error above:

m...@cygwinbox ~/bin/duplicity-0.6.09$ python setup.py install
...
> error: Python was built with Visual Studio 2003;

Note that I'd cheerfully replace that version of python (the 2.5.2
that shipped with my ArcGIS 9.3), except that I use some ArcGIS
extensions which seem to choke on other pythons :-( so I'd prefer to
build against that if at all possible.

> extensions must be built with a compiler than can generate
> compatible binaries. Visual Studio 2003 was not found on this
> system. If you have Cygwin installed, you can try compiling with
> MingW32, by passing "-c mingw32" to setup.py.

I try to take the advice offered, but either it's wrong or I'm missing
something:

m...@cygwinbox ~/bin/duplicity-0.6.09$ python -c mingw32 setup.py install
> Traceback (most recent call last):
>   File "", line 1, in 
> NameError: name 'mingw32' is not defined
m...@cygwinbox ~/bin/duplicity-0.6.09$ python setup.py -c mingw32 install
> usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
>or: setup.py --help [cmd1 cmd2 ...]
>or: setup.py --help-commands
>or: setup.py cmd --help
> error: option -c not recognized
m...@cygwinbox ~/bin/duplicity-0.6.09$ python setup.py install -c mingw32 
> usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
>or: setup.py --help [cmd1 cmd2 ...]
>or: setup.py --help-commands
>or: setup.py cmd --help
> error: invalid command 'mingw32'

What's the appropriate syntax here? Or how else should I fix this?

Apologies if this is a FAQ. If this is the wrong list/forum/whatever
for this query, please direct me appropriately. Note that the
duplicity list is apparently not the place, though :-(

TIA, Tom Roche 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] bind line-oriented device output?

2010-03-29 Thread Tom Roche

http://mail.python.org/pipermail/tutor/2010-March/075438.html
>> I'd like to learn to pythonically redirect the output from a
>> line-oriented character device to a particular file or process,
>> regardless of focus, on a generic graphical OS. But I don't want to
>> redirect stdin entirely.
...
>> It Would Be Nice, and useful for this seminar's mechanics, to be
>> able to run some code to which one could say, see this device? and
>> this file? Make the device's output go only to that file. For extra
>> credit, don't let anything else write that file while this code is
>> running.

http://mail.python.org/pipermail/tutor/2010-March/075443.html
> if you can assure that the target computer will be running a certain
> set of python features (i.e. Tkinter/pyGTK+/wxPython, etc)

Presuming they're available on the user's platform and not too onerous
to install, I can definitely say, "if you want , you need
to install ."

> you can fairly easily write a program that will run fullscreen and
> continually grab focus to whatever widget (in this case a text entry
> field) you want.

*Continually* grabbing focus to a UI is functionally (from the user's
point of view) equivalent to redirecting stdin, no? The user is made
unable to do anything but take attendance for the duration of the
task. In fact, for this usecase, continually grabbing focus is worse,
since the user would be unable to, e.g., read the directions for
setting up the audio. To clarify the usecase:

The barcode scanner (here, a Wasp WLS9500) is connected to an ordinary
multiprocessing laptop (which may be linux, mac, or windows) on which
the user will want to do other things while taking attendance: the
attendees don't come in all at once, and the user must accomplish
other tasks while taking attendance (notably setting up to record the
seminar audio). Hence the desired application

0 is portable.

1 does not redirect all of stdin, only the output from the scanner.
  The user is allowed to continue to work on other tasks (e.g. with
  output from the laptop's keyboard going to whatever frame), with
  only the output from the scanner being bound to a particular file or
  process.

2 does not continually grab focus. The user is allowed to continue to
  work on other tasks (e.g. with output from the laptop's keyboard
  going to whatever frame), with only scanner events being bound to a
  particular frame or widget.

But what might satisfy the usecase is

> if the device is something like the CueCat and reports a control
> character (I think it's alt+f7 for the cuecat), then at least on
> linux/windows I think it's much more trivial. You just have to
> register a global hotkey handler that will send the focus to that
> particular window.

I'll read the Product Reference Guide and hope it tells me that the
Wasp WLS9500 "reports a control character." Unfortunately when I
search the PDF

http://tinyurl.com/waspWLS9500manual

for "control character" I get no hits. Are there synonyms for that
term in this context?

TIA, Tom Roche 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] bind line-oriented device output?

2010-03-28 Thread Tom Roche

I'd like to learn to pythonically redirect the output from a
line-oriented character device to a particular file or process,
regardless of focus, on a generic graphical OS. But I don't want to
redirect stdin entirely. Here's the usecase:

My school has a seminar for which we record attendance by scanning the
student ID card, or rather the barcode on its back, with a handheld
USB scanner. This is pretty straightforward, except that the barcode
scanner is like a keyboard writing the ASCII equivalent of the barcode
(== the student's ID#) to stdin. FWIW, the scanner writes lines: I'm
not sure if EOL is \r, \n, or \r\n, but I suspect the latter.

Since the scanner is connected to an ordinary multiprocessing laptop on
which one will likely be doing other things while scanning (notably
setting up to record the presenter), it sometimes happens (especially
until one learns to pay attention to this) that one writes to a frame
other than the text file into which we want record attendee ID#s. This
semester recurs every {fall, spring}, so someone faces this {pitfall,
learning curve} at regular intervals.

How to prevent writing the wrong target? One trivial solution--shlep a
dedicated USB host for the scanner--is deprecated. An OS-specific
solution (e.g. relying on a linux raw device) is also undesirable: I
use ubuntu, but others will probably use mac or windows.

Rather, It Would Be Nice, and useful for this seminar's mechanics, to
be able to run some code to which one could say, see this device? and
this file? Make the device's output go only to that file. For extra
credit, don't let anything else write that file while this code is
running.

Can python do that? Or does one need to get closer to the metal?

TIA, Tom Roche 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Network Socket question

2010-02-20 Thread Tom Green
Hello group,

First, I love this forum as I find it to be a wealth of info on Python
and programming in general.  I have a general question about sockets,
which is what I primarily use Python for.  My environment is Windows
and I am using Python 2.5.

My sockets are working great but now I am running into a client that
sends multiple sends and I have no EOF (end of file) marker.  I have
read up on Twistted and threads and was wondering if someone could
share a Windows method for working with a non-blocking socket.  I
believe I have to use POLL or select to check for data.  Right now my
socket hangs on RECV.  Sorry if I am not explaining this correctly.
Maybe someone can share with me some papers on writing Windows
sockets.

Thank you,
Tom Green.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] composing one test suite from two test cases

2010-01-11 Thread Tom Roche


Tom Roche Sun, Jan 10, 2010 at 10:44 PM
>> How to create a single unittest test suite class that runs all
>> methods from multiple TestCase classes?

Kent Johnson Mon, 11 Jan 2010 06:42:39 -0500
> The supported way to do this is to create a test suite. There is an
> example here:
> http://docs.python.org/library/unittest.html#organizing-test-code

Yes, I saw that, in particular

http://docs.python.org/library/unittest.html#organizing-test-code
>>> unittest provides a TestLoader class that can be used to automate
>>> the process of creating a test suite and populating it with
>>> individual tests. For example,

>>> suite = unittest.TestLoader().loadTestsFromTestCase(WidgetTestCase)

>>> will create a test suite that will run
>>> WidgetTestCase.testDefaultSize() and WidgetTestCase.testResize.
...
>>> TestSuite instances can be added to a TestSuite just as TestCase
>>> instances can be added to a TestSuite:

>>> suite1 = module1.TheTestSuite()
>>> suite2 = module2.TheTestSuite()
>>> alltests = unittest.TestSuite([suite1, suite2])

but I couldn't get AllTests.py to run: I kept getting errors about
"unbound method", "no such test method", class/instance problems, etc.
Thanks to your assistance, I suspect my key faults were:

* namespace: I was doing

- import PidTests
- import TallyPidTests

instead of

+ from PidTests import PidTests
+ from TallyPidTests import TallyPidTests

* not encapsulating the TestSuite-adding code in another suite()

The only thing your code was missing was the main(), but that was easy
to add. (The complete AllTests.py that runs for me follows my .sig)

> However I don't recommend this style of organizing tests. I prefer
> using nose for test discovery, it saves the work of creating all the
> aggregating suites.

I've heard of Nose and am planning to try it, but for now I thought
I'd "do the simplest thing that could possibly work."

> I think py.test also has a test discovery component. In Python 2.7
> the unittest module will finally have it's own test discovery.

> http://somethingaboutorange.com/mrl/projects/nose/0.11.1/finding_tests.html
> http://docs.python.org/dev/library/unittest.html#test-discovery

Thanks again, Tom Roche ---AllTests.py follows---

import unittest
from PidTests import PidTests
from TallyPidTests import TallyPidTests

class AllTests(unittest.TestCase):
  def suite():
suite1 = unittest.TestLoader().loadTestsFromTestCase(PidTests)
suite2 = unittest.TestLoader().loadTestsFromTestCase(TallyPidTests)
return unittest.TestSuite([suite1, suite2])

def main():
unittest.main()

if __name__ == '__main__':
main()
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] composing one test suite from two test cases

2010-01-10 Thread Tom Roche

How to create a single unittest test suite class that runs all methods
from multiple TestCase classes? Why I ask:

I'm trying to relearn TDD and learn Python by coding a simple app.
Currently the app has 2 simple functional classes, Pid and TallyPid,
and 2 very simple testcases, PidTests and TallyPidTests:

http://www.unc.edu/~tr/courses/ENVR400/Pid.py
http://www.unc.edu/~tr/courses/ENVR400/PidTests.py
http://www.unc.edu/~tr/courses/ENVR400/Tally.py
http://www.unc.edu/~tr/courses/ENVR400/TallyPidTests.py

I can run both testcases

> >python PidTests.py
> 
> --
> Ran 20 tests in 0.000s
> OK

> >python TallyPidTests.py
> .
> --
> Ran 1 test in 0.563s
> OK

Before I continue, I'd like to create a single suite, in a separate
cfile file/module (e.g. AllTests.py), that will run both testcases
(PidTests.py and TallyPidTests.py). Unfortunately I have not been able
to do this! which surprises me, since creating such a suite in JUnit
is trivial.  Can someone show me how to create this suite in python?
(FWIW the python version=2.5.2: downlevel, I know, but the box also
needs to run ArcGIS.)

TIA, Tom Roche 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pack as HEX question

2009-10-24 Thread Tom Green
Sweet nice tip I love this list.  Thank you.

Mike

On Sat, Oct 24, 2009 at 7:40 PM, Dave Angel  wrote:

> Tom Green wrote:
>
>> Thanks for your reply Dave.  I am capturing the data off the network
>> (wireshark) and saving it in WinHex for testing.  I am actually building a
>> socket to decrypt the data, so prior to implementing my logic in the
>> socket,
>> I figured I would write the algorithm in a quick script.  Here is what I
>> have so far and it works.
>>
>> import struct,binascii
>> decrypt=[]
>> data_count=0
>> key_pos=0
>> #packed data consists of HEX values
>> packed_data = binascii.unhexlify('313B372C2E2C63362E2128')
>> #XorKey data consists of HEX values
>> packed_XorKey=binascii.unhexlify('41424344')
>> while data_count < len(packed_data):
>>if key_pos >len(packed_XorKey)-1:
>>key_pos=0
>>
>>
>> decrypt.append(chr(ord(packed_data[data_count])^ord(packed_XorKey[key_pos])))
>>key_pos+=1
>>data_count+=1
>> print "".join(decrypt)
>>
>> This decrypts to Python rock
>>
>> This logic seems to work, but I am certain there is a better way.
>>
>> Mike
>>
>>
>> On Sat, Oct 24, 2009 at 4:43 PM, Dave Angel  wrote:
>>
>>
>>
>>> Tom Green wrote:
>>>
>>>
>>>
>>>> Alan,
>>>>
>>>> Thanks for your response and hopefully I can clear things up.  I
>>>> apologize
>>>> for not being more clear.
>>>>
>>>> I obtain the HEX encoded data from Winhex i.e. copy Hex values.  The HEX
>>>> encode data is very large and I simply paste it into my Python script
>>>> along
>>>> with the XOR key.  The data is a string of bytes represented in HEX, as
>>>> I
>>>> showed.
>>>>
>>>> Here is the problem I ran into.
>>>>
>>>> Take the 4 byte XOR key.  If I convert them to int with Base 16 it takes
>>>> the
>>>> 4 and converts it to 0x34 when I in turn I actually need 0x41.
>>>>
>>>> Thanks for your feedback.
>>>>
>>>> Mike
>>>>
>>>> On Sat, Oct 24, 2009 at 10:24 AM, Alan Gauld >>>
>>>>
>>>>> wrote:
>>>>>
>>>>>
>>>> 
>>>>
>>>>
>>>>
>>>>>  Encrypted string in hex
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> "313B372C2E2C63362E2128"
>>>>>>
>>>>>> Four byte key
>>>>>> XOR key "41424344"
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> 
>>>>>
>>>>>
>>>>>
>>>> If by Winhex, you mean the hex editor, then you're undoubtedly going
>>>> about
>>>>
>>>>
>>> it the long way.  There's no need to convert the file to printable hex,
>>> you
>>> should be able to work on it directly.  Just open the file, read it into
>>> a
>>> string (in python2.x), then loop through it, one byte at a time.  Store
>>> your
>>> key in a binary string as well.  Now just loop through the two in pairs
>>> (use
>>> zip, and cycle) doing a chr of xor of ords.
>>>
>>>
>>> And when you respond, give us your python version, and show us the code
>>> you've got (almost) working.
>>>
>>> DaveA
>>>
>>>
>>>
>>
>>
>>
> (You top-posted, so your message is out of order)
>
> Replace your while -- loop with the following simpler version.
>
>
> for byte0, byte1 in itertools.izip(packed_data,
> itertools.cycle(packed_XorKey)):
>   decrypt.append(chr(ord(byte0) ^ ord(byte1)))
>
> (You'll need an import itertools, at beginning, of course.)
>
> itertools.cycle() repeats the pattern of the keys.  itertools.izip()
> combines two iterables into one.  Then you just loop through that one in the
> usual way, where byte0 comes from the packed_data, and byte1 comes from the
> XorKey.
>
> DaveA
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pack as HEX question

2009-10-24 Thread Tom Green
Thanks for your reply Dave.  I am capturing the data off the network
(wireshark) and saving it in WinHex for testing.  I am actually building a
socket to decrypt the data, so prior to implementing my logic in the socket,
I figured I would write the algorithm in a quick script.  Here is what I
have so far and it works.

import struct,binascii
decrypt=[]
data_count=0
key_pos=0
#packed data consists of HEX values
packed_data = binascii.unhexlify('313B372C2E2C63362E2128')
#XorKey data consists of HEX values
packed_XorKey=binascii.unhexlify('41424344')
while data_count < len(packed_data):
if key_pos >len(packed_XorKey)-1:
key_pos=0

decrypt.append(chr(ord(packed_data[data_count])^ord(packed_XorKey[key_pos])))
key_pos+=1
data_count+=1
print "".join(decrypt)

This decrypts to Python rock

This logic seems to work, but I am certain there is a better way.

Mike


On Sat, Oct 24, 2009 at 4:43 PM, Dave Angel  wrote:

> Tom Green wrote:
>
>> Alan,
>>
>> Thanks for your response and hopefully I can clear things up.  I apologize
>> for not being more clear.
>>
>> I obtain the HEX encoded data from Winhex i.e. copy Hex values.  The HEX
>> encode data is very large and I simply paste it into my Python script
>> along
>> with the XOR key.  The data is a string of bytes represented in HEX, as I
>> showed.
>>
>> Here is the problem I ran into.
>>
>> Take the 4 byte XOR key.  If I convert them to int with Base 16 it takes
>> the
>> 4 and converts it to 0x34 when I in turn I actually need 0x41.
>>
>> Thanks for your feedback.
>>
>> Mike
>>
>> On Sat, Oct 24, 2009 at 10:24 AM, Alan Gauld > >wrote:
>>
>> 
>>
>>>
>>>  Encrypted string in hex
>>>
>>>
>>>> "313B372C2E2C63362E2128"
>>>>
>>>> Four byte key
>>>> XOR key "41424344"
>>>>
>>>>
>>>>
>>> 
>>>
>> If by Winhex, you mean the hex editor, then you're undoubtedly going about
> it the long way.  There's no need to convert the file to printable hex, you
> should be able to work on it directly.  Just open the file, read it into a
> string (in python2.x), then loop through it, one byte at a time.  Store your
> key in a binary string as well.  Now just loop through the two in pairs (use
> zip, and cycle) doing a chr of xor of ords.
>
>
> And when you respond, give us your python version, and show us the code
> you've got (almost) working.
>
> DaveA
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pack as HEX question

2009-10-24 Thread Tom Green
This is what I have so far,

import struct

EncryptString="313B372C2E2C63362E2128"
XorKey="41424344"
key = struct.unpack("d", XorKey)
num_ints = len(EncryptString)/11
data = struct.unpack("%dd"% num_ints,EncryptString)

The above code generates an error the my string must be a string length of
16

When you say I need to determine the number of ints in my data i.e.
EncryptString that value would be 11 right?

I appreciate your help.

Mike.

On Sat, Oct 24, 2009 at 2:41 PM, ALAN GAULD wrote:

> > Take the 4 byte XOR key.  If I convert them to int with Base 16
> >  it takes the 4 and converts it to 0x34 when I in turn I actually need
> 0x41.
>
> OK, thats because int is for converting strings. You need to use
> struct.unpack
> to convert the 4 bytes into an int.
>
> You also need to figure out how many ints you have in your data and
> construct a format string with that many ints to struct unpack the data.
>
> Them apply the xor to each int using the key
>
> something like
>
> key = struct.unpack("d", keydata)
> num_ints = len(raw_data)/len(int)
> data = struct.unpack("%dd" % num_ints, raw_data)
>
> result = [n^key for n in data]
>
> (untested pseudo code!)
>
> HTH,
>
> Alan G.
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pack as HEX question

2009-10-24 Thread Tom Green
Alan,

Thanks for your response and hopefully I can clear things up.  I apologize
for not being more clear.

I obtain the HEX encoded data from Winhex i.e. copy Hex values.  The HEX
encode data is very large and I simply paste it into my Python script along
with the XOR key.  The data is a string of bytes represented in HEX, as I
showed.

Here is the problem I ran into.

Take the 4 byte XOR key.  If I convert them to int with Base 16 it takes the
4 and converts it to 0x34 when I in turn I actually need 0x41.

Thanks for your feedback.

Mike

On Sat, Oct 24, 2009 at 10:24 AM, Alan Gauld wrote:

>
> "Tom Green"  wrote
>
>
>  wondering if there was someway in Python to indicate that the string is a
>> string of HEX values similar to Perl's pack.
>>
>
> You need to be very careful in your terminology here.
>
> Is it "a string of hex values" ie a string representation of a hex
> value or is it a string of bytes which can be represented in hex
> as you showed? The two and their processing are entirely different!
>
>
>  Encrypted string in hex
>> "313B372C2E2C63362E2128"
>>
>> Four byte key
>> XOR key "41424344"
>>
>
>
> Assuming the data really is binary data represented by the hex
> value you display above then you can use the struct module to
> unpack the values into integers directly.
>
> If it is a string of characters representing hex values then you can use
> the int() function to convert them by providing a base argument of 16..
>
>
>  I have done this numerous times, but I wanted to throw it out there as I
>> know there must be a easier way.  I am using Python 2.5.2
>>
>
> There is almost certainly an easier way but which way we
> that is cannot tell for sure from the information given.
>
> HTH,
>
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Pack as HEX question

2009-10-24 Thread Tom Green
Hello everyone,

First, I wanted to thank everyone in advance for your help and any feedback
is appreciated.  Here is what I am trying to accomplish:

I have this encrypted data that was sent across the network.  The decryption
is a simple XOR with a 16 byte key.  I started writing a basic Python script
that would decrypt the traffic by XORing each byte with the XOR key.  I was
wondering if there was someway in Python to indicate that the string is a
string of HEX values similar to Perl's pack.

For example:

Encrypted string in hex
"313B372C2E2C63362E2128"

Four byte key
XOR key "41424344"

Is there any way to tell Python that the encrypted string and XOR key is
HEX? This way I can XOR each byte without having to either place a \x
between every two characters.  I realize I need to convert everything to an
integer first.

I have done this numerous times, but I wanted to throw it out there as I
know there must be a easier way.  I am using Python 2.5.2

Thank you,
Mike
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Conversion question

2009-06-16 Thread Tom Green
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.  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. anks
>
>
>
>
>1. # convert a decimal (denary, base 10) integer to a binary string (base 
> 2)
>
>2. # tested with Python24   vegaseat6/1/2005
>3.
>4. def Denary2Binary(n):
>
>5. '''convert denary integer n to binary string bStr'''
>6.
>bStr = ''
>7. if n < 0:  raise ValueError, "must be a positive integer"
>
>8. if n == 0: return '0'
>9. while n > 0:
>
>10. bStr = str(n % 2) + bStr
>11. n = n >> 1
>
>12. return bStr
>13.
>14. def int2bin(n, count=24):
>
>15. """returns the binary of integer n, using count number of digits"""
>16. return "".join([str((n >> y) & 1) for y in range(count-1, -1, -1)])
>
>17.
>18. # this test runs when used as a standalone program, but not as an 
> imported module
>19.
># let's say you save this module as den2bin.py and use it in another 
> program
>20. # when you import den2bin the __name__ namespace would now be  den2bin 
>  and the
>
>21. # test would be ignored
>22. if __name__ == '__main__':
>23. print Denary2Binary(255)  # 
>24.
>
>25. # convert back to test it
>26. print int(Denary2Binary(255), 2)  # 255
>
>27.
>28. print
>29.
>30. # this version formats the binary
>
>31. print int2bin(255, 12)  # 
>
>32. # test it
>33. print int("", 2)  # 255
>
>34.
>35. print
>36.
>37. # check the exceptions
>
>38. print Denary2Binary(0)
>39. print Denary2Binary(-5)  # should give a ValueError
>
>
> from http://www.daniweb.com/code/snippet285.html#
>
> HTH,
> Wayne
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Conversion question

2009-06-16 Thread Tom Green
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 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 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] Best Python Editor

2009-06-15 Thread Tom Green
This has been a great discussion and when I first entered college I was
required to take Pascal.  At that time we used Turbo Pascal IDE--if you want
to call it an IDE.  As with anything technology advances and we have new
tools for the job and I became spoiled once Visual Studio hit the market.  I
really can't see doing any large project without a full blown IDE.  Yes, vim
or any text editor is suitable for Python, but I prefer having a nice GUI
interface while coding.  I mean the automobile replaced the horse and buggy,
while they both get you to your destination I would still rather travel in a
car.

Regards,
T.Green

On Mon, Jun 15, 2009 at 2:00 AM, Lie Ryan  wrote:

> Michael Powe wrote:
>
> > It's good to see so much common sense prevailing on this topic.
>
> It's good that this newsgroup is not as prevalent to being flamed. In
> certain other newsgroup, even (an honest and naive) mentioning of
> preferred editor would turn the thread into World War E.
>
> > An
> > IDE such as eclipse or VS really only becomes a necessity for
> > productivity when (a) you are dealing with multiple code files and
> > proper compilation and linking and so forth becomes complicated; or
>
> People that write in text editors often uses makefiles to handle that.
> However, in python, there is nothing much to be done with multiple file
> handling. Python's import mechanism just works like magic...
>
> > Most often, simply the ability to jump to the error line is provided
> > and I suppose that must be generally acceptable.
>
> vim does.
>
> ___
> 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] Best Python Editor

2009-06-14 Thread Tom Green
Since VIM seems to be the editor of choice and I have been programming in
Python for many years using Pyscripter and Eclipse I was wondering how I
could transition away from the IDE world to VIM.  My main issue is how do I
go about using VIM to debug my code?  With Pyscripter and other IDES its as
simple as placing a breakpoint and pressing F7 to step thru the code and you
have the ability to see the variable values etc.  Also, with an IDE such as
Pyscripter when calling a function a nice balloon hint appears showing you
the number of parameters and their types.  Coming from a Visual Studio
background this is great, as I might be calling a function or method and I
don't know off hand the values.  Maybe someone could share how they go about
programming a good size program with VIM as I would like to use it.  Don't
get me wrong for quick programs I will use VIM or notepad, but when it comes
to building a OOP program I find Eclipse or Pyscripter much easier to use.

Regards,
T. Green

On Sun, Jun 14, 2009 at 12:54 AM, 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
> 5.1 and after messing around with these, I think I prefer PyScripter
> and will use that for the mean time.
>
> I'll also take a look at VIM as being able to use the same program for
> PHP/CSS/HTML (and Basic if it supports it) as well as hopefully Python
> (I've only just started learning it) would be an advantage.
>
> Thanks guys
> Eddie
>
> 2009/6/14 Mike Hoy :
> >>
> >>
> >> I really like using F5 to run my code, so you can put in your .vimrc so
> >> you don't have to type it, or just type it every time:
> >>
> >> map  :!python %
> >>
> >> and every time you hit  it will run your current script.
> >>
> > Thanks for that. It's even better than typing :!python % because it
> doesn't
> > spawn a shell separate from the Vim window.
> >
> > ___
> > 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


Re: [Tutor] Best Python Editor

2009-06-13 Thread Tom Green
For Windows check out PyScripter.  Its IDE is similar to Borland Delphi and
I find it very easy to use.  Whatever works for you would be "best" for
you.  PyScripter is FREE and I would highly recommend it for people who are
new to Python or people with programming experience that are used to
programming in a IDE.

Regards,
T. Green


On Sat, Jun 13, 2009 at 6:52 AM, Dave Angel  wrote:

> Eddie  wrote:
>
>  Hi guys,
>>
>> What would you regard as the best free Python editor to use on Windows
>> for a new guy? Searching Google i see that there is quite a few out
>> there and is "VIM" the best one to go with?
>>
>> Regards
>> Eddie
>>
>>
>>
> This is such a common question on the python forums it ought to be in a
> FAQ, and maybe it is.
>
> VI and EMACS are the two "standard" Unix editors, going back decades.
>  Somebody used to the flexibility of either of those two, who is now stuck
> on Windows, would naturally not want to give up any of the "customizability"
> of these.  And people have posted macros for each to automate some of the
> things you'd like for Python, such as auto-indent.  VIM is an editor in that
> heritage.
>
> Somebody who's used Windows for 20 years, however, might expect that
> Ctrl-S, Ctrl-F4, Alt-F4, etc. have standard meanings.  So they might be more
> comfortable in an editor that starts with the Windows interface, and builds
> on it.   I use metapad for many things, though not for Python.  Others use
> Notepad++.
>
> Next question is whether you want an IDE.  The ability to single-step in
> the debugger, locate and fix a problem in source, and start again, in a
> single environment is appealing.  When I have a stack trace showing in the
> debugger, I can use the debugger to locate the source at any level of that
> stack without having to explicitly load the file and jump to the specified
> line number.  And no risk that the same file is already loaded into some
> other editor and I'm going to lose changes if some are made one place and
> some another.  And of course, it's nice to have a locals window, a globals
> window, a watch window, ...
>
> People that do not like an IDE cite the advantage of using a single editor
> for several programming languages, for word processing, and for web design.
>  If such an editor is highly programmable, that would seem very good as
> well.
>
> So then it comes down to opinion.  I use the (not-free) Komodo IDE.  There
> is a free Komodo-Edit with most of the same features, but I really don't
> know what subset it includes.  It is programmable with many canned add-ins,
> or you can customize it yourself with recorded macros and with scripts in
> Python or (I think) Javascript.  Its addin technology is related somehow to
> Firefox, and I think it used a lot of the Mozilla code in its engine.  The
> default UI is very familiar to people with Windows experience, though I
> don't know how it works on Mac and Linux
>
> http://www.activestate.com/komodo/Komodo IDE
> http://www.activestate.com/komodo_edit/   opensource Komodo Edit
> http://www.activestate.com/komodo_edit/comparison/comparison between
> the two
>
>
>
>
> ___
> 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] Conversion question

2009-05-05 Thread Tom Green
Thanks everyone for your replies.  This reason for the long string is
sometimes I have to pass a 32 byte key (MD5 hash value) to the socket.  The
data I am sending is the hex values i.e. 41=A.  I believe the binascii will
work.

Mike

On Mon, May 4, 2009 at 7:52 PM, Alan Gauld wrote:

>
> "Tom Green"  wrote
>
>  Here is my question.  I work with a lot of sockets and most of them
>> require
>> hex data.  I am usually given a string of data to send to the socket.
>> Example:
>>
>> "414243440d0a"
>>
>> Is there a way in Python to say this is a string of HEX characters like
>> Perl's pack?  Right now I have to take the string and add a \x to every
>> two
>> values i.e. \x41\x42...
>>
>
> Assuming you actually want to send the hex values rather than
> a hex string representation then the way I'd send that would be
> to convert that to a number using int() then transmit it using
> struct()
>
>  Sometimes my string values are 99+ bytes in length.  I did write a parsing
>> program that would basically loop thru the string and insert the \x, but I
>> was wondering if there was another or better way.
>>
>
> OK, Maybe you do want to send the hex representation rather than
> the actual data (I can't think why unless you have a very strange
> parser at the other end). In that case I think you do need  to insert
> the \x characters.
>
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
> ___
> 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] Conversion question

2009-05-04 Thread Tom Green
Thank you, I didn't realize it was that easy.  I tried binascii before and I
thought it didn't work properly.

I appreciate it.

Mike.

On Mon, May 4, 2009 at 7:40 PM, Emile van Sebille  wrote:

> On 5/4/2009 4:17 PM Tom Green said...
>
>> First, thanks in advance for any insight on how to assist in making me a
>> better Python programmer.
>>
>> Here is my question.  I work with a lot of sockets and most of them
>> require hex data.  I am usually given a string of data to send to the
>> socket.  Example:
>>
>> "414243440d0a"
>>
>> Is there a way in Python to say this is a string of HEX characters like
>> Perl's pack?  Right now I have to take the string and add a \x to every two
>> values i.e. \x41\x42...
>>
>
>
> import binascii
> binascii.a2b_hex('41424344')
>
> Emile
>
> ___
> 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] Conversion question

2009-05-04 Thread Tom Green
First, thanks in advance for any insight on how to assist in making me a
better Python programmer.

Here is my question.  I work with a lot of sockets and most of them require
hex data.  I am usually given a string of data to send to the socket.
Example:

"414243440d0a"

Is there a way in Python to say this is a string of HEX characters like
Perl's pack?  Right now I have to take the string and add a \x to every two
values i.e. \x41\x42...

Sometimes my string values are 99+ bytes in length.  I did write a parsing
program that would basically loop thru the string and insert the \x, but I
was wondering if there was another or better way.

Again, thanks in advance for any feedback.

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


Re: [Tutor] WINSOCK stdin question

2009-02-06 Thread Tom Green
The Python app is on the Server side. Sorry, I don't mean to cause hassle
for anyone.  I appreciate everyone's assistance.

I am trying to reproduce what Netcat does.

Thanks,
Mike

On Fri, Feb 6, 2009 at 9:19 PM, Kent Johnson  wrote:

> On Fri, Feb 6, 2009 at 3:52 PM, Tom Green  wrote:
> > Hello Python group,
> >
> > I need some advice on a problem I am facing.  Basically I have a binary
> that
> > sends out a reverse shell (CMD prompt).  I have a listening Python socket
> > and I would like to know how I can redirect the CMD prompt to stdin, so I
> > can interact with the host that is sending the shell.  Basically this is
> a
> > reverse shell.  Any tips is much appreciated.
>
> Like Alan, I never heard of reverse shell before. With a little
> googling I think I understand it but I don't understand your question.
> Is the python program on the client (user) side or the server side?
>
> Kent
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] WINSOCK stdin question

2009-02-06 Thread Tom Green
Hello Python group,

I need some advice on a problem I am facing.  Basically I have a binary that
sends out a reverse shell (CMD prompt).  I have a listening Python socket
and I would like to know how I can redirect the CMD prompt to stdin, so I
can interact with the host that is sending the shell.  Basically this is a
reverse shell.  Any tips is much appreciated.

Thank you,
Tom
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Adding Lists?

2008-08-23 Thread Tom Wakelam
Hi, hope i've got the email right, and you can help

If i have a list of integers, could i then total up the list?

e.g.

range (1, 5) gives [1, 2, 3, 4]  which is easily totalled at 10, 

yet if i wrote range (1, 500, 2) [1, 3, 5, 7... ..499] is there a command 
where i could total that list quickly?

Many thanks, Tom

_
Make a mini you on Windows Live Messenger!
http://clk.atdmt.com/UKM/go/107571437/direct/01/___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] IDE

2008-06-11 Thread Tom
I use PythonWin and find the Interactive Python Window invaluable.
Does anyone know which of the IDE's mentioned above have a similar
feature. (I'm on Vista,sorry!)

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


Re: [Tutor] How to get a script to open a text file with Python?

2008-06-11 Thread Tom
Or this can open most things:

import webbrowser
webbrowser.open_new('file///' + filename)

On 11/06/2008, Alan Gauld <[EMAIL PROTECTED]> wrote:
>
>  "Terry Carroll" <[EMAIL PROTECTED]> wrote
>
>
> >
> > > If TextPad is your default txt editor just use
> > > os.system("foo.txt")
> > >
> >
> > or os.startfile("foo.txt"); sounds like the equivalent, but for some
> > reason, I prefer it.
> >
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 <[EMAIL PROTECTED]>
wrote:

> Can I get list of supported platform by python?
>
> can I install python on AS/400 and HP-Unix?
>
> Regards
> Amit
>
> ___
> 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] Creating Sudoku

2008-04-06 Thread Tom Haynes
G’day, 

 

I am trying to create a simple Sudoku game that takes a simple raw_input of
a, r, c or something similar (where a = row, r = column, c = number to place
there) and place it in a Sudoku game square. I have tried many times to
start it from different angles and just can’t do it. If someone could help
step me through what needs to be done that would be greatly appreciated!

 

Thanks,

Tom 


No virus found in this outgoing message.
Checked by AVG. 
Version: 7.5.519 / Virus Database: 269.22.8/1362 - Release Date: 6/04/2008
11:12 AM
 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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.stat(/path)[WXYZ}, and os.path.getsize, but they are lacking.

Thanks for the help,

Tom
___
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 + ' Aeris'
>>> print x
Elis Aeris



On Fri, Mar 21, 2008 at 8:04 PM, elis aeris <[EMAIL PROTECTED]> wrote:

> how do I append to the end of strings?
>
> ___
> 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] 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
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 of my
head might be name resolution, network failure, either system being offline,
crond problems on originating system, /var/lib filesystem full on host77,
etc.  I would continue to brainstorm other possible causes and think of ways
to check for it in your script. For example, perform a name resolution check
on host77. If resolvable, proceed to ping check method.   Good luck.


On Fri, Mar 21, 2008 at 3:08 AM, Kaushal Shriyan <[EMAIL PROTECTED]>
wrote:

> Hi
>
> [EMAIL PROTECTED]
> 0 18 * * * rsync -av /var/lib/mysql [EMAIL PROTECTED]:/var/lib/
>
> If i put this two lines in crontab it will run correctly,My requirement
> was to create a python script, this python script should indicate success or
> failures and the reason for failure
>
> Any ideas
>
> Thanks and Regards
>
> Kaushal
> ___
> 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] rss feed reader, but having trouble with unicode

2008-02-28 Thread Tom
Yeah I was considering using that. Thanks for the tip.

On 28/02/2008, Michael Langford <[EMAIL PROTECTED]> wrote:
> feedparser.org also works really well for this sort of thing. Does a
>  lot of the unicode automagically for you.
>
>--michael
>
>
>  On Wed, Feb 27, 2008 at 8:58 AM, Tom <[EMAIL PROTECTED]> wrote:
>  > Finally got it working. I used your suggestion Rui, but I also had to
>  >  change the charset encoding that my database was using. Changed from
>  >  Latin-1 to UCS2.
>  >
>  >  I read http://www.joelonsoftware.com/articles/Unicode.html too.
>  >  Essential reading.
>  >
>  >  Thanks.
>  >
>  >
>  >
>  >  On 26/02/2008, rui <[EMAIL PROTECTED]> wrote:
>  >  > Hello Tom,
>  >  >
>  >  >  Try doing this:
>  >  >
>  >  >  xml = unicode(xml, encoding, "ignore")
>  >  >  elem = ElementTree.fromstring(xml.encode("utf8"))
>  >  >
>  >  >
>  >  >  >  #do stuff with elem...
>  >  >  >
>  >  >  >  feed.xml = xml
>  >  >  >  feed.save()
>  >  >  >
>  >  >  >
>  >  >  >  Thanks for your time :-)
>  >  >
>  >  > >  ___
>  >  >  >  Tutor maillist  -  Tutor@python.org
>  >  >  >  http://mail.python.org/mailman/listinfo/tutor
>  >  >  >
>  >  >
>  >  >
>  >  >
>  >  >  --
>  >  >  Rui
>  >  >  http://ruivaldo.wordpress.com
>  >  >
>  >  >  "Rubi? Aquela novela do SBT?"
>  >  > ~ Carla Perez sobre Ruby
>  >  >
>  >  >  "Em Python, tudo é objeto, além de lindo e maravilhoso."
>  >  > ~ Caetano Veloso sobre Python
>  >  >
>  >  ___
>  >  Tutor maillist  -  Tutor@python.org
>  >  http://mail.python.org/mailman/listinfo/tutor
>  >
>
>
>
>  --
>
> Michael Langford
>  Phone: 404-386-0495
>  Consulting: http://www.RowdyLabs.com
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] SSH with Python

2008-02-27 Thread Tom
I have a webfaction server (highly recommended btw) and I'm trying to
use automate some tasks over ssh but I'm not having much luck with
pyssh http://pyssh.sourceforge.net/ .

Some of the docs mention methods that don't exist in the version I
downloaded, such as pyssh.run.

I'm using windows vista (work pc). Any ideas?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] rss feed reader, but having trouble with unicode

2008-02-27 Thread Tom
Finally got it working. I used your suggestion Rui, but I also had to
change the charset encoding that my database was using. Changed from
Latin-1 to UCS2.

I read http://www.joelonsoftware.com/articles/Unicode.html too.
Essential reading.

Thanks.

On 26/02/2008, rui <[EMAIL PROTECTED]> wrote:
> Hello Tom,
>
>  Try doing this:
>
>  xml = unicode(xml, encoding, "ignore")
>  elem = ElementTree.fromstring(xml.encode("utf8"))
>
>
>  >  #do stuff with elem...
>  >
>  >  feed.xml = xml
>  >  feed.save()
>  >
>  >
>  >  Thanks for your time :-)
>
> >  ___
>  >  Tutor maillist  -  Tutor@python.org
>  >  http://mail.python.org/mailman/listinfo/tutor
>  >
>
>
>
>  --
>  Rui
>  http://ruivaldo.wordpress.com
>
>  "Rubi? Aquela novela do SBT?"
> ~ Carla Perez sobre Ruby
>
>  "Em Python, tudo é objeto, além de lindo e maravilhoso."
> ~ Caetano Veloso sobre Python
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] rss feed reader, but having trouble with unicode

2008-02-26 Thread Tom
I'm trying to write a little rss feed reader, but having trouble with
unicode. I would appreciate some help as I feel I'm going round in
circles.

Even when the save command works, ElementTree won't or vice-versa. You
can see what I've been trying from my commented out lines. I think
there is a problem with my understanding of unicode, so feel free to
enlighten me. What encoding is the xml string before I do anything?
Does my approach below make any sense???

import urllib, re, os, sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'djsite.settings'
from djsite.djapp.models import Feed
from xml.etree import ElementTree

url = 'http://www.osirra.com/rss/rss20/1'
#'http://www.michaelmoore.com/rss/mikeinthenews.xml'
#'http://www.michaelmoore.com/rss/mustread.xml'

f = urllib.urlopen(url)
xml = f.read()
f.close()

feed = Feed.objects.get(url=url)

if xml:
ms = re.findall('\<\?xml version\=\"[^"]+\" encoding\=\"([^"]+)\"\?\>', xml)
if ms:
encoding = ms[0]
else:
encoding = 'utf-8'
print 'using encoding:', encoding

#xml = xml.encode(encoding, 'replace')
##xml = xml.decode(encoding, 'replace')
#xml = unicode(xml, encoding)
#xml = unicode(xml)

elem = ElementTree.fromstring(xml)
#do stuff with elem...

feed.xml = xml
feed.save()


Thanks for your time :-)
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Little subclass understanding problem

2007-11-15 Thread Tom
I am trying to understand what happens in the following scenario:

class Sub_class(Base_class):
def __init__(self, data):
Base_class.__init__(self, data)

as in:

# snippet from http://viner.tv/go?set
class Set(list):
def __init__(self, value = []):
list.__init__([])


The last line is the one I don't understand. Nothing appears to be
assigned or instantiated.

I have just re-read the relevant part of Wesley Chun's 'Core' book,
again, and think I *may* understand.

Base_class.__init__(self, data)

is *kind of* like saying:

self.Base_class.__init__(data)

i.e. it's doing something *to* self. But then the 2nd example above
doesn't make sense! It looks like list.__init__([]) is doing something
special just because of where it is, i.e. in the class definition of a
subclass of list.

Help!

If anyone has a better way of explaining this / thinking about this, I
would be most grateful!
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] making a typing speed tester

2007-11-07 Thread Tom
Hi, I asked this question last year but got no response.

I'm trying to write a program to test someones typing speed and show
them their mistakes. However I'm getting weird results when looking
for the differences in longer (than 100 chars) strings:

import difflib

# a tape measure string (just makes it easier to locate a given index)
a = 
'1-3-5-7-9-12-15-18-21-24-27-30-33-36-39-42-45-48-51-54-57-60-63-66-69-72-75-78-81-84-87-90-93-96-99-103-107-111-115-119-123-127-131-135-139-143-147-151-155-159-163-167-171-175-179-183-187-191-195--200'

# now with a few mistakes
b = 
'1-3-5-7-l-12-15-18-21-24-27-30-33-36-39o42-45-48-51-54-57-60-63-66-69-72-75-78-81-84-8k-90-93-96-9l-103-107-111-115-119-12b-1v7-131-135-139-143-147-151-m55-159-163-167-a71-175j179-183-187-191-195--200'

s = difflib.SequenceMatcher(None, a ,b)
ms = s.get_matching_blocks()

print ms

>>>[(0, 0, 8), (200, 200, 0)]

Have I made a mistake or is this function designed to give up when the
input strings get too long? If so what could I use instead to compute
the mistakes in a typed text?

Thanks in advance,
Thomas
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] difflib.SequenceMatcher with get_matching_blocks is incorrect

2007-11-05 Thread Tom
Hi, I asked this question last year but got no response.

I'm trying to write a program to test someone's typing speed and show
them their mistakes. However I'm getting weird results when looking
for the differences in longer (than 100 chars) strings:

import difflib

# a tape measure string (just makes it easier to locate a given index)
a = 
'1-3-5-7-9-12-15-18-21-24-27-30-33-36-39-42-45-48-51-54-57-60-63-66-69-72-75-78-81-84-87-90-93-96-99-103-107-111-115-119-123-127-131-135-139-143-147-151-155-159-163-167-171-175-179-183-187-191-195--200'

# now with a few mistakes
b = 
'1-3-5-7-l-12-15-18-21-24-27-30-33-36-39o42-45-48-51-54-57-60-63-66-69-72-75-78-81-84-8k-90-93-96-9l-103-107-111-115-119-12b-1v7-131-135-139-143-147-151-m55-159-163-167-a71-175j179-183-187-191-195--200'

s = difflib.SequenceMatcher(None, a ,b)
ms = s.get_matching_blocks()

print ms


>>>[(0, 0, 8), (200, 200, 0)]


Have I made a mistake or is this function designed to give up when the
input strings get too long? If so what could I use instead to compute
the mistakes in a typed text.

Thanks in advance,
Thomas
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] I need an 'atomic read/ write action'

2007-11-04 Thread Tom
Thank you for your replies.I think lockfile is a good solution.

Kent, I have python 2.2.3 running on my server (not my choice) could you
tell me which module(s) I could use to access cron. Otherwise the only other
relavent way I can access my sever is Secure Shell Access (SSH). And what
about for my desktop computer (Vista Task Scheduler looks fancy but doesn't
seem to work so well for me) which uses python 2.5?

Thanks again. - Hide quoted text -


On 05/11/2007, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Tom wrote:
> > So all my ideas for how to record task x as 'done', like using shelve
> > or writing a log file etc are not sufficient because, I need an 'atomic
> > read/ write action' (I think that's the jargon).
>
> A couple of ideas:
> - Michael's file lock
> - lockfile is another way to lock files
> http://pypi.python.org/pypi/lockfile/0.1
>
> - you could put the tasks in a database that supports transactions
> - you could run the scheduler as a single cron task rather than
> opportunistically when a user makes a request.
> - you could just use cron as your scheduler directly
>
> Kent
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] I need an 'atomic read/ write action'

2007-11-04 Thread Tom
Hi,

I am trying to write a cron/ task scheduler like system for my website. The
users of my site and also more than one external rss feed reader request my
scripts regularly and I'd like to insert code in each script that
will decide whether to run a scheduled task or not.

It would go something like this:


for task in tasks:
if current_time inside relevant time range for task:
if task not already done:
record that task has been done
do task


Now the problem is that this script could possibly be called more than once
simultaneously! Having studied 'concurrent programming' I understand the
possibility of the following pathological example:

call 1: if task not already done:
call 2: if task not already done:
call 1: record that task x has been done
 call 2: record that task x has been done
 call 1: do task x
 call 2: do task x #AGAIN

now we have the task recorded done twice and carried out twice.

So all my ideas for how to record task x as 'done', like using shelve
or writing a log file etc are not sufficient because, I need an 'atomic
read/ write action' (I think that's the jargon).

I thought about asking how to lock a log file so that it couldn't be
accessed simultaneously, but I then realise that you STILL have the problem
of the 'gap' between "sleep while log file locked" and "access log file". I
need something where the 'does the task need doing?' and the 'I'm going to
do the task. Please no one else do it!' are atomic(?) and leave no room for
mischief in between.

Another problem is that the task may fail and need redoing, but I think I
can solve that given a solution to the above.

Do let me know if my question isn't clear.
Thanks in advance!
Tom
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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
functionality already.





On 10/28/07, John <[EMAIL PROTECTED]> wrote:
> Hello, I've written a little script with the intention of killing all of my
> bash, sshd sessions... is this dangerous? How could I make it work so that
> it didn't kill the session it was run from (as it is I suppose I have to run
> it with nohup):
>
>
>
> #!/usr/bin/env python
> import os
>
> cmd="ps -u myuser | grep 'bash' > .ps"
> os.system(cmd)
>
> pid=[]
> fid=open('.ps','r')
> for line in fid:
> pid.append(line.split(' ')[0])
>
> for i in pid:
> cmd="""kill -9 %s""" % (i)
> os.system(cmd)
>
>
> cmd="ps -u myuser | grep 'sshd' > .ps"
> os.system(cmd)
>
> pid=[]
> fid=open('.ps','r')
> for line in fid:
> pid.append(line.split(' ')[0])
>
> for i in pid:
> cmd="""kill -9 %s""" % (i)
> os.system(cmd)
>
> ___
> 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] 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 to take a
look at the sys.stdout object; it's a file object that corresponds to the
output we send to the user.

###
>>> import sys
>>> sys.stdout
', mode 'w' at 0x2a060>
###

As a file object, we can use the methods that files provide:

   http://www.python.org/doc/lib/bltin-file-objects.html

But the one we'll probably want is 'write()': the write() method of a file
object lets us send content out, without any adulteration:

##
>>> import sys
>>> for i in range(5):
... sys.stdout.write('hello' + str(i))
...
hello0hello1hello2hello3hello4
##


We might have to be a little bit more careful with write(), because unlike
the print statement, the write() method isn't magical, and won't
automatically try to coerse objects to strings.  The code above shows that
we str() each number, and for good reason.  If we try without it, we'll
get a TypeError:

##
>>> sys.stdout.write(42)
Traceback (most recent call last):
 File "", line 1, in ?
TypeError: argument 1 must be string or read-only character buffer, not
int
##

So it just means we'll have to be more aware about the type of a value
when we use write().


For some more information, see:

   http://www.python.org/doc/tut/node9.html#SECTION00920
   http://www.python.org/doc/tut/node9.html#SECTION00910


Please feel free to ask more questions.  Good luck!




On 9/25/07, Tim <[EMAIL PROTECTED]> wrote:
>
> Hello,
> I have a print statement where I use concatenation of variables with "+"
> to
> avoid extra whitespaces. The variables are mixed (float/int).
>
> How can I convert them all to strings to have a clean print statement?
>
> example
> print str(var1)+"and this "+str(var2)+"needs to check "+str(var3)
>
> how can I convert var1, var2, var3 all at once?
>
> This would avoid errors because of mixed data types.
>
> BTW, why does a statment like
> print var1, var2
> automatically add spaces between the variables?
>
> Thanks in advance for your help.
>
> Timmie
>
> ___
> 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] 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):
... print 'we have a match'
... else:
... print 'no match found'
...
no match found



On 9/16/07, 王超 <[EMAIL PROTECTED]> wrote:
> hi,
>
> I want to match the regular expression from right to left, such as:
>
> TAG_pattern = re.compile(r"(us::.*) .*(1002|1003).*$")
> TAG_pattern.search(line)
>
> Does the search method support this?
>
> Thanks,
> Daniel
>
> ___
> 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] 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 suppose i could also do this with a module, and create a new instance of
> whatever i want to pass it to,
> but all the same, how would i go about this. like if i had a program that
> i wanted to pass a number into.
>
> i am sure i do it with sys args, but don't know how.
>
> like
>
> python run_my_script.py somevar
>
> does this make sense ?
>
> The other way to do this is create a class i suppose that could be called.
> Should probably do it that way, but still, i would like to know.
>
> thanks.
>
> shawn
>
> ___
> 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] Tutor Digest, Vol 43, Issue 36

2007-09-12 Thread Tom Tucker
Comments below.

On 9/12/07, chinni <[EMAIL PROTECTED]> wrote:
>
> Hi,
> Thanx for Responding for the Query.
> The actual Output what i want is my python script has to change the
> version number(degrade) in plist file.and automatically change the time to
> 25 hrs more from present time cause my product will check for updates for
> every 25hrs.
> But u all told that cronjob and at inbuilt features of UNIX but every time
> ihave to manually go and change the version.i can't so that's why i want
> to write a script for this
>
> 1.open the app
>
   2.degrade the version automatically to least version
What is the manual process for this task?  More info is need here.  Is plist
a text file?

3.change the time to 25hrs more

Are we changing the system time 25 hours ahead, changing a time variable in
the script, or flag/timestamp in the plist file?


4.check for updates(1.force Update and silent update)

This is achievable with a system call.


5.the whole procedure is for admin and non-admin users

We change the unix file permission to restrict which user and groups are
allowed access to the file.


can i implement this by using both python and shell scripting.if possible
> give the reference book for quick learn.

>From what we know so far, yes.  Please share what you have coded so far.


Message: 2
> > Date: Tue, 11 Sep 2007 22:24:37 +0530
> > From: chinni <[EMAIL PROTECTED]>
> > Subject: [Tutor] automate daily tasks
> > To: tutor@python.org
> > Message-ID:
> > <[EMAIL PROTECTED]>
> > Content-Type: text/plain; charset="iso-8859-1"
> >
> > Hi all,
> >
> > I am working on MAC OS x my project is updating all ready installed
> > products.I have to automate this in python.so,can any one will give some
> > suggestions and some examples how to automate.some basic things of my
> > project is ... i think u all know that there will be a plist file for
> > each
> > product in mac.i have to degrade the version of plist automatically
> > through
> > my script and it has to edit the plist file and degrade it to least
> > version
> > and as to check for updates by itself.like this there are 15 products
> > under
> > this now each time i can't go and 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 --
> > An HTML attachment was scrubbed...
> > URL:
> > http://mail.python.org/pipermail/tutor/attachments/20070911/75c73c5e/attachment-0001.htm
> >
> > --
> >
> > Message: 3
> > Date: Tue, 11 Sep 2007 13:03:54 -0400
> > From: "Tom Tucker" < [EMAIL PROTECTED]>
> > Subject: Re: [Tutor] automate daily tasks
> > To: [EMAIL PROTECTED]
> > Cc: tutor@python.org
> > Message-ID:
> > <[EMAIL PROTECTED]>
> > Content-Type: text/plain; charset="iso-8859-1"
> >
> > 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 installed
> > > products.I have to automate this in python.so,can any one will give
> > some
> > > suggestions and some examples how to automate.some basic things of my
> > > project is ... i think u all know that there will be a plist file for
> > each
> > > product in mac.i have to degrade the version of plist automatically
> > > through my script and it has to edit the plist file and degrade it to
> > least
> > > version and as to check for updates by itself.like this there are 15
> > > products under this now each time i can't go and 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,
> > >
> > >
> > > ___
> > > Tutor maillist  -  Tutor@python.org
> > > http://mail.python.org/mailman/listinfo/tutor
> > >
> > >
> > -- next part --
> > An HTML attachment was scrubbed...
> > URL: 
> > http://mail.python.org/

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 installed
> products.I have to automate this in python.so,can any one will give some
> suggestions and some examples how to automate.some basic things of my
> project is ... i think u all know that there will be a plist file for each
> product in mac.i have to degrade the version of plist automatically
> through my script and it has to edit the plist file and degrade it to least
> version and as to check for updates by itself.like this there are 15
> products under this now each time i can't go and 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,
>
>
> ___
> 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] Question re Tutor List Etiquette

2007-08-14 Thread Tom Fitzhenry
On Tue, Aug 14, 2007 at 11:06:05AM -0700, Dick Moores wrote:
> Replying only to the list takes a bit of trouble. The default 
> behavior seems to be that the "Reply" button addresses the author 
> only and not the list; "Reply to all" addresses both the list, the 
> author, and any others included in the To: or Cc: headers of the post 
> being replied to. Or at least that's how Eudora and Gmail work.
> 
> Ten years ago or so I managed a Majordomo list, and I recall that it 
> was possible for the list manager to configure the list to include a 
> "Reply-To" header. If this would be possible for the admins to do 
> with Tutor -- to include a "Reply-To: tutor@python.org" header in the 
> posts sent out by the list, it would enable us to address a reply 
> only to the list by hitting the "Reply" button.

Mutt can be configured to recognize which emails are from a mailing list and
provides a list-reply command which only replies to the list.
http://www.mutt.org/doc/manual/manual-3.html#ss3.9

I've read Thunderbird have been planning a list-reply button, but could only
find information on a plugin (and patch) which does this at the moment:
http://alumnit.ca/wiki/index.php?page=ReplyToListThunderbirdExtension#toc3

About other mail clients, I don't know.

Procmail can be configured to detect these duplicates and
filter/delete/forward/etc. them:
http://linuxbrit.co.uk/procmail/ (7th paragraph, "Now, here's a really useful
rule, ...")

I don't post that often so I don't get this that often, so it doesn't bother me
that much, but I could see how it'd be annoying to those who post frequently.

-- 
Tom Fitzhenry

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


Re: [Tutor] Simple way to compare Two lists

2007-08-10 Thread Tom Fitzhenry
On Fri, Aug 10, 2007 at 02:54:44AM -0700, Jaggo wrote:
> Can anyone think of any better way?

If SmallList and BigList are sorted (in order), there is a faster method:

def IsAPartOfList(SmallList,BigList):
for i in BigList:
for j in SmallList:
if i==j:
return true
if i>j:
break
return false

(I'm not sure how encouraged using break statements are, so wait for a tutor to
answer)

If one list is already sorted but the other isn't, it may still be faster to
sort the unsorted list then use the method above.

If neither SmallList or BigList are sorted, it's probably best to use your
original method, which I cannot improve.

-- 
Tom Fitzhenry

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


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","w")

f.write("yeahppe")

f.close()
___
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] 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 Agent LO 1
(0018,0012) Contrast/Bolus Agent Sequence SQ 1
(0018,0014) Contrast/Bolus Administration Route Sequence SQ 1
(0018,0015) Body Part Examined CS 1


Script
#
#!/usr/bin/python

import re

#matchstr regex flow
# (\(\d+,\d+\)) # (0018,0014)
# \s   # [space]
# (..*)# Contrast/Bolus Administration Route Sequence
# \s   # space
# ([a-z]{2}) # SQ - two letters and no more
# \s  # [space]
# (\d)# 1 - single digit
# re.I)   # case insensitive

matchstr = re.compile(r"(\(\d+,\d+\))\s(..*)\s([a-z]{2})\s(\d)",re.I)
myfile = open('/tmp/file','r')

for line in myfile.readlines():
   regex_match = matchstr.match(line)
   if regex_match:
   print regex_match.group(1) + ";" + regex_match.group(2) +
";" + regex_match.group(3) + ";" + regex_match.group(4)


Output
#
(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 Agent;LO;1
(0018,0012);Contrast/Bolus Agent Sequence;SQ;1
(0018,0014);Contrast/Bolus Administration Route Sequence;SQ;1
(0018,0015);Body Part Examined;CS;1


On 6/27/07, Gardner, Dean <[EMAIL PROTECTED]> wrote:


 Hi

I have a text file that I would like to split up so that I can use it in
Excel to filter a certain field. However as it is a flat text file I need to
do some processing on it so that Excel can correctly import it.

File Example:
tag descVR  VM
(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 Agent LO 1
(0018,0012) Contrast/Bolus Agent Sequence SQ 1
(0018,0014) Contrast/Bolus Administration Route Sequence SQ 1
(0018,0015) Body Part Examined CS 1

What I essentially want is to use python to process this file to give me

(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 Agent; LO; 1
(0018,0012); Contrast/Bolus Agent Sequence; SQ ;1
(0018,0014); Contrast/Bolus Administration Route Sequence; SQ; 1
(0018,0015); Body Part Examined; CS; 1

so that I can import to excel using a delimiter.

This file is extremely long and all I essentially want to do is to break
it into it 'fields'

Now I suspect that regular expressions are the way to go but I have only
basic experience of using these and I have no idea what I should be doing.

Can anyone help.

Thanks

DISCLAIMER:
Unless indicated otherwise, the information contained in this message is
privileged and confidential, and is intended only for the use of the
addressee(s) named above and others who have been specifically authorized to
receive it. If you are not the intended recipient, you are hereby notified
that any dissemination, distribution or copying of this message and/or
attachments is strictly prohibited. The company accepts no liability for any
damage caused by any virus transmitted by this email. Furthermore, the
company does not warrant a proper and complete transmission of this
information, nor does it accept liability for any delays. If you have
received this message in error, please contact the sender and delete the
message. Thank you.

___
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] 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
4.5systems.



On 6/20/07, Richard Querin <[EMAIL PROTECTED]> wrote:


I'm interested in writing a quick script that would run a diff-type
command that would compare a local directory to a remote one to
identify the changes in the files within that directory.

I was initially thinking that I would maybe use the linux diff command
in conjunction with the wget command (or something similar) to create
a local copy but that involves downloading files. Is there any way in
python to do a similar thing but without having to download a copy of
the remote files/directories?

Any ideas?
___
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] 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://mail.python.org/mailman/listinfo/tutor

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


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-test
TestingSome2
something2-test
TestingSome3
something3-test
TestingSome4
something4-test



On 5/21/07, Andreas Kostyrka <[EMAIL PROTECTED]> wrote:


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Well, there are a number of ways to achieve this, but the classical one
would be:

"""abc%(i)s
def%(i)s
""" % dict(i=1)

Andreas

Chandrashekar wrote:
> Hi,
>
> I am trying to do something like this in python. Can you please help?
>
> handle= open('test.txt','a')
>
> handle.write('''
>
> Testsomething$i
>
> something$i-test
>
> '''
> )
>
> when i write into the file, i would like to have the output like this.
>
> Testsomething1
> something1-test
> Testsomething2
> something2-test
> Testsomething3
> something3-test
> ...
>
> I can perform the same using a loop. But how do i append i (1,2,..n)
> while i am writing into the file.(I mean inside the handle.write)
>
> Thanks,
> Chandru
>
> 
> Pinpoint customers
> <
http://us.rd.yahoo.com/evt=48250/*http://searchmarketing.yahoo.com/arp/sponsoredsearch_v9.php?o=US2226&cmp=Yahoo&ctv=AprNI&s=Y&s2=EM&b=50
>who
> are looking for what you sell.
>
>
> 
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGUVPtHJdudm4KnO0RAgZwAJ9XOamfWZHd1CXYGuLIlOP11p7PWwCgxPD7
UILsdZNbknZz4zq71EuvxSs=
=0y02
-END PGP SIGNATURE-
___
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] Continue Matching after First Match

2007-05-21 Thread Tom Tucker

Alan & Martin,

Thanks for the feedback and suggestions.  Kodos is a great tool.  I use it
regularly to debug my regex mistakes.  It can also be a excellent learning
tool to those unfamiliar with regular expressions.   Thanks for the
Python-LDAP link and ldif example code.

On 5/20/07, Martin 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 through the ouput
> collected.  Hmm.  Come to think of it, I guess I could match on the
> first "^dn" catpure that output and then keep looping until "^cn:" is
> seen. Then repeat.

Honestly, I'm not very good with regular expressions -- and try to avoid
them when possible. But in cases where they seem to be the best option,
I have formed a heavy dependence on regex debuggers like kodos.
http://kodos.sourceforge.net/




Kodos is an excellent regex tool.  I use it regularly to verify regex
strings.


Anyways, any suggestions to fix the below code?


Have you had a look at the python-ldap package?

http://python-ldap.sourceforge.net/




Thanks.  I  checked the Python module index page and

You could probably access ldap directly with python, if that's an

option. Or, you could roll your own ldif parser (but make sure your data
contains a newline between each dn, or the parser will choke with a
'ValueError: Two lines starting with dn: in one record.'):

import ldif
from cStringIO import StringIO

class MyLDIF(ldif.LDIFParser):
def __init__(self, inputfile):
ldif.LDIFParser.__init__(self, inputfile)
self.users = []

def handle(self, dn, entry):
self.users.append((entry['uid'], entry['cn']))

raw = """\

"""

if __name__ == '__main__':
io = StringIO(raw)
lp = MyLDIF(io)
lp.parse()
for user in lp.users:
uid = user[0][0]
cn = user[1][0]
print uid
print cn

... or ...

You could also use ldif.LDIFRecordList directly without creating a
custom parser class which would return a list of (dn, entry) tuples. The
module author warns that 'It can be a memory hog!', and I can imagine
this is true if you are working with a particularly large ldap directory.

io = StringIO(raw)
directory = ldif.LDIFRecordList(io)
directory.parse()
for dn, entry in directory.all_records:
print entry['uid'][0]
print entry['cn'][0]

___
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] 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 continue matching and printing until EOF.  Any
suggestions?

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.
Matching with a string seemed easier than looping through the ouput
collected.  Hmm.  Come to think of it, I guess I could match on the first
"^dn" catpure that output and then keep looping until "^cn:" is seen. Then
repeat.

Anyways, any suggestions to fix the below code?

Thanks for the help,



Code Snipet
###
multi_regex = re.compile(r'dn: uid=(\w+)..*cn: ((\w+ \w+)|(\w+ \w+\.
\w+))..*(?=dn:)', re.MULTILINE| re.DOTALL)
output = os.popen(command).readlines()
voutput = cStringIO.StringIO()
for line in output:
  voutput.write(line)
  contents = voutput.getvalue()  #<-- contents is 
match = re.search(multi_regex, contents)
if match:
print match.group(1)
print match.group(2)



Blue = is what the regex matches
Red = regex groups # match.group(#)
Green = next regex groups not being captured

INPUT Data
###
version: 1
dn: uid= jtucker,ou=people,dc=companyA,dc=com
host: hostA
host: hostB
host: hostC
description: other
gecos: John Tucker
gidNumber: 1
uidNumber: 1157
sn: Tucker
cn: John Tucker
uid: jtucker
objectClass: top
objectClass: account
objectClass: 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: Tucker
objectClass: top
objectClass: account
objectClass: person
objectClass: posixAccount
objectClass: shadowAccount
objectClass: inetorgperson
objectClass: organizationalPerson
uidNumber: 108
gidNumber: 102
gecos: Tom Tucker
homeDirectory: /home/ttucker
description: system


Current OUTPUT
#
jtucker
John Tucker


Desired OUTPUT
########
jtucker
John Tucker
ttucker
Tom Tucker



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


[Tutor] Continue Matching after First Match

2007-05-18 Thread Tom Tucker

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 continue matching and printing until EOF.  Any
suggestions?

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.  Matching
with a string seemed easier than looping through the ouput collected.  Hmm.
Come to think of it, I guess I could match on the first "^dn" catpure that
output and then keep looping until "^cn:" is seen. Then repeat.

Anyways, any suggestions to fix the below code?

Thanks for the help,



Code Snipet
###
multi_regex = re.compile(r'dn: uid=(\w+)..*cn: ((\w+ \w+)|(\w+ \w+\.
\w+))..*(?=dn:)', re.MULTILINE| re.DOTALL)
output = os.popen(command).readlines()
voutput = cStringIO.StringIO()
for line in output:
 voutput.write(line)
 contents = voutput.getvalue()  #<-- contents is 
match = re.search(multi_regex, contents)
if match:
   print match.group(1)
   print match.group(2)



Blue = is what the regex matches
Red = regex groups # match.group(#)
Green = next regex groups not being captured

INPUT Data
###
version: 1
dn: uid=jtucker,ou=people,dc=companyA,dc=com
host: hostA
host: hostB
host: hostC
description: other
gecos: John Tucker
gidNumber: 1
uidNumber: 1157
sn: Tucker
cn: John Tucker
uid: jtucker
objectClass: top
objectClass: account
objectClass: 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: Tucker
objectClass: top
objectClass: account
objectClass: person
objectClass: posixAccount
objectClass: shadowAccount
objectClass: inetorgperson
objectClass: organizationalPerson
uidNumber: 108
gidNumber: 102
gecos: Tom Tucker
homeDirectory: /home/ttucker
description: system


Current OUTPUT
#
jtucker
John Tucker


Desired OUTPUT
####
jtucker
John Tucker
ttucker
Tom Tucker
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 pointed out).  What REALLY
works is a graph.  I used a dictionary, the keys are main coordinates that
are a path that the .gif follows using a greedy algorithm that finds all
the
paths to a determined location.  The definition of the keys are all the
possible directions the .gif can go.  Not all paths are covered on
purpose.
In any case, here is the updated code, for those who asked me to post it.
I'm hoping to have it completed next week, without the gif of my dog (lol)
and a bad guy or two to follow the gif that will be used in the maze.

The next thing I have to do is bind an event to the arrow keys that will
update the current x and y position.. I haven't quite worked that out yet.
Right now the gif moves through the maze based on the path.  Now the event
(an keyboard arrow) should tell it to go to that direction at the next
turn.
The function that defines the move is called move_gif().  I could use some
ideas because I keep getting stuck on the details. How does the event
effect
the current course through the maze? Does it somehow update the current
call
to find_all_paths?
Or some sort of Helper function that interrupts the current path at a
vertex
giving it a new path?  That one seems most likely, but I'm still stuck on
how to stop at the vertex and move to the new location.  Any help would be
appreciated.

TYIA

T

___
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] version and path

2007-05-14 Thread Tom Tucker
If you let the command finish, you should have seen the following or
something equivalent below.  Running the find command I sent you
works, however you will see some noise (Permission Denied message).
These are common messages because your general user account is trying
to access restricted parts of the filesystem.  This is normal
behavior.

Here are some example files on my Mac system.

/usr/bin/python
/usr/bin/python2.3
/usr/bin/pythonw
/usr/bin/pythonw2.3
/usr/lib/python2.3

I'm assuming you are running a stock version of OS X and you have NOT
installed Python manually.  The typical Python path on my version OS X
(11.4) is /usr/bin/python. /usr/bin/python is a link to the actual
Python binary installed at /usr/bin/python2.3

For example...

>which python
/usr/bin/python

>ls -l /usr/bin/python
lrwxr-xr-x   1 root  wheel  9 Jan 17  2006 /usr/bin/python -> python2.3


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*"
> >
> >
> >
> > 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!
>
> That is what I got:
> find: /.Spotlight-V100: Permission denied
> find: /.Trashes: Permission denied
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 PROTECTED]> wrote:
> How exacly can you use python to create a web site? I have a small program
> I'm working on that I would like to create available via internet but I dont
> know how to make python work through internet.
>
>  
> Be a better Globetrotter. Get better travel answers from someone who knows.
> Yahoo! Answers - Check it out.
> ___
> 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] 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!
> ___
> 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] Multiple lines with the command line

2007-04-16 Thread Tom Tucker

Sorry, you mentioned you wanted to use the Unix mail program.

Is your information static? If yes, how bout this.
cmd = "mail -s 'my subject' [EMAIL PROTECTED] <[EMAIL PROTECTED]> <
/path/to/static_message"
os.system(cmd)

Similar approach could be to capture the users message body as command line
arguments, save them to a file, and then include them in the execution. Not
very sexy, but it will work.


example
##
~>/tmp/mail_wrapper.py  this is the body of my message
['this', 'is', 'the', 'body', '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.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 unix
>
> Mail [EMAIL PROTECTED] -f [EMAIL PROTECTED]
> Subject : hello alex
>
> #message part
> how is it going
>
> #the end of mail
> .
>
> When I write os.system("Mail [EMAIL PROTECTED]") my program will send
> email to where i want it to go
>
> MY PROBLEM is that i need to enter multiple lines of input into unix.
> os.system() takes only one argument
>
> thanks for the time
>
> ___
> 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] 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 unix

Mail [EMAIL PROTECTED] -f [EMAIL PROTECTED]
Subject : hello alex

#message part
how is it going

#the end of mail
.

When I write os.system("Mail [EMAIL PROTECTED]") my program will send email
to where i want it to go

MY PROBLEM is that i need to enter multiple lines of input into unix.
os.system() takes only one argument

thanks for the time

___
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] 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 example and sample log will make more
sense.
Thank you,


Logic:
--
1) Search for this string 'Writing Message to'
2) Search ahead for this string 'TRANSPORT_STREAM_ID'
3) Followed by a blank line
4) If 1,2, and 3:  increase a counter or something (counter +=1)
4) Repeat process


Example log

2006/10/24 20:46:05.853 Writing Message to 192.168.1.1:3211
Protocol:  2
Message Type:  PROVISION
Parameters:
Parameter type:  CHANNEL_IDParameter value:   0001
Parameter type:  SCG_IDParameter value:   0001
Parameter type:  TRANSPORT_STREAM_IDParameter value:   0160
Parameter type:  PROGRAM_NUMBERParameter value:   0001
Parameter type:  GROUPParameter value:   0009 0002
2006/10/24 20:46:05.957 Receiving message from 192.168.1.1:3211
2006/10/24 20:47:05.011 Writing Message to 192.168.1.2:3211
Protocol:  2
Message Type:  PROVISION
Parameters:
Parameter type:  CHANNEL_IDParameter value:   0001
Parameter type:  SCG_IDParameter value:   0001
Parameter type:  TRANSPORT_STREAM_IDParameter value:   0160

2006/10/24 20:47:05.057 Blah Blah..more logging
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Variable help

2006-10-08 Thread Tom R.
I have a number of arrays:

player1 = [data, data, data]
player2 = [data, data, data]
player3 = [data, data, data]
player4 = [data, data, data]

I want to be able to do something like:

count = 2
if player + count[3] == 5:
   do this
   do that
  count += 1

And that would do this and that to the array 'player2' in slot 3. It adds 1 
to 'count', so next time through it will access the array 'player3'. 
Basically I want to be able to integrate the value of one variable into 
another variables name. It's hard explain, hopefully the code above will 
give you an idea of what I'm trying to achieve.

Alternately, how can I use the return of a function as a variables name? eg:

def choose_player(player):
if player == 1:
return player1[3
if player == 2:
return player2[3]
if player == 3:
return player3[3]
if player == 4:
return player4[3]

choose_player(2) = 5

This was another way I thought of doing it - one that might actually work - 
but it comes back with "Can't assign to function call." I'm not trying to 
assign it to the function itself, but the outcome of the function. I can use 
it to read the value of the player2 variable (ie. if choose_player(2) == 5), 
but not set it.

Once again, I hope I've given an idea of what I'm trying to do. Any way I 
can achieve this?


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


[Tutor] Roack, Paper Scissors

2006-08-12 Thread Tom Wilson
could someone please explain to me how the scripts for the rock, paper, 
scissors game work because i'm not quite sure.


tom

_
Windows Live™ Messenger has arrived. Click here to download it for free! 
http://imagine-msn.com/messenger/launch80/?locale=en-gb


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


[Tutor] python

2006-08-09 Thread Tom Wilson
could someone explain to me how the "import" function works?

tom

_
The new Windows Live Toolbar helps you guard against viruses 
http://toolbar.live.com/?mkt=en-gb

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


Re: [Tutor] stfftime question

2006-07-04 Thread Tom Tucker
I found a temporary solution.  The goal in the end was to compare two
dates/times and  retrieve the millisecond delta between the two.

Work around
#
import datetime
import time
t1 = datetime.datetime(1973,9,4,04,3,25,453)
t2 = datetime.datetime(1973,9,4,04,3,25,553)
t1tuple = 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 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 (Apple Computer, Inc. build 1809)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import datetime
> >>> dtstr = datetime.datetime(1973,9,4,04,3,25,453)
> >>> output = dtstr.strftime('%s.%%03d') % (dtstr.microsecond)
> >>> print output
> 115977805.453
>
>
> From Work (Solaris)
> 
> Python 2.3.2 (#1, Nov 17 2003, 22:32:28)
> [GCC 2.95.3 20010315 (release)] on sunos5
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import datetime
> >>> dtstr = datetime.datetime(1973,9,4,04,3,25,453)
> >>> output = dtstr.strftime('%s.%%03d') % (dtstr.microsecond)
> Traceback (most recent call last):
>   File "", line 1, in ?
> TypeError: not enough arguments for format string
> >>>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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 (Apple Computer, Inc. build 1809)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> dtstr = datetime.datetime(1973,9,4,04,3,25,453)
>>> output = dtstr.strftime('%s.%%03d') % (dtstr.microsecond)
>>> print output
115977805.453


>From Work (Solaris)

Python 2.3.2 (#1, Nov 17 2003, 22:32:28)
[GCC 2.95.3 20010315 (release)] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> dtstr = datetime.datetime(1973,9,4,04,3,25,453)
>>> output = dtstr.strftime('%s.%%03d') % (dtstr.microsecond)
Traceback (most recent call last):
  File "", line 1, in ?
TypeError: not enough arguments for format string
>>>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] I HAVE A QUESTION

2006-03-25 Thread Tom Bachik
des easygui only demo boxes because thats all i can get it todo
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] i need help please read

2006-03-22 Thread Tom Bachik
ok does anyone know how to righ a script were a box pops up then if it goes over a number on the screen it pops up in the box become the input number so you can alter the number that popped up in the box? if you do can you right it and send it to me and  if you cant doit all but know how i can do part will you please help me do it but remeber im new so i dont know to much

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


  1   2   >