regular expression

2011-08-16 Thread Danny Wong (dannwong)
Hi All, If I get multiline standard output from a command. How can I retrieve this part of the string "(1006)" Example: #Committing... #Workspace: (1003) "My OS_8.12.0 Work" <-> (1004) "OS_8.12.0" # Component: (1005) "he-Group" <-> (1004) "OS_8.12.0" #Outgoing: # Change sets: #

subprocess.Popen question

2011-08-16 Thread Danny Wong (dannwong)
Hi All, I'm executing a command which I want to capture the standard/stderr output into a file (which I have with the code below), but I also want the standard output to go into a variable so I can process the information for the next command. Any ideas? Thanks. CMD_OUTPUT = subprocess.Pop

Re: subprocess.Popen question

2011-08-16 Thread Chris Rebert
On Tue, Aug 16, 2011 at 12:03 AM, Danny Wong (dannwong) wrote: > Hi All, >        I'm executing a command which I want to capture the > standard/stderr output into a file (which I have with the code below), > but I also want the standard output to go into a variable so I can > process the informat

Re: testing if a list contains a sublist

2011-08-16 Thread alex23
Laszlo Nagy wrote: > Fastest, error-free and simplest solution is to use sets: > >  >>> l1 = [1,2] >  >>> l2 = [1,2,3,4,5] >  >>> set(l1)-set(l2) > set([]) >  >>> set(l2)-set(l1) > set([3, 4, 5]) >  >>> Error-free? Not given the stated requirements: > l1 = [1,2,2,], l2 = [1,2,3,4,5] -> l1 is not

Re: testing if a list contains a sublist

2011-08-16 Thread alex23
On Aug 16, 4:51 pm, Laszlo Nagy wrote: > >> hi list, > >> what is the best way to check if a given list (lets call it l1) is > >> totally contained in a second list (l2)? > > >> for example: > >> l1 = [1,2], l2 = [1,2,3,4,5] ->  l1 is contained in l2 > >> l1 = [1,2,2,], l2 = [1,2,3,4,5] ->  l1 is

Re: Ten rules to becoming a Python community member.

2011-08-16 Thread alex23
rantingrick wrote: > These specific phrases i have pointed out ("used to" and "supposed > to") are a result of a mind choosing the easy way out instead of > putting in the wee bit more effort required to express one's self in > an articulate manner. Also these two phrases are quite prolifically >

Re: regular expression

2011-08-16 Thread Chris Rebert
On Tue, Aug 16, 2011 at 12:00 AM, Danny Wong (dannwong) wrote: > Hi All, >        If I get multiline standard output from a command. How can I > retrieve this part of the string "(1006)" > Example: > > #Committing... > #Workspace: (1003) "My OS_8.12.0 Work" <-> (1004) "OS_8.12.0" > #  Component: (

Re: testing if a list contains a sublist

2011-08-16 Thread ChasBrown
On Aug 15, 11:51 pm, Laszlo Nagy wrote: > >> hi list, > >> what is the best way to check if a given list (lets call it l1) is > >> totally contained in a second list (l2)? > > >> for example: > >> l1 = [1,2], l2 = [1,2,3,4,5] ->  l1 is contained in l2 > >> l1 = [1,2,2,], l2 = [1,2,3,4,5] ->  l1 is

Re: testing if a list contains a sublist

2011-08-16 Thread Peter Otten
Johannes wrote: > what is the best way to check if a given list (lets call it l1) is > totally contained in a second list (l2)? > > for example: > l1 = [1,2], l2 = [1,2,3,4,5] -> l1 is contained in l2 > l1 = [1,2,2,], l2 = [1,2,3,4,5] -> l1 is not contained in l2 > l1 = [1,2,3], l2 = [1,3,5,7] ->

Linux : create a user if not exists

2011-08-16 Thread smain kahlouch
Hi all, I'm learning the python language and i'm trying to create a user if it is not found in the system. I figured it out by doing the following thing : >>> def finduser(user): ... for line in open('/etc/passwd'): ... if line.startswith(user): ... print user,

Re: Windows service in production?

2011-08-16 Thread Tim Golden
On 16/08/2011 05:32, snorble wrote: Anyone know of a Python application running as a Windows service in production? I'm planning a network monitoring application that runs as a service and reports back to the central server. Sort of a heartbeat type agent to assist with "this server is down, go c

Re: testing if a list contains a sublist

