Tk.iconname still there?

2006-05-21 Thread Gary Wessle
Hi

I am going through a tutorial on Tkinter
http://doctormickey.com/python/pythontutorial_201.html, it referees to
Tk.iconname() but I could not locate one after googleing and browsed
and searched the Tkinter On-line reference material in the  Tkinter
reference: a GUI for Python, 84 pp. pdf from 
here http://infohost.nmt.edu/tcc/help/pubs/lang.html

can any one fill us in.

thanks

-- 
http://mail.python.org/mailman/listinfo/python-list


getting the value of an attribute from pdb

2006-05-17 Thread Gary Wessle
Hi

how can I using pdb get a value of an attribute?, read the docs and
played around with pdb 'p' for no avail.

thanks

class main:
  def __init__(self, master):
self.master = master
self.master.title('parent')
self.master.geometry('200x150+300+225')
...
root = Tk()



ignore the following if you are not interested on how I tried


(Pdb) n
 /home/fred/python/practic/window_08.py(12)__init__()
- self.master.geometry('200x150+300+225')
(Pdb) p root.title
bound method Tk.wm_title of Tkinter.Tk instance at 0xb717c16c
(Pdb) p root.title[Tk.wm_title]
*** TypeError: exceptions.TypeError instance at 0xb717c3cc
(Pdb) p root.title[wm_title]
*** NameError: exceptions.NameError instance at 0xb717c3cc
(Pdb) p root[wm_title]
*** NameError: exceptions.NameError instance at 0xb717c3cc
(Pdb) p root['wm_title']
*** TclError: _tkinter.TclError instance at 0xb717c3cc
(Pdb) p self.master[title]
*** NameError: exceptions.NameError instance at 0xb717c3cc
(Pdb) p self.master['title']
*** TclError: _tkinter.TclError instance at 0xb717c40c
(Pdb) p self.master[title]
*** TclError: _tkinter.TclError instance at 0xb717c42c
(Pdb) p self.master[wm_title]
*** NameError: exceptions.NameError instance at 0xb717c42c
(Pdb) p self.master['wm_title']
*** TclError: _tkinter.TclError instance at 0xb717c3cc
(Pdb) p self.master[wm_title']
*** SyntaxError: exceptions.SyntaxError instance at 0xb717c3cc
(Pdb) p self.master[wm_title]
*** TclError: _tkinter.TclError instance at 0xb717c40c
(Pdb) q
Traceback (most recent call last):
  File ./window_08.py, line 65, in ?
main(root) 
  File ./window_08.py, line 12, in __init__
self.master.geometry('200x150+300+225')
  File ./window_08.py, line 12, in __init__
self.master.geometry('200x150+300+225')
  File /usr/lib/python2.4/bdb.py, line 48, in trace_dispatch
return self.dispatch_line(frame)
  File /usr/lib/python2.4/bdb.py, line 67, in dispatch_line
if self.quitting: raise BdbQuit
bdb.BdbQuit


-- 
http://mail.python.org/mailman/listinfo/python-list


continue out of a loop in pdb

2006-05-14 Thread Gary Wessle
Hi

using the debugger, I happen to be on a line inside a loop, after
looping few times with n and wanting to get out of the loop to the
next line, I set a break point on a line after the loop structure and
hit c, that does not continue out of the loop and stop at the break
line, how is it down, I read the ref docs on pdb but could not figure
it out.

thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: copying files into one

2006-05-14 Thread Gary Wessle

thanks, I was able 'using pdb' to fix the problem as per Edward's
suggestion.



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: continue out of a loop in pdb

2006-05-14 Thread Gary Wessle
Paul McGuire [EMAIL PROTECTED] writes:

 Gary Wessle [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Hi
 
  using the debugger, I happen to be on a line inside a loop, after
  looping few times with n and wanting to get out of the loop to the
  next line, I set a break point on a line after the loop structure and
  hit c, that does not continue out of the loop and stop at the break
  line, how is it down, I read the ref docs on pdb but could not figure
  it out.
 
  thanks
 
 This is exactly how I do this operation using pdb, and it works for me, so
 you are on the right track.  Is it possible that something inside the loop
 is raising an exception, thereby jumping past your breakpoint? Try putting
 the loop inside a try-except.
 
 -- Paul

the code works with no problem, I am playing around with the pdb, i.e


from pdb import *
set_trace() 

for i in range(1,50):
print i
print tired of this
print I am out


[EMAIL PROTECTED]:~/python/practic$ python practic.py 
 /home/fred/python/practic/practic.py(4)?()
- for i in range(1,50):
(Pdb) n
 /home/fred/python/practic/practic.py(5)?()
- print i
(Pdb) n
1
 /home/fred/python/practic/practic.py(4)?()
- for i in range(1,50):
(Pdb) b 6
Breakpoint 1 at /home/fred/python/practic/practic.py:6
(Pdb) c
 /home/fred/python/practic/practic.py(5)?()
- print i  I expected (print tired of this)
(Pdb) 
-- 
http://mail.python.org/mailman/listinfo/python-list


retain values between fun calls

2006-05-13 Thread Gary Wessle
Hi

the second argument in the functions below suppose to retain its value
between function calls, the first does, the second does not and I
would like to know why it doesn't? and how to make it so it does?

thanks

# it does
def f(a, L=[]):
L.append(a)
return L
print f('a')
print f('b')


# it does not
def f(a, b=1):
b = a + b
return b
print f(1)
print f(2)
-- 
http://mail.python.org/mailman/listinfo/python-list


copying files into one

2006-05-13 Thread Gary Wessle
Hi

I am looping through a directory and appending all the files in one
huge file, the codes below should give the same end results but are
not, I don't understand why the first code is not doing it.

thanks


combined = open(outputFile, 'wb')

for name in flist:
if os.path.isdir(file): continue

infile = open(os.path.join(file), 'rb')

# CODE 1 this does not work
tx = infile.read(1000)
if tx == : break
combined.write(tx)
infile.close()

# CODE 2 but this works fine 
for line in infile:
combined.write(line)
infile.close()

combined.close()
-- 
http://mail.python.org/mailman/listinfo/python-list


TkTable for info gathering

2006-05-12 Thread Gary Wessle
Hi

I just finished with 1.5 tutorials about Tkinter, my thought is to use
a table maybe TkTable to gather info from the user as to what file
to chart data from, as well as info provided by the TkTable
properties. 
each cell of the table will be either empty or contains a file path,
let x=1  be the x-index of the cells on the first col and y=1 be the
y-index of the cells on the first row. the position of the cell with
the max-x and max-y will determine how many frames will be displayed,
grid with x columns corresponding to max-x and x rows corresponding to
max-y.

i.e, the look of the table will resemble the gui, empty cell - empty
frame, cell with filepth - frame with canvas. 

is TkTable or NovaGrid suitable for this?

thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


2 books for me

2006-05-11 Thread Gary Wessle
Hi

I am about to order 2 books, and thought I should talk to you first.
I am getting Python Cookbook by Alex Martelli, David Ascher, Anna
Martelli Ravenscroft, Anna Martelli Ravenscroft, since Bruce Eckel's
Thinking in Python is not finished and didn't have any new revisions
since some time in 2001, having owned his Thinking in C++ v1 and v2 I
am used to learning from him. any way, the second book is gui one, I
notices there are 3 flavors according to
http://wiki.python.org/moin/GuiBooks, wxPython, Qt, and Tkinter.I am
not sure what package is best for and would like to know before I
order one of those three. 

thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: installing numpy

2006-05-10 Thread Gary Wessle
Robert Kern [EMAIL PROTECTED] writes:

 Raymond L. Buvel wrote:
 
  Since you are a new Linux user, you should definitely follow Robert's
  advice about building as an ordinary user separately from the install.
  I sometimes take a shortcut and just do the install as user root.
  However, I then wind up cleaning out the build directory as user root
  (not a very safe thing to do).
 
 For small, pure Python packages, that may be fine. numpy's build is 
 complicated
 enough that you really, *really* want to build as a regular user.
 
 -- 
 Robert Kern

I have read as much as I can form the python installation manual.
as a regular user, I created a personal configuration file here


:~$ cat .pydistutils.cfg 
[install]
prefix=/usr/local


now to build as a regular user, I am getting some errors


$ cd numpy-0.9.6
$ python setup.py build
Running from numpy source directory.
Warning: not existing path in numpy/distutils: site.cfg
F2PY Version 2_2236
Traceback (most recent call last):
  File setup.py, line 76, in ?
setup_package()
  File setup.py, line 63, in setup_package
config.add_subpackage('numpy')
  File /home/fred/numpy-0.9.6/numpy/distutils/misc_util.py, line 592, in 
add_s   ubpackage
config_list = self.get_subpackage(subpackage_name,subpackage_path)
  File /home/fred/numpy-0.9.6/numpy/distutils/misc_util.py, line 582, in 
get_s   ubpackage
subpackage_path)
  File /home/fred/numpy-0.9.6/numpy/distutils/misc_util.py, line 539, in 
_get_   
configuration_from_setup_py
config = setup_module.configuration(*args)
  File /home/fred/numpy-0.9.6/numpy/setup.py, line 10, in configuration
config.add_subpackage('core')
  File /home/fred/numpy-0.9.6/numpy/distutils/misc_util.py, line 592, in 
add_s   ubpackage
config_list = self.get_subpackage(subpackage_name,subpackage_path)
  File /home/fred/numpy-0.9.6/numpy/distutils/misc_util.py, line 582, in 
get_s   ubpackage
subpackage_path)
  File /home/fred/numpy-0.9.6/numpy/distutils/misc_util.py, line 539, in 
