Re: AI Example Help

2012-10-11 Thread Trevor Nelson
> > An interesting concept. AI monitoring systems have never really > > appealed to me; I personally prefer something with simpler and clearer > > rules (eg "if server load exceeds 3.0, raise an alert"), coupled with > > information retrieval commands that read like commands, not natural > >

Re: AI Example Help

2012-10-11 Thread Chris Angelico
On Fri, Oct 12, 2012 at 4:44 PM, Trevor Nelson wrote: > I really would truely appreciate and example coding of how to put together an > initial basic "AI" bot where it can monitor the system and tell me alerts as > with being able to query it for questions. As with I am looking for some sort >

AI Example Help

2012-10-11 Thread Trevor Nelson
Hello all, For the first time in well... a very long time I am coming to a loss on where to really get started here on the project I wish to undertake to help me really get into Python programming. A quick explanation of how I learn. I learn best with example working small code bits. With the

Re: Static analysis tools

2012-10-11 Thread Tim Leslie
On 12 October 2012 04:25, Dan Stromberg wrote: > > I'm familiar with pylint, and have recently played with pyflakes and flake8. > I've also heard of pychecker. > > Are there others, perhaps including some that aren't written in Python, but > still check Python? Another one I've found useful for s

Re: Is `wsample` a proper name for a function like this?

2012-10-11 Thread suzaku
On Friday, October 12, 2012 10:22:16 AM UTC+8, Steven D'Aprano wrote: > On Wed, 10 Oct 2012 23:44:42 -0700, suzaku wrote: > > > > > I think if a programmer has used the built-in `random` module before, he > > > would expect a function with "sample" in its name to return a population > > > sequ

Re: Is `wsample` a proper name for a function like this?

2012-10-11 Thread Steven D'Aprano
On Wed, 10 Oct 2012 23:44:42 -0700, suzaku wrote: > I think if a programmer has used the built-in `random` module before, he > would expect a function with "sample" in its name to return a population > sequence. I have used the random module for about fifteen years, and I still write random.samp

Re: Insert item before each element of a list

2012-10-11 Thread Steven D'Aprano
On Fri, 12 Oct 2012 00:21:57 +0200, Hans Mulder wrote: > On 9/10/12 04:39:28, rusi wrote: >> On Oct 9, 7:34 am, rusi wrote: >>> How about a 2-paren version? >>> >> x = [1,2,3] >> reduce(operator.add, [['insert', a] for a in x]) >>> >>> ['insert', 1, 'insert', 2, 'insert', 3] >> >> Or if

Re: __setitem__ without position

2012-10-11 Thread Ethan Furman
Kevin Anthony wrote: I'm not supprised... and understand why it's happening. I'm asking how to get around it. I don't think you do understand what's happening. What's happening is the basic application of name binding in Python: --> C = anything whatever C was bound to before, it no longer

Re: __setitem__ without position

2012-10-11 Thread Terry Reedy
On 10/11/2012 5:32 PM, Dave Angel wrote: Alternatively, you could call one of the other methods in the class. But since you gave us no clues, I'm shouldn't guess what it was called. But if I were to make such a class, I might use slicing: C[:] = [57, 50, 59, 60] In 3.x, you would write __

Re: Insert item before each element of a list

2012-10-11 Thread Terry Reedy
On 10/11/2012 6:21 PM, Hans Mulder wrote: On 9/10/12 04:39:28, rusi wrote: On Oct 9, 7:34 am, rusi wrote: How about a 2-paren version? x = [1,2,3] reduce(operator.add, [['insert', a] for a in x]) ['insert', 1, 'insert', 2, 'insert', 3] Or if one prefers the different parens on the other

Re: Posix call (execve) breaks mercurial?

2012-10-11 Thread Wayne Werner
On Thu, 11 Oct 2012, Wayne Werner wrote: So here's where things got weird. I could call `subprocess.check_output(['hg', 'root'])`, and things worked just fine. But when I added the env parameter, I got the untrusted issues. So if I did: import os, subprocess # Works just fine subprocess.chec

