Re: run a function in another processor in python

2010-12-10 Thread Astan Chee
Sorry about that, here is a summary of my complete code. I haven't cleaned it up much or anything, but this is what it does: import time import multiprocessing test_constx =0 test_consty =0 def functionTester(x): global test_constx global test_consty print "constx " + str(test_constx) pr

Re: ctypes question

2010-12-10 Thread Mark Tolonen
"News Wombat" wrote in message news:2abdd9b3-66ec-4125-a5f8-41315008c...@l17g2000yqe.googlegroups.com... Hi everyone, I've been experimenting with the ctypes module and think it's great. I'm hitting a few snags though with seg faults. I attached two links that holds the code. The line i'm h

stuck with Pexpect script need help!!

2010-12-10 Thread Darshak Bavishi
Hi Experts, got ready made code for ssh to unix using python host machine is windows now when i run this its gives following error : * Traceback (most recent call last): File "C:\Python26\pexpect-2.1\pexpect-2.1\pxssh.py", line 1, in from pexpect import * File "C:\Python26\pexpect-2.1\pexpect-2.1

Re: run a function in another processor in python

2010-12-10 Thread Peter Otten
geremy condra wrote: > On Fri, Dec 10, 2010 at 4:42 AM, Astan Chee wrote: >> On Fri, Dec 10, 2010 at 1:37 AM, Peter Otten <__pete...@web.de> wrote: >>> >>> I can't replicate the crash. However, your problem looks like there is a >>> ready-to-use solution: >>> >>> >>> http://docs.python.org/librar

Re: Python critique

2010-12-10 Thread Stefan Behnel
John Nagle, 11.12.2010 00:51: On 12/10/2010 3:25 PM, Stefan Behnel wrote: Benjamin Kaplan, 11.12.2010 00:13: On Fri, Dec 10, 2010 at 5:46 PM, Octavian Rasnita wrote: The only scopes Python has are module and function. There's more. Both a lambda, and in Python 3.x, list comprehensions, int

Re: Python critique

2010-12-10 Thread Dan Stromberg
On Fri, Dec 10, 2010 at 3:51 PM, John Nagle wrote: > On 12/10/2010 3:25 PM, Stefan Behnel wrote: >> >> Benjamin Kaplan, 11.12.2010 00:13: >>> >>> On Fri, Dec 10, 2010 at 5:46 PM, Octavian Rasnita wrote: > >>> The only scopes Python has are module and function. > >   There's more.  Both a lambda, a

Re: Python critique

2010-12-10 Thread John Nagle
On 12/10/2010 3:25 PM, Stefan Behnel wrote: Benjamin Kaplan, 11.12.2010 00:13: On Fri, Dec 10, 2010 at 5:46 PM, Octavian Rasnita wrote: The only scopes Python has are module and function. There's more. Both a lambda, and in Python 3.x, list comprehensions, introduce a new scope.

ctypes question

2010-12-10 Thread News Wombat
Hi everyone, I've been experimenting with the ctypes module and think it's great. I'm hitting a few snags though with seg faults. I attached two links that holds the code. The line i'm having problems with is this, sn=clibsmi.smiGetNextNode(pointer(sno),SMI_NODEKIND_ANY) It will work one time,

Re: Python critique

2010-12-10 Thread Stefan Behnel
Benjamin Kaplan, 11.12.2010 00:13: On Fri, Dec 10, 2010 at 5:46 PM, Octavian Rasnita wrote: How narrow are the scopes in Python? Is each block (each level of indentation) a scope? If it is, then I think it is very enough because the other cases can be detected easier or it might not appear at a

Re: Python critique

2010-12-10 Thread Steven D'Aprano
On Sat, 11 Dec 2010 00:46:41 +0200, Octavian Rasnita wrote: > How narrow are the scopes in Python? > Is each block (each level of indentation) a scope? Thankfully, no. > If it is, then I > think it is very enough because the other cases can be detected easier > or it might not appear at all in

Re: Python critique