_get_   
configuration_from_setup_py
config = setup_module.configuration(*args)
  File numpy/core/setup.py, line 11, in configuration
from numpy.distutils.system_info import get_info, default_lib_dirs
  File /home/fred/numpy-0.9.6/numpy/distutils/system_info.py, line 151, in ?
so_ext = get_config_vars('SO')[0] or ''
  File /usr/lib/python2.4/distutils/sysconfig.py, line 488, in get_config_vars
func()
  File /usr/lib/python2.4/distutils/sysconfig.py, line 358, in _init_posix
raise DistutilsPlatformError(my_msg)
distutils.errors.DistutilsPlatformError: invalid Python installation: unable to 
   open 
/usr/lib/python2.4/config/Makefile (No such file or directory)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: combined files together

2006-05-10 Thread Gary Wessle
Eric Deveaud [EMAIL PROTECTED] writes:

 Gary Wessle wrote:
  
   I need to traverse those files in the order they were created
   chronologically. listdir() does not do it, is there a way besides
   build a list then list.sort(), then for element in list_of_files open
   element?
 
 are the name of the files describing the cration date, 

yes 

 or have to rely on the creation date ?

no


 
 if the name allows to discriminate the chronology, check glob module.

I just tried glob, it does not put out a list with file names sorted. 
 
   Eric
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: installing numpy

