Simon Forman wrote:
Carl J. Van Arsdall wrote:
Hrmms, well, here's an interesting situation. So say we wanna catch
most exceptions but we don't necessarily know what they are going to
be. For example, I have a framework that executes modules (python
functions), the framework wraps each
placid wrote:
quick hack
def thefunc(s):
return s = || + s +
def thefunc(s):
return s = || + s +
SyntaxError: invalid syntax
--
http://mail.python.org/mailman/listinfo/python-list
greenflame wrote:
Jason wrote:
There /are/ a few hacks which will do what you want. However, if you
really need it, then you probably need to rethink your program design.
Remember, you can't change a string since a string is immutable! You
can change a variable to bind to another
borris wrote:
ive been trying to do a test for type with wxpython objects
like
passing in a wx.TextCtrl into
def XXX(obj)
if type(obj) is type(self.Button)
I have to make an object self.Button to get its type.
as I tried is type(wx.Button) which didnt work.
type(wx.Button) would
[EMAIL PROTECTED] wrote:
I reported the bug to python.org and apparently it has already been
fixed in the latest SVN build :).
Awesome! Open Source at work! :D
--
http://mail.python.org/mailman/listinfo/python-list
Ernesto wrote:
Within the scope of one Python file (say myFile.py), I'd like to print
a message on ANY exception that occurs in THAT file, dependent on a
condition.
Here's the pseudocode:
if anyExceptionOccurs():
if myCondition:
print Here's my global exception message
BartlebyScrivener wrote:
I don't know if it's standard, but why not just:
dir = './foo/bar/moo/lar/myfile.txt'
dir.split('/')
['.', 'foo', 'bar', 'moo', 'lar', 'myfile.txt']
rd
There's also os.path.sep, from the docs: The character used by the
operating system to separate pathname
h3m4n wrote:
i have a short script that allows users to upload files, but when i try
to check for a valid filesize (using fileitem) i get '-1' i can't find
information about using filesize anywhere. any ideas?
code:
form = cgi.FieldStorage()
fileitem = form[datafile]
print
crystalattice wrote:
I've finally figured out the basics of OOP; I've created a basic character
creation class for my game and it works reasonably well. Now that I'm
trying to build a subclass that has methods to determine the rank of a
character but I keep getting errors.
I want to redefine
[EMAIL PROTECTED] wrote:
I tried what you said and it looked like maybe AttributeError, but that
didn't work either.
This code snippet:
import shelve
from traceback import format_exc
try:
db = shelve.open(meh, r)
except:
print format_exc()
Gave me this output:
Traceback (most
Thomas Nelson wrote:
I have this code:
type1 = [0]
type2 = [0]
type3 = [0]
map = {0:type1, 1:type1, 2:type3, 3:type1, 4:type2} # the real map is
longer than this
def increment(value):
map[value][0] += 1
increment(1)
increment(1)
increment(0)
increment(4)
#increment will
Kenneth McDonald wrote:
Would a mailing list and newsgroup for python contributions be of
interest? I currently have a module which is built on top of, and is
...
I'd very much likes a ML/newsgroup wherein potential python contributors
could
* Post alphas/betas and seek feedback.
* Request
Tim Chase wrote:
You'll notice that the OP's code had multiple references to the
same counter (0, 1, and 3 all mapped to type1)
The OP's method was about as good as it gets. One might try to
D'oh! Didn't notice that.
Yeah, Thomas, if you really do want more than type code (i.e. key to
Thomas Nelson wrote:
Thanks to everyone who posted. First, I don't think my question was
clear enough: Rob Cowie, Ant, Simon Forman, [EMAIL PROTECTED], and Jon
Ribbens offered solutions that don't quite work as-is, because I need
multiple values to map to a single type. Tim Chase and Bruno
Jim Anderson wrote:
I'm running Kubuntu a derivative of Debian Linux. I'm using
Python 2.4 and tcl/tk 8.4. I'm running Tkinter programs and
they were running about a month ago. When I tried them again
yesterday, I got the following message:
python ~/prog/python/iodef/iodef.py
Traceback
[EMAIL PROTECTED] wrote:
Hello,Im using Python 2.4.2 and I'm starting a few very basic
programs,but theres two problems I've not found the answers for.
My first problem is I need code that will count the number of letters
in a string and return that number to a variable.
Do you mean like this
manstey wrote:
Hi,
I often use:
a='yy'
tup=('x','yy','asd')
if a in tup:
...
but I can't find an equivalent code for:
a='xfsdfyysd asd x'
tup=('x','yy','asd')
if tup in a:
...
I can only do:
if 'x' in a or 'yy' in a or 'asd' in a:
...
but then I can't make the if
[EMAIL PROTECTED] wrote:
manstey:
is there a faster way of implementing this? Also, does the if clause
increase the speed?
I doubt the if increases the speed. The following is a bit improved
version:
# Original data:
data = 'asdfbasdf'
find = (('a', 'f'), ('s', 'g'), ('x', 'y'))
#
Yves Glodt wrote:
Hi,
I have a daemon which runs permanently, and I want it to do a special
operation at some specifiy times every day, consider this configfile
extract:
[general]
runat=10:00,12:00
What would be the easiest and most pythonic way to do this?
Something like this
Yves Glodt wrote:
while True:
if now(hours) in runat:
act()
sleep(60)
sleep(10)
Note that, if now(hours) *is* in runat, this loop will sleep 70
seconds, not 60. It probably doesn't matter.
--
http://mail.python.org/mailman/listinfo/python-list
madpython wrote:
...
self.b=Tkinter.Button(root,txt=Button,command=self.doSmth).pack()
self.l=Tkinter.Label(root,txt=default).pack()
def doSmth(self):
var=globals()[m].__dict__[progLogic].func(some
input)
self.l.config(txt=var)
self.l.update_idletasks()
...
Not related to your actual question, but note:
if len(result) == 0:
empty lists test as False, so this can just be
if not result:
and
result[len(result)-1] -= 128
you can index lists with negative ints, backwards from the end of the
list, so this can be
[EMAIL PROTECTED] wrote:
I wanted to write the following code:
import shelve
try:
db = shelve.open(file, r)
except SomeError:
print Oh no, db not found
Only, I'm not sure what SomeError should be. I tried error,
anydbm.error, shelve.open.anydb.error, etc. but can't find it. Things
gel wrote:
snip
class testclass:
import wmi
import time
global d_software
global l_notepad
global d_licence_numbers
d_licence_numbers = {notepad.exe:1, Adobe:1}
l_notepad =[]
d_software = {notepad.exe:[[],[]], Adobe:[[],[]]}
Wow! For a second there I
not think it means what you think it
means.
-Inigo Montoya, The Princess Bride
-bruce
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of Simon Forman
Sent: Monday, July 03, 2006 7:17 PM
To: python-list@python.org
Subject: Re: ascii character
I've got a function that I'd like to improve.
It takes a list of lists and a target element, and it returns the set
of the items in the lists that appear either before or after the target
item. (Actually, it's a generator, and I use the set class outside of
it to collect the unique items, but
Rony Steelandt wrote:
Hi all,
I wonder if somebody had a Sudoko solver written in Python ?
Rony
Dude, there's like a million of them. Try Sudoko solver Python in
google.
I wrote one myself based on Knuth's Dancing Links algorithm and using
Tkinter for the gui. I'll send it to you or post
Simon Forman wrote:
I've got a function that I'd like to improve.
It takes a list of lists and a target element, and it returns the set
of the items in the lists that appear either before or after the target
item. (Actually, it's a generator, and I use the set class outside of
it to collect
Sheldon wrote:
Hi,
I have a series of classes that are all within the same file. Each is
called at different times by the main script. Now I have discovered
that I need several variables returned to the main script. Simple,
right? I thought so and simply returned the variables in a tuple:
[EMAIL PROTECTED] wrote:
bruce wrote:
is there anyone with XPath expertise here? i'm trying to figure out if
there's a way to use regex expressions with an xpath query? i've seen
references to the ability to use regex and xpath/xml, but i'm not sure how
to do it...
i have a situation
[EMAIL PROTECTED] wrote:
I woulkdn't interate at the same time. zip takes two lists, and makes
a single list of tuples, not the other way around. The easilest
solution is
feed_list = [ix.url for ix in feeds_list_select]
feed_id = [ix.id for ix in feeds_list_select]
The zip built-in
bruce wrote:
hi...
i'm running into a problem where i'm seeing non-ascii chars in the parsing
i'm doing. in looking through various docs, i can't find functions to
remove/restrict strings to valid ascii chars.
i'm assuming python has something like
valid_str = strip(invalid_str)
where
Grant Edwards wrote:
On 2006-07-03, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
My problem now, is that I need to send certain binary data over a
socket. That is, I want to make some bytes, and stuff them in a TCP
packet, send them down the pipe, and then listen for a response.
...
In my
bruce wrote:
hi...
update. i'm getting back html, and i'm getting strings like foo nbsp;
which is valid HTML as the 'nbsp;' is a space.
, n, b, s, p, ; Those are all ascii characters.
i need a way of stripping/removing the 'nbsp;' from the string
the nbsp; needs to be treated as a
Nick Vatamaniuc wrote:
Robert Kern wrote:
[EMAIL PROTECTED] wrote:
The same thing goes for the values(). Here most people will argue that
...
This part is pretty much a non-starter. Not all Python objects are hashable.
...
Also, I may need keys to map to different objects that happen
bruce wrote:
hi
is there anyone with XPath expertise here? i'm trying to figure out if
there's a way to use regex expressions with an xpath query? i've seen
references to the ability to use regex and xpath/xml, but i'm not sure how
to do it...
i have a situation where i have something
bruce wrote:
simon..
you may not.. but lot's of people use python and xpath for html/xml
functionality.. check google python xpath...
later..
...
i have a situation where i have something like:
/html/table//[EMAIL PROTECTED]'foo']
is it possible to do soomething like [EMAIL
bruce wrote:
hi...
perl has the concept of die. does python have anything similar. how can a
python app be stopped?
the docs refer to a sys.stop.. but i can't find anything else... am i
missing something...
thanks
-bruce
What you want is sys.exit()
See:
python programming newb wrote:
Hi all, first post.
I'm new to python and tkinter. I'm trying to write a program that
opens the root window with a button that then opens a toplevel window
that then has it's own widgets. I can get the new toplevel window to
open but none of the widgets
a wrote:
hi simon thanks for your reply
You're most welcome
what if i want to do this
feed_list=[]
feed_id=[]
for ix in feeds_list_select:
global feeds_list
global feeds_id
Bruno Desthuilliers wrote:
Andy Dingley [EMAIL PROTECTED] wrote:
Simon Forman wrote:
There's more to it, but that's the basic idea.
This much I knew, but _why_ and _when_ would I choose to use list
comprehension (for good Python style), rather than using a simple
traditional loop
Nick Maclaren wrote:
...
Create a file called 'stdin' in your current directory containing
'print Oh, yeah?\n' and then import a module that doesn't exist.
Don't include the single quotes.
Why would you have a file named 'stdin' in your current directory?
~Simon
--
Nick Maclaren wrote:
In article [EMAIL PROTECTED],
Simon Forman [EMAIL PROTECTED] writes:
| Nick Maclaren wrote:
| ...
| Create a file called 'stdin' in your current directory containing
| 'print Oh, yeah?\n' and then import a module that doesn't exist.
| Don't include the single quotes
a wrote:
can someone tell me how to use them
thanks
basically, a list comprehension is just like a for loop, if you wrote
it out the long way it would be something like this:
results = []
for var in some_iterable:
if some condition:
results.append(some expression)
The list
[EMAIL PROTECTED] wrote:
I have a list
x = [0] * 2
x = x * [2]
You're certainly not doing that.
x = [0] * 2
x = x * [2]
Traceback (most recent call last):
File stdin, line 1, in ?
TypeError: can't multiply sequence by non-int
And even if you *do* do what it looks like you think you
Roman wrote:
I am new to python.
I am looking to read in a 12mb csv file, parse it, generate web pages,
summarize on a column and make drop down bottons.
Where would I be able to find sample code that does something similar
to this?
Also, I know that microsoft has put out .net beta
Roman wrote:
I am new to python.
I am looking to read in a 12mb csv file, parse it, generate web pages,
summarize on a column and make drop down bottons.
Where would I be able to find sample code that does something similar
to this?
Also, I know that microsoft has put out .net beta
Michael Abbott wrote:
It seems to be an invariant of Python (insofar as Python has invariants)
that a module is executed at most once in a Python session. I have a
rather bizzare example that breaks this invariant: can anyone enlighten
me as to what is going on?
--- test.py ---
import
[EMAIL PROTECTED] wrote:
i was wondering if anyone could point me to some good reading about the
for and while loops
i am trying to write some programs
Exercise 1
Write a program that continually reads in numbers from the user and
adds them together until the sum reaches 100. Write another
[EMAIL PROTECTED] wrote:
What are the reason one would get this error: TypeError: Cannot create
a consistent method resolution order (MRO) for bases object ??
I can provide the code if needed
Yes, do that.
That's an amazing error.
~Simon
--
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
placid wrote:
Simon Forman wrote:
...
For what you're asking about you'd probably want to use the
CGIHTTPRequestHandler from the CGIHTTPServer module instead. Check out
http://docs.python.org/lib/module-CGIHTTPServer.html
This is what i was after, thanks for the tip.
You're welcome
placid wrote:
Simon Forman wrote:
...
The file was named test.cgi. I changed it too test.py and it worked
Awesome! Glad to hear it.
...
Thanks for the help. I got it to work now.
You're welcome. I'm glad I could help you. :-D
Peace,
~Simon
--
http://mail.python.org/mailman
placid wrote:
Hi all,
Ive been reading about creating a HTTP server like the one pydoc
creates (and studying pydoc source code). What i want to know, is it
possible to create server that creates a webpage with hyperlinks that
communicate back to the HTTP server, where each link accessed
spohle wrote:
hi
how can i modify multiple widgets with one scrollbar ?
thanks in advance
sven
If you're using Tkinter check out:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52266
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
Bruno Desthuilliers wrote:
Simon Forman wrote:
rodmc wrote:
...
except:
print A database connection error has occurred
How can you assert it is a database connection error ?
assert database connection in error
(just kidding)
I was really just leaving as much of the OP's code
damacy wrote:
hello, everyone.
...
this works well. however, it does not show me any warning nor error
messages if there is one. for example, i am trying to create a table
which already exists in the database, it should show me a warning/error
message saying there already is one present in
Roland Rickborn wrote:
Hi folks,
...
As the subject says, I'd like to feed a wx.ComboBox with a
dictionary/hash. According to the posting of Stano Paska (wxComboBox
combobox, 20 Jul. 2004), there seems to be a way to do this:
You must use something like
combo.Append('aaa', 'a')
Sheldon wrote:
Hi,
I have a written a script that will check to see if the divisor is zero
before executing but python will not allow this:
if statistic_array[0:4] 0.0:
statistic_array[0,0:4] =
int(multiply(divide(statistic_array[0,0:4],statistic_array \
[0,4]),1.0))/100.0
Does
rodmc wrote:
Hi,
Thanks for your email. Well I am kind of new to exceptions in Python,
but here is the code used below, as you can see it is somewhat basic.
Is there a way to display more information about the exception?
Best,
rod
Use the traceback module (See
401 - 460 of 460 matches
Mail list logo