Posix call (execve) breaks mercurial?

2012-10-11 Thread Wayne Werner
So... this is certainly the deepest I've got to dig into any source code. I'm experimenting with Review Board for code reviews, and trying to get it set up/working here at work. When using post-review, however, I started getting issues with untrusted users - even though they were set to trusted

Re: __setitem__ without position

2012-10-11 Thread Ian Kelly
On Thu, Oct 11, 2012 at 4:13 PM, Kevin Anthony wrote: > I'm not supprised... and understand why it's happening. I'm asking how to > get around it. > > Basically i'm asking how to override, if i can, the `=` You cannot override assignment of local variables. To get around it, use slicing as Dave

Re: Insert item before each element of a list

2012-10-11 Thread Hans Mulder
On 9/10/12 04:39:28, rusi wrote: > On Oct 9, 7:34 am, rusi wrote: >> How about a 2-paren version? >> > x = [1,2,3] > reduce(operator.add, [['insert', a] for a in x]) >> >> ['insert', 1, 'insert', 2, 'insert', 3] > > Or if one prefers the different parens on the other side: > reduce

Re: __setitem__ without position

2012-10-11 Thread Kevin Anthony
I'm not supprised... and understand why it's happening. I'm asking how to get around it. Basically i'm asking how to override, if i can, the `=` On Thu, Oct 11, 2012 at 5:32 PM, Dave Angel wrote: > On 10/11/2012 04:48 PM, Kevin Anthony wrote: > > I have a class that contains a list of items

Re: an error in python lib?

2012-10-11 Thread Wenhua Zhao
> On Wed, Oct 10, 2012 at 6:18 AM, Ulrich Eckhardt >> The comment clearly states "owned by current thread", not "owned by any >> thread". The latter would also be useless, as that can change concurrently >> at any time when owned by a different thread, so making decisions on this >> state is futile

Re: __setitem__ without position

2012-10-11 Thread Dave Angel
On 10/11/2012 04:48 PM, Kevin Anthony wrote: > I have a class that contains a list of items > I can set items using __setitem__ but if i want to set the while list, i > changes the variable from a myclass to a list. How can i accomblish this > Example C = myclass() C[0] = 57 type(C)

Re: for-loop on cmd-line

2012-10-11 Thread Gisle Vanem
"Dave Angel" wrote: Why would you write some C-program just to save having two separate files, one batch and one for the script? For that matter, several answers have given you approaches that didn't involve list comprehensions, including merging the two in a single file, using an initial vari

__setitem__ without position

2012-10-11 Thread Kevin Anthony
I have a class that contains a list of items I can set items using __setitem__ but if i want to set the while list, i changes the variable from a myclass to a list. How can i accomblish this Example >>>C = myclass() >>>C[0] = 57 >>>type(C) myclass >>> C = [57,58,59,60] >>>type(C) list -- http://m

Re: for-loop on cmd-line

2012-10-11 Thread Dave Angel
On 10/11/2012 09:40 AM, Gisle Vanem wrote: > "Dave Angel" wrote: > >> it has nothing to do with being on a command line. You're using >> semicolon to combine several statements, and there are restrictions on >> what can be combined that way. One restriction is the looping >> constructs, for, if,

Re: __builtins__ thread-safe / __builtins__ as function?

