On 02/25/10 16:18, D'Arcy J.M. Cain wrote:
Very interesting, I had a similar kind of problem (a network balancer
that doesn't balance small tcp packages too well) and solved it by
wrapping the TCP package in UDP. UDP was treated differently, although
in overall switch and router manager it has
* Chris Gray:
Lawrence D'Oliveiro writes:
In message , Wanja Gayk wrote:
Reference counting is about the worst technique for garbage collection.
It avoids the need for garbage collection. It means I can write things like
I'm by no means an expert, but how does reference counting deal with
* Michael Pardee:
I'm relatively new to python and I was very surprised by the following behavior:
a=1
b=2
'a' refers to an object representing the integer 1.
Since 1 is an immutable value you can just as well think of it as 'a' containing
the value 1, because a reference to an immutable va
* qtrimble:
I'm a python newbie but I do have some basic scripting experience. I
need to take the line starting with "wer" and extract the year and day
of year from that string. I want to be able to add the year and day
of year from the last line having "wer*" to the lines occurring in
between
* Raphael Mayoraz:
Hello,
I'd like to define variables with some specific name that has a common
prefix.
Something like this:
varDic = {'red': 'a', 'green': 'b', 'blue': 'c'}
for key, value in varDic.iteritems():
'myPrefix' + key = value
I know this is illegal, but there must be a trick s
* MRAB:
Steven D'Aprano wrote:
On Fri, 26 Feb 2010 09:09:36 -0600, Tim Daneliuk wrote:
Reminiscent of:
mov AX,BX ; Move the contents of BX into AX
That's a *good* comment, because without it most English-speaking
people would assume you were moving the contents of AX into B
On 02/27/10 09:36, @ Rocteur CC wrote:
Hi a couple of fragmented things popped in my head reading your
question, non of them is very constructive though in what you actually
want, but here it goes anyway.
- Oneline through away script with re as a built in syntax, yup that
sounds like perl t
* @ Rocteur CC:
On 27 Feb 2010, at 12:44, Steven D'Aprano wrote:
On Sat, 27 Feb 2010 10:36:41 +0100, @ Rocteur CC wrote:
cat file.dos | python -c "import sys,re;
[sys.stdout.write(re.compile('\r\n').sub('\n', line)) for line in
sys.stdin]" >file.unix
Holy cow!!! Calling a regex just fo
* Dr. Phillip M. Feldman:
Stefan Behnel-3 wrote:
alexander@gmail.com wrote:
I think the speed function may be broken from the turtle graphics package
"from turtle import *
speed('fastest')
forward(50)"
I have tried all of the different speed settings, but I get no change
in the turtl
On 02/28/10 11:05, Stefan Behnel wrote:
Steven D'Aprano, 28.02.2010 09:48:
There ought to be some kind of competition for the least efficient
solution to programming problems
That wouldn't be very interesting. You could just write a code generator
that spits out tons of garbage code including
* Michael Rudolf:
Out of curiosity I tried this and it actually worked as expected:
>>> class T(object):
x=[]
foo=x.append
def f(self):
return self.x
>>> t=T()
>>> t.f()
[]
>>> T.foo(1)
>>> t.f()
[1]
>>>
At first I thought "hehe, always fun to play around with p
* vsoler:
I have a class that is a wrapper:
class wrapper:
def __init__(self, object):
self.wrapped = object
def __getattr__(self, attrname):
print 'Trace: ', attrname
#print arguments to attrname, how?
return getattr(self.wrapped, attrname)
I can run it
In case Someone Else(TM) may need this.
This code is just how it currently looks, what I needed for my code, so it's not
a full-fledged or even tested class.
But it works.
import tkinter as t
import tkinter.simpledialog
import tkinter.messagebox
t.askstring = tkinter.simpledialog.askstr
* rantingrick:
On Feb 28, 6:30 pm, "Alf P. Steinbach" wrote:
In case Someone Else(TM) may need this.
This code is just how it currently looks, what I needed for my code, so it's not
a full-fledged or even tested class.
Thanks for sharing Alf,
Thats works fine "a
* rantingrick:
kw.setdefault('activestyle', 'none')
Hm, let me steal this line... Thanks!
Cheers,
- Alf
--
http://mail.python.org/mailman/listinfo/python-list
How to crash CPython 3.1.1 in Windows XP:
python -c "import os; os.spawnl( os.P_WAIT, 'blah' )"
I reported this as a bug, http://bugs.python.org/issue8036>
Workaround: it seems that spawnl is happy with an absolute path as second arg,
followed by a third arg which should be the name of the p
* Steven Woody:
Hi,
I want to interactive with an OLE application with pywin32. The
problem is I get totally no idea how to find the object in OLEView and
how to figure out it's interface.
With pywin32's example, I even don't understand that in the below statement,
win32com.client.Dispatch(
* Tracubik:
hi, i've to convert from Pascal this code:
iterations=0;
count=0;
REPEAT;
iterations = iterations+1;
...
IF (genericCondition) THEN count=count+1;
...
CASE count OF:
1: m = 1
2: m = 10
3: m = 100
Uhm, is this syntactically valid Pascal? As I recall
* Alf P. Steinbach:
* Tracubik:
hi, i've to convert from Pascal this code:
iterations=0;
count=0;
REPEAT;
iterations = iterations+1;
...
IF (genericCondition) THEN count=count+1;
...
CASE count OF:
1: m = 1
2: m = 10
3: m = 100
Uhm, is this syntactically
* Alf P. Steinbach:
* Alf P. Steinbach:
* Tracubik:
hi, i've to convert from Pascal this code:
iterations=0;
count=0;
REPEAT;
iterations = iterations+1;
...
IF (genericCondition) THEN count=count+1;
...
CASE count OF:
1: m = 1
2: m = 10
3: m = 100
Uhm, is
On 03/02/10 19:44, MRAB wrote:
information, such as when it was completed, the status (OK or failed),
etc. You might want to wrap it in a class with locks (mutexes) to ensure
it's threadsafe.
What actually happens if multiple threads at the same time, write to a
shared dictionary (Not using the
* Patrick Maupin:
On Mar 2, 5:36 pm, Steven D'Aprano wrote:
You seem to be taking the position that if you start with a config file
config.json, it is "too hard to edit", but then by renaming it to
config.rson it magically becomes easier to edit. That *is* ludicrous.
No, but that seems to be
For C++ Petru Marginean once invented the "scope guard" technique (elaborated on
by Andrei Alexandrescu, they published an article about it in DDJ) where all you
need to do to ensure some desired cleanup at the end of a scope, even when the
scope is exited via an exception, is to declare a Scope
* Mike Kent:
What's the compelling use case for this vs. a simple try/finally?
if you thought about it you would mean a simple "try/else". "finally" is always
executed. which is incorrect for cleanup
by the way, that's one advantage:
a "with Cleanup" is difficult to get wrong, while a "try"
* Steven D'Aprano:
On Wed, 03 Mar 2010 15:30:36 +, Grant Edwards wrote:
I definitely remember that old MS-DOS programs would treat Ctrl-Z as an
EOF marker when it was read from a text file and would terminate a text
file with a Ctrl-Z when writing one.
I believe that Windows (at least up
* Robert Kern:
On 2010-03-03 09:39 AM, Mike Kent wrote:
What's the compelling use case for this vs. a simple try/finally?
original_dir = os.getcwd()
try:
os.chdir(somewhere)
# Do other stuff
finally:
os.chdir(original_dir)
# Do other cleanup
A custo
* Robert Kern:
On 2010-03-03 09:56 AM, Alf P. Steinbach wrote:
* Mike Kent:
What's the compelling use case for this vs. a simple try/finally?
if you thought about it you would mean a simple "try/else". "finally" is
always executed. which is incorrect for clean
* Alf P. Steinbach:
In case Someone Else(TM) may need this.
This code is just how it currently looks, what I needed for my code, so
it's not a full-fledged or even tested class.
But it works.
That code evolved a little to cover more Tk listbox quirks (thanks to Ratingrick
fo
* Robert Kern:
On 2010-03-03 11:18 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 09:56 AM, Alf P. Steinbach wrote:
* Mike Kent:
What's the compelling use case for this vs. a simple try/finally?
if you thought about it you would mean a simple "try/else".
"
* Robert Kern:
On 2010-03-03 13:32 PM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 11:18 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 09:56 AM, Alf P. Steinbach wrote:
* Mike Kent:
What's the compelling use case for this vs. a simple try/finally?
if you thought
* Robert Kern:
On 2010-03-03 15:35 PM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 13:32 PM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 11:18 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 09:56 AM, Alf P. Steinbach wrote:
* Mike Kent:
What's the compe
* Jean-Michel Pichavant:
Alf P. Steinbach wrote:
From your post, the scope guard technique is used "to ensure some
desired cleanup at the end of a scope, even when the scope is exited
via an exception." This is precisely what the try: finally: syntax is
for.
You'd have to
* Robert Kern:
On 2010-03-03 18:49 PM, Alf P. Steinbach wrote:
* Robert Kern:
[snip]
can you
understand why we might think that you were saying that try: finally:
was wrong and that you were proposing that your code was equivalent to
some try: except: else: suite?
No, not really. His code
* Robert Kern:
On 2010-03-04 09:48 AM, Alf P. Steinbach wrote:
* Jean-Michel Pichavant:
Alf P. Steinbach wrote:
From your post, the scope guard technique is used "to ensure some
desired cleanup at the end of a scope, even when the scope is exited
via an exception." This is precisel
* Robert Kern:
On 2010-03-04 10:56 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 18:49 PM, Alf P. Steinbach wrote:
[snippety]
If you call the possibly failing operation "A", then that systematic
approach goes like this: if A fails, then it has cleaned up its own
mess
* Mike Kent:
On Mar 4, 12:30 pm, Robert Kern wrote:
He's ignorant of the use cases of the with: statement, true.
Ouch! Ignorant of the use cases of the with statement, am I?
Odd, I use it all the time.
Given only your
example of the with: statement, it is hard to fault him for thinking
* Robert Kern:
On 2010-03-04 12:37 PM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-04 10:56 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 18:49 PM, Alf P. Steinbach wrote:
[snippety]
If you call the possibly failing operation "A", then that systematic
approach
* Steve Holden:
Alf P. Steinbach wrote:
* Robert Kern:
[...]
No, it only argues that "with Cleanup():" is supernumerary.
I don't know what "supernumerary" means, but to the degree that the
argument says anything about a construct that is not 'finally', i
* Robert Kern:
On 2010-03-04 17:52 , Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-04 12:37 PM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-04 10:56 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 18:49 PM, Alf P. Steinbach wrote:
[snippety]
If you call the possibly
* Robert Kern:
On 2010-03-04 16:27 , Alf P. Steinbach wrote:
* Mike Kent:
However, I fail to understand his response that I must have meant try/
else instead, as this, as Mr. Kern pointed out, is invalid syntax.
Perhaps Mr. Steinbach would like to give an example?
OK.
Assuming that you
* Mike Kent:
On Mar 4, 8:04 pm, Robert Kern wrote:
No, the try: finally: is not implicit. See the source for
contextlib.GeneratorContextManager. When __exit__() gets an exception from the
with: block, it will push it into the generator using its .throw() method. This
raises the exception insid
* Steve Howell:
On Mar 3, 7:10 am, "Alf P. Steinbach" wrote:
For C++ Petru Marginean once invented the "scope guard" technique (elaborated on
by Andrei Alexandrescu, they published an article about it in DDJ) where all you
need to do to ensure some desired cleanup at the
On 03/05/10 19:21, wongjoek...@yahoo.com wrote:
Any specific reason why threading.Thread or multiprocessing is not
suitable to solve your problem?
--
mph
--
http://mail.python.org/mailman/listinfo/python-list
On 03/05/10 19:45, wongjoek...@yahoo.com wrote:
On 5 mrt, 20:40, "Martin P. Hellwig"
wrote:
On 03/05/10 19:21, wongjoek...@yahoo.com wrote:
Any specific reason why threading.Thread or multiprocessing is not
suitable to solve your problem?
--
mph
Because I got a memory leak in my
On 03/05/10 19:24, Pete Emerson wrote:
In a module, how do I create a conditional that will do something
based on whether or not another module has been loaded?
>
If someone is using foo module, I want to take advantage of its
features and use it in foobar, otherwise, I want to do something els
On 03/05/10 20:09, wongjoek...@yahoo.com wrote:
On 5 mrt, 21:02, "Martin P. Hellwig"
wrote:
On 03/05/10 19:45, wongjoek...@yahoo.com wrote:
On 5 mrt, 20:40, "Martin P. Hellwig"
wrote:
On 03/05/10 19:21, wongjoek...@yahoo.com wrote:
Any specific reason why
* Robert Kern:
On 2010-03-03 09:39 AM, Mike Kent wrote:
What's the compelling use case for this vs. a simple try/finally?
original_dir = os.getcwd()
try:
os.chdir(somewhere)
# Do other stuff
finally:
os.chdir(original_dir)
# Do other cleanup
A custo
On 03/06/10 09:45, wongjoek...@yahoo.com wrote:
Yes, I saw this example also before. HOwever what I want is to call an
internal function which gets a reference of another internal function
as input and not calling an external program. Do you have any example
on that with subprocess module ?
Tha
* Joan Miller:
How to escape the first '}' in the next string?
s = "}\n{0}".format('foo')
s = "}}\n{0}".format('foo')
Cheers & hth.,
- Alf
--
http://mail.python.org/mailman/listinfo/python-list
Since Mohamed is talking about compilation I think it's more likely he's talking
about an intermediate program represention based on quad tuples like
(OP, DESTINATION, ARG1, ARG2)
Cheers,
- Alf
* Steven Howe:
Is it possible he's talking about a 'quad core'? as in a CPU? In that
case I thi
at:
http://code.google.com/p/dcuktec/source/browse/source/wrapped_xmlrpc_server/rpc.py
with perhaps special interest at the comment on lines 172-174.
--
mph
--
http://mail.python.org/mailman/listinfo/python-list
or example look at:
http://code.google.com/p/dcuktec/source/browse/source/wrapped_xmlrpc_server/rpc.py
with perhaps special interest at the comment on lines 172-174.
I
Thanks. this looks like a good solution for an XMLRPC server.
However when playing with different server modules I fall over and
On 03/08/10 00:18, Paweł Banyś wrote:
Hello,
I have already read about Python and multiprocessing which allows using
many processors. The idea is to split a program into separate tasks and
run each of them on a separate processor. However I want to run a Python
program doing a single simple task
On 03/08/10 02:10, monkeys paw wrote:
I can xfer a file from a remote server using:
import urllib2 as u
x=u.urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl')
for line in x:
print line
How can i write a file to the remote server?
I tried:
x = u.url.open('http://joemoney.net/somefile.txt
On 03/08/10 02:51, monkeys paw wrote:
On 3/7/2010 9:20 PM, Martin P. Hellwig wrote:
On 03/08/10 02:10, monkeys paw wrote:
I can xfer a file from a remote server using:
import urllib2 as u
x=u.urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl')
for line in x:
print line
How can
* Gabriel Genellina:
En Thu, 04 Mar 2010 20:52:04 -0300, Alf P. Steinbach
escribió:
Sorry, as with the places noted above, I can't understand what you're
trying to say here.
Regarding your posts, neither can I. All the time. Sorry, deciphering
your posts would force me to spend
On 03/08/10 17:06, Stephen Nelson-Smith wrote:
Hi,
I've written some (primitive) code to parse some apache logfies and
establish if apache has appended a session cookie to the end. We're
finding that some browsers don't and apache doesn't just append a "-"
- it just omits it.
It's working fine
* C. Benson Manica:
Hours of Googling has not helped me resolve a seemingly simple
question - Given a string s, how can I tell whether it's ascii (and
thus 1 byte per character) or UTF-8 (and two bytes per character)?
This is python 2.4.3, so I don't have getsizeof available to me.
Generally, i
On 02/09/10 14:00, Phlip wrote:
Ah, now we get down to the root of the problem. Because Python is so
stuck on the "one best way to do it" mentality, language bigotry
prevented the Committee from picking from among several equally valid
but non-best options. And after 20 years of growth, Python s
Hi all,
Before I start reinventing a squared wheel, I have the following question:
Is there already a (standard) module that wraps around the various
os/sys information which checks if the platform + version is supported
for what I want to do with it.
For example I am currently looking at mak
* James Harris:
On 10 Mar, 06:29, "Gabriel Genellina" wrote:
En Tue, 09 Mar 2010 18:41:10 -0300, Daniel Klein
escribi :
Basically I'm wondering if there are any plans to implemented named
loops in Python, so I can tell a break command to break out of a
specific loop in the case of nested l
On 03/10/10 21:52, J wrote:
I'm working on a project and thought I'd ask for a suggestion on how
to proceed (I've got my own ideas, but I wanted to see if I was on the
right track)
Well I can't speak with authority but I would go into similar lines,
especially since you want to call an externa
On 03/11/10 22:08, Cal Who wrote:
Thanks, that helped a lot.
I'm having trouble knowing what to search for to find documenatation. For
example, is print a Python command, a numpy command or a java command?
I like to read the documentation even if the command is working for me.
Thanks again
On 03/11/10 01:37, Gabriel Genellina wrote:
En Wed, 10 Mar 2010 10:54:27 -0300, Martin P. Hellwig
escribió:
Before I start reinventing a squared wheel, I have the following
question:
Is there already a (standard) module that wraps around the various
os/sys information which checks if the
* Félix-Antoine Fortin:
Given this code :
# Experience with frame
import sys
import inspect
def foo():
stack = inspect.stack()
print "foo frame : " + str(hex(id(sys._getframe(
hex returns a string. applying str is therefore redundant.
def foo2():
inspect.stack()
print "f
* Gib Bogle:
Steven D'Aprano wrote:
As the old proverb goes: give a man a fish, and you feed him for a
day. Teach him how to fish, and he has food forever.
I like this version:
Light a man a fire, and you keep him warm for hours. Set a man on fire,
and you keep him warm for the rest of his
On 03/13/10 19:23, Steven D'Aprano wrote:
On Sat, 13 Mar 2010 12:52:39 -0600, John Bokma wrote:
For quite some time I thought that comp.lang.perl.misc was quite
unfriendly because of a certain attitude. comp.lang.python was quite a
refreshment for a while: very newbie friendly, less pissing con
On 03/14/10 08:14, ahmet erdinc yilmaz wrote:
Hello,
Recenetly we are developing a senior project and decide to use xmlrpclib.
However I have some questions. In the documentation I could not find any
clue about
handling requests? Does the server handles each request in a separate
thread? Or is
t
On 03/14/10 10:32, hackingKK wrote:
Instead of using the library directly,
isn't python-twisted a better choice?
Why?
--
mph
--
http://mail.python.org/mailman/listinfo/python-list
* Mark Tolonen:
"Terry Reedy" wrote in message
news:hnjkuo$n1...@dough.gmane.org...
On 3/14/2010 4:40 PM, Guillermo wrote:
Adding the byte that some call a 'utf-8 bom' makes the file an invalid
utf-8 file.
Not true. From http://unicode.org/faq/utf_bom.html:
Q: When a BOM is used, is it o
* Alex Hall:
Hi all,
I have a dll I am trying to use, but I get a Windows error 126, "the
specified module could not be found". Here is the code segment:
nvdaController=ctypes.windll.LoadLibrary("nvdaControllerClient32.dll")
I have the specified dll file in the same directory as the file
* Sang-Ho Yun:
I learned that I can check the existence of a file using
os.path.isfile("filename").
What if I need to check if there is a file that contains "HV" in the
filename? What should I do?
from __future__ import print_function
import os
for filename in os.listdir( "." ):
* Alex Hall:
On 3/15/10, Ulrich Eckhardt wrote:
Alex Hall wrote:
I have a dll I am trying to use, but I get a Windows error 126, "the
specified module could not be found". Here is the code segment:
nvdaController=ctypes.windll.LoadLibrary("nvdaControllerClient32.dll")
In addition to Alf's ans
* Ulrich Eckhardt:
Chris Rebert wrote:
You're a bit behind the times.
If my calculations are right, that comic is over 2 years old.
import timetravel
C:\test> python
Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)]
on win32
Type "help", "copyright", "credi
On 03/16/10 19:30, Hans Mulder wrote:
Ulrich Eckhardt wrote:
Chris Rebert wrote:
You're a bit behind the times.
If my calculations are right, that comic is over 2 years old.
import timetravel
I think you mean:
from __future__ import timetravel
-- HansM
Well according to Marty it is:
fr
* Dave Angel:
Stefan Behnel wrote:
mikelisa...@gmail.com, 17.03.2010 10:08:
Its interesting you've mentioned the hard work involved in this
interface (binding to an EXE instead of a DLL). A year or more ago I
was looking at interfacing IPMITOOL to python. Do to the problems
incurred with swig/py
On 03/17/10 13:30, Tim Arnold wrote:
Hi,
I'm checking to see if multiprocessing works on freebsd for any
version of python. My server is about to get upgraded from 6.3 to 8.0
and I'd sure like to be able to use multiprocessing.
I think the minimal test would be:
-
import mult
* Lawrence D'Oliveiro:
In message , Chris
Rebert wrote:
I see that you published my unobfuscated e-mail address on USENET for all to
see. I obfuscated it for a reason, to keep the spammers away. I'm assuming
this was a momentary lapse of judgement, for which I expect an apology.
Otherwise, it b
* Stefan Behnel:
Alf P. Steinbach, 18.03.2010 09:53:
Path:
feeder.eternal-september.org!eternal-september.org!feeder.erje.net!newsfeed.straub-nv.de!news.linkpendium.com!news.linkpendium.com!newsfeeds.ihug.co.nz!lust.ihug.co.nz!ihug.co.nz!not-for-mail
From: Lawrence D'Oliveiro
Newsg
* Jussi Piitulainen:
Alf P. Steinbach writes:
The point is, if he's upset about Chris quoting that, then he's
probably unaware that he's posting it in plaintext himself.
The complaint was not about quoting but about using in public. Chris
sent his piece to three addresses. F
On 03/18/10 16:17, drstoka wrote:
Hello,
I have to run a program as a child process inside my python program and
redirect it's output through a pipe to a parent program process.
So, I wrote this:
pipe = Popen('example_program', shell=True, bufsize=0, stdout=PIPE).stdout
and it works great.
No
* Dave Angel:
Alf P. Steinbach wrote:
* Dave Angel:
Stefan Behnel wrote:
mikelisa...@gmail.com, 17.03.2010 10:08:
Its interesting you've mentioned the hard work involved in this
interface (binding to an EXE instead of a DLL). A year or more ago I
was looking at interfacing IPMITOOL to p
* Tim Roberts:
Dave Angel wrote:
There's no real reason parts of an exe cannot be exported, same as a
dll. They are in fact the same structure. And in fact many other files
in the Windows environment are also the same structure, from fonts to ocx's
This is a bit off-topic, but your explan
* MRAB:
Gabriel Genellina wrote:
En Fri, 19 Mar 2010 23:31:23 -0300, MRAB
escribió:
moerchendiser2k3 wrote:
class SetPointer
{
private:
void *ptr;
MY_LOCK lock;
public:
void SetPointer(void *p)
{
Lock(this->lock);
this->ptr = p;
}
3.
* News123:
I wondered about the best way, that a module's function could determine
the existance and value of variables in the __main__ module.
What I came up with is:
### main.py ##
import mod
A = 4
if __name__ == "__main__": mod.f()
### mod.py ##
def f():
probabilities ):
assert len( values ) == len( probabilities )
get2nd = operator.itemgetter( 1 )
v_p = sorted( zip( values, probabilities ), key = get2nd, reverse =
True )
v_ap = []; sum = 0;
for (v, p) in v_p:
v_ap.append( (v, p + sum) );
sum += p
* Alf P. Steinbach:
* Jah_Alarm:
I've got a vector length n of integers (some of them are repeating),
and I got a selection probability vector of the same length. How will
I sample with replacement k (<=n) values with the probabilty vector.
In Matlab this function is randsample. I could
* newton10471:
Hi,
I'm trying to use subprocess.Popen() to do a Linux chroot to a mount
point passed in as a parameter to the following function:
def getInstalledKernelVersion(mountPoint):
linuxFsRoot = mountPoint + "/root"
print "type of linuxFsRoot is %s" % type(linuxFsRoot)
insta
* kj:
In Dennis Lee Bieber
writes:
On Sun, 21 Mar 2010 16:57:40 + (UTC), kj
declaimed the following in gmane.comp.python.general:
Regarding properties, is there a built-in way to memoize them? For
example, suppose that the value of a property is obtained by parsing
the contents of a
of like an Easter
holiday mystery.
# Py3
# Copyright 2010 Alf P. Steinbach
import tkinter as tk
from collections import namedtuple
import random
Point = namedtuple( "Point", "x, y" )
Size= namedtuple( "Size", "x, y" )
RGB
On 03/23/10 23:38, Tim Chase wrote:
Just in case you're okay with a regexp solution, you can use
>>> s = "\t\tabc def "
>>> import re
>>> r = re.compile(r'^(\s*)(.*?)(\s*)$')
>>> m = re.match(s)
>>> m.groups()
('\t\t', 'abc def', ' ')
>>> leading, text, trailing = m.groups()
Ahhh regex,
* Alex Hall:
Hi all,
I have a program with a timer in it, therefore I have multiple
threads.
Is the "therefore..." an inference or independendent information?
If it is an inference then it may not be correct.
For example, timers in a GUI program need not involve additional threads.
My meth
* Neil Cerutti:
On 2010-03-25, Steven D'Aprano wrote:
You might not want to be so glib. The sum doc sure doesn't
sound like it should work on lists.
Returns the sum of a sequence of numbers (NOT strings) plus the
value of parameter 'start' (which defaults to 0).
What part of that sugg
Hi all,
When I run the following snippet (drastically simplified, to just show
what I mean):
>>
import platform, sys
class One(object):
def __init__(self):
self.one = True
def change(self):
self.one = False
class Two(object):
def __init__(self):
self._inst
On 03/25/10 23:41, Christian Heimes wrote:
Martin P. Hellwig schrieb:
What I don't understand why in the second test, the last boolean is True
instead of (what I expect) False.
Could somebody enlighten me please as this has bitten me before and I am
confused by this behavior.
Hint: TEST
On 03/26/10 01:10, Rhodri James wrote:
Pretty much. In the sense that you're thinking of, every assignment
works that way, even the initial "TEST1 = One()". Assignment binds names
to objects, though you have to be aware that names can be such exotic
things as "t", "a[15]" or "TEST2.__instance_o
* Andrej Mitrovic:
I would like to traverse through the entire structure of dir(), and
write it to a file.
Now, if I try to write the contents of dir() to a file (via pickle), I
only get the top layer. So even if there are lists within the returned
list from dir(), they get written as a list of
* Steve Howell:
On Mar 28, 8:17 am, Duncan Booth wrote:
Steve Howell wrote:
The mildly surprising part of sum() is that is does add vs. add-in-
place, which leads to O(N) vs. O(1) for the inner loop calls, for
certain data structures, notably lists, even though none of the
intermediate result
* Steven D'Aprano:
On Sun, 28 Mar 2010 18:56:26 +0200, Alf P. Steinbach wrote:
From a more practical point of view, the sum efficiency could be
improved by doing the first addition using '+' and the rest using '+=',
without changing the behavior.
But that would
* Jean-Michel Pichavant:
John Nagle wrote:
Jonathan Hayward wrote:
I've posted "Usability, the Soul of Python: An Introduction to the
Python Programming Language Through the Eyes of Usability", at:
http://JonathansCorner.com/python/
No, it's just a rather verbose introduction to Python
1301 - 1400 of 1697 matches
Mail list logo