2006-05-10 Thread Gary Wessle

thanks
I followed your suggestions, it built the package ok, while it was
building, I noticed lots of lines going by the screen in groups of
different colors, white, yellow, red.
the red got my attention: 


Could not locate executable gfortran
Could not locate executable f95


is there a way to find out if the built is fine and it is using the
high performance libraries?

thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


two of pylab.py

2006-05-09 Thread Gary Wessle
Hi

I use debian/testing linux Linux debian/testing 2.6.15-1-686 

I found some duplicate files in my system, I don't if the are both
needed, should I delete one of the groups below and which one?

-rw-r--r-- 1 root root 80375 2006-01-24 00:28 
/usr/lib/python2.3/site-packages/matplotlib/pylab.py
-rw-r--r-- 1 root root 96202 2006-05-07 13:44 
/usr/lib/python2.3/site-packages/matplotlib/pylab.pyc
-rw-r--r-- 1 root root 96202 2006-05-07 13:45 
/usr/lib/python2.3/site-packages/matplotlib/pylab.pyo
-rw-r--r-- 1 root root31 2004-12-10 03:05 
/usr/lib/python2.3/site-packages/pylab.py
-rw-r--r-- 1 root root   160 2006-05-07 13:44 
/usr/lib/python2.3/site-packages/pylab.pyc
-rw-r--r-- 1 root root   160 2006-05-07 13:45 
/usr/lib/python2.3/site-packages/pylab.pyo


