, 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
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
instance
p = player() # calls __init__
# poison the player
p.take_poison()
--
Juho Schultz
--
http://mail.python.org/mailman/listinfo/python-list
[^A-Za-z0-9_]
[^xy] is approximately not in ('x', 'y')
--
Juho Schultz
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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_extensions
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 to enable users to place
their own python files
for reqRpm in listOfRpms if not
checkForRpm(reqRpm)]
# or you could use the builtin function filter() - see
filter.__doc__ for that
# now, list of lenght 0 is False.
if missingRpms:
# print error messages, exit.
--
Juho Schultz
--
http://mail.python.org/mailman/listinfo/python
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
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'][0] = 2
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 dead.
-- maybe it will help.
--
Steven.
Or try the program pdftotext?
-- Juho Schultz
--
http://mail.python.org/mailman/listinfo/python-list
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 have
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
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 it's a bit
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 do it using
keyword
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 system.
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 class. Can someone tell me the
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
Traceback (most recent
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
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
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.
--
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
[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 most
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 pages
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'
statements,
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 explicit line break.
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 shell :)
(I have used the shell a bit. I started using
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.
The script works
[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
[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
fries ,coke
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 accessible
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 needed
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, and
are
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'
--
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 wrote the 1st line has MSc in Physics from Cambridge (UK
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
[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 enter 3
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
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. When
[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 elements, not 1000, as he wrote:
And I noticed that all
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 this because if
x =
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/
--
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 conversion
--
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:
pass
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 like
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 is
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
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 work
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
I guess that's
[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 data
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
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
[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]):
# DEFINE TWO
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
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
parameter.
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 for OpenSSL
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
have
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.py host
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(a0)]
I'm using Numeric arrays but can't seem to find a function that does
[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):
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 possible to
[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 tex
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 I'm not
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 =
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
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...
--
68 matches
Mail list logo