2011-08-16 Thread Laszlo Nagy
Error free? Consider this stated requirement: l1 = [1,2,2,], l2 = [1,2,3,4,5] -> l1 is not contained in l2 If you look it the strict way, "containment" relation for lists is meant this way: l1 = [] l2 = [1,l1,2] # l2 CONTAINS l1 But you are right, I was wrong. So let's clarify what the

Re: Linux : create a user if not exists

2011-08-16 Thread Chris Rebert
On Tue, Aug 16, 2011 at 12:45 AM, smain kahlouch wrote: > Hi all, > > I'm learning the python language and i'm trying to create a user if it is > not found in the system. > I figured it out by doing the following thing : > def finduser(user): > ... for line in open('/etc/passwd'): > ...  

Re: Windows service in production?

2011-08-16 Thread alex23
snorble wrote: > If using Visual Studio and C# is the more reliable way, then I'll go > that route. I love Python, but everything I read about Python services > seems to have workarounds ahoy for various situations (or maybe that's > just Windows services in general?). What workarounds do you mea

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Chris Angelico
On Tue, Aug 16, 2011 at 2:32 AM, Steven D'Aprano wrote: > On Tue, 16 Aug 2011 08:15 am Chris Angelico wrote: > >> It's actually masking, not reassigning. That may make it easier or >> harder to resolve the issue. > > The usual term is "shadowing builtins", and it's a feature, not a bug :) Sorry,

Re: testing if a list contains a sublist

2011-08-16 Thread Steven D'Aprano
On Tue, 16 Aug 2011 12:12 pm Steven D'Aprano wrote: > On Tue, 16 Aug 2011 09:26 am Johannes wrote: > >> hi list, >> what is the best way to check if a given list (lets call it l1) is >> totally contained in a second list (l2)? > > This is not the most efficient algorithm, but for short lists it

Re: testing if a list contains a sublist

2011-08-16 Thread Johannes
Am 16.08.2011 09:44, schrieb Peter Otten: > Johannes wrote: > >> what is the best way to check if a given list (lets call it l1) is >> totally contained in a second list (l2)? >> >> for example: >> l1 = [1,2], l2 = [1,2,3,4,5] -> l1 is contained in l2 >> l1 = [1,2,2,], l2 = [1,2,3,4,5] -> l1 is no

Re: testing if a list contains a sublist

2011-08-16 Thread Steven D'Aprano
On Tue, 16 Aug 2011 04:14 pm ChasBrown wrote: > On Aug 15, 4:26 pm, Johannes wrote: >> hi list, >> what is the best way to check if a given list (lets call it l1) is >> totally contained in a second list (l2)? >> >> for example: >> l1 = [1,2], l2 = [1,2,3,4,5] -> l1 is contained in l2 >> l1 = [1,

Anyone here can do a comparation between Djang and RoR

2011-08-16 Thread smith jack
what is the advantage of Django over RoR:) -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess.Popen question

2011-08-16 Thread Thomas Rachel
Am 16.08.2011 09:03 schrieb Danny Wong (dannwong): Hi All, I'm executing a command which I want to capture the standard/stderr output into a file (which I have with the code below), but I also want the standard output to go into a variable so I can process the information for the next com

Re: testing if a list contains a sublist

2011-08-16 Thread Peter Otten
Johannes wrote: > Am 16.08.2011 09:44, schrieb Peter Otten: >> Johannes wrote: >> >>> what is the best way to check if a given list (lets call it l1) is >>> totally contained in a second list (l2)? >>> >>> for example: >>> l1 = [1,2], l2 = [1,2,3,4,5] -> l1 is contained in l2 >>> l1 = [1,2,2,], l

Re: String concatenation - which is the fastest way ?

2011-08-16 Thread przemolicc
On Fri, Aug 12, 2011 at 11:25:06AM +0200, Stefan Behnel wrote: > przemol...@poczta.fm, 11.08.2011 16:39: >> On Thu, Aug 11, 2011 at 02:48:43PM +0100, Chris Angelico wrote: >>> On Thu, Aug 11, 2011 at 2:46 PM, wrote: This is the way I am going to use. But what is the best data type to hol

Messed up Mac installation

2011-08-16 Thread Christopher Brewster
Are there instructions somewhere online as to how to sort out a messed up installation of Python on a Mac? I have a 2 month old Macbook running Snow Leopard, I installed Python 2.7.1 some time ago. Now when I run 'python' this is what it shows. But easy_install and pip are installing modules to the