my sys.path shows that /usr/lib/python2.3/site-packages/ is present.


$cat /usr/lib/python2.3/site-packages/pylab.py
from matplotlib.pylab import *


This imports all names except those beginning with an underscore (_).

thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


installing numpy

2006-05-09 Thread Gary Wessle
Hi

I am trying to install NumPy in my debian/testing linux
2.6.15-1-686. 

with no numpy for debian/testing, I am left alone, since the
experimental version available by debian will result in a dependency
nightmares,

so after unpacking the downloaded file numpy-0.9.6.tar.gz
which crated a directory in my home directory called numpy-0.9.6 with 


-rw-r--r--  1 fred fred 1537 2006-01-21 19:12 LICENSE.txt
-rw-r--r--  1 fred fred  246 2006-01-22 12:44 MANIFEST.in
drwxr-xr-x 11 fred fred 4096 2006-05-08 20:06 numpy
-rw-r--r--  1 fred fred 1472 2006-03-14 19:27 PKG-INFO
-rw-r--r--  1 fred fred  476 2006-01-07 08:29 README.txt
-rw-r--r--  1 fred fred 1164 2006-05-08 20:06 semantic.cache
-rwxr-xr-x  1 fred fred 2516 2006-03-13 18:02 setup.py



$cat README.txt
...
To install:

python setup.py install

The setup.py script will take advantage of fast BLAS on your system if
it can find it.  You can help the process with a site.cfg file.

If fast BLAS and LAPACK cannot be found, then a slower default version
is used. 
...


do I issue the command above python setup.py install from the
unpacked directory numpy-0.9.6, would it put the packages in the
correct places in my system, I was under the impression that a
numpy.py is unpacked and then I place it the sys.path but this is not
the case here.


thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: installing numpy

2006-05-09 Thread Gary Wessle
Christoph Haas [EMAIL PROTECTED] writes:

 On Tue, May 09, 2006 at 09:03:31PM +1000, Gary Wessle wrote:
  I am trying to install NumPy in my debian/testing linux
  2.6.15-1-686. 
  
  with no numpy for debian/testing, I am left alone, since the
  experimental version available by debian will result in a dependency
  nightmares,
 
 What about python-numeric? Found through apt-cache search numpy.

is no longer maintained, notice my previous post titled Numerical
Python Tutorial errors

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: installing numpy

2006-05-09 Thread Gary Wessle
Raymond L. Buvel [EMAIL PROTECTED] writes:

 Gary Wessle wrote:
  Hi
  
  I am trying to install NumPy in my debian/testing linux
  2.6.15-1-686. 
  
 snip
 
 When installing from source on a Debian system, you want the installed
 package to wind up in /usr/local/lib/python2.x/site-packages (where x
 represents the version of Python you are running the installer from).
 This allows you to keep it separate from the apt managed directories and
 allows for easy removal/upgrade.  So the command you want to execute
 from root is
 
 python setup.py install --prefix=/usr/local


sorry if this is boring since I am not a seasoned Linux user.

setup.py isn't located at the root, do you mean, execute the command above
from root, as to do this
:~$ cd /
:/$ python setup.py install --prefix=/usr/local
or 
:/$ python home/fred/numpy-0.9.6/setup.py install --pref...
or AS root
:/# python setup.py install --prefix=/usr/local
or 
:/# python home/fred/numpy-0.9.6/setup.py install --pref...

 
 
 By the way, to get NymPy to use the high-performance libraries, you must
 install these libraries and the associated -dev packages before running
 the Python install.