2012-10-11 Thread Dave Angel
On 10/11/2012 10:16 AM, Juergen Bartholomae wrote: > Hello. > I have quite a peculiar problem. > > A little overview of our situation: > Our program enables our users to write their own python code (which they > use extensively). > Unfortunately, (due to us actually encouraging this in an earlier r

RE: for-loop on cmd-line

2012-10-11 Thread Prasad, Ramit
Chris Angelico wrote: > On Fri, Oct 12, 2012 at 3:49 AM, Gisle Vanem wrote: > > wrote in comp.lang.python > > > > (my ISP no longer updates this group. Last message is from 8. April. > > Does the postings to the python mailing-list automatically get reposted to > > comp.lang.python?) > > Yes, c.

Re: Static analysis tools

2012-10-11 Thread Mark Lawrence
On 11/10/2012 18:25, Dan Stromberg wrote: I'm familiar with pylint, and have recently played with pyflakes and flake8. I've also heard of pychecker. Are there others, perhaps including some that aren't written in Python, but still check Python? We're considering doing static analysis of a large

Static analysis tools

2012-10-11 Thread Dan Stromberg
I'm familiar with pylint, and have recently played with pyflakes and flake8. I've also heard of pychecker. Are there others, perhaps including some that aren't written in Python, but still check Python? We're considering doing static analysis of a large CPython 3.2 project, but so far the traditi

Re: for-loop on cmd-line

2012-10-11 Thread Chris Angelico
On Fri, Oct 12, 2012 at 3:49 AM, Gisle Vanem wrote: > wrote in comp.lang.python > > (my ISP no longer updates this group. Last message is from 8. April. > Does the postings to the python mailing-list automatically get reposted to > comp.lang.python?) Yes, c.l.p and python-list mirror each other.

Re: for-loop on cmd-line

2012-10-11 Thread Gisle Vanem
wrote in comp.lang.python (my ISP no longer updates this group. Last message is from 8. April. Does the postings to the python mailing-list automatically get reposted to comp.lang.python?) C:\Windows\system32\python32.zip c:\python32\DLLs I see a similar result: f:\Windows\system32\python

Re: for-loop on cmd-line

2012-10-11 Thread Chris Angelico
On Fri, Oct 12, 2012 at 3:24 AM, wrote: > Le jeudi 11 octobre 2012 15:16:33 UTC+2, Ramchandra Apte a écrit : > > PS C:\> $cmd="import sys;" > PS C:\> $cmd+="print('\n'.join(sys.path))" > PS C:\> $cmd > import sys;print('\n'.join(sys.path)) > PS C:\> c:\python32\python -c $cmd > > C:\Windows\syste

Re: for-loop on cmd-line

2012-10-11 Thread wxjmfauth
Le jeudi 11 octobre 2012 15:16:33 UTC+2, Ramchandra Apte a écrit : PS C:\> $cmd="import sys;" PS C:\> $cmd+="print('\n'.join(sys.path))" PS C:\> $cmd import sys;print('\n'.join(sys.path)) PS C:\> c:\python32\python -c $cmd C:\Windows\system32\python32.zip c:\python32\DLLs c:\python32\lib c:\pytho

Re: Getting ipython notebook to plot inline [updated]

2012-10-11 Thread Frank Franklin
Ok, so just to add to this, there is no problem plotting when I used the following command in my terminal to start the notebook: ipython notebook The only problem is that this plots my figures outside of the notebook page, and I really want to get everything into the notebook, since that's th

Re: __builtins__ thread-safe / __builtins__ as function?

2012-10-11 Thread Chris Angelico
On Fri, Oct 12, 2012 at 1:16 AM, Juergen Bartholomae wrote: > One possible solution is to somehow redirect every __builtins__ to a > function that returns a different __builtins__ dictionary for each thread > (such a function already exists). How exactly does the code reference it? If they're si

Re: [Python-ideas] Make undefined escape sequences have SyntaxWarnings

2012-10-11 Thread MRAB
On 2012-10-11 06:34, Greg Ewing wrote: Steven D'Aprano wrote: If you escape a character, you should get something. If it's a special character, you get the special meaning. If it's not, escaping should be transparent: escaping something that doesn't need escaping is a null op I think that call

__builtins__ thread-safe / __builtins__ as function?

2012-10-11 Thread Juergen Bartholomae
Hello. I have quite a peculiar problem. A little overview of our situation: Our program enables our users to write their own python code (which they use extensively). Unfortunately, (due to us actually encouraging this in an earlier release (!stupid!)) this meant that, in several cases, there are

Re: for-loop on cmd-line

2012-10-11 Thread Gisle Vanem
"Dave Angel" wrote: it has nothing to do with being on a command line. You're using semicolon to combine several statements, and there are restrictions on what can be combined that way. One restriction is the looping constructs, for, if, while. Ok, I suspected something like that. You can

Re: [ANN] pylint 0.26 / logilab-astng 0.24.1

2012-10-11 Thread Ramchandra Apte
On Monday, 8 October 2012 19:50:18 UTC+5:30, Sylvain Thénault wrote: > Hi all, > > > > I'm very pleased to announce new releases of Pylint and > > underlying ASTNG library, respectivly 0.26 and 0.24.1. The great > > news is that both bring a lot of new features and some bug fixes, > > mostly

Re: for-loop on cmd-line

2012-10-11 Thread Chris Angelico
On Fri, Oct 12, 2012 at 12:16 AM, Ramchandra Apte wrote: > What about the "Power" in PowerShell? What about it? Are you suggesting that the OP use it? Are you saying that Windows batch already includes it? You quoted my entire post (double-spaced), but that context adds nothing to your statement;

Re: for-loop on cmd-line

2012-10-11 Thread Ramchandra Apte
On Thursday, 11 October 2012 18:44:44 UTC+5:30, Chris Angelico wrote: > On Thu, Oct 11, 2012 at 11:16 PM, D'Arcy J.M. Cain wrote: > > > On Thu, 11 Oct 2012 13:24:22 +0200 > > > Gisle Vanem wrote: > > > > > >> Hello list. I'm a newbie when it comes to Python. > > >> > > >> I'm trying to tur

Re: for-loop on cmd-line

2012-10-11 Thread Chris Angelico
On Thu, Oct 11, 2012 at 11:16 PM, D'Arcy J.M. Cain wrote: > On Thu, 11 Oct 2012 13:24:22 +0200 > Gisle Vanem wrote: > >> Hello list. I'm a newbie when it comes to Python. >> >> I'm trying to turn this: >> >> def print_sys_path(): >> i = 0 >> for p in sys.path: >> print ('sys.path[%

Re: for-loop on cmd-line

2012-10-11 Thread D'Arcy J.M. Cain
On Thu, 11 Oct 2012 13:24:22 +0200 Gisle Vanem wrote: > Hello list. I'm a newbie when it comes to Python. > > I'm trying to turn this: > > def print_sys_path(): > i = 0 > for p in sys.path: > print ('sys.path[%2d]: %s' % (i, p)) > i += 1 > > into a one-line python command

Re: for-loop on cmd-line

2012-10-11 Thread Dave Angel
On 10/11/2012 07:24 AM, Gisle Vanem wrote: > Hello list. I'm a newbie when it comes to Python. > > I'm trying to turn this: > > def print_sys_path(): >i = 0 >for p in sys.path: > print ('sys.path[%2d]: %s' % (i, p)) > i += 1 > > into a one-line python command (in a .bat file): > >

Re: for-loop on cmd-line

2012-10-11 Thread suzaku
According to the document (http://docs.python.org/using/cmdline.html#interface-options), > When called with -c command, it executes the Python statement(s) given as > command. Here command may contain multiple statements separated by newlines. > Leading whitespace is significant in Python statem

for-loop on cmd-line

2012-10-11 Thread Gisle Vanem
Hello list. I'm a newbie when it comes to Python. I'm trying to turn this: def print_sys_path(): i = 0 for p in sys.path: print ('sys.path[%2d]: %s' % (i, p)) i += 1 into a one-line python command (in a .bat file): python -c "import sys,os; i=0; for p in sys.path: print('sys.p

Re: Generating C++ code

2012-10-11 Thread Etienne Robillard
On Wed, 10 Oct 2012 20:12:36 -0700 Tim Roberts wrote: > Jean-Michel Pichavant wrote: > > > >I'm trying to generate C++ code from an XML file. I'd like to use a template > >engine, which imo produce something readable and maintainable. > >My google search about this subject has been quite unsucc