Re: Messed up Mac installation

2011-08-16 Thread aspineux
On Aug 16, 12:03 pm, Christopher Brewster wrote: > Are there instructions somewhere online as to how to sort out a messed > up installation of Python on a Mac? > I have a 2 month old Macbook running Snow Leopard, I installed Python > 2.7.1 some time ago. Now when I run 'python' this is what it sho

Re: Anyone here can do a comparation between Djang and RoR

2011-08-16 Thread Alex Po
Many things already done in RoR if comparing it with Django. -- http://mail.python.org/mailman/listinfo/python-list

Re: Anyone here can do a comparation between Djang and RoR

2011-08-16 Thread Tim Chase
On 08/16/2011 04:15 AM, smith jack wrote: what is the advantage of Django over RoR:) *THE* advantage is that you get to program in Python instead of Ruby. :) -tkc -- http://mail.python.org/mailman/listinfo/python-list

Application monitoring

2011-08-16 Thread Abhishek Bajpai
I need to monitor applications like apache, mysql etc there live status, errors etc on my LAN is there any tool or lib for this any help will be appreciated thanks in advance -- http://mail.python.org/mailman/listinfo/python-list

Re: testing if a list contains a sublist

2011-08-16 Thread Nobody
On Tue, 16 Aug 2011 01:26:54 +0200, Johannes wrote: > what is the best way to check if a given list (lets call it l1) is > totally contained in a second list (l2)? "Best" is subjective. AFAIK, the theoretically-optimal algorithm is Boyer-Moore. But that would require a fair amount of code, and Py

Re: Application monitoring

2011-08-16 Thread Nitin Pawar
We use nagios for such monitoring On Tue, Aug 16, 2011 at 4:47 PM, Abhishek Bajpai wrote: > I need to monitor applications like apache, mysql etc there live > status, errors etc on my LAN is there any tool or lib for this any > help will be appreciated thanks in advance > -- > http://mail.python

Re: subprocess.Popen question

2011-08-16 Thread Nobody
On Tue, 16 Aug 2011 02:03:50 -0500, Danny Wong (dannwong) wrote: > I'm executing a command which I want to capture the > standard/stderr output into a file (which I have with the code below), > but I also want the standard output to go into a variable so I can > process the information for t

Re: Application monitoring

2011-08-16 Thread smain kahlouch
or shinken ( written in python :) ); Regards, Sam 2011/8/16 Nitin Pawar > We use nagios for such monitoring > > > On Tue, Aug 16, 2011 at 4:47 PM, Abhishek Bajpai wrote: > >> I need to monitor applications like apache, mysql etc there live >> status, errors etc on my LAN is there any tool or li

Idea for pure-python templates using AST.

2011-08-16 Thread Paul Wray
Hello all Ive had what I think is a great idea for pure-python templates (I can almost hear the groans, bear with me...) For the impatient, proof of concept is at http://pastie.org/2379978 demonstrating simple substitution, balanced tags using context manager, subtemplates, and template inh

Re: regular expression

2011-08-16 Thread Roy Smith
In article , Chris Rebert wrote: > pat = re.compile("^ *(\\([^)]+\\))", re.MULTILINE) First rule of regexes in Python is to always use raw strings, to eliminate the doubled backslashes: > pat = re.compile(r"^ *(\([^)]+\))", re.MULTILINE) Is easier to read. -- http://mail.python.org/mailman/

How to install easy_install on windows ?

2011-08-16 Thread smith jack
it needs read registry, but the python i used is extracted from .zip, so there is no record in the registry, what should i do in order to install easy_install for my python environment? -- http://mail.python.org/mailman/listinfo/python-list

Re: testing if a list contains a sublist

2011-08-16 Thread Alain Ketterlin
Roy Smith writes: >> what is the best way to check if a given list (lets call it l1) is >> totally contained in a second list (l2)? [...] > import re > > def sublist(l1, l2): > s1 = ''.join(map(str, l1)) > s2 = ''.join(map(str, l2)) > return re.search(s1, s2) This is complete nonsen

Re: Idea for pure-python templates using AST.

2011-08-16 Thread aspineux
On Aug 16, 1:33 pm, "Paul Wray" wrote: > Hello all > > Ive had what I think is a great idea for pure-python templates (I can almost > hear the groans, bear with me...) > > For the impatient, proof of concept is athttp://pastie.org/2379978 > demonstrating simple substitution, balanced tags using co