I wish to know the debian names for those packages, my first guess
would be refblas3 under testing since blas is not available for
debian/testing, there is also
refblas3-dev  Basic Linear Algebra Subroutines 3, static library 
which I don't have installed.

would refblas3 be all what NymPy need to the high-performance?

thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python rounding problem.

2006-05-07 Thread Gary Wessle
Erik Max Francis [EMAIL PROTECTED] writes:

 chun ping wang wrote:
 
  Hey i have a stupid question.
  How do i get python to print the result in only three decimal
  place...
  Example round (2.9954254, 3)
  2.9951
  but i want to get rid of all trailing 0's..how would i do that?
 
 Floating point arithmetic is inherently imprecise.  This is not a
 Python problem.

does python support true rations, which means that 1/3 is a true
one-third and not 0.3 rounded off at some arbitrary precision?

-- 
http://mail.python.org/mailman/listinfo/python-list


Numerical Python Tutorial errors

2006-05-07 Thread Gary Wessle
Hi

is the Numerical Python tutorial maintained?
http://www.pfdubois.com/numpy/html2/numpy.html
seams to have some errors and no email to mail them to when found.

if interested, read about the errors below






(1)
http://www.pfdubois.com/numpy/html2/numpy-6.html#pgfId-35606
Creating arrays from scratch
the html showing code lines below on the top of text lines from the
surrounding paragraphs, I was surprise to be able to copy and paste
the lines below as they are not visually clear on the page.

 x,y,z = 1,2,3
 a = array([x,y,z]) # integers are enough for 1, 2 and 3
 print a
[1 2 3]
 a = array([x,y,z], Float) # not the 


(2)
http://www.pfdubois.com/numpy/html2/numpy-5.html#pgfId-57136
Universal Functions
 print add.reduce([1,2,4,5])

12 # 1 + 2 + 3 + 4 + 5   is
12 # 1 + 2 + 4 + 5   should be

-- 
http://mail.python.org/mailman/listinfo/python-list


evaluation of

2006-05-07 Thread Gary Wessle
Hi

what does the i  a in this code mean. because the code below is
giving False for all the iteration. isn't suppose to evaluate each
value of i to the whole list? thanks

a = range(8)
i = 0
while i  11:
print i  a
i = i + 1

False
False
False
False
False
False
False
False
False
False
False


thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Numerical Python Tutorial errors

2006-05-07 Thread Gary Wessle
Robert Kern [EMAIL PROTECTED] writes:

 Gary Wessle wrote:
  Hi
  
  is the Numerical Python tutorial maintained?
  http://www.pfdubois.com/numpy/html2/numpy.html
  seams to have some errors and no email to mail them to when found.
 
 No, it is not since Numeric itself is no longer maintained. The successor to
 Numeric is numpy and is being actively developed:
 
   http://numeric.scipy.org

thank you
-- 
http://mail.python.org/mailman/listinfo/python-list


reading a column from a file

2006-05-07 Thread Gary Wessle
Hi

I have a file with data like
location pressure temp
str   flootfloot

I need to read pressure and temp in 2 different variables so that I
can plot them as lines. is there a package which reads from file with
a given formate and returns desired  variables? or I need to open,
while not EOF read, parse, build list, return?

thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


combined files together

2006-05-06 Thread Gary Wessle
Hi

is there a module to do things like concatenate all files in a given
directory into a big file, where all the files have the same data
formate?
name address phone_no.

or do I have to open each, read from old/write-or-append to new ...

thanks

-- 
http://mail.python.org/mailman/listinfo/python-list


sort a list of files

2006-05-06 Thread Gary Wessle
Hi

I am trying to print out the contents of a directory, sorted.

 the code 
 1  import os, sys
 2  
 3  if len(sys.argv)  2:
 4  sys.exit(please enter a suitable directory.)
 5  
 6  print os.listdir(sys.argv[1]).sort()


if I remove .sort() at the end of line 6 I get an unsorted list of
files, if I leave it I get None. who do I fix this?

thank you
-- 
http://mail.python.org/mailman/listinfo/python-list


os.isfile() error

2006-05-06 Thread Gary Wessle
Hi

could someone help me to find out whats wrong with this code?

 code 
import os, sys

if len(sys.argv)  2:
sys.exit(please enter a suitable directory.)

dpath = sys.argv[1]
for name in os.listdir(dpath):
if os.isfile(dpath+name):
infile = open(os.path.join(dpath,name), 'rb')
print type(infile)


 error 
Traceback (most recent call last):
  File python/useful/cat2all.py, line 13, in ?
if os.isfile(dpath+name):
AttributeError: 'module' object has no attribute 'isfile'


thank you
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: combined files together

2006-05-06 Thread Gary Wessle
Gary Herron [EMAIL PROTECTED] writes:

 Gary Wessle wrote:
 
 Hi
 
 is there a module to do things like concatenate all files in a given
 directory into a big file, where all the files have the same data
 formate?
 name address phone_no.
 
 or do I have to open each, read from old/write-or-append to new ...
 
 thanks
 
 
 There's hardly enough code here to make a module out of this:
 
 combined = open('...', 'wb')
 for name in os.listdir(path):

I need to traverse those files in the order they were created
chronologically. listdir() does not do it, is there a way besides
build a list then list.sort(), then for element in list_of_files open
element?

thanks

 infile = open(os.path.join(path,name), 'rb')
 for line in infile:
 combined.write(line)
 
 It could be more efficient by reading larger chunks than single lines,
 and could be more accurate by closing both input and output files when
 done, but you get the point I hope.
 
 On the other hand, if you've got the right OS, you might try something like:
 os.system(cat *  combined)
 
 Gary Herron
-- 
http://mail.python.org/mailman/listinfo/python-list


print formate

2006-05-05 Thread Gary Wessle
Hi


import string
import re
accumulator = []

pattern = '(\S*)\s*(\S*)\s*(\S*)'
for each text file in dir
openfile and read into text
data = re.compile(pattern, re.IGNORECASE).findall(text)
accumulator = accumulator + data
gives a list of tuples which when printed looks like
('jack', 'bony', 'J')
('sam', 'lee', 'S')
...

how can I get the output in the formate
jack bony J
sam lee S
...


thank you
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scope of variables

2006-05-04 Thread Gary Wessle
Ryan Forsythe [EMAIL PROTECTED] writes:

 Gary Wessle wrote:
  the example was an in-accuretlly representation of a the problem I am
  having. my apologies.
  
  a = []
  def prnt():
 print len(a)
  
  prnt
  function prnt at 0xb7dc21b4
  
  I expect to get 0 the length of list a
 
 You want prnt(), not prnt:
 

I finally was able to duplicate the error with a through away code
as follows, 


acc = [1,2,3]

def a():
b = [4, 5, 6]
acc = acc + b
print len(acc)

a()

 error 
Traceback (most recent call last):
  File a.py, line 12, in ?
a()
  File a.py, line 9, in a
acc = acc + b
UnboundLocalError: local variable 'acc' referenced before assignment
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scope of variables

2006-05-04 Thread Gary Wessle
thank you
-- 
http://mail.python.org/mailman/listinfo/python-list


scope of variables

2006-05-03 Thread Gary Wessle
Hi

is the code below correct?

b = 3
def adding(a)
print a + b

it seams not to see the up-level scope where b is defined.

thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scope of variables

2006-05-03 Thread Gary Wessle
Steve R. Hastings [EMAIL PROTECTED] writes:

 On Thu, 04 May 2006 07:02:43 +1000, Gary Wessle wrote:
  b = 3
  def adding(a)
  print a + b
  
  it seams not to see the up-level scope where b is defined.
 
 Assuming you put a ':' after the def adding(a), this should work in
 recent versions of Python.  In Python 2.0 and older, this will not work.

the example was an in-accuretlly representation of a the problem I am
having. my apologies.

a = []
def prnt():
   print len(a)

 prnt
function prnt at 0xb7dc21b4

I expect to get 0 the length of list a
-- 
http://mail.python.org/mailman/listinfo/python-list


string.find first before location

2006-05-02 Thread Gary Wessle
Hi

I have a string like this

text = abc abc and Here and there
I want to grab the first abc before Here

import string
string.find(text, Here) # type int

I am having a problem with the next step.

thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


redemo.py with Tkinter

2006-05-02 Thread Gary Wessle
Hi

I was reading the Regular Expression HowTo, it refers to redemo.py if
you have Tkinter installed. a quick #locate redemo.py returned none on
my debian/testing, however #locate Tkinter returned many.
any body out there is using it, is it a separate download?

thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


data regex match

2006-05-02 Thread Gary Wessle
Hi

I am having an issue with this match

tx = now 04/30/2006 then
data = re.compile('(\d{2})/\1/\1\1', re.IGNORECASE)
d = data.search(tx)
print d

Nono
I was expecting 04/30/2006, what went wrong?

thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: string.find first before location

2006-05-02 Thread Gary Wessle
Serge Orlov [EMAIL PROTECTED] writes:

 Peter Otten wrote:
  Gary Wessle wrote:
 
   These days str methods are preferred over the string module's functions.
  
text = abc abc and Here and there
here_pos = text.find(Here)
text.rfind(abc, 0, here_pos)
   4
  
   Peter
  
   and what about when python 3.0 is released and those depreciated
   functions like find and rfind are not supported. is there another
   solution which is more permanent?
 
  I think the functions may go away, the methods will stay; so I'm confident
  the above will continue to work.
 
 find and rfind methods are in danger too. AFAIR they are to be replaced
 by partion and rpartition methods. People who are worried about future
 can continue to use index and rindex

except with index and rindex, if the search string is not present,
they return a 
[
Traceback (most recent call last):
ValueError: substring not found
]

ps. is there a online doc or web page where one enters a method and it
returns the related docs?

-- 
http://mail.python.org/mailman/listinfo/python-list


assignment in if

2006-05-02 Thread Gary Wessle
Hi

is there a way to make an assignment in the condition of if and use
it later, e.g.

nx = re.compile('regex')
if nx.search(text):
   funCall(text, nx.search(text))

nx.search(text) is evaluated twice, I was hoping for something like

nx = re.compile('regex')
if x = nx.search(text):
   funCall(text, x))

thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


file open no such file

2006-04-30 Thread Gary Wessle
I am getting this error when I try to run the code below


f = open(~/m, r)
print f.read()



:~$ python python/my.py 
Traceback (most recent call last):
  File python/my.py, line 1, in ?
f = open(~/m, r)
IOError: [Errno 2] No such file or directory: '~/m'


but I have the m file in my home/username/


thank you
-- 
http://mail.python.org/mailman/listinfo/python-list


TypeError: 'module' object is not callable

2006-04-28 Thread Gary Wessle
dear python users

I am not sure why I am getting


Traceback (most recent call last):
  File my.py, line 3, in ?
urlparse('http://www.cwi.nl:80/%7Eguido/Python.html')
TypeError: 'module' object is not callable


with this code


import urlparse

urlparse('http://www.cwi.nl:80/%7Eguido/Python.html')



thank you
-- 
http://mail.python.org/mailman/listinfo/python-list


convert a int to a list

2006-04-28 Thread Gary Wessle
Hi

can type conversion work to convert an int to a list?
I am trying to solve an problem in one tutorial.



a = ['spam!', 1, ['Brie', 'Roquefort', 'Pol le Veq'], [1, 2, 3]]

As an exercise, write a loop that traverses the previous list and
prints the length of each element. What happens if you send an
integer to len? 


for i in a:
print len(a[i])

will not do.
the list has str, int, list, list.
I am expecting the output to be 1, 1, 3, 3 which are the number of
elements of each element of a, someone might think the result should
be 4, 3, 3 which is len(a), len(a[2]), len(a[3]) but how can I do both
thoughts with a loop?


thank you
-- 
http://mail.python.org/mailman/listinfo/python-list


raw_input passing to fun

2006-04-27 Thread Gary Wessle


the output of this code below is not what one would expect, it outputs
all kind of numbers and it never stops, I want to ask the user for a
number and then print out the multiplication table up to that number.

thanks


import math

def printMultiples(n, hight):
 i = 1
 while i = hight:
 print n*i, '\t',
 i = i + 1
 print


def printMultTable(hight):
i = 1
while i = hight:
printMultiples(i, i)
i = i + 1

num = raw_input (produce a multiplication table up to: )
printMultTable(num)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: raw_input passing to fun

2006-04-27 Thread Gary Wessle
John Machin [EMAIL PROTECTED] writes:

 On 28/04/2006 2:04 PM, Gary Wessle wrote:
  the output of this code below is not what one would expect, it
  outputs
  all kind of numbers and it never stops, I want to ask the user for a
  number and then print out the multiplication table up to that number.
 
 That's what you want, but not what you did. You asked them for a string.
 
  thanks
  
  import math
 
 Not used.
 
  def printMultiples(n, hight):
   i = 1
   while i = hight:
   print n*i, '\t',
   i = i + 1
   print
  def printMultTable(hight):
  i = 1
  while i = hight:
 
 Temporarily, insert here:
print types:, type(i), type(hight)
print values:, i, hight
if i  100: return
 
  printMultiples(i, i)
  i = i + 1
  num = raw_input (produce a multiplication table up to: )
  printMultTable(num)
 
 Try this: printMultTable(int(num))
 
 You may wish to consider changing hight to height :-)

thank you
-- 
http://mail.python.org/mailman/listinfo/python-list


print out each letter of a word

2006-04-27 Thread Gary Wessle
I am going through this tut from
http://ibiblio.org/obp/thinkCS/python/english/chap07.htm

I am getting errors running those 2 groups as below as is from the tut


thanks


 index = 0
 while index  len(fruit):
   letter = fruit[index]
   print letter
   index = index + 1

or

  
for char in fruit:
  print char 
-- 
http://mail.python.org/mailman/listinfo/python-list


help finding

2006-04-25 Thread Gary Wessle
Hi

I am going through some tutorials, how do I find out about running a
script from the python prompt?
is there a online ref and how to access it?


thank you
-- 
http://mail.python.org/mailman/listinfo/python-list


debugging in emacs

2006-04-23 Thread Gary Wessle
Hi python users

I am using emacs and python-mode.el under dabian testing.
is there a way to debug python code where I can step over each line
and watch the value of all the variables and be able to change
any during debugging. say you have a loop structure and want to see
what the values of your variables are during debugging when your code
is running as you step line by line.

thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: debugging in emacs

2006-04-23 Thread Gary Wessle
Gary Wessle [EMAIL PROTECTED] writes:

 Hi python users
 
 I am using emacs and python-mode.el under dabian testing.
 is there a way to debug python code where I can step over each line
 and watch the value of all the variables and be able to change
 any during debugging. say you have a loop structure and want to see
 what the values of your variables are during debugging when your code
 is running as you step line by line.
 
 thanks

what is the most used the older python-mode.el or the newer python.el?

I am using eamcs 21.4.1 under dabian testing.
-- 
http://mail.python.org/mailman/listinfo/python-list


charting

2006-04-20 Thread Gary Wessle
Dear python users

I am just wondering if python is the language to use to build a custom
charting package which is live updated from live data stream coming
through  a socket. as well as dynamically execute data analysis code
on the data being fed. I have been looking at SpecTix.

thank you
-- 
http://mail.python.org/mailman/listinfo/python-list