2010-12-10 Thread Stefan Behnel
John Nagle, 10.12.2010 21:02: Probably the biggest practical problem with CPython is that C modules have to be closely matched to the version of CPython. There's no well-defined API that doesn't change. Well, there are no huge differences between CPython versions (apart from the Py_ssize_t cha

Re: Python critique

2010-12-10 Thread Benjamin Kaplan
On Fri, Dec 10, 2010 at 5:46 PM, Octavian Rasnita wrote: > From: "John Nagle" >> On 12/10/2010 2:31 AM, kolo 32 wrote: >>> Hi, all, >>> >>> Python critique from strchr.com: >>> >>> http://www.strchr.com/python_critique >> >>    I have criticisms of Python, but those aren't them. >> >>    Probably

Re: Python critique

2010-12-10 Thread Antoine Pitrou
On Fri, 10 Dec 2010 12:02:21 -0800 John Nagle wrote: > > Probably the biggest practical problem with CPython is > that C modules have to be closely matched to the version of > CPython. There's no well-defined API that doesn't change. Please stop spreading FUD: http://docs.python.org/c-api/i

Re: Python critique

2010-12-10 Thread Octavian Rasnita
From: "John Nagle" > On 12/10/2010 2:31 AM, kolo 32 wrote: >> Hi, all, >> >> Python critique from strchr.com: >> >> http://www.strchr.com/python_critique > >I have criticisms of Python, but those aren't them. > >Probably the biggest practical problem with CPython is > that C modules have

ANN: ActivePython 3.1.3.5 is now available

2010-12-10 Thread Sridhar Ratnakumar
ActiveState is pleased to announce ActivePython 3.1.3.5, a complete, ready-to-install binary distribution of Python 3.1. http://www.activestate.com/activepython/downloads What's New in ActivePython-3.1.3.5 == *Release date: 6-Dec-2010* New Features & Upgrade

Re: surprised by import in python 2.6

2010-12-10 Thread Emile van Sebille
On 12/10/2010 2:22 PM Ian said... On Dec 10, 3:06 pm, Stefaan Himpe wrote: Somehow, in the first session I cannot modify the global variable a returned from f, but in the second session I can. To my eye, the only difference seems to be a namespace. Can anyone shine some light on this matter?

Re: surprised by import in python 2.6

2010-12-10 Thread Ian
On Dec 10, 3:06 pm, Stefaan Himpe wrote: > Somehow, in the first session I cannot modify the global variable a > returned from f, but in the second session I can. To my eye, the only > difference seems to be a namespace. Can anyone shine some light on this > matter? It's not the same global varia

surprised by import in python 2.6

2010-12-10 Thread Stefaan Himpe
Hello list, Recently someone asked me this question, to which I could not give an answer. I'm hoping for some insight, or a manual page. What follows is python 2.6. The problem is with the difference between from test import * and import test First things first. Here's the code to test.py

Re: run a function in another processor in python

2010-12-10 Thread geremy condra
On Fri, Dec 10, 2010 at 4:42 AM, Astan Chee wrote: > On Fri, Dec 10, 2010 at 1:37 AM, Peter Otten <__pete...@web.de> wrote: >> >> I can't replicate the crash. However, your problem looks like there is a >> ready-to-use solution: >> >> >> http://docs.python.org/library/multiprocessing.html#using-a-

Re: unicode compare errors

2010-12-10 Thread Nobody
On Fri, 10 Dec 2010 11:51:44 -0800, Ross wrote: > Since I can't control the encoding of the input file that users > submit, how to I get past this? How do I make such comparisons be > True? On Fri, 10 Dec 2010 12:07:19 -0800, Ross wrote: > I found I could import codecs that allow me to read the

Re: decouple copy of a list

2010-12-10 Thread Ben Finney
Dirk Nachbar writes: > I want to take a copy of a list a > > b=a In addition to the other good replies you've received: To take a copy of an object, the answer is never ‘b = a’. That binds a reference ‘b’ to the same object referenced by ‘a’. The assignment operator ‘=’ never copies; it binds

Re: unicode compare errors

2010-12-10 Thread Ross
On Dec 10, 2:51 pm, Ross wrote: > Initially I was simply doing: > >   currs = [u'$', u'£', u'€', u'¥'] >   aFile = open(thisFile, 'r') >   for mline in aFile:              # mline might be "£5.50" >      if item[0] in currs: >           item = item[1:] > Don't you love it when someone solves the

Re: Python critique

2010-12-10 Thread John Nagle
On 12/10/2010 2:31 AM, kolo 32 wrote: Hi, all, Python critique from strchr.com: http://www.strchr.com/python_critique I have criticisms of Python, but those aren't them. Probably the biggest practical problem with CPython is that C modules have to be closely matched to the version of C

Biography, Dr Michel Chossudovsky, Dr.Evgeny Chossudovsky: Writer with a distinguished UN career

2010-12-10 Thread small Pox
http://www.globalresearch.ca/index.php?context=viewArticle&code=20060212&articleId=1955 Evgeny Chossudovsky: Writer with a distinguished UN career Global Research, February 12, 2006 The Irish Times - 2006-01-18 Throughout his UN career and until his death, Evgeny Chossudovsky expressed his firm

Re: Python creates "locked" temp dir

2010-12-10 Thread Alex Willmer
On Dec 8, 6:26 pm, Christian Heimes wrote: > There isn't a way to limit access to a single process. mkdtemp creates > the directory with mode 0700 and thus limits it to the (effective) user > of the current process. Any process of the same user is able to access > the directory. > > Christian Qui

unicode compare errors

2010-12-10 Thread Ross
I've a character encoding issue that has stumped me (not that hard to do). I am parsing a small text file with some possibility of various currencies being involved, and want to handle them without messing up. Initially I was simply doing: currs = [u'$', u'£', u'€', u'¥'] aFile = open(thisFil

Re: run a function in another processor in python

2010-12-10 Thread MRAB
On 10/12/2010 17:52, Dennis Lee Bieber wrote: On Fri, 10 Dec 2010 23:02:24 +1100, Astan Chee declaimed the following in gmane.comp.python.general: for thread in threads: if not thread.is_alive(): threads.remove(thread) I can see a potential flaw ju

Re: continuing development on modules after they're installed

2010-12-10 Thread Jonathan Gardner
On Fri, Dec 10, 2010 at 9:32 AM, Ian wrote: > On Dec 10, 9:57 am, hoesley wrote: >> I just started using distutils to install the modules I'm working on >> to site-packages. Now, however, if I make changes in my development >> directory, then import the modules into python, it always loads up the

Re: 64 bit memory usage

2010-12-10 Thread Rob Randall
I manged to get my python app past 3GB on a smaller 64 bit machine. On a test to check memory usage with gc disabled only an extra 6MB was used. The figures were 1693MB to 1687MB. This is great. Thanks again for the help. On 10 December 2010 13:54, Rob Randall wrote: > You guys are right. If

Interview Programming puzzles

2010-12-10 Thread aviral gupta
For Programming puzzles visit the blog http://coders-stop.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Proposed changes to logging defaults

2010-12-10 Thread Vinay Sajip
On Dec 10, 10:17 am, Jean-Michel Pichavant wrote: Hi Jean-Michel, I think Antoine answered your other points, so I'll address the last one: > Last question, if no handler is found, why not simply drop the log > event, doing nothing ? It sounds pretty reasonable and less intrusive. That is what

Re: decouple copy of a list

2010-12-10 Thread Jean-Michel Pichavant
cassiope wrote: Alternatively, you can write import copy a = [1,2,3] b = a.copy() JM I'm not a pyguru, but... you didn't use copy quite right. Try instead: b= copy.copy(a) You're right, you're not a python guru so don't even try to contradict me ever again. ... :D of course I di

Re: continuing development on modules after they're installed

2010-12-10 Thread Ian
On Dec 10, 9:57 am, hoesley wrote: > I just started using distutils to install the modules I'm working on > to site-packages. Now, however, if I make changes in my development > directory, then import the modules into python, it always loads up the > installed version. Thus, I can't continue devel

Sage's Python

2010-12-10 Thread Akand Islam
In my system (Ubuntu 10.04) there are sage-4.6, python 2.6.5, tk8.5- dev installed. When I give command from terminal "sage -f python-2.6.5.p8" to get sage's python it shows following message: No command 'sage' found, did you mean: Command 'save' from package 'atfs' (universe) Command 'page' fr

continuing development on modules after they're installed

2010-12-10 Thread hoesley
I just started using distutils to install the modules I'm working on to site-packages. Now, however, if I make changes in my development directory, then import the modules into python, it always loads up the installed version. Thus, I can't continue development without first uninstalling the module

optparse/argparse for cgi/wsgi?

2010-12-10 Thread samwyse
Has anyone ever built some sort of optparse/argparse module for cgi/ wsgi programs? I can see why a straight port wouldn't work, but a module that can organize parameter handling for web pages seems like a good idea, especially if it provided a standard collection of both client- and server-side v

Re: decouple copy of a list

2010-12-10 Thread nn
On Dec 10, 8:48 am, Dirk Nachbar wrote: > I want to take a copy of a list a > > b=a > > and then do things with b which don't affect a. > > How can I do this? > > Dirk Not knowing the particulars, you may have to use: import copy b=copy.deepcopy(a) -- http://mail.python.org/mailman/listinfo/pyt

Re: trace cmd line args in 2.7

2010-12-10 Thread rusi
On Dec 10, 10:53 am, rusi wrote: > Ive installed python 2.7 > And trace still ignores my ignore-module etc requests Is this a know bug with the trace module? I find it hard to believe that as traces naturally tend to get huge unless carefully trimmed -- http://mail.python.org/mailman/listinfo/py

Re: Deprecation warnings (2.7 -> 3 )

2010-12-10 Thread rusi
On Dec 10, 9:17 pm, nn wrote: > On Dec 9, 10:15 pm, rusi wrote: > > > In trying to get from 2.x to 3 Terry suggested I use 2.7 with > > deprecation warnings > > > Heres the (first) set > > > DeprecationWarning: Overriding __eq__ blocks inheritance of __hash__ > > in 3.x > > DeprecationWarning: ca

Re: Deprecation warnings (2.7 -> 3 )

2010-12-10 Thread Tim Golden
On 10/12/2010 16:17, nn wrote: On Dec 9, 10:15 pm, rusi wrote: In trying to get from 2.x to 3 Terry suggested I use 2.7 with deprecation warnings Heres the (first) set DeprecationWarning: Overriding __eq__ blocks inheritance of __hash__ in 3.x DeprecationWarning: callable() not supported in 3

Re: Deprecation warnings (2.7 -> 3 )

2010-12-10 Thread nn
On Dec 10, 11:17 am, nn wrote: > On Dec 9, 10:15 pm, rusi wrote: > > > In trying to get from 2.x to 3 Terry suggested I use 2.7 with > > deprecation warnings > > > Heres the (first) set > > > DeprecationWarning: Overriding __eq__ blocks inheritance of __hash__ > > in 3.x > > DeprecationWarning: c

Re: decouple copy of a list

2010-12-10 Thread cassiope
On Dec 10, 6:06 am, Jean-Michel Pichavant wrote: > Dirk Nachbar wrote: > > I want to take a copy of a list a > > > b=a > > > and then do things with b which don't affect a. > > > How can I do this? > > > Dirk > > In [1]: a = [1,2,3] > > In [2]: b = a[:] > > In [3]: b[0] = 5 > > In [4]: a > Out[4]:

Re: Deprecation warnings (2.7 -> 3 )

2010-12-10 Thread nn
On Dec 9, 10:15 pm, rusi wrote: > In trying to get from 2.x to 3 Terry suggested I use 2.7 with > deprecation warnings > > Heres the (first) set > > DeprecationWarning: Overriding __eq__ blocks inheritance of __hash__ > in 3.x > DeprecationWarning: callable() not supported in 3.x; use isinstance(x

Re: Python critique

2010-12-10 Thread Octavian Rasnita
From: "Jean-Michel Pichavant" > > Octavian Rasnita wrote: >> It is true that Python doesn't use scope limitations for variables? >> >> Octavian >> > Python does have scope. The problem is not the lack of scope, to > problem is the shadow declaration of some python construct in the > curren

about module import ..

2010-12-10 Thread Teratux
Hello ... I'm using buildbot to build some of my projects. I'm having problems when I configure it and I think it might be with the python configuration on my pc: I'm getting this error: Traceback (most recent call last): File "/usr/bin/buildbot", line 3, in from buildbot.scripts import ru

Re: decouple copy of a list

2010-12-10 Thread Wolfgang Rohdewald
On Freitag 10 Dezember 2010, Dirk Nachbar wrote: > > b=a[:] > > > > -- > > Wolfgang > > I did that but then some things I do with b happen to a as > well. as others said, this is no deep copy. So if you do something to an element in b, and if the same element is in a, both are changed as they ar

Re: Python critique

2010-12-10 Thread Stefan Behnel
Jean-Michel Pichavant, 10.12.2010 15:02: the shadow declaration of some python construct in the current scope. print x # raise NameError [x for x in range(10)] # shadow declaration of x print x # will print 9 Note that this is rarely a problem in practice, and that this has been fixed in Pyth

Re: decouple copy of a list

2010-12-10 Thread Dirk Nachbar
On Dec 10, 1:56 pm, Wolfgang Rohdewald wrote: > On Freitag 10 Dezember 2010, Dirk Nachbar wrote: > > > I want to take a copy of a list a > > > b=a > > > and then do things with b which don't affect a. > > > How can I do this? > > > Dirk > > b=a[:] > > -- > Wolfgang I did that but then some things

Re: decouple copy of a list

2010-12-10 Thread Jean-Michel Pichavant
Dirk Nachbar wrote: I want to take a copy of a list a b=a and then do things with b which don't affect a. How can I do this? Dirk In [1]: a = [1,2,3] In [2]: b = a[:] In [3]: b[0] = 5 In [4]: a Out[4]: [1, 2, 3] In [5]: b Out[5]: [5, 2, 3] Alternatively, you can write import copy a

Re: Comparisons of incompatible types

2010-12-10 Thread Mark Wooding
Steven D'Aprano writes: > On Thu, 09 Dec 2010 12:21:45 +, Mark Wooding wrote: > > > John Nagle writes: > > >> "sort" has failed because it assumes that a < b and b < c implies a < > >> c. But that's not a valid assumption here. > >> > >> It's not good to break trichotomy. > > > > You're con

Re: Python critique

2010-12-10 Thread Jean-Michel Pichavant
Octavian Rasnita wrote: It is true that Python doesn't use scope limitations for variables? Octavian Python does have scope. The problem is not the lack of scope, to problem is the shadow declaration of some python construct in the current scope. print x # raise NameError [x for x in ra

Re: decouple copy of a list

2010-12-10 Thread Wolfgang Rohdewald
On Freitag 10 Dezember 2010, Dirk Nachbar wrote: > I want to take a copy of a list a > > b=a > > and then do things with b which don't affect a. > > How can I do this? > > Dirk b=a[:] -- Wolfgang -- http://mail.python.org/mailman/listinfo/python-list

Re: decouple copy of a list

2010-12-10 Thread Daniel Urban
b = list(a) or b = a[:] -- http://mail.python.org/mailman/listinfo/python-list

Re: decouple copy of a list

2010-12-10 Thread Kushal Kumaran
On Fri, Dec 10, 2010 at 7:18 PM, Dirk Nachbar wrote: > I want to take a copy of a list a > > b=a > > and then do things with b which don't affect a. > > How can I do this? > b = a[:] will create a copy of the list. If the elements of the list are references to mutable objects (objects of your ow

Re: 64 bit memory usage

2010-12-10 Thread Rob Randall
You guys are right. If I disable the gc it will use all the virtual RAM in my test. The application I have been running these tests for is a port of a program written in a LISP-based tool running on Unix. It does a mass of stress calculations. The port has been written using a python-based toolki

decouple copy of a list

2010-12-10 Thread Dirk Nachbar
I want to take a copy of a list a b=a and then do things with b which don't affect a. How can I do this? Dirk -- http://mail.python.org/mailman/listinfo/python-list

Re: Python critique

2010-12-10 Thread Octavian Rasnita
It is true that Python doesn't use scope limitations for variables? Octavian - Original Message - From: "kolo 32" Newsgroups: comp.lang.python To: Sent: Friday, December 10, 2010 12:31 PM Subject: Python critique > Hi, all, > > Python critique from strchr.com: > > http://www.strchr

Re: run a function in another processor in python

2010-12-10 Thread Astan Chee
On Fri, Dec 10, 2010 at 1:37 AM, Peter Otten <__pete...@web.de> wrote: > I can't replicate the crash. However, your problem looks like there is a > ready-to-use solution: > > http://docs.python.org/library/multiprocessing.html#using-a-pool-of-workers > > -- > http://mail.python.org/mailman/listinf

Re: run a function in another processor in python

2010-12-10 Thread Astan Chee
I just saw this: http://bugs.python.org/issue8094 which seem to be similar to what I'm having. Does anyone know if there is a fix for it? Thanks again On Fri, Dec 10, 2010 at 11:02 PM, Astan Chee wrote: > Thanks for that. I'll try and see if it makes any difference but I'm using > python 2.6 not

Re: run a function in another processor in python

2010-12-10 Thread Astan Chee
Thanks for that. I'll try and see if it makes any difference but I'm using python 2.6 not 3 Are the multiprocessing modules different? That code (or whatever is using the multiprocessing module) seems to cause infinite python processes on my machine and eventually kills it. I'm running python 2.6 o

Re: Proposed changes to logging defaults

2010-12-10 Thread Antoine Pitrou
On Fri, 10 Dec 2010 11:17:33 +0100 Jean-Michel Pichavant wrote: > Why would you log informative messages to stderr ? (debug, info, warning) > How stderr is a better choice than stdout ? By construction really. stderr is initially for errors, but it is generally used for "out of band" messages suc

Re: instance has no __call__ method

2010-12-10 Thread Dave Angel
On 01/-10/-28163 02:59 PM, frank cui wrote: Hi all, I'm a novice learner of python and get caught in the following trouble and hope experienced users can help me solve it:) Code: --- $ cat Muffle_ZeroDivision.py #!/usr/bin/env

Python critique

2010-12-10 Thread kolo 32
Hi, all, Python critique from strchr.com: http://www.strchr.com/python_critique -- http://mail.python.org/mailman/listinfo/python-list

Re: printing error message from an Exception

2010-12-10 Thread Jean-Michel Pichavant
mark jason wrote: On Dec 10, 11:55 am, Steven D'Aprano wrote: # By the way, IOError is not the only exception you could see. thanks for the help Steven. Is it OK to catch Exception instead of IOError ? In some operation which can cause many errors ,can I use the following? try:

instance has no __call__ method

2010-12-10 Thread frank cui
Hi all, I'm a novice learner of python and get caught in the following trouble and hope experienced users can help me solve it:) Code: --- $ cat Muffle_ZeroDivision.py #!/usr/bin/env python class MuffledCalculator: muffled =

Re: Proposed changes to logging defaults

2010-12-10 Thread Jean-Michel Pichavant
Vinay Sajip wrote: Some changes are being proposed to how logging works in default configurations. Briefly - when a logging event occurs which needs to be output to some log, the behaviour of the logging package when no explicit logging configuration is provided will change, most likely to log t

Re: printing error message from an Exception

2010-12-10 Thread Peter Otten
mark jason wrote: > hi > I was trying out some file operations and was trying to open a non > existing file as below > > def do_work(filename): > try: > f = open(filename,"r"); > print 'opened' > except IOError, e: > print 'failed',e.message > finally: >

Re: printing error message from an Exception

2010-12-10 Thread mark jason
On Dec 10, 11:55 am, Steven D'Aprano wrote: >     # By the way, IOError is not the only exception you could see. thanks for the help Steven. Is it OK to catch Exception instead of IOError ? In some operation which can cause many errors ,can I use the following? try: do_something() except Ex

Re: little emacs lisp tutorial on turning a url into a link

2010-12-10 Thread Steve Holden
On 12/10/2010 4:52 AM, small Pox wrote: [... irrelevant stuff...] > I advocate neither anti semitism nor pro semitism. just the rule of > law that treats people equally and fairly and where money does not > count. this cannot be achieved without demolishing fractional reserve > lending, and not wit