Re: How to Check Write Access of a Folder on Windows

2011-08-16 Thread Ayaskant Swain
Hi Tim, Thanks for your reply. It seems this issue is related to python bug - http://bugs.python.org/issue2528 But the patch code looks complex to me. I want to make changes only in my python script which will read an user given directory path & check it's write access. What is the use of posixmo

Re: How to install easy_install on windows ?

2011-08-16 Thread aspineux
On Aug 16, 2:17 pm, smith jack wrote: > it needs read registry, but the python i used is extracted from .zip, > so there is no record in the registry, Noone need it, Python dont use any registry key > what should i do in order to install easy_install for my python environment? get ez_setup.py f

Re: testing if a list contains a sublist

2011-08-16 Thread Roy Smith
In article <8739h18rzj@dpt-info.u-strasbg.fr>, Alain Ketterlin wrote: > Roy Smith writes: > > >> what is the best way to check if a given list (lets call it l1) is > >> totally contained in a second list (l2)? > > [...] > > import re > > > > def sublist(l1, l2): > > s1 = ''.join(map(s

Re: Windows service in production?

2011-08-16 Thread aspineux
On Aug 16, 6:32 am, snorble wrote: > Anyone know of a Python application running as a Windows service in > production? I'm planning a network monitoring application that runs as > a service and reports back to the central server. Sort of a heartbeat > type agent to assist with "this server is down

Re: Application monitoring

2011-08-16 Thread Miki Tebeka
http://www.nagios.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: How to use python environment created using virtualenv?

2011-08-16 Thread Fabio Zadrozny
On Tue, Aug 16, 2011 at 2:15 AM, smith jack wrote: > I have created a python environment using virtualenv, but when i want > to import such environment to PyDev, error just appears, > it tells there should be a Libs dir, but there is no Libs DIr in the > virtual envronment created using virtualenv

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Philip Semanchuk
On Aug 16, 2011, at 1:15 AM, Steven D'Aprano wrote: > On Tue, 16 Aug 2011 01:23 pm Philip Semanchuk wrote: > >> >> On Aug 15, 2011, at 9:32 PM, Steven D'Aprano wrote: >> >>> On Tue, 16 Aug 2011 08:15 am Chris Angelico wrote: >>> If you want a future directive that deals with it, I'd do i

Re: Linux : create a user if not exists

2011-08-16 Thread Christian Heimes
Am 16.08.2011 10:04, schrieb Chris Rebert: > You can replace the /etc/passwd parsing with a call to pwd.getpwnam(): > http://docs.python.org/library/pwd.html#pwd.getpwnam You should replace it. /etc/passwd is not the only source for users. /etc/nsswitch.conf may list more user and group sources li

Failed to create virtual environment when using --relocatable option, what's wrong?

2011-08-16 Thread smith jack
all things works well without --relocatable option, the error info when using --relocatable option is as follows : F:\PythonEnv\djangoEnv>virtualenv f:\PythonEnv\djangoEnv2 --relocatable PYTHONHOME is set. You *must* activate the virtualenv before using it The environment doesn't have a file f:\P

Re: testing if a list contains a sublist

2011-08-16 Thread John Posner
On 2:59 PM, Nobody wrote: > On Tue, 16 Aug 2011 01:26:54 +0200, Johannes wrote: > >> what is the best way to check if a given list (lets call it l1) is >> totally contained in a second list (l2)? > "Best" is subjective. AFAIK, the theoretically-optimal algorithm is > Boyer-Moore. But that would req

Re: testing if a list contains a sublist

2011-08-16 Thread John Posner
On 2:59 PM, Nobody wrote: > On Tue, 16 Aug 2011 01:26:54 +0200, Johannes wrote: > >> what is the best way to check if a given list (lets call it l1) is >> totally contained in a second list (l2)? > "Best" is subjective. AFAIK, the theoretically-optimal algorithm is > Boyer-Moore. But that would req

Re: Windows service in production?

2011-08-16 Thread snorble
On Aug 16, 2:52 am, Tim Golden wrote: > On 16/08/2011 05:32, snorble wrote: > > > Anyone know of a Python application running as a Windows service in > > production? I'm planning a network monitoring application that runs as > > a service and reports back to the central server. Sort of a heartbeat

why i cannot import djang?

2011-08-16 Thread smith jack
this package is already in the site-packages directory, but i cannot import it , it's really confusing ... -- http://mail.python.org/mailman/listinfo/python-list

Re: testing if a list contains a sublist

2011-08-16 Thread nn
On Aug 16, 8:23 am, Alain Ketterlin wrote: > Roy Smith writes: > >> what is the best way to check if a given list (lets call it l1) is > >> totally contained in a second list (l2)? > > [...] > > > import re > > > def sublist(l1, l2): > >     s1 = ''.join(map(str, l1)) > >     s2 = ''.join(map(str

Re: Linux : create a user if not exists

2011-08-16 Thread smain kahlouch
Ok than you. You're right but it doesn't help me : I replaced it : >>> def finduser(user): ... if pwd.getpwnam(user): ... print user, "user exists" ... return True ... return False ... >>> finduser('realuser') realuser user exists True >>> finduser('blabla') Traceba

Re: Ten rules to becoming a Python community member.

2011-08-16 Thread rantingrick
On Aug 16, 2:07 am, alex23 wrote: > All the way down indeed. Can you pick who said these? Obviously your grep skills are superb however you need to brush up on those reading and comprehension skills a bit. > "There are noobs watching and we to provide code that can be used to > teach!" Yes i s

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Chris Angelico
On Tue, Aug 16, 2011 at 3:13 PM, Philip Semanchuk wrote: > I am an example. I know enough to turn the theoretical warning on, and I > would if I could. I have never shadowed a builtin deliberately. I've done it > accidentally plenty of times. There are 84 builtins in my version of Python > and

Re: testing if a list contains a sublist

2011-08-16 Thread Laszlo Nagy
That can be easily fixed: def sublist(lst1, lst2): s1 = ','.join(map(str, lst1)) s2 = ','.join(map(str, lst2)) return False if s2.find(s1)==-1 else True I don't know about best, but it works for the examples given. For numbers, it will always work. But what about l

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Ethan Furman
Philip Semanchuk wrote: On Aug 16, 2011, at 1:15 AM, Steven D'Aprano wrote: Protecting n00bs from their own errors is an admirable aim, but have you considered that warnings for something which may be harmless could do more harm than good? Isn't the whole point of a warning to highlight behavi

Re: testing if a list contains a sublist

2011-08-16 Thread Johannes
Am 16.08.2011 10:00, schrieb Laszlo Nagy: > >> Error free? Consider this stated requirement: >>> l1 = [1,2,2,], l2 = [1,2,3,4,5] -> l1 is not contained in l2 > If you look it the strict way, "containment" relation for lists is meant > this way: > > > l1 = [] > l2 = [1,l1,2] # l2 CONTAINS l1 >

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Philip Semanchuk
On Aug 16, 2011, at 11:12 AM, Chris Angelico wrote: > On Tue, Aug 16, 2011 at 3:13 PM, Philip Semanchuk > wrote: > >> One need look no further than the standard library to see a strong >> counterexample. grep through the Python source for " file =". I see dozens >> of examples of this builti

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Philip Semanchuk
On Aug 16, 2011, at 11:41 AM, Ethan Furman wrote: > Philip Semanchuk wrote: >> On Aug 16, 2011, at 1:15 AM, Steven D'Aprano wrote: >>> Protecting n00bs from their own errors is an admirable aim, but have you >>> considered that warnings for something which may be harmless could do more >>> harm t

Re: testing if a list contains a sublist

2011-08-16 Thread Alain Ketterlin
Laszlo Nagy writes: > def sublist(lst1, lst2): >> s1 = ','.join(map(str, lst1)) >> s2 = ','.join(map(str, lst2)) >> return False if s2.find(s1)==-1 else True >> >> I don't know about best, but it works for the examples given. >> > For numbers, it will always work. I'm not even

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Terry Reedy
On 8/16/2011 7:33 AM, Paul Wray wrote: Hello all Ive had what I think is a great idea for pure-python templates (I can almost hear the groans, bear with me...) For the impatient, proof of concept is at http://pastie.org/2379978 demonstrating simple substitution, balanced tags using context mana

Re: Linux : create a user if not exists

2011-08-16 Thread Terry Reedy
On 8/16/2011 10:57 AM, smain kahlouch wrote: Ok than you. You're right but it doesn't help me : I replaced it : >>> def finduser(user): ... if pwd.getpwnam(user): ... print user, "user exists" ... return True ... return False ... >>> finduser('realuser') realuse

Re: Linux : create a user if not exists

2011-08-16 Thread Alexander Kapps
On 16.08.2011 16:57, smain kahlouch wrote: Ok than you. You're right but it doesn't help me : I replaced it : >>> def finduser(user): ... if pwd.getpwnam(user): ... print user, "user exists" ... return True ... return False ... >>> finduser('realuser') realuser

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Ethan Furman
Philip Semanchuk wrote: On Aug 16, 2011, at 11:41 AM, Ethan Furman wrote: Philip Semanchuk wrote: If we are to eschew warnings in cases where they might be highlighting something harmless, then we would have no warnings at all. >> Sounds good to me. ;) Keep such things in the IDE's, and the

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Tim Chase
On 08/16/2011 10:31 AM, Philip Semanchuk wrote: On Aug 16, 2011, at 11:12 AM, Chris Angelico wrote: There are several types of shadowing: 1) Deliberate shadowing because you want to change the behavior of the name. Extremely rare. 2) Shadowing simply by using the name of an unusual builtin (lik

Re: Idea for pure-python templates using AST.

2011-08-16 Thread anand jeyahar
Hi all, I did it. Finally managed to port mysqltuner.pl to python. Was a real pain in the butt doing it from bottom up manually, without ever really learing perl syntax. But i finally got it done. Now i need help testing it. find it here. g...@github.com:anandjeyahar/mysqlDbAdmin-python.git. A

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Chris Angelico
On Tue, Aug 16, 2011 at 12:33 PM, Paul Wray wrote: > The idea is simply to use python ASTs to transform this code so that it > accumulates the values of the bare expressions. That'd be similar to what the interactive loop does. Are you aware, though, that docstrings are bare expressions? You may

Re: why i cannot import djang?

2011-08-16 Thread John Gordon
In smith jack writes: > this package is already in the site-packages directory, but i cannot > import it , it's really confusing ... Is it in the site-packages directory for the particular version of python you're using? For example, my system has both python2.3 and python2.5 installed, and t

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Philip Semanchuk
On Aug 16, 2011, at 12:19 PM, Ethan Furman wrote: > Philip Semanchuk wrote: >> On Aug 16, 2011, at 11:41 AM, Ethan Furman wrote: >>> Philip Semanchuk wrote: If we are to eschew warnings in cases where they might be highlighting something harmless, then we would have no warnings at

Re: why i cannot import djang?

2011-08-16 Thread Gennadiy Zlobin
import sys print sys.path # All directories where Python looks for packages - Gennadiy On Tue, Aug 16, 2011 at 11:12 PM, John Gordon wrote: > In smith jack < > thinke...@gmail.com> writes: > > > this package is already in the site-packages directory, but i cannot > > import it , it's really

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread rantingrick
On Aug 16, 9:13 am, Philip Semanchuk wrote: > "Sometimes X is safe and sometimes it isn't" can be said > of many, many things, from taking a walk down the street > to juggling with knives. But it has little to do with > whether or not Python should issue a warning in the > specific case we're tal

Re: testing if a list contains a sublist

2011-08-16 Thread MRAB
On 16/08/2011 00:26, Johannes wrote: hi list, what is the best way to check if a given list (lets call it l1) is totally contained in a second list (l2)? for example: l1 = [1,2], l2 = [1,2,3,4,5] -> l1 is contained in l2 l1 = [1,2,2,], l2 = [1,2,3,4,5] -> l1 is not contained in l2 l1 = [1,2,3]

python mysqltuner port

2011-08-16 Thread anand jeyahar
Hi all, Sorry for the repeat post. Had posted earlier in between an irrelevant thread by accident. > Hi all, >   I did it. Finally managed to port mysqltuner.pl to python. Was a > real pain in the butt doing it from bottom up manually, without ever > really learing perl syntax. But i finally got

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Ethan Furman
Philip Semanchuk wrote: I think Python does lots of beneficial hand-holding. Garbage collection > is a good example. $DIETY knows, people have been struggling with manual > memory management in C and its ilk for a long time. Even though there > are good tools to help, memory leaks still happen.

Re: Anyone here can do a comparation between Djang and RoR

2011-08-16 Thread Seebs
On 2011-08-16, smith jack wrote: > what is the advantage of Django over RoR:) This question is pretty much... I mean, you're not gonna get useful answers. They're based on such different languages that I think any comparison past that is likely going to be uninteresting to a programmer, and I'm

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Seebs
On 2011-08-16, Steven D'Aprano wrote: > On Tue, 16 Aug 2011 01:23 pm Philip Semanchuk wrote: >>> Why should built-ins be treated as more sacred than your own objects? >> Because built-ins are described in the official documentation as having a >> specific behavior, while my objects are not. > *

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Seebs
On 2011-08-16, Ethan Furman wrote: > I think warnings should be reserved for language changes and such (like > DeprecationWarning, RuntimeWarning, and FutureWarning), not for possible > programmer mistakes. I disagree, on the basis of the following: The quality of C code I have to deal with ha

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Seebs
On 2011-08-16, Ethan Furman wrote: > What makes you think it's unintentional? Programming experience. People *often* do things unintentionally. > Seems to me the real issue is somebody using a builtin, such as str or > int, and that they somehow manage to do this without realizing, "wait a >

RE: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Gerrat Rickert
> On Aug 16, 2011, at 1:15 AM, Steven D'Aprano wrote: ... > A warning that is off by default won't help the people who need it, > because > they don't know enough to turn the warning on. A warning that is on by > default will be helpful to the newbie programmer for the first week or > so, > and the

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Andrew Berg
On 2011.08.16 10:44 AM, rantingrick wrote: > One word: SYNTAX HILIGHT And I had thought your troll skills had disappeared. Good one. -- CPython 3.2.1 | Windows NT 6.1.7601.17592 | Thunderbird 5.0 PGP/GPG Public Key ID: 0xF88E034060A78FCB -- http://mail.python.org/mailman/listinfo/python-list

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Ethan Furman
Seebs wrote: On 2011-08-16, Ethan Furman wrote: I think warnings should be reserved for language changes and such (like DeprecationWarning, RuntimeWarning, and FutureWarning), not for possible programmer mistakes. I disagree, on the basis of the following: The quality of C code I have to de

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Ethan Furman
Seebs wrote: On 2011-08-16, Ethan Furman wrote: What makes you think it's unintentional? Programming experience. People *often* do things unintentionally. Seems to me the real issue is somebody using a builtin, such as str or int, and that they somehow manage to do this without realizing,

Re: Linux : create a user if not exists

2011-08-16 Thread Smaine Kahlouch
Le 16/08/2011 17:56, Alexander Kapps a écrit : On 16.08.2011 16:57, smain kahlouch wrote: Ok than you. You're right but it doesn't help me : I replaced it : >>> def finduser(user): ... if pwd.getpwnam(user): ... print user, "user exists" ... return True ... retur

Re: testing if a list contains a sublist

2011-08-16 Thread Neil Cerutti
On 2011-08-16, nn wrote: > That can be easily fixed: > def sublist(lst1, lst2): > s1 = ','.join(map(str, lst1)) > s2 = ','.join(map(str, lst2)) > return False if s2.find(s1)==-1 else True > sublist([1,2,3],[1,2,3,4,5]) > True sublist([1,2,2],[1,2,3,4,5]) > False >>

RE: Ten rules to becoming a Python community member.

2011-08-16 Thread Prasad, Ramit
>Incorrect past tense usage of "used to": > """ I "used to" wear wooden shoes """ >Incorrect description using "used to": > """ I have become "used to" wearing wooden shoes """ >Correct usage of "used to": > """ Wooden shoes can be "used to" torture someone """ Double you tee eff? Maybe this is

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Chris Angelico
On Tue, Aug 16, 2011 at 6:43 PM, Ethan Furman wrote: > Seebs wrote: >> >> On 2011-08-16, Ethan Furman wrote: >>> >>> I think warnings should be reserved for language changes and such (like >>> DeprecationWarning, RuntimeWarning, and FutureWarning), not for possible >>> programmer mistakes. >> >>

Python 2.7.2 on AIX 6.1: Unable to compile with ctypes

2011-08-16 Thread eroussel
Hello, I'm trying to figure out the recipe to compile Python 2.7.2 on AIX 6.1 with the ctypes module. I'm using the xlc_r compiler V9.0. I am currently able to generate an interpreter that works, but lacks the ctypes module because of compilation errors. From looking at the newgroup posts and bug

Re: Ten rules to becoming a Python community member.

2011-08-16 Thread Martin P. Hellwig
On 16/08/2011 18:51, Prasad, Ramit wrote: Incorrect past tense usage of "used to": """ I "used to" wear wooden shoes """ Incorrect description using "used to": """ I have become "used to" wearing wooden shoes """ Correct usage of "used to": """ Wooden shoes can be "used to" torture someone

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Tim Chase
On 08/16/2011 12:11 PM, Seebs wrote: Under which circumstance will you have more problems? 1. There is not a single shadowed built-in in the entire project. 2. There are dozens of shadowed built-ins based on when the original programmer felt there wasn't going to be a need for a given built-in

Re: Ten rules to becoming a Python community member.

2011-08-16 Thread Chris Angelico
On Tue, Aug 16, 2011 at 7:37 PM, Martin P. Hellwig wrote: > With the second sentence meaning: in the past I was not used to (i.e. > uncomfortable, hey bonus points!) wearing wooden shoes, but presently I am > used to it (although not necessarily comfortable, but at least not > uncomfortable). > T

Re: Wait for a keypress before continuing?

2011-08-16 Thread John Doe
def wait_for_keystroke(): char=0 while not char==0x1B: char=msvcrt.getch() That freezes the process. Am I using the right code for the escape key, or doing anything else wrong? Again, I know it could be my system. But I must find a way to do this from within Windows. I use a keyboard ho

Re: Wait for a keypress before continuing?

2011-08-16 Thread John Doe
> def wait_for_keystroke(): > char=0 > while not char==0x1B: > char=msvcrt.getch() I tried using while not char==chr(27): -- http://mail.python.org/mailman/listinfo/python-list

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Seebs
On 2011-08-16, Ethan Furman wrote: > Seebs wrote: >> The quality of C code I have to deal with has increased dramatically as >> gcc's aggressive use of warnings has spread. > With gcc you pay the cost once, with Python you would pay it with every > run. A linter would be more along the lines of

Re: allow line break at operators

2011-08-16 Thread rantingrick
On Aug 16, 1:49 am, alex23 wrote: > On Aug 16, 2:37 pm, rantingrick wrote: > > > The reading proceeds naturally from right to left. > > Well, "naturally" if you're coding in Hebrew or Japanese perhaps :) Yes :). I typo-ed that one. It was getting late when i sent that reply. I did consider posti

Re: Ten rules to becoming a Python community member.

2011-08-16 Thread MRAB
On 16/08/2011 19:37, Martin P. Hellwig wrote: On 16/08/2011 18:51, Prasad, Ramit wrote: Incorrect past tense usage of "used to": """ I "used to" wear wooden shoes """ Incorrect description using "used to": """ I have become "used to" wearing wooden shoes """ Correct usage of "used to": """

RE: regular expression

2011-08-16 Thread Danny Wong (dannwong)
Thanks chris. I had similar code to what you provided. I included the "#" (it was a comment in my code) as part of the string when it shouldn't be as part of my test. As soon as you pointed it out that the #'s aren't supposed to be part of the output, I removed them and it worked. How dumb of me

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Irmen de Jong
On 16-08-11 13:33, Paul Wray wrote: The idea: Python syntax allows a statement to be a bare literal or identifier. These have no effect on the program. So the function below is legal python: def myFunc(): 'a' x = 45 'b'; 'c'; x So is this (within the appropriate class context of course): def

RE: allow line break at operators

2011-08-16 Thread Prasad, Ramit
>1. Indentation as flow control was a bad idea. >2. People are subconsciously aware of this. >3. There is a HUGE degree of emotional investment in defending it. > >The responses I have seen on this issue are highly emotional, full of insults, >full of blame-throwing, and utterly contrary to the

RE: allow line break at operators

2011-08-16 Thread Prasad, Ramit
>> PS: I will admit that a few of our community members can be rather >> acerbic at times. >Yeah. And the thing is... This can't possibly lead to convincing people of >your position, so presumably the purpose is that you don't want anyone who >didn't start out agreeing with you to ever come to ag

Re: Syntactic sugar for assignment statements: one value to multiple targets?

2011-08-16 Thread gc
Thanks for all the discussion on this. Very illuminating. Sorry for the long delay in responding--deadlines intervened. I will use the list comprehension syntax for the foreseeable future. Tim, I agree with you about the slurping in final position--it's actually quite surprising. As I'm sure you

Re: allow line break at operators

2011-08-16 Thread Chris Angelico
On Tue, Aug 16, 2011 at 8:26 PM, Prasad, Ramit wrote: > I am not sure why people are so stuck on braces. I figured other people would > be like me and tired of having to do things like figuring out where I missed > an end brace. > I'm one of the fans of braces, but search the list archives and

  1   2   >