> I also started to ponder about the "'do
> something' if 'true' else 'do this'", and pondered if perhaps
> this statement could do with the including of the keyword do.
Python has support for this in versions >= 2.5:
>>> a = range(0, 5)
>>> b = range(5, 8)
>>> min(a) if sum(a) < sum(b) else min(
Hi,
A while ago I asked a question on the list about a simple eval
function, capable of eval'ing simple python constructs (tuples, dicts,
lists, strings, numbers etc) in a secure manner:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/58a01273441d445f/
>From the answers I got
Hi,
I've tried locating some code that can recreate an object from it's
string representation...
The object in question is really a dictionary containing other
dictionaries, lists, unicode strings, floats, ints, None, and
booleans.
I don't want to use eval, since I can't trust the source sending
Hi,
Does anyone know how to interrupt the lookup of an integer value? I
know I need to subclass int, since builtin types can't be altered
directly...
Below is how far I've come... What I want is to tap into the access of
instance i's value 1...
>>> class Int(int):
def __init__(self, *a,
Python in a nutshell also comes in a second edition:
http://www.oreilly.com/catalog/pythonian2/index.html. Here, many of
the new features in Python 2.5 are included. I haven't read through
the first the edition, but I can honestly say that reading through the
second edition has made me a better pro
Hi,
How can I transform b so that the assertion holds? I.e., how can I
reverse the backslash-replaced encoding, while retaining the str-type?
>>> a = u'æ'
>>> b = a.encode('ascii', 'backslashreplace')
>>> b
'\\xe6'
>>> assert isinstance(b, str) and b == 'æ'
Traceback (most recent call last):
F
Hi
I create a canvas that is to big for the default window-size, so it gets cut
to fit...
How can I increase the window-size to make sure the canvas fits?
regards tores
--
http://mail.python.org/mailman/listinfo/python-list
Hi
In php I can assign a value to a variable and use this varaible to access a
property in some object:
$var = 'property';
$object->{$var}
This will transelate to $object->property...
Is this possible in Python?
# Prints help on methods in Canvas-instance
for method in dir(self.canvas):
pr
Hi
For an online game I'm developing I need some advice concerning tcp-sockets,
and especially which socket options to set and not.
What I want is a connection where nothing is buffered (but are sent
immediatly), and I also want to keep the connections persistent until
explicitly closed.
The se
Hi
Have the following code:
import logging
logging.basicConfig(level = logging.DEBUG,
format = '[%(levelname)-8s %(asctime)s]
%(message)s',
filename = 'rfs.log',
filemode = 'w')
When using logging.(debug
Hi
>From a client I read a file into a string using read().
On the server-side (it's a HTTPServer) i access the same string through the
input stream rfile.
However all useful read-methods (readlines, readline, read) expect an EOF
before terminating.
And for some reason the stream doesn't have th
Hi
How can I select a random entry from a dictionary, regardless of its
key-values?
regards tores
--
http://mail.python.org/mailman/listinfo/python-list
Hi
How can I read the first line of a file and then delete this line, so that
line 2 is line 1 on next read?
regards
--
http://mail.python.org/mailman/listinfo/python-list
Hi.
>From my Python-program I spawn a new process. When using P_NOWAIT spawnl
returns the pid but in windows it returns a process handle.
Later I want to kill this process. How can I do this when I only have the
process handle?
-tores-
--
http://mail.python.org/mailman/listinfo/python-list
14 matches
Mail list logo