Re: Changing variable to integer

2006-12-17 Thread Juho Schultz
20, "copyright":25, "credits":35} # show dictionary >>> for w, s in words.iteritems(): print w, s ... credits 35 help 20 copyright 25 # show sorted dictionary # dicts are not ordered, so you have to sort them. >>> for w, s in sorted(words.iteritems()): print w, s ... copyright 25 credits 35 help 20 -- Juho Schultz -- http://mail.python.org/mailman/listinfo/python-list

Re: I think Python is a OO and lite version of matlab

2006-12-08 Thread Juho Schultz
cs. I also need: 1) Regular expressions 2) XML library 3) Database interface Python covers it all. I think Matlab has a Database interface, but how about the others? -- Juho Schultz -- http://mail.python.org/mailman/listinfo/python-list

Re: question about function not executing

2006-11-26 Thread Juho Schultz
# effects of poison in here: # take some hitpoints # maybe reduce some stats # and so on... # now, generate a player instance p = player() # calls __init__ # poison the player p.take_poison() -- Juho Schultz -- http://mail.python.org/mailman/listinfo/python-list

Re: String Replace only if whole word?

2006-11-17 Thread Juho Schultz
m the docs: re.sub(pattern, repl, string[, count]) Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl. Your pattern would be "[^A-Za-z0-9_]word[^A-Za-z0-9_]" [^xy] is approximately not in ('x', 'y') -- Juho Schultz -- http://mail.python.org/mailman/listinfo/python-list

Re: Standard Forth versus Python: a case study

2006-10-12 Thread Juho Schultz
? Are you aiming for accuracy, speed or getting as complete time series as possible? (for me, speed has never been an issue) Photometry/astrometry/something else? Is there some trade-off like "get best possible result in X seconds"? -- Juho Schultz -- http://mail.python.org/mailman/listinfo/python-list

Re: user modules

2006-10-05 Thread Juho Schultz
Juho Schultz wrote: > Cameron Walsh wrote: > > Hi, > > > > I'm writing a python program to analyse and export volumetric data. To > > make development and extension easier, and to make it more useful to the > > public when it is released (LGPL), I would like

Re: user modules

2006-10-05 Thread Juho Schultz
Cameron Walsh kirjoitti: > Hi, > > I'm writing a python program to analyse and export volumetric data. To > make development and extension easier, and to make it more useful to the > public when it is released (LGPL), I would like to enable users to place > their own python files in a "user_exten

Re: user modules

2006-10-05 Thread Juho Schultz
Cameron Walsh wrote: > Hi, > > I'm writing a python program to analyse and export volumetric data. To > make development and extension easier, and to make it more useful to the > public when it is released (LGPL), I would like to enable users to place > their own python files in a "user_extensions

Re: Comment on this script. Possible error in communication with list arg between functions

2006-07-24 Thread Juho Schultz
se: print rpmname + ' is not installed' return output def checkPreReqs(): missingRpms = [] for requiredRpm in listOfRpms: if not checkForRpm(requiredRpm): missingRpms.append(requiredRpm) # you could also do this by a list comprehen

Re: building lists of dictionaries

2006-07-23 Thread Juho Schultz
Tim Chase wrote: > parinfo = [{'value':0., 'fixed':0, 'limited':[0,0], > 'limits':[0.,0.]}.copy() for i in xrange(0,6)] > > However, this will still reference internal lists that have > been referenced multiple times, such that > > >>> parinfo[5]['limited'] > [0, 0] > >>> parinfo[4]['limited'][

Re: building lists of dictionaries

2006-07-23 Thread Juho Schultz
Jean_Francois Moulin wrote: > Hi all, > > I tried this piece of code (FWIW, it was taken as is from a help section of > mpfit, a mathematical routine for least square fitting): > > parinfo = [{'value':0., 'fixed':0, 'limited':[0,0], 'limits':[0.,0.]}]*6 > The first line builds a list of six dicti

Re: RegEx conditional search and replace

2006-07-05 Thread Juho Schultz
Martin Evans wrote: > Sorry, yet another REGEX question. I've been struggling with trying to get > a regular expression to do the following example in Python: > > Search and replace all instances of "sleeping" with "dead". > > This parrot is sleeping. Really, it is sleeping. > to > This parrot is

Re: converting file formats to txt

2006-07-04 Thread Juho Schultz
Perhaps you should > look at the program pdf2ps -- maybe it will help. > > > -- > Steven. Or try the program pdftotext? -- Juho Schultz -- http://mail.python.org/mailman/listinfo/python-list

Re: print shell output in a file

2006-06-30 Thread Juho Schultz
Juergen Huber wrote: > hello, > > one more question i will have! > > now i have written a little programm, which delivers me an output on the > shell! > > > Is there a way to put this output in an file?!?! i searched about 2h for > this, but i couldn`t find an answer! > > thnks, juergen Others h

Re: break the loop in one object and then return

2006-06-26 Thread Juho Schultz
Alex Pavluck wrote: > I am trying to write the following code to block up evaluation and > prompting for entering new information. However, when I break the loop > in one object and then return it does not start at the beginning again > but rather at the point where it exited. Can someone look at

Re: File Permissions

2006-03-10 Thread Juho Schultz
VJ wrote: > Hi All > > Basically i want to write into a file .If the permissions are not there > then print a error message. > How do i achive this ??? > > Thanks, > VJ > One way would be a try-except block, and leave the permission checking error message generation, etc. to the operating syst

Re: Why python doesn't use syntax like function(,,x) for default parameters?

2006-03-10 Thread Juho Schultz
Antoon Pardon wrote: > Op 2006-03-10, Roy Smith schreef <[EMAIL PROTECTED]>: > >>"Dmitry Anikin" <[EMAIL PROTECTED]> wrote: >> >>>There are often situations when a function has independent >>>parameters, all having reasonable defaults, and I want to >>>provide just several of them. In fact, I can

Re: Python Evangelism

2006-03-10 Thread Juho Schultz
Magnus Lycka wrote: > rtilley wrote: > >> >> I think it's the name. Python. Let's change it to something nicer. >> Think about it... if you found a Ruby, you'd pick it up and put it in >> your pocket. If you ran across a Python, you'd run away. > > > I think you have a point, but I also think

Re: implementation of "complex" type

2006-03-09 Thread Juho Schultz
Russ wrote: > I tried the following: > > x = complex(4) y = x y *= 2 print x, y > > (4+0j) (8+0j) > > But when I tried the same thing with my own class in place of > "complex" above, I found that both x and y were doubled. I'd like to > make my class behave like the "complex" cl

Re: What version of python is running a script

2006-03-07 Thread Juho Schultz
Fernando Rodríguez wrote: > > Hi, > > How can my script tell which version of python is running it? > > Thanks > > import sys # examine these variables sys.version_info sys.version -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting File Permissions

2006-03-07 Thread Juho Schultz
Hari wrote: > Hi, > For getting permissions of a file, the following script has been > suggested in the same group > > import os, stat > st = os.stat(myfile) > mode = st[stat.ST_MODE] > print "mode is", octal(mode & 0777) > > But while executing I am getting error message as follows > > Tracebac

Re: Vectorization and Numeric (Newbie)

2006-02-28 Thread Juho Schultz
Ronny Mandal wrote: > Assume you have a mathematical function, e.g. f(x) = x + 4 > > To calculate all the values from 1 to n, a loop is one alternative. > Numeric and friends (numarray,numpy) have something like numarray.arange - they return arrays similar to the lists returned by standard libs

Re: How to run shell commands within python

2006-02-16 Thread Juho Schultz
fileexit wrote: > How can I execute shell commands from within python. Specifically, I > am looking for something like the shell "cat". But this also made me > wonder how to execute shell commands anyway, just if i needed to do > that in the future. > You can use os.system() for that. -- http:/

Re: a numarray question

2006-02-15 Thread Juho Schultz
[EMAIL PROTECTED] wrote: > hello everyone > > would anyone please tell me what is the best (fastest) way of replacing > values in numarray arrays? > > lets say i have an array that may contain 0s, and i just want to get > rid of those 0s by replacing them with another number. what would be > the

Re: Python advocacy in scientific computation

2006-02-15 Thread Juho Schultz
Michael Tobis wrote: > Someone asked me to write a brief essay regarding the value-add > proposition for Python in the Fortran community. Slightly modified to > remove a few climatology-related specifics, here it is. > Thank you - this was very good reading. > I would welcome comments and correc

Re: Too Many if Statements?

2006-02-10 Thread Juho Schultz
Steven D'Aprano wrote: > On Fri, 10 Feb 2006 06:50:25 -0800, slogging_away wrote: > > >>Excellent suggestion, (behold the power of the command line!). I ran >>two saved versions of the script that had produced the symptom >>originally described. The fist seemed to be caused by too many 'if' >>s

Re: Determining an operating system's default browser

2006-02-10 Thread Juho Schultz
John McMonagle wrote: > Is there a python module which can determine an operating system's > default web browser application. > > I would like to use it in the following context: I have a GUI > application where all the documentation is written as html pages. I > wish to have these html help pag

Re: line wrapping problem

2006-02-09 Thread Juho Schultz
ZeD wrote: > Ciao, Juho Schultz! Che stavi dicendo? > Moro, ZeD! Kunhan pulisen. Should we stick to English? > >>should work. IMO file.write() is self-explanatory but "print >> file" is >>a bit obscure. > > is obscure only if you have never used a

Re: line wrapping problem

2006-02-09 Thread Juho Schultz
S Borg wrote: > Hello, > > I am parsing text from one document to another. I have a scheme > similar to: > > for x in myfoobar: >print >> mytextfile, "%s" % mydictionary[x], #all on same line > print >> mytextfile, '\n' #new line > > > I am getting line breaks before my explic

Re: Too Many if Statements?

2006-02-08 Thread Juho Schultz
Bryan Olson wrote: > Alan Morgan wrote: > >> slogging_away wrote: >> >>> Hi - I'm running Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 >>> 32 bit (Intel)] on win32, and have a script that makes numerous checks >>> on text files, (configuration files), so discrepancies can be reported. >>>

Re: how to copy a Python object

2006-02-07 Thread Juho Schultz
[EMAIL PROTECTED] wrote: > Already thanks for the reply, > > but how to write your own copy operator? Won't you always be passing > referrences to new_obj? > If you need to modify the behaviour of copy or deepcopy, you can give your class __copy__ and __deepcopy__ methods. Then copy.copy and c

Re: problems writing tuple to log file

2006-02-03 Thread Juho Schultz
[EMAIL PROTECTED] wrote: > i am having a problem writing a tuple to a text file. my code is > below. > > what i end up getting is a text file that looks like this > > burger, 7up > burger, 7up > burger, 7up > > and this is instead of getting a list that should look like this > > burger, 7up >

Re: beta.python.org content

2006-01-27 Thread Juho Schultz
Steve Holden wrote: > How does > > http://beta.python.org/about/beginners/ > > look? > > regards > Steve I think the content is good, but I would suggest putting some bullet points with links at the top. IMO top part of the beginner page should somehow indicate that tutorial and FAQ is acc

Nitpicking - slightly misleading traceback

2006-01-26 Thread Juho Schultz
if ((data[x][y] > 0) or (datadict.has_key[key])): Traceback (most recent call last): File "reduce.py", line 524, in remove_badvalues if ((data[x][y] > 0) or TypeError: unsubscriptable object However, the bug sits on the next line. I used square brackets when normal brackets were nee

Re: append to the end of a dictionary

2006-01-24 Thread Juho Schultz
Yves Glodt wrote: > Hi there, > > I seem to be unable to find a way to appends more keys/values to the end > of a dictionary... how can I do that? > > E.g: > > mydict = {'a':'1'} > > I need to append 'b':'2' to it to have: > > mydict = {'a':'1','b':'2'} > mydict['b'] = '2' -- http://mail.py

Re: Using non-ascii symbols

2006-01-24 Thread Juho Schultz
Christoph Zwerschke wrote: > "These operators ≤ ≥ ≠ should be added to the language having the > following meaning: > > <= >= != > > this should improve readibility (and make language more accessible to > beginners). > I assume most python beginners know some other programming language

Re: OT: excellent book on information theory

2006-01-20 Thread Juho Schultz
Bengt Richter wrote: > On Thu, 19 Jan 2006 14:12:24 +0200, Juho Schultz <[EMAIL PROTECTED]> wrote: > >>Last month I spent about an hour trying to explain why >>a*2.5e-8 = x >>raises a SyntaxError and why it should be written >>x = a*2.5e-8 >>The guy who

Re: OT: excellent book on information theory

2006-01-19 Thread Juho Schultz
Anton Vredegoor wrote: > > Returning to the original book, why did they write a lot of it (at > least the first few pages until I gave up, after having trouble > understanding formulas about concepts I have no such trouble with when > framed in less jargonized from) in unintelligible mathemathical

Re: Find and slice problem

2006-01-18 Thread Juho Schultz
[EMAIL PROTECTED] wrote: > Hi guys, been going around in circles with this so I hope you can help! > > My current situation is I'm using Grinder and Jython to test pages, but > the log on process is giving me some headaches. After entering the > correct username and password, you then need to ente

Re: how do "real" python programmers work?

2006-01-13 Thread Juho Schultz
bblais wrote: > In Python, there seems to be a couple ways of doing things. I could > write it in one window, and from a Unix shell call >python myscript.py > and be like C++, but then I lose the interactiveness which makes > prototyping easier. If I use the python s

Re: how to improve this simple block of code

2006-01-11 Thread Juho Schultz
py wrote: > Say I have... > x = "132.00" > > but I'd like to display it to be "132" ...dropping the trailing > zeros...I currently try this > > if x.endswith("0"): > x = x[:len(x)-1] > if x.endswith("0"): > x = x[:len(x)-1] > if x.endswith("."): > x = x[:len(x)-1] > > I do it like th

Re: Maximum List size (item number) limit?

2006-01-11 Thread Juho Schultz
[EMAIL PROTECTED] wrote: > Juho Schultz > >>NIR_mean_l only from lines 1, 4, 7, ... >>R_mean_l only from lines 2, 5, 8, ... >>G_mean_l only from lines 3, 6, 9, ... > > > This can be the problem, but it can be right too. I guess he is expecting 3000 element

Re: Maximum List size (item number) limit?

2006-01-11 Thread Juho Schultz
Kriston-Vizi Janos wrote: > Dear Mr. Kern, and Members, > > Thank you very much for the fast answer, my question became > over-simplified. > > My source code is appended below. It uses two text files (L.txt and > GC.txt) as input and merges them. > > Both L.txt and GC.txt contains 3000 rows. W

Re: Visualisation Engine for Python

2006-01-05 Thread Juho Schultz
rodmc wrote: > I am looking for a 2D data visualisation or graphics library for > Python. Can anyone point me in the right direction? > > > Thanks in advance, > > rod > Two tools I have used are Gnuplot-py http://gnuplot-py.sourceforge.net/ and matplotlib http://matplotlib.sourceforge.net/ --

Re: os.path.splitext() and case sensitivity

2005-12-21 Thread Juho Schultz
rbt wrote: > Hi, > > Is there a way to make os.path.splitext() case agnostic? > > def remove_file_type(target_dir, file_type): > for root, dirs, files in os.walk(target_dir): > for f in files: > if os.path.splitext(os.path.join(root, f))[1] in file_type: >

Re: How to check if a string "is" an int?

2005-12-21 Thread Juho Schultz
Neuruss wrote: > Can't we just check if the string has digits? > For example: > > x = '15' if x.isdigit(): > > print int(x)*3 > > > 45 > > No, we can't. '-15' has non-digits but is a valid int. Another point is that the try-except can also be used for string-to-float con

Re: text manipulation

2005-12-16 Thread Juho Schultz
Johhny wrote: > Hello, > > I am trying to write a script in python (to replace a perl script with > limited functionality). Now I have some issues. Currently I am using > the perl to load the file then regex parse certain lines to remove > characters (uncomment lines and change variables). I would

Re: How to creat a file?

2005-12-02 Thread Juho Schultz
sandorf wrote: > I'm new to python. Have a simple question. > > "open" function can only open an existing file and raise a IOerror when > the given file does not exist. How can I creat a new file then? > You already have two correct answers. A warning: if you open a existing file for writing, it

Re: Nested loop

2005-11-30 Thread Juho Schultz
viewcharts wrote: > I am reading two text files comparing the values in one to the other, > this requires two loops. The problem is that when the inner loop is > finished, it never goes back into the loop. Any suggestions? > > > for refSymbol in symbols.readlines(): > for lookupSymbol in my

Re: append to non-existing list

2005-11-09 Thread Juho Schultz
Yves Glodt wrote: > Hello, > > if I do this: > > for row in sqlsth: > pkcolumns.append(row[0].strip()) > etc > > > without a prior: > > pkcolumns = []; > > > I get this error on first iteration: > UnboundLocalError: local variable 'pkcolums' referenced before assignment > >

Re: Cursor Position.

2005-11-09 Thread Juho Schultz
Samantha wrote: > I will be using Tkinter. All I need is a way to get the X,Y position from a > mouse click. I am trying to have an image loaded to click on, but that seems > to be a problem. So if I can just get the position from the screen of a > graphics program, showing an image, it will wor

Re: How do I create a dir using Python.

2005-11-08 Thread Juho Schultz
sumi wrote: > How do i create a dir using python. > You could use os.mkdir("my_dir_name") -- http://mail.python.org/mailman/listinfo/python-list

Re: any python module to calculate sin, cos, arctan?

2005-11-08 Thread Juho Schultz
Shi Mu wrote: > any python module to calculate sin, cos, arctan? math There are two versions of arctan: atan and atan2. atan2(y,x) does the quadrant selection you do not get from atan(y/x) -- http://mail.python.org/mailman/listinfo/python-list

Re: Pylab and pyserial plot in real time

2005-11-08 Thread Juho Schultz
[EMAIL PROTECTED] wrote: > Hiya, > > I've got a PIC microcontroller reading me humidity data via rs232, this > is in ASCII format. I can view this data easily using hyperterminal or > pyserial and convert it to its value (relative humidty with ord(input)) > > But what im trying to do is plot the

Re: Not Equal to Each Other?

2005-11-04 Thread Juho Schultz
[EMAIL PROTECTED] wrote: > How do I 'define' set? Is there something to include (like import > random)? > set is a built-in type in Python 2.4 If you use 2.3 you can use the sets module with "import sets" > while (choice == 3) and len(set(cellboard[0:8]))==len(cellboard[0:8]): > # DEFIN

Re: * TypeError - Need help passings args

2005-11-02 Thread Juho Schultz
Ernesto wrote: > Thanks, that ran without errors. The only problem now is that it > launches devcon.exe without actually passing the parameters to the > program. It's as if I just typed "devcon" at a Windows command prompt > and pressed enter. I can't figure out why it doesn't accept my > parame

Re: * TypeError - Need help passings args

2005-11-02 Thread Juho Schultz
Ernesto wrote: > My program is below. I'm trying to use two Windows ".exe" files with > my command line python interface. I get user input, then call > "launchWithoutConsole". This was working OK until I introduced the > 'args' part. Now I get the following error everytime I call > "launchWitho

Re: OpenSSL in Python

2005-11-01 Thread Juho Schultz
dcrespo wrote: > Hi to all, > > What do I have to install to get the following code work (Win XP, > Python 2.4.2) > > > from OpenSSL import SSL > import config > > KEY_FILE = config.SSL_KEY_FILE > CERT_FILE = config.SSL_CERT_FILE > > > -- > > I've been looking

Re: Jpg

2005-10-28 Thread Juho Schultz
Tuvas wrote: > I am building a GUI interface at the moment, and would like to have > support for displaying a jpg file, and a FITS file if possible. Is > there any way to do this? My interface has been written in Tkinter at > the moment, especially because of it's great portability, I wouldn't > ha

Re: nested escape chars in a shell command

2005-10-19 Thread Juho Schultz
Eli Criffield wrote: > I'm try run an ssh command in pexpect and I'm having trouble getting > everything escaped to do what i want. > > Here's a striped down script showing what i want to do. > > -- > #!/usr/bin/env python > import pexpect > import sys > if len(sys.argv) < 3: > print "ssh

Re: my array subset method could be improved?

2005-10-14 Thread Juho Schultz
Jim O'D wrote: > Hi all > > I have an array a=array([2,3,1]). > > I want to extract an array with all the elements of a that are less than 0. > > Method 1. > new = array([i for i in a if i < 0]) > > Method 2. > new = a[nonzero(a<0)] > > I'm using Numeric arrays but can't seem to find a functio

Re: how to make this code faster

2005-10-12 Thread Juho Schultz
[EMAIL PROTECTED] wrote: > def f(x,y): > return math.sin(x*y) + 8 * x > I have code like this: > > def main(): > n = 2000 > a = zeros((n,n), Float) > xcoor = arange(0,1,1/float(n)) > ycoor = arange(0,1,1/float(n)) > > > for i in range(n): > for j in range(n): >

Re: recursive function

2005-10-07 Thread Juho Schultz
mg wrote: > Hello, > > In a recursive function like the following : > > > def foo( j ) : > j += 1 > while j < n : j = foo( j ) > return j > > > in found that the recursivity is limited (1000 iterations). Then, I have > two questions : > - why this mecanism has been implemented ? > - it is

Re: python plotting with greek symbols within labels recommendations?

2005-10-05 Thread Juho Schultz
[EMAIL PROTECTED] wrote: > hello all, > > this message is geared toward those of you in the scientific community. > i'm looking for a python plotting library that can support rendering > greek symbols and other various characters on plot axes labels, etc. I > would prefer something that adheres to

Re: Background process for ssh port forwarding

2005-10-03 Thread Juho Schultz
Jesse Rosenthal wrote: > Hello all, > > I'm writing a script which will backup data from my machine to a server > using rsync. It checks to see if I am on the local network. If I am, it > runs rsync over ssh to 192.168.2.6 using the pexpect module to log in. > That's the easy part. > > Now, when

Re: Straight line detection

2005-09-30 Thread Juho Schultz
PyPK wrote: > Does anyone know of a simple implementation of a straight line > detection algorithm something like hough or anything simpler.So > something like if we have a 2D arary of pixel elements representing a > particular Image. How can we identify lines in this Image. > for example: > > ary

Re: Changing the module not taking effect in calling module

2005-09-27 Thread Juho Schultz
Gopal wrote: > Hi, > > I've a module report.py having a set of funtions to open/close/write > data to a log file. I invoke these functions from another module > script.py. > > Whenever I'm changing something in report.py, I'm running the file > (however, it has not effect). After that I'm running

Re: plateform info.

2005-09-20 Thread Juho Schultz
Monu Agrawal wrote: > Hi I want to know whether the program is being run on windows or on > Xnix. Is there any variable or method which tells me that it's windows? > os.name - the value is "posix" for Linux/Unix, "nt" or "ce" for Windows, and so on... -- http://mail.python.org/mailman/